Changeset 1249
- Timestamp:
- May 4, 2007 7:25:19 AM (18 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/symbian_ua
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/symbian_ua/main_symbian.cpp
r1248 r1249 1 //Auto-generated file. Please do not modify. 2 //#include <e32cmn.h> 3 4 //#pragma data_seg(".SYMBIAN") 5 //__EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0) 6 //#pragma data_seg() 7 1 /* $Id$ */ 2 /* 3 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 8 19 #include "ua.h" 9 #include <stdlib.h>10 #include <pj/errno.h>11 #include <pj/os.h>12 #include <pj/log.h>13 #include <pj/unicode.h>14 #include <stdio.h>15 20 16 21 #include <e32std.h> 17 18 #include <pj/os.h>19 20 22 #include <e32base.h> 21 23 #include <e32std.h> 22 24 #include <stdlib.h> 23 25 24 26 … … 27 29 28 30 29 ///////////////////////////////////// 31 //////////////////////////////////////////////////////////////////////////// 30 32 class MyTask : public CActive 31 33 { … … 87 89 void MyTask::DoCancel() 88 90 { 91 89 92 } 93 94 //////////////////////////////////////////////////////////////////////////// 90 95 91 96 LOCAL_C void DoStartL() … … 116 121 //////////////////////////////////////////////////////////////////////////// 117 122 118 // Global Functions123 // E32Main() 119 124 GLDEF_C TInt E32Main() 120 125 { 126 // Mark heap usage 127 __UHEAP_MARK; 128 121 129 // Create cleanup stack 122 __UHEAP_MARK;123 130 CTrapCleanup* cleanup = CTrapCleanup::New(); 124 131 … … 131 138 132 139 console->Printf(_L("[press any key to close]\n")); 133 //console->Getch();140 console->Getch(); 134 141 135 142 delete console; 136 143 delete cleanup; 137 144 138 CloseSTDLIB(); 145 CloseSTDLIB(); 146 147 // Mark end of heap usage, detect memory leaks 139 148 __UHEAP_MARKEND; 140 149 return KErrNone; -
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
r1248 r1249 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 20 /**21 * simple_pjsua.c22 *23 * This is a very simple but fully featured SIP user agent, with the24 * following capabilities:25 * - SIP registration26 * - Making and receiving call27 * - Audio/media to sound device.28 *29 * Usage:30 * - To make outgoing call, start simple_pjsua with the URL of remote31 * destination to contact.32 * E.g.:33 * simpleua sip:user@remote34 *35 * - Incoming calls will automatically be answered with 200.36 *37 * This program will quit once it has completed a single call.38 */39 40 19 #include <pjsua-lib/pjsua.h> 41 20 #include <pjsua-lib/pjsua_internal.h> … … 43 22 44 23 #define THIS_FILE "symbian_ua.cpp" 24 25 // 26 // Basic config. 27 // 28 #define SIP_PORT 5060 29 45 30 46 31 // … … 253 238 static void log_writer(int level, const char *buf, unsigned len) 254 239 { 255 wchar_t buf16[PJ_LOG_MAX_SIZE];240 static wchar_t buf16[PJ_LOG_MAX_SIZE]; 256 241 257 242 PJ_UNUSED_ARG(level); … … 283 268 284 269 /* Init pjsua */ 285 { 286 pjsua_config cfg; 287 pjsua_logging_config log_cfg; 288 pjsua_media_config med_cfg; 289 290 pjsua_config_default(&cfg); 291 cfg.max_calls = 2; 292 cfg.thread_cnt = 0; // Disable threading on Symbian 293 cfg.cb.on_incoming_call = &on_incoming_call; 294 cfg.cb.on_call_media_state = &on_call_media_state; 295 cfg.cb.on_call_state = &on_call_state; 296 cfg.cb.on_buddy_state = &on_buddy_state; 297 cfg.cb.on_pager = &on_pager; 298 cfg.cb.on_typing = &on_typing; 299 cfg.cb.on_call_transfer_status = &on_call_transfer_status; 300 cfg.cb.on_call_replaced = &on_call_replaced; 301 302 if (SIP_PROXY) { 303 cfg.outbound_proxy_cnt = 1; 304 cfg.outbound_proxy[0] = pj_str(SIP_PROXY); 305 } 306 307 if (NAMESERVER) { 308 cfg.nameserver_count = 1; 309 cfg.nameserver[0] = pj_str(NAMESERVER); 310 } 311 312 if (NAMESERVER && STUN_DOMAIN) { 313 cfg.stun_domain = pj_str(STUN_DOMAIN); 314 } else if (STUN_SERVER) { 315 cfg.stun_host = pj_str(STUN_SERVER); 316 } 317 318 319 pjsua_logging_config_default(&log_cfg); 320 log_cfg.console_level = 4; 321 log_cfg.cb = &log_writer; 322 323 pjsua_media_config_default(&med_cfg); 324 med_cfg.thread_cnt = 0; // Disable threading on Symbian 325 med_cfg.has_ioqueue = PJ_FALSE; 326 med_cfg.clock_rate = 8000; 327 med_cfg.ec_tail_len = 0; 328 med_cfg.enable_ice = USE_ICE; 329 330 status = pjsua_init(&cfg, &log_cfg, &med_cfg); 331 if (status != PJ_SUCCESS) { 332 pjsua_perror(THIS_FILE, "pjsua_init() error", status); 333 pjsua_destroy(); 334 return status; 335 } 270 pjsua_config cfg; 271 pjsua_logging_config log_cfg; 272 pjsua_media_config med_cfg; 273 274 pjsua_config_default(&cfg); 275 cfg.max_calls = 2; 276 cfg.thread_cnt = 0; // Disable threading on Symbian 277 cfg.cb.on_incoming_call = &on_incoming_call; 278 cfg.cb.on_call_media_state = &on_call_media_state; 279 cfg.cb.on_call_state = &on_call_state; 280 cfg.cb.on_buddy_state = &on_buddy_state; 281 cfg.cb.on_pager = &on_pager; 282 cfg.cb.on_typing = &on_typing; 283 cfg.cb.on_call_transfer_status = &on_call_transfer_status; 284 cfg.cb.on_call_replaced = &on_call_replaced; 285 286 if (SIP_PROXY) { 287 cfg.outbound_proxy_cnt = 1; 288 cfg.outbound_proxy[0] = pj_str(SIP_PROXY); 289 } 290 291 if (NAMESERVER) { 292 cfg.nameserver_count = 1; 293 cfg.nameserver[0] = pj_str(NAMESERVER); 294 } 295 296 if (NAMESERVER && STUN_DOMAIN) { 297 cfg.stun_domain = pj_str(STUN_DOMAIN); 298 } else if (STUN_SERVER) { 299 cfg.stun_host = pj_str(STUN_SERVER); 300 } 301 302 303 pjsua_logging_config_default(&log_cfg); 304 log_cfg.console_level = 4; 305 log_cfg.cb = &log_writer; 306 307 pjsua_media_config_default(&med_cfg); 308 med_cfg.thread_cnt = 0; // Disable threading on Symbian 309 med_cfg.has_ioqueue = PJ_FALSE; 310 med_cfg.clock_rate = 8000; 311 med_cfg.ec_tail_len = 0; 312 med_cfg.enable_ice = USE_ICE; 313 314 status = pjsua_init(&cfg, &log_cfg, &med_cfg); 315 if (status != PJ_SUCCESS) { 316 pjsua_perror(THIS_FILE, "pjsua_init() error", status); 317 pjsua_destroy(); 318 return status; 336 319 } 337 320 338 321 /* Add UDP transport. */ 339 {340 pjsua_transport_config cfg;341 pjsua_transport_id tid; 342 343 pjsua_transport_config_default(&cfg);344 cfg.port = 5060;345 status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, &tid); 346 if (status != PJ_SUCCESS) {347 pjsua_perror(THIS_FILE, "Error creating transport", status);348 pjsua_destroy();349 return status; 350 } 351 352 353 } 322 pjsua_transport_config tcfg; 323 pjsua_transport_id tid; 324 325 pjsua_transport_config_default(&tcfg); 326 tcfg.port = SIP_PORT; 327 status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &tcfg, &tid); 328 if (status != PJ_SUCCESS) { 329 pjsua_perror(THIS_FILE, "Error creating transport", status); 330 pjsua_destroy(); 331 return status; 332 } 333 334 /* Add account for the transport */ 335 pjsua_acc_add_local(tid, PJ_TRUE, &g_acc_id); 336 354 337 355 338 /* Initialization is done, now start pjsua */ … … 397 380 398 381 //////////////////////////////////////////////////////////////////////////// 382 /* 383 * The interractive console UI 384 */ 399 385 #include <e32base.h> 400 386 … … 402 388 { 403 389 public: 404 405 406 407 408 409 410 390 ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con); 391 392 // Run console UI 393 void Run(); 394 395 // Stop 396 void Stop(); 411 397 412 398 protected: 413 414 415 416 417 399 // Cancel asynchronous read. 400 void DoCancel(); 401 402 // Implementation: called when read has completed. 403 void RunL(); 418 404 419 405 private: 420 421 406 CActiveSchedulerWait *asw_; 407 CConsoleBase *con_; 422 408 }; 423 409 … … 426 412 : CActive(EPriorityStandard), asw_(asw), con_(con) 427 413 { 428 414 CActiveScheduler::Add(this); 429 415 } 430 416 … … 432 418 void ConsoleUI::Run() 433 419 { 434 435 420 con_->Read(iStatus); 421 SetActive(); 436 422 } 437 423 … … 439 425 void ConsoleUI::Stop() 440 426 { 441 427 DoCancel(); 442 428 } 443 429 … … 445 431 void ConsoleUI::DoCancel() 446 432 { 447 433 con_->ReadCancel(); 448 434 } 449 435 450 436 static void PrintMenu() 451 437 { 452 453 454 455 456 457 " m Make call\n"458 459 460 " s Subscribe to buddy presence\n"461 " S Unsubscribe buddypresence\n"462 463 464 438 PJ_LOG(3, (THIS_FILE, "\n\n" 439 "Menu:\n" 440 " d Dump states\n" 441 " D Dump all states (detail)\n" 442 " P Dump pool factory\n" 443 " m Make call to " SIP_DST_URI "\n" 444 " a Answer call\n" 445 " h Hangup all calls\n" 446 " s Subscribe to " SIP_DST_URI "\n" 447 " S Unsubscribe presence\n" 448 " o Set account online\n" 449 " O Set account offline\n" 450 " q Quit\n")); 465 451 } 466 452 … … 468 454 void ConsoleUI::RunL() 469 455 { 470 TKeyCode kc = con_->KeyCode(); 471 pj_bool_t reschedule = PJ_TRUE; 472 473 switch (kc) { 474 case 'q': 475 asw_->AsyncStop(); 476 reschedule = PJ_FALSE; 477 break; 478 case 'D': 479 case 'd': 480 pjsua_dump(kc == 'D'); 481 break; 482 case 'P': 483 pj_pool_factory_dump(&pjsua_var.cp.factory, PJ_TRUE); 484 break; 485 case 'm': 486 if (g_call_id != PJSUA_INVALID_ID) { 487 PJ_LOG(3,(THIS_FILE, "Another call is active")); 488 break; 489 } 490 491 if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 492 pj_str_t dst = pj_str(SIP_DST_URI); 493 pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 494 NULL, &g_call_id); 495 } else { 496 PJ_LOG(3,(THIS_FILE, "Invalid SIP URI")); 497 } 498 break; 499 case 'a': 500 if (g_call_id != PJSUA_INVALID_ID) 501 pjsua_call_answer(g_call_id, 200, NULL, NULL); 502 break; 503 case 'h': 504 pjsua_call_hangup_all(); 505 break; 506 case 's': 507 case 'S': 508 if (g_buddy_id != PJSUA_INVALID_ID) 509 pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s'); 510 break; 511 case 'o': 512 case 'O': 513 pjsua_acc_set_online_status(g_acc_id, kc=='o'); 514 break; 515 default: 516 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", 517 kc, kc)); 518 break; 519 } 520 521 PrintMenu(); 522 523 if (reschedule) 524 Run(); 456 TKeyCode kc = con_->KeyCode(); 457 pj_bool_t reschedule = PJ_TRUE; 458 459 switch (kc) { 460 case 'q': 461 asw_->AsyncStop(); 462 reschedule = PJ_FALSE; 463 break; 464 case 'D': 465 case 'd': 466 pjsua_dump(kc == 'D'); 467 break; 468 case 'p': 469 case 'P': 470 pj_pool_factory_dump(&pjsua_var.cp.factory, PJ_TRUE); 471 break; 472 case 'm': 473 if (g_call_id != PJSUA_INVALID_ID) { 474 PJ_LOG(3,(THIS_FILE, "Another call is active")); 475 break; 476 } 477 478 if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 479 pj_str_t dst = pj_str(SIP_DST_URI); 480 pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 481 NULL, &g_call_id); 482 } else { 483 PJ_LOG(3,(THIS_FILE, "Invalid SIP URI")); 484 } 485 break; 486 case 'a': 487 if (g_call_id != PJSUA_INVALID_ID) 488 pjsua_call_answer(g_call_id, 200, NULL, NULL); 489 break; 490 case 'h': 491 pjsua_call_hangup_all(); 492 break; 493 case 's': 494 case 'S': 495 if (g_buddy_id != PJSUA_INVALID_ID) 496 pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s'); 497 break; 498 case 'o': 499 case 'O': 500 pjsua_acc_set_online_status(g_acc_id, kc=='o'); 501 break; 502 default: 503 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", 504 kc, kc)); 505 break; 506 } 507 508 PrintMenu(); 509 510 if (reschedule) 511 Run(); 525 512 } 526 513 … … 529 516 int ua_main() 530 517 { 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 } 555 518 pj_status_t status; 519 520 // Initialize pjsua 521 status = app_startup(); 522 if (status != PJ_SUCCESS) 523 return status; 524 525 // Run the UI 526 CActiveSchedulerWait *asw = new CActiveSchedulerWait; 527 ConsoleUI *con = new ConsoleUI(asw, console); 528 529 con->Run(); 530 531 PrintMenu(); 532 asw->Start(); 533 534 delete con; 535 delete asw; 536 537 // Shutdown pjsua 538 pjsua_destroy(); 539 540 return 0; 541 } 542 -
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.h
r1242 r1249 1 #include <e32cons.h> // Console 1 /* $Id$ */ 2 /* 3 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 #include <e32cons.h> 2 20 3 extern CConsoleBase* console; // write all messages to this21 extern CConsoleBase* console; 4 22 5 23 int ua_main();
Note: See TracChangeset
for help on using the changeset viewer.