Ignore:
Timestamp:
May 10, 2019 8:27:22 AM (5 years ago)
Author:
ming
Message:

Re #2189: Fixing various bugs:

  • assertion: !Endpoint::instance().mediaExists(*this) in Media::registerMediaPort() when using AudioMedia?

Sound device is already registered in the conference bridge, while AudioMediaPlayer/Recorder? creation function, i.e. pjsua_player_create(), pjsua_playlist_create(), and pjsua_recorder_create() already call pjmedia_conf_add_port(), so mediaExists() will always return TRUE.

  • Endpoint.mediaAdd() should check in its own internal list if the media exists, rather than querying pjsua.
  • Calling Endpoint::libDestroy() first, then deleting Endpoint will cause crash, since the mutex to remove the medias has been deleted in libDestroy().

The introduction of the mutex is in r5964.

  • DevAudioMedia? never removes itself from mediaList, potentially causing infinite loop/crash.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/pjsua2_demo.cpp

    r5899 r5986  
    3131private: 
    3232    MyAccount *myAcc; 
     33    AudioMediaPlayer *wav_player; 
    3334 
    3435public: 
     
    3637    : Call(acc, call_id) 
    3738    { 
     39        wav_player = NULL; 
    3840        myAcc = (MyAccount *)&acc; 
     41    } 
     42     
     43    ~MyCall() 
     44    { 
     45        if (wav_player) 
     46            delete wav_player; 
    3947    } 
    4048     
     
    4250    virtual void onCallTransferRequest(OnCallTransferRequestParam &prm); 
    4351    virtual void onCallReplaced(OnCallReplacedParam &prm); 
     52    virtual void onCallMediaState(OnCallMediaStateParam &prm); 
    4453}; 
    4554 
     
    115124} 
    116125 
     126void MyCall::onCallMediaState(OnCallMediaStateParam &prm) 
     127{ 
     128    PJ_UNUSED_ARG(prm); 
     129 
     130    unsigned i; 
     131    CallInfo ci = getInfo(); 
     132    AudioMedia aud_med; 
     133    AudioMedia& play_dev_med = 
     134        Endpoint::instance().audDevManager().getPlaybackDevMedia(); 
     135 
     136    try { 
     137        // Get the first audio media 
     138        aud_med = getAudioMedia(-1); 
     139    } catch(...) { 
     140        std::cout << "Failed to get audio media" << std::endl; 
     141        return; 
     142    } 
     143 
     144    if (!wav_player) { 
     145        wav_player = new AudioMediaPlayer(); 
     146        try { 
     147            wav_player->createPlayer( 
     148                "../../../../tests/pjsua/wavs/input.16.wav", 0); 
     149        } catch (...) { 
     150            std::cout << "Failed opening wav file" << std::endl; 
     151            delete wav_player; 
     152            wav_player = NULL; 
     153        } 
     154    } 
     155 
     156    // This will connect the wav file to the call audio media 
     157    if (wav_player) 
     158        wav_player->startTransmit(aud_med); 
     159 
     160    // And this will connect the call audio media to the sound device/speaker 
     161    aud_med.startTransmit(play_dev_med); 
     162} 
     163 
    117164void MyCall::onCallTransferRequest(OnCallTransferRequestParam &prm) 
    118165{ 
     
    164211     
    165212    // Hangup all calls 
    166     pj_thread_sleep(8000); 
     213    pj_thread_sleep(4000); 
    167214    ep.hangupAllCalls(); 
    168215    pj_thread_sleep(4000); 
Note: See TracChangeset for help on using the changeset viewer.