Changeset 1648 for pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
- Timestamp:
- Dec 31, 2007 11:27:35 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
r1646 r1648 22 22 23 23 #define THIS_FILE "symbian_ua.cpp" 24 #define LOG_LEVEL 4 24 25 25 26 // … … 32 33 // Destination URI (to make call, or to subscribe presence) 33 34 // 34 #define SIP_DST_URI "sip:192.168.0.1 1:5060"35 #define SIP_DST_URI "sip:192.168.0.13" 35 36 36 37 // … … 58 59 // 59 60 // STUN server 60 #if 061 #if 1 61 62 // Use this to have the STUN server resolved normally 62 63 # define STUN_DOMAIN NULL … … 75 76 // Use ICE? 76 77 // 77 #define USE_ICE 078 #define USE_ICE 1 78 79 79 80 … … 269 270 270 271 /* Redirect log before pjsua_init() */ 271 pj_log_set_log_func((void (*)(int,const char*,int)) &log_writer); 272 pj_log_set_log_func(&log_writer); 273 274 /* Set log level */ 275 pj_log_set_level(LOG_LEVEL); 272 276 273 277 /* Create pjsua first! */ … … 456 460 " l Start loopback audio device\n" 457 461 " L Stop loopback audio device\n" 458 " 1Call " SIP_DST_URI "\n"459 " 2Answer call\n"460 " 3Hangup all calls\n"462 " m Call " SIP_DST_URI "\n" 463 " a Answer call\n" 464 " g Hangup all calls\n" 461 465 " s Subscribe " SIP_DST_URI "\n" 462 466 " S Unsubscribe presence\n" 463 467 " o Set account online\n" 464 468 " O Set account offline\n" 465 " 9Quit\n"));469 " w Quit\n")); 466 470 } 467 471 … … 473 477 474 478 switch (kc) { 475 case ' 9':479 case 'w': 476 480 asw_->AsyncStop(); 477 481 reschedule = PJ_FALSE; … … 491 495 pjsua_conf_disconnect(0, 0); 492 496 break; 493 case ' 1':497 case 'm': 494 498 if (g_call_id != PJSUA_INVALID_ID) { 495 499 PJ_LOG(3,(THIS_FILE, "Another call is active")); … … 505 509 } 506 510 break; 507 case ' 2':511 case 'a': 508 512 if (g_call_id != PJSUA_INVALID_ID) 509 513 pjsua_call_answer(g_call_id, 200, NULL, NULL); 510 514 break; 511 case ' 3':515 case 'g': 512 516 pjsua_call_hangup_all(); 513 517 break; … … 533 537 } 534 538 539 #if 0 540 // IP networking related testing 541 static pj_status_t test_addr(void) 542 { 543 int af; 544 unsigned i, count; 545 pj_addrinfo ai[8]; 546 pj_sockaddr ifs[8]; 547 const pj_str_t *hostname; 548 pj_hostent he; 549 pj_status_t status; 550 551 pj_log_set_log_func(&log_writer); 552 553 status = pj_init(); 554 if (status != PJ_SUCCESS) { 555 pjsua_perror(THIS_FILE, "pj_init() error", status); 556 return status; 557 } 558 559 af = pj_AF_INET(); 560 561 // Hostname 562 hostname = pj_gethostname(); 563 if (hostname == NULL) { 564 status = PJ_ERESOLVE; 565 pjsua_perror(THIS_FILE, "pj_gethostname() error", status); 566 goto on_return; 567 } 568 569 PJ_LOG(3,(THIS_FILE, "Hostname: %.*s", hostname->slen, hostname->ptr)); 570 571 // Gethostbyname 572 status = pj_gethostbyname(hostname, &he); 573 if (status != PJ_SUCCESS) { 574 pjsua_perror(THIS_FILE, "pj_gethostbyname() error", status); 575 } else { 576 PJ_LOG(3,(THIS_FILE, "gethostbyname: %s", 577 pj_inet_ntoa(*(pj_in_addr*)he.h_addr))); 578 } 579 580 // Getaddrinfo 581 count = PJ_ARRAY_SIZE(ai); 582 status = pj_getaddrinfo(af, hostname, &count, ai); 583 if (status != PJ_SUCCESS) { 584 pjsua_perror(THIS_FILE, "pj_getaddrinfo() error", status); 585 } else { 586 for (i=0; i<count; ++i) { 587 char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 588 PJ_LOG(3,(THIS_FILE, "Addrinfo: %s", 589 pj_sockaddr_print(&ai[i].ai_addr, ipaddr, sizeof(ipaddr), 2))); 590 } 591 } 592 593 // Enum interface 594 count = PJ_ARRAY_SIZE(ifs); 595 status = pj_enum_ip_interface(af, &count, ifs); 596 if (status != PJ_SUCCESS) { 597 pjsua_perror(THIS_FILE, "pj_enum_ip_interface() error", status); 598 } else { 599 for (i=0; i<count; ++i) { 600 char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 601 PJ_LOG(3,(THIS_FILE, "Interface: %s", 602 pj_sockaddr_print(&ifs[i], ipaddr, sizeof(ipaddr), 2))); 603 } 604 } 605 606 // Get default iinterface 607 status = pj_getdefaultipinterface(af, &ifs[0]); 608 if (status != PJ_SUCCESS) { 609 pjsua_perror(THIS_FILE, "pj_getdefaultipinterface() error", status); 610 } else { 611 char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 612 PJ_LOG(3,(THIS_FILE, "Default IP: %s", 613 pj_sockaddr_print(&ifs[0], ipaddr, sizeof(ipaddr), 2))); 614 } 615 616 // Get default IP address 617 status = pj_gethostip(af, &ifs[0]); 618 if (status != PJ_SUCCESS) { 619 pjsua_perror(THIS_FILE, "pj_gethostip() error", status); 620 } else { 621 char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 622 PJ_LOG(3,(THIS_FILE, "Host IP: %s", 623 pj_sockaddr_print(&ifs[0], ipaddr, sizeof(ipaddr), 2))); 624 } 625 626 status = -1; 627 628 on_return: 629 pj_shutdown(); 630 return status; 631 } 632 #endif 633 634 635 #include <ES_SOCK.H> 535 636 536 637 //////////////////////////////////////////////////////////////////////////// 537 638 int ua_main() 538 639 { 640 RSocketServ aSocketServer; 641 RConnection aConn; 642 TInt err; 643 pj_symbianos_params sym_params; 539 644 pj_status_t status; 645 646 // Initialize RSocketServ 647 if ((err=aSocketServer.Connect()) != KErrNone) 648 return PJ_STATUS_FROM_OS(err); 649 650 // Open up a connection 651 if ((err=aConn.Open(aSocketServer)) != KErrNone) { 652 aSocketServer.Close(); 653 return PJ_STATUS_FROM_OS(err); 654 } 655 656 if ((err=aConn.Start()) != KErrNone) { 657 aSocketServer.Close(); 658 return PJ_STATUS_FROM_OS(err); 659 } 660 661 // Set Symbian OS parameters in pjlib. 662 // This must be done before pj_init() is called. 663 pj_bzero(&sym_params, sizeof(sym_params)); 664 sym_params.rsocketserv = &aSocketServer; 665 sym_params.rconnection = &aConn; 666 pj_symbianos_set_params(&sym_params); 540 667 541 668 // Initialize pjsua 542 669 status = app_startup(); 543 if (status != PJ_SUCCESS) 670 //status = test_addr(); 671 if (status != PJ_SUCCESS) { 672 aConn.Close(); 673 aSocketServer.Close(); 544 674 return status; 675 } 545 676 546 677 // Run the UI … … 559 690 pjsua_destroy(); 560 691 561 on_return: 692 // Close connection and socket server 693 aConn.Close(); 694 aSocketServer.Close(); 695 562 696 return status; 563 697 }
Note: See TracChangeset
for help on using the changeset viewer.