Changeset 4790 for pjproject/trunk/pjsip-apps/src/samples/pjsua2_demo.cpp
- Timestamp:
- Mar 11, 2014 7:03:22 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/pjsua2_demo.cpp
r4708 r4790 22 22 #include <pj/file_access.h> 23 23 24 #define THIS_FILE "pjsua2_demo.cpp" 25 24 26 using namespace pj; 25 27 … … 105 107 } 106 108 107 static void mainProg1() throw(Error) 108 { 109 Endpoint ep; 110 111 // Create library 112 ep.libCreate(); 113 109 static void mainProg1(Endpoint &ep) throw(Error) 110 { 114 111 // Init library 115 112 EpConfig ep_cfg; … … 154 151 } 155 152 156 void mainProg2() throw(Error) 157 { 158 Endpoint ep; 159 160 // Create library 161 ep.libCreate(); 162 153 static void mainProg2() throw(Error) 154 { 163 155 string json_str; 164 165 156 { 166 157 EpConfig epCfg; … … 203 194 pj_file_delete("jsontest.js"); 204 195 } 205 206 ep.libDestroy(); 207 } 208 209 210 void mainProg3() throw(Error) 211 { 212 Endpoint ep; 213 214 // Create library 215 ep.libCreate(); 196 } 197 198 199 static void mainProg3(Endpoint &ep) throw(Error) 200 { 201 const char *paths[] = { "../../../../tests/pjsua/wavs/input.16.wav", 202 "../../tests/pjsua/wavs/input.16.wav", 203 "input.16.wav"}; 204 unsigned i; 205 const char *filename = NULL; 216 206 217 207 // Init library … … 219 209 ep.libInit( ep_cfg ); 220 210 211 for (i=0; i<PJ_ARRAY_SIZE(paths); ++i) { 212 if (pj_file_exists(paths[i])) { 213 filename = paths[i]; 214 break; 215 } 216 } 217 218 if (!filename) { 219 PJSUA2_RAISE_ERROR3(PJ_ENOTFOUND, "mainProg3()", 220 "Could not locate input.16.wav"); 221 } 222 221 223 // Start library 222 224 ep.libStart(); … … 226 228 { 227 229 AudioMediaPlayer amp; 228 amp.createPlayer( "../../tests/pjsua/wavs/input.16.wav");230 amp.createPlayer(filename); 229 231 230 232 AudioMediaRecorder amr; … … 236 238 pj_thread_sleep(5000); 237 239 } 238 239 ep.libDestroy(); 240 } 241 242 243 void mainProg() throw(Error) 244 { 245 Endpoint ep; 246 247 // Create library 248 ep.libCreate(); 249 240 } 241 242 243 static void mainProg() throw(Error) 244 { 250 245 string json_str; 251 246 … … 295 290 std::cout << json_str << std::endl << std::endl; 296 291 } 297 298 ep.libDestroy();299 292 } 300 293 … … 302 295 { 303 296 int ret = 0; 304 305 /* Test endpoint instantiation and destruction without libCreate(), 306 * libInit() etc. 307 */ 308 { 309 Endpoint ep; 310 } 297 Endpoint ep; 311 298 312 299 try { 313 mainProg3(); 314 std::cout << "Success" << std::endl; 300 ep.libCreate(); 301 302 mainProg3(ep); 303 ret = PJ_SUCCESS; 315 304 } catch (Error & err) { 316 305 std::cout << "Exception: " << err.info() << std::endl; … … 318 307 } 319 308 309 try { 310 ep.libDestroy(); 311 } catch(Error &err) { 312 std::cout << "Exception: " << err.info() << std::endl; 313 ret = 1; 314 } 315 316 if (ret == PJ_SUCCESS) { 317 std::cout << "Success" << std::endl; 318 } else { 319 std::cout << "Error Found" << std::endl; 320 } 321 320 322 return ret; 321 323 }
Note: See TracChangeset
for help on using the changeset viewer.