WebRTC Windows Demo1

Source: Internet
Author: User

    //Setup Video engine    CharCcameraname[max_camera_name_length]; memset (Ccameraname,0, max_camera_name_length); intIRet =ret_success;    Capturecapability stcurselectcapbility; CharCcameraid[max_camera_id_length]; memset (Ccameraid,0, max_camera_id_length); intIcapdevicecount =0; Icapdevicecount= m_viecapture->numberofcapturedevices (); ASSERT (Icapdevicecount>0);  for(inti =0; i < Icapdevicecount; i++) {IRet= m_viecapture->Getcapturedevice (i, Ccameraname, Max_camera_name_length, Ccameraid, max_camera_id_length); ASSERT (IRet==ret_success); intIcapbilitycount =0; Icapbilitycount= m_viecapture->numberofcapabilities (Ccameraid, max_camera_id_length); ASSERT (Icapbilitycount>0); IRet= M_viecapture->getcapturecapability (Ccameraid, Max_camera_id_length, Icapbilitycount-1, stcurselectcapbility); ASSERT (IRet==ret_success); }    intIcaptureid; IRet= m_viecapture->Allocatecapturedevice (Ccameraid, Max_camera_id_length, Icaptureid); ASSERT (IRet==ret_success); IRet= Viecreatewindow (M_caprenderhwnd, -, $, -, -, _t ("Local Render")); ASSERT (IRet==ret_success); IRet= Viecreatewindow (M_decrenderhwnd, -, the, -, -, _t ("Remote Render")); ASSERT (IRet==ret_success); IRet= M_vierender->addrenderer (Icaptureid, (void*) M_caprenderhwnd,0,0.0,0.0,1.0,1.0); ASSERT (IRet==ret_success); IRet= m_viecapture->startcapture (Icaptureid, stcurselectcapbility); ASSERT (IRet==ret_success); IRet= m_vierender->Startrender (Icaptureid);          Videocodec Videocodec; intNumofviecodecs = m_viecodec->numberofcodecs (); BOOLBfindvideocode =false; ASSERT (Numofviecodecs>0);  for(intI=0; i<numofviecodecs;++i) {if(M_viecodec->getcodec (I,VIDEOCODEC)!=-1)          {              if(Videocodec.codectype = =kVideoCodecVP8) {Bfindvideocode=true;  Break;    }}} ASSERT (Bfindvideocode); IRet= m_viebase->CreateChannel (m_channelid); ASSERT (IRet==ret_success); IRet= M_vierender->addrenderer (M_channelid, (void*) M_decrenderhwnd,0,0.0,0.0,1.0,1.0); ASSERT (IRet==ret_success); IRet= m_vierender->Startrender (m_channelid); ASSERT (IRet==ret_success); IRet= m_viecodec->Setsendcodec (M_channelid, Videocodec); ASSERT (IRet==ret_success); IRet= m_viecodec->Setreceivecodec (M_channelid, Videocodec); ASSERT (IRet==ret_success); IRet= m_viecapture->Connectcapturedevice (Icaptureid, m_channelid); ASSERT (IRet==ret_success); IRet= m_viertp_rtcp->setrtcpstatus (M_channelid, webrtc::krtcpcompound_rfc4585); ASSERT (IRet==ret_success); IRet= m_viertp_rtcp->Setkeyframerequestmethod (M_channelid, webrtc::kviekeyframerequestplirtcp); ASSERT (IRet==ret_success); IRet= M_viertp_rtcp->settmmbrstatus (M_channelid,true); ASSERT (IRet==ret_success); IRet= M_vienetwork->setsenddestination (M_channelid,"127.0.0.1",11111,11112); ASSERT (IRet==ret_success); IRet= M_vienetwork->setlocalreceiver (M_channelid,11111,11112,"127.0.0.1"); IRet= m_viebase->startsend (m_channelid); ASSERT (IRet==ret_success); IRet= m_viebase->startreceive (m_channelid); ASSERT (IRet==ret_success); //Setup Voice engineCodecinst Voicecodec; intNumofvoecodecs = m_voecodec->numofcodecs (); BOOLBfindaudiocode =false;  for(intI=0; i<numofvoecodecs;++i) {if(M_voecodec->getcodec (I,VOICECODEC)!=-1)          {              if(STRNCMP (Voicecodec.plname,"ISAC",4)==0) {Bfindaudiocode=true;  Break;    }}} ASSERT (Bfindaudiocode); //define ISAC codec parametersstrcpy (Voicecodec.plname,"ISAC"); Voicecodec.plfreq=16000;//Isac Broadband ModeVoicecodec.pltype =103;//default dynamic payload typeVoicecodec.pacsize =480;//480kbps, that is, using the 30MS packet sizeVoicecodec.channels =1;//Single channelVoicecodec.rate =-1;//Channel Adaptive mode, Unit bps    intImaxaechannelnum = m_voebase->maxnumofchannels (); M_audiochannel= m_voebase->CreateChannel (); ASSERT ((M_audiochannel< Imaxaechannelnum) && (M_audiochannel >=0)); IRet= m_voecodec->Setsendcodec (M_audiochannel, Voicecodec); ASSERT (IRet==ret_success); IRet= M_voertcp->setrtcpstatus (M_audiochannel,true); ASSERT (IRet==ret_success); IRet= M_voenetwork->setsourcefilter (M_audiochannel,11113,11114,"127.0.0.1"); ASSERT (IRet==ret_success); IRet= M_voebase->setsenddestination (M_audiochannel,11113,"127.0.0.1", -1,11114); ASSERT (IRet==ret_success); IRet= M_voebase->setlocalreceiver (M_audiochannel,11113,11114,"127.0.0.1"); ASSERT (IRet==ret_success); IRet= m_voebase->startplayout (M_audiochannel); ASSERT (IRet==ret_success); IRet= m_voebase->startreceive (M_audiochannel); ASSERT (IRet==ret_success); IRet= m_voebase->startsend (M_audiochannel); ASSERT (IRet==ret_success); Nsmodes mode (knsdefault);//IRet = M_voeapmptr->setrxnsstatus (M_audiochannel,true, mode); ASSERT (IRet==ret_success);    Agcmodes Agcmode (Kagcdefault); IRet= M_voeapmptr->setrxagcstatus (M_audiochannel,true, Agcmode); ASSERT (IRet==ret_success); IRet= M_voeapmptr->setecstatus (true, KECAEC); ASSERT (IRet= = ret_success);


Translated from http://www.xuebuyuan.com/1719933.html

WebRTC Windows Demo1 (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.