Changeset 5986 for pjproject/trunk/pjsip-apps/src/samples/pjsua2_demo.cpp
- Timestamp:
- May 10, 2019 8:27:22 AM (5 years ago)
- File:
-
- 1 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);
Note: See TracChangeset
for help on using the changeset viewer.