Changeset 5986
- Timestamp:
- May 10, 2019 8:27:22 AM (5 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/pjsua2_demo.cpp
r5899 r5986 31 31 private: 32 32 MyAccount *myAcc; 33 AudioMediaPlayer *wav_player; 33 34 34 35 public: … … 36 37 : Call(acc, call_id) 37 38 { 39 wav_player = NULL; 38 40 myAcc = (MyAccount *)&acc; 41 } 42 43 ~MyCall() 44 { 45 if (wav_player) 46 delete wav_player; 39 47 } 40 48 … … 42 50 virtual void onCallTransferRequest(OnCallTransferRequestParam &prm); 43 51 virtual void onCallReplaced(OnCallReplacedParam &prm); 52 virtual void onCallMediaState(OnCallMediaStateParam &prm); 44 53 }; 45 54 … … 115 124 } 116 125 126 void 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 117 164 void MyCall::onCallTransferRequest(OnCallTransferRequestParam &prm) 118 165 { … … 164 211 165 212 // Hangup all calls 166 pj_thread_sleep( 8000);213 pj_thread_sleep(4000); 167 214 ep.hangupAllCalls(); 168 215 pj_thread_sleep(4000); -
pjproject/trunk/pjsip/src/pjsua2/call.cpp
r5985 r5986 861 861 /* Clear medias. */ 862 862 for (mi = 0; mi < medias.size(); mi++) { 863 if (medias[mi]) 863 if (medias[mi]) { 864 Endpoint::instance().mediaRemove((AudioMedia&)*medias[mi]); 864 865 delete medias[mi]; 866 } 865 867 } 866 868 medias.clear(); … … 923 925 /* Clear medias. */ 924 926 for (mi = 0; mi < medias.size(); mi++) { 925 if (medias[mi]) 927 if (medias[mi]) { 928 Endpoint::instance().mediaRemove((AudioMedia &)*medias[mi]); 926 929 delete medias[mi]; 930 } 927 931 } 928 932 medias.clear(); -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5976 r5986 503 503 delete pendingJobs.front(); 504 504 pendingJobs.pop_front(); 505 }506 507 while(mediaList.size() > 0) {508 AudioMedia *cur_media = mediaList[0];509 delete cur_media; /* this will remove itself from the list */510 505 } 511 506 … … 1788 1783 } 1789 1784 1785 while(mediaList.size() > 0) { 1786 AudioMedia *cur_media = mediaList[0]; 1787 delete cur_media; /* this will remove itself from the list */ 1788 } 1789 1790 1790 if (mediaListMutex) { 1791 1791 pj_mutex_destroy(mediaListMutex); … … 2089 2089 pj_mutex_lock(mediaListMutex); 2090 2090 2091 if (mediaExists(media)) {2092 pj_mutex_unlock(mediaListMutex);2093 return;2094 } 2095 2096 mediaList.push_back(&media);2091 AudioMediaVector::iterator it = std::find(mediaList.begin(), 2092 mediaList.end(), 2093 &media); 2094 2095 if (it == mediaList.end()) 2096 mediaList.push_back(&media); 2097 2097 pj_mutex_unlock(mediaListMutex); 2098 2098 } -
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r5972 r5986 132 132 { 133 133 /* Check if media already added to Conf bridge. */ 134 pj_assert(!Endpoint::instance().mediaExists(*this)); 135 136 if (port != NULL) { 134 if (!Endpoint::instance().mediaExists(*this) && port != NULL) { 137 135 pj_assert(id == PJSUA_INVALID_ID); 138 136 … … 664 662 /* Avoid removing this port (conf port id=0) from conference */ 665 663 this->id = PJSUA_INVALID_ID; 664 unregisterMediaPort(); 666 665 } 667 666
Note: See TracChangeset
for help on using the changeset viewer.