Changes between Version 6 and Version 7 of pjsip-doc/media


Ignore:
Timestamp:
May 10, 2019 7:39:26 AM (11 months ago)
Author:
ming
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pjsip-doc/media

    v6 v7  
    3131 
    3232    AudioMediaPlayer player; 
    33     AudioMedia& play_med = Endpoint::instance().audDevManager().getPlaybackDevMedia(); 
     33    AudioMedia& play_dev_med = Endpoint::instance().audDevManager().getPlaybackDevMedia(); 
    3434    try { 
    3535        player.createPlayer("file.wav"); 
    36         player.startTransmit(play_med); 
     36        player.startTransmit(play_dev_med); 
    3737    } catch(Error& err) { 
    3838    } 
     
    5151 
    5252    try { 
    53         player.stopTransmit(play_med); 
     53        player.stopTransmit(play_dev_med); 
    5454    } catch(Error& err) { 
    5555    } 
     
    6565 
    6666    AudioMediaRecorder recorder; 
    67     AudioMedia& cap_med = Endpoint::instance().audDevManager().getCaptureDevMedia(); 
     67    AudioMedia& cap_dev_med = Endpoint::instance().audDevManager().getCaptureDevMedia(); 
    6868    try { 
    6969        recorder.createRecorder("file.wav"); 
    70         cap_med.startTransmit(recorder); 
     70        cap_dev_med.startTransmit(recorder); 
    7171    } catch(Error& err) { 
    7272    } 
     
    7777 
    7878    try { 
    79        cap_med.stopTransmit(recorder); 
     79       cap_dev_med.stopTransmit(recorder); 
    8080    } catch(Error& err) { 
    8181    } 
     
    9494.. code-block:: c++ 
    9595 
    96     cap_med.startTransmit(play_med); 
     96    cap_dev_med.startTransmit(play_dev_med); 
    9797 
    9898 
     
    104104+++++++++++ 
    105105 
    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; 
     106A 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; 
    118120        } 
    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 
    122136        // 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); 
    124138 
    125139        // 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} 
    129142 
    130143 
     
    137150    AudioMedia *aud_med2 = (AudioMedia *)call2.getMedia(aud_idx); 
    138151    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); 
    141154    } 
    142155 
     
    161174.. code-block:: c++ 
    162175 
    163     cap_med.startTransmit(recorder); 
     176    cap_dev_med.startTransmit(recorder); 
    164177    aud_med->startTransmit(recorder); 
    165178    aud_med2->startTransmit(recorder);