- Timestamp:
- Feb 12, 2009 12:35:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/aps-direct/pjsip-apps/src/symbian_ua/ua.cpp
r2444 r2450 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 … … 578 579 } 579 580 580 static void PrintM enu()581 static void PrintMainMenu() 581 582 { 582 583 PJ_LOG(3, (THIS_FILE, "\n\n" 583 "Menu:\n" 584 " d Dump states\n" 585 " D Dump states detail\n" 586 " P Dump pool factory\n" 587 " l Start loopback audio device\n" 588 " L Stop loopback audio device\n" 584 "Main Menu:\n" 585 " d Enable/disable codecs\n" 589 586 " m Call " SIP_DST_URI "\n" 590 587 " a Answer call\n" 591 588 " g Hangup all calls\n" 589 #if PJMEDIA_SOUND_IMPLEMENTATION == PJMEDIA_SOUND_SYMB_APS_SOUND 590 " t Switch audio route\n" 591 #endif 592 #if !defined(PJMEDIA_CONF_USE_SWITCH_BOARD) || PJMEDIA_CONF_USE_SWITCH_BOARD==0 593 " j Start/stop loopback audio device\n" 594 #endif 592 595 " s Subscribe " SIP_DST_URI "\n" 593 596 " S Unsubscribe presence\n" … … 597 600 } 598 601 602 static void PrintCodecMenu() 603 { 604 PJ_LOG(3, (THIS_FILE, "\n\n" 605 "Codec Menu:\n" 606 " a Enable all codecs\n" 607 #if PJMEDIA_SOUND_IMPLEMENTATION == PJMEDIA_SOUND_SYMB_APS_SOUND 608 " d Enable only AMR\n" 609 " g Enable only G.729\n" 610 " j Enable only iLBC\n" 611 #endif 612 " m Enable only Speex\n" 613 " p Enable only GSM\n" 614 " t Enable only PCMU\n" 615 " w Enable only PCMA\n")); 616 } 617 618 static void HandleMainMenu(TKeyCode kc) { 619 switch (kc) { 620 621 # if PJMEDIA_SOUND_IMPLEMENTATION == PJMEDIA_SOUND_SYMB_APS_SOUND 622 case 't': 623 if (snd_port) { 624 static pj_bool_t act_loudspk = PJ_TRUE; 625 pjmedia_snd_stream *strm; 626 627 strm = pjmedia_snd_port_get_snd_stream(snd_port); 628 pjmedia_snd_aps_activate_loudspeaker(strm, act_loudspk); 629 act_loudspk = !act_loudspk; 630 } else { 631 PJ_LOG(3,(THIS_FILE, "Sound device is not active.")); 632 } 633 break; 634 # endif 635 636 case 'j': 637 do { 638 static pj_bool_t loopback_active = PJ_FALSE; 639 if (!loopback_active) 640 pjsua_conf_connect(0, 0); 641 else 642 pjsua_conf_disconnect(0, 0); 643 loopback_active = !loopback_active; 644 } while (0); 645 break; 646 647 case 'm': 648 if (g_call_id != PJSUA_INVALID_ID) { 649 PJ_LOG(3,(THIS_FILE, "Another call is active")); 650 break; 651 } 652 653 if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 654 pj_str_t dst = pj_str(SIP_DST_URI); 655 pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 656 NULL, &g_call_id); 657 } else { 658 PJ_LOG(3,(THIS_FILE, "Invalid SIP URI")); 659 } 660 break; 661 case 'a': 662 if (g_call_id != PJSUA_INVALID_ID) 663 pjsua_call_answer(g_call_id, 200, NULL, NULL); 664 break; 665 case 'g': 666 pjsua_call_hangup_all(); 667 break; 668 case 's': 669 case 'S': 670 if (g_buddy_id != PJSUA_INVALID_ID) 671 pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s'); 672 break; 673 case 'o': 674 case 'O': 675 pjsua_acc_set_online_status(g_acc_id, kc=='o'); 676 break; 677 678 default: 679 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", kc, kc)); 680 break; 681 } 682 683 PrintMainMenu(); 684 } 685 686 static void HandleCodecMenu(TKeyCode kc) { 687 const pj_str_t ID_ALL = {"*", 1}; 688 pj_str_t codec = {NULL, 0}; 689 690 if (kc == 'a') { 691 pjsua_codec_set_priority(&ID_ALL, PJMEDIA_CODEC_PRIO_NORMAL); 692 PJ_LOG(3,(THIS_FILE, "All codecs activated")); 693 } else { 694 switch (kc) { 695 case 'd': 696 codec = pj_str("AMR"); 697 break; 698 case 'g': 699 codec = pj_str("G729"); 700 break; 701 case 'j': 702 codec = pj_str("ILBC"); 703 break; 704 case 'm': 705 codec = pj_str("SPEEX/8000"); 706 break; 707 case 'p': 708 codec = pj_str("GSM"); 709 break; 710 case 't': 711 codec = pj_str("PCMU"); 712 break; 713 case 'w': 714 codec = pj_str("PCMA"); 715 break; 716 default: 717 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", kc, kc)); 718 break; 719 } 720 721 if (codec.slen) { 722 pj_status_t status; 723 724 pjsua_codec_set_priority(&ID_ALL, PJMEDIA_CODEC_PRIO_DISABLED); 725 726 status = pjsua_codec_set_priority(&codec, 727 PJMEDIA_CODEC_PRIO_NORMAL); 728 if (status == PJ_SUCCESS) 729 PJ_LOG(3,(THIS_FILE, "%s activated", codec.ptr)); 730 else 731 PJ_LOG(3,(THIS_FILE, "Failed activating %s, err=%d", 732 codec.ptr, status)); 733 } 734 } 735 } 736 599 737 // Implementation: called when read has completed. 600 738 void ConsoleUI::RunL() 601 739 { 740 enum { 741 MENU_TYPE_MAIN = 0, 742 MENU_TYPE_CODEC = 1 743 }; 744 static int menu_type = MENU_TYPE_MAIN; 602 745 TKeyCode kc = con_->KeyCode(); 603 746 pj_bool_t reschedule = PJ_TRUE; 604 747 605 switch (kc) {606 case 'w': 748 if (menu_type == MENU_TYPE_MAIN) { 749 if (kc == 'w') { 607 750 CActiveScheduler::Stop(); 608 751 reschedule = PJ_FALSE; 609 break; 610 case 'D': 611 case 'd': 612 pjsua_dump(kc == 'D'); 613 break; 614 case 'p': 615 case 'P': 616 pj_pool_factory_dump(pjsua_get_pool_factory(), PJ_TRUE); 617 break; 618 case 'l': 619 pjsua_conf_connect(0, 0); 620 break; 621 case 'L': 622 pjsua_conf_disconnect(0, 0); 623 break; 624 case 'm': 625 if (g_call_id != PJSUA_INVALID_ID) { 626 PJ_LOG(3,(THIS_FILE, "Another call is active")); 627 break; 628 } 629 630 if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) { 631 pj_str_t dst = pj_str(SIP_DST_URI); 632 pjsua_call_make_call(g_acc_id, &dst, 0, NULL, 633 NULL, &g_call_id); 634 } else { 635 PJ_LOG(3,(THIS_FILE, "Invalid SIP URI")); 636 } 637 break; 638 case 'a': 639 if (g_call_id != PJSUA_INVALID_ID) 640 pjsua_call_answer(g_call_id, 200, NULL, NULL); 641 break; 642 case 'g': 643 pjsua_call_hangup_all(); 644 break; 645 case 's': 646 case 'S': 647 if (g_buddy_id != PJSUA_INVALID_ID) 648 pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s'); 649 break; 650 case 'o': 651 case 'O': 652 pjsua_acc_set_online_status(g_acc_id, kc=='o'); 653 break; 654 default: 655 PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", 656 kc, kc)); 657 break; 658 } 659 660 PrintMenu(); 752 } else if (kc == 'd') { 753 menu_type = MENU_TYPE_CODEC; 754 PrintCodecMenu(); 755 } else { 756 HandleMainMenu(kc); 757 } 758 } else { 759 HandleCodecMenu(kc); 760 761 menu_type = MENU_TYPE_MAIN; 762 PrintMainMenu(); 763 } 661 764 662 765 if (reschedule) … … 869 972 870 973 con->Run(); 871 PrintM enu();974 PrintMainMenu(); 872 975 873 976 CActiveScheduler::Start();
Note: See TracChangeset
for help on using the changeset viewer.