Changes between Version 6 and Version 7 of pjsip-doc/media
- Timestamp:
- May 10, 2019 7:39:26 AM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
pjsip-doc/media
v6 v7 31 31 32 32 AudioMediaPlayer player; 33 AudioMedia& play_ med = Endpoint::instance().audDevManager().getPlaybackDevMedia();33 AudioMedia& play_dev_med = Endpoint::instance().audDevManager().getPlaybackDevMedia(); 34 34 try { 35 35 player.createPlayer("file.wav"); 36 player.startTransmit(play_ med);36 player.startTransmit(play_dev_med); 37 37 } catch(Error& err) { 38 38 } … … 51 51 52 52 try { 53 player.stopTransmit(play_ med);53 player.stopTransmit(play_dev_med); 54 54 } catch(Error& err) { 55 55 } … … 65 65 66 66 AudioMediaRecorder recorder; 67 AudioMedia& cap_ med = Endpoint::instance().audDevManager().getCaptureDevMedia();67 AudioMedia& cap_dev_med = Endpoint::instance().audDevManager().getCaptureDevMedia(); 68 68 try { 69 69 recorder.createRecorder("file.wav"); 70 cap_ med.startTransmit(recorder);70 cap_dev_med.startTransmit(recorder); 71 71 } catch(Error& err) { 72 72 } … … 77 77 78 78 try { 79 cap_ med.stopTransmit(recorder);79 cap_dev_med.stopTransmit(recorder); 80 80 } catch(Error& err) { 81 81 } … … 94 94 .. code-block:: c++ 95 95 96 cap_ med.startTransmit(play_med);96 cap_dev_med.startTransmit(play_dev_med); 97 97 98 98 … … 104 104 +++++++++++ 105 105 106 A single call can have more than one media (for example, audio and video). Application can retrieve the audio media by using the API Call.getMedia(). Then for a normal call, we would want to establish bidirectional audio with the remote person, which can be done easily by connecting the sound device and the call audio media and vice versa: 107 108 .. code-block:: c++ 109 110 CallInfo ci = call.getInfo(); 111 AudioMedia *aud_med = NULL; 112 113 // Find out which media index is the audio 114 for (unsigned i=0; i<ci.media.size(); ++i) { 115 if (ci.media[i].type == PJMEDIA_TYPE_AUDIO) { 116 aud_med = (AudioMedia *)call.getMedia(i); 117 break; 106 A single call can have more than one media (for example, audio and video). Application can retrieve the audio media by using the API Call.getAudioMedia(). Then for a normal call, we would want to establish bidirectional audio with the remote person, which can be done easily by connecting the sound device and the call audio media and vice versa: 107 108 .. code-block:: c++ 109 110 void MyCall::onCallMediaState(OnCallMediaStateParam &prm) 111 { 112 CallInfo ci = call.getInfo(); 113 AudioMedia aud_med; 114 115 try { 116 // Get the first audio media 117 aud_med = getAudioMedia(-1); 118 } catch(...) { 119 return; 118 120 } 119 } 120 121 if (aud_med) { 121 122 /* Deprecated: for PJSIP version 2.8 or earlier 123 AudioMedia *aud_med = NULL; 124 125 // Find out which media index is the audio 126 for (unsigned i=0; i<ci.media.size(); ++i) { 127 if (ci.media[i].type == PJMEDIA_TYPE_AUDIO) { 128 aud_med = (AudioMedia *)call.getMedia(i); 129 break; 130 } 131 } 132 133 if (!aud_med) return; 134 */ 135 122 136 // This will connect the sound device/mic to the call audio media 123 cap_ med.startTransmit(*aud_med);137 cap_dev_med.startTransmit(aud_med); 124 138 125 139 // And this will connect the call audio media to the sound device/speaker 126 aud_med->startTransmit(play_med); 127 } 128 140 aud_med.startTransmit(play_dev_med); 141 } 129 142 130 143 … … 137 150 AudioMedia *aud_med2 = (AudioMedia *)call2.getMedia(aud_idx); 138 151 if (aud_med2) { 139 cap_ med->startTransmit(*aud_med2);140 aud_med2->startTransmit(play_ med);152 cap_dev_med->startTransmit(*aud_med2); 153 aud_med2->startTransmit(play_dev_med); 141 154 } 142 155 … … 161 174 .. code-block:: c++ 162 175 163 cap_ med.startTransmit(recorder);176 cap_dev_med.startTransmit(recorder); 164 177 aud_med->startTransmit(recorder); 165 178 aud_med2->startTransmit(recorder);