Changeset 2506 for pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
- Timestamp:
- Mar 12, 2009 6:11:37 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
-
Property
svn:mergeinfo
set to
False
/pjproject/branches/projects/aps-direct merged eligible
-
Property
svn:mergeinfo
set to
False
-
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
r2481 r2506 20 20 #include <pjsua-lib/pjsua.h> 21 21 #include <pjsua-lib/pjsua_internal.h> 22 //#include <pjmedia/symbian_sound_aps.h> 22 23 #include "ua.h" 23 24 24 25 #define THIS_FILE "symbian_ua.cpp" 25 #define LOG_LEVEL 3 26 #define CON_LOG_LEVEL 3 // console log level 27 #define FILE_LOG_LEVEL 4 // logfile log level 26 28 27 29 // … … 281 283 282 284 /* Set log level */ 283 pj_log_set_level( LOG_LEVEL);285 pj_log_set_level(CON_LOG_LEVEL); 284 286 285 287 /* Create pjsua first! */ … … 329 331 330 332 pjsua_logging_config_default(&log_cfg); 331 log_cfg.level = LOG_LEVEL;332 log_cfg.console_level = LOG_LEVEL;333 log_cfg.level = FILE_LOG_LEVEL; 334 log_cfg.console_level = CON_LOG_LEVEL; 333 335 log_cfg.cb = &log_writer; 334 //log_cfg.log_filename = pj_str("C:\\data\\symbian_ua.log");336 log_cfg.log_filename = pj_str("C:\\data\\symbian_ua.log"); 335 337 336 338 pjsua_media_config_default(&med_cfg); … … 338 340 med_cfg.has_ioqueue = PJ_FALSE; 339 341 med_cfg.clock_rate = 8000; 340 #if defined(PJMEDIA_SYM_SND_USE_APS) && (PJMEDIA_SYM_SND_USE_APS==1)341 med_cfg.audio_frame_ptime = 20;342 #else343 342 med_cfg.audio_frame_ptime = 40; 344 #endif345 343 med_cfg.ec_tail_len = 0; 346 344 med_cfg.enable_ice = USE_ICE; 347 med_cfg.snd_auto_close_time = 5; // wait for 5 seconds idle before sound dev get auto-closed 345 med_cfg.snd_auto_close_time = 0; // wait for 0 seconds idle before sound dev get auto-closed 346 //med_cfg.no_vad = PJ_TRUE; 348 347 349 348 status = pjsua_init(&cfg, &log_cfg, &med_cfg); … … 492 491 } 493 492 494 static void PrintMenu() 495 { 496 PJ_LOG(3, (THIS_FILE, "\n\n" 497 "Menu:\n" 498 " d Dump states\n" 499 " D Dump states detail\n" 500 " P Dump pool factory\n" 501 " l Start loopback audio device\n" 502 " L Stop loopback audio device\n" 493 static void PrintMainMenu() 494 { 495 const char *menu = 496 "\n\n" 497 "Main Menu:\n" 498 " d Enable/disable codecs\n" 503 499 " m Call " SIP_DST_URI "\n" 504 500 " a Answer call\n" 505 501 " g Hangup all calls\n" 502 " t Toggle audio route\n" 503 #if !defined(PJMEDIA_CONF_USE_SWITCH_BOARD) || PJMEDIA_CONF_USE_SWITCH_BOARD==0 504 " j Toggle loopback audio\n" 505 #endif 506 "up/dn Increase/decrease output volume\n" 506 507 " s Subscribe " SIP_DST_URI "\n" 507 508 " S Unsubscribe presence\n" 508 509 " o Set account online\n" 509 510 " O Set account offline\n" 510 " w Quit\n")); 511 " w Quit\n"; 512 513 PJ_LOG(3, (THIS_FILE, menu)); 514 } 515 516 static void PrintCodecMenu() 517 { 518 const char *menu = 519 "\n\n" 520 "Codec Menu:\n" 521 " a Enable all codecs\n" 522 #if PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 523 " d Enable only AMR\n" 524 #endif 525 #if PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 526 " g Enable only G.729\n" 527 #endif 528 #if PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 529 " j Enable only iLBC\n" 530 #endif 531 " m Enable only Speex\n" 532 " p Enable only GSM\n" 533 " t Enable only PCMU\n" 534 " w Enable only PCMA\n"; 535 536 PJ_LOG(3, (THIS_FILE, menu)); 537 } 538 539 static void HandleMainMenu(TKeyCode kc) { 540 switch (kc) { 541 542 case EKeyUpArrow: 543 case EKeyDownArrow: 544 { 545 unsigned vol; 546 pj_status_t status; 547 548 status = pjsua_snd_get_setting( 549 PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, &vol); 550 if (status == PJ_SUCCESS) { 551 if (kc == EKeyUpArrow) 552 vol = PJ_MIN(100, vol+10); 553 else 554 vol = (vol>=10 ? vol-10 : 0); 555 status = pjsua_snd_set_setting( 556 PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, 557 &vol, PJ_TRUE); 558 } 559 560 if (status == PJ_SUCCESS) { 561 PJ_LOG(3,(THIS_FILE, "Output volume set to %d", vol)); 562 } else { 563 pjsua_perror(THIS_FILE, "Error setting volume", status); 564 } 565 } 566 break; 567 568 case 't': 569 { 570 pjmedia_aud_dev_route route; 571 pj_status_t status; 572 573 status = pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, 574 &route); 575 576 if (status == PJ_SUCCESS) { 577 if (route == PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER) 578 route = PJMEDIA_AUD_DEV_ROUTE_EARPIECE; 579 else 580 route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; 581 582 status = pjsua_snd_set_setting( 583 PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, 584 &route, PJ_TRUE); 585 } 586 587 if (status != PJ_SUCCESS) 588 pjsua_perror(THIS_FILE, "Error switch audio route", status); 589 } 590 break; 591 592 case 'j': 593 { 594 static pj_bool_t loopback_active = PJ_FALSE; 595 if (!loopback_active) 596 pjsua_conf_connect(0, 0); 597 else 598 pjsua_conf_disconnect(0, 0); 599 loopback_active = !loopback_active; 600 } 601 break; 602 603 case 'm': 604 if (g_call_id != PJSUA_INVALID_ID) { 605 PJ_LOG(3,(THIS_FILE, "Another call is active")); 606 break; 607 } 608 609 if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 610 pj_str_t dst = pj_str(SIP_DST_URI); 611 pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 612 NULL, &g_call_id); 613 } else { 614 PJ_LOG(3,(THIS_FILE, "Invalid SIP URI")); 615 } 616 break; 617 case 'a': 618 if (g_call_id != PJSUA_INVALID_ID) 619 pjsua_call_answer(g_call_id, 200, NULL, NULL); 620 break; 621 case 'g': 622 pjsua_call_hangup_all(); 623 break; 624 case 's': 625 case 'S': 626 if (g_buddy_id != PJSUA_INVALID_ID) 627 pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s'); 628 break; 629 case 'o': 630 case 'O': 631 pjsua_acc_set_online_status(g_acc_id, kc=='o'); 632 break; 633 634 default: 635 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", kc, kc)); 636 break; 637 } 638 639 PrintMainMenu(); 640 } 641 642 static void HandleCodecMenu(TKeyCode kc) { 643 const pj_str_t ID_ALL = {"*", 1}; 644 pj_str_t codec = {NULL, 0}; 645 646 if (kc == 'a') { 647 pjsua_codec_set_priority(&ID_ALL, PJMEDIA_CODEC_PRIO_NORMAL); 648 PJ_LOG(3,(THIS_FILE, "All codecs activated")); 649 } else { 650 switch (kc) { 651 case 'd': 652 codec = pj_str("AMR"); 653 break; 654 case 'g': 655 codec = pj_str("G729"); 656 break; 657 case 'j': 658 codec = pj_str("ILBC"); 659 break; 660 case 'm': 661 codec = pj_str("SPEEX/8000"); 662 break; 663 case 'p': 664 codec = pj_str("GSM"); 665 break; 666 case 't': 667 codec = pj_str("PCMU"); 668 break; 669 case 'w': 670 codec = pj_str("PCMA"); 671 break; 672 default: 673 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", kc, kc)); 674 break; 675 } 676 677 if (codec.slen) { 678 pj_status_t status; 679 680 pjsua_codec_set_priority(&ID_ALL, PJMEDIA_CODEC_PRIO_DISABLED); 681 682 status = pjsua_codec_set_priority(&codec, 683 PJMEDIA_CODEC_PRIO_NORMAL); 684 if (status == PJ_SUCCESS) 685 PJ_LOG(3,(THIS_FILE, "%s activated", codec.ptr)); 686 else 687 PJ_LOG(3,(THIS_FILE, "Failed activating %s, err=%d", 688 codec.ptr, status)); 689 } 690 } 511 691 } 512 692 … … 514 694 void ConsoleUI::RunL() 515 695 { 696 enum { 697 MENU_TYPE_MAIN = 0, 698 MENU_TYPE_CODEC = 1 699 }; 700 static int menu_type = MENU_TYPE_MAIN; 516 701 TKeyCode kc = con_->KeyCode(); 517 702 pj_bool_t reschedule = PJ_TRUE; 518 703 519 switch (kc) {520 case 'w': 704 if (menu_type == MENU_TYPE_MAIN) { 705 if (kc == 'w') { 521 706 CActiveScheduler::Stop(); 522 707 reschedule = PJ_FALSE; 523 break; 524 case 'D': 525 case 'd': 526 pjsua_dump(kc == 'D'); 527 break; 528 case 'p': 529 case 'P': 530 pj_pool_factory_dump(pjsua_get_pool_factory(), PJ_TRUE); 531 break; 532 case 'l': 533 pjsua_conf_connect(0, 0); 534 break; 535 case 'L': 536 pjsua_conf_disconnect(0, 0); 537 break; 538 case 'm': 539 if (g_call_id != PJSUA_INVALID_ID) { 540 PJ_LOG(3,(THIS_FILE, "Another call is active")); 541 break; 542 } 543 544 if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 545 pj_str_t dst = pj_str(SIP_DST_URI); 546 pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 547 NULL, &g_call_id); 548 } else { 549 PJ_LOG(3,(THIS_FILE, "Invalid SIP URI")); 550 } 551 break; 552 case 'a': 553 if (g_call_id != PJSUA_INVALID_ID) 554 pjsua_call_answer(g_call_id, 200, NULL, NULL); 555 break; 556 case 'g': 557 pjsua_call_hangup_all(); 558 break; 559 case 's': 560 case 'S': 561 if (g_buddy_id != PJSUA_INVALID_ID) 562 pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s'); 563 break; 564 case 'o': 565 case 'O': 566 pjsua_acc_set_online_status(g_acc_id, kc=='o'); 567 break; 568 default: 569 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", 570 kc, kc)); 571 break; 572 } 573 574 PrintMenu(); 708 } else if (kc == 'd') { 709 menu_type = MENU_TYPE_CODEC; 710 PrintCodecMenu(); 711 } else { 712 HandleMainMenu(kc); 713 } 714 } else { 715 HandleCodecMenu(kc); 716 717 menu_type = MENU_TYPE_MAIN; 718 PrintMainMenu(); 719 } 575 720 576 721 if (reschedule) … … 816 961 817 962 PJ_LOG(3, (THIS_FILE, "PJSUA restarted.")); 818 PrintM enu();963 PrintMainMenu(); 819 964 } 820 965 … … 874 1019 875 1020 con->Run(); 876 PrintM enu();1021 PrintMainMenu(); 877 1022 878 1023 // Init & start connection monitor … … 911 1056 aConn.Close(); 912 1057 aSocketServer.Close(); 913 1058 914 1059 return status; 915 1060 }
Note: See TracChangeset
for help on using the changeset viewer.