Changeset 4497


Ignore:
Timestamp:
Apr 24, 2013 5:38:35 AM (11 years ago)
Author:
ming
Message:

Re #1655: Modified pjsua iOS due to change in pjsua app framework

Location:
pjproject/trunk/pjsip-apps/src/pjsua/ios
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/ios/ipjsua.xcodeproj/project.pbxproj

    r4465 r4497  
    88 
    99/* Begin PBXBuildFile section */ 
    10                 3A00CD2E170EA6590093CE38 /* pjsua_cli.c in Sources */ = {isa = PBXBuildFile; fileRef = 3A00CD2A170EA6590093CE38 /* pjsua_cli.c */; }; 
    11                 3A00CD2F170EA6590093CE38 /* pjsua_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 3A00CD2B170EA6590093CE38 /* pjsua_common.c */; }; 
    12                 3A00CD30170EA6590093CE38 /* pjsua_config.c in Sources */ = {isa = PBXBuildFile; fileRef = 3A00CD2C170EA6590093CE38 /* pjsua_config.c */; }; 
    13                 3A00CD31170EA6590093CE38 /* pjsua_legacy.c in Sources */ = {isa = PBXBuildFile; fileRef = 3A00CD2D170EA6590093CE38 /* pjsua_legacy.c */; }; 
    14                 3A92068416F1CE8000D49F96 /* pjsua_app.c in Sources */ = {isa = PBXBuildFile; fileRef = 3A92067F16F1CE8000D49F96 /* pjsua_app.c */; }; 
    15                 3A92068516F1CE8000D49F96 /* pjsua_cli_cmd.c in Sources */ = {isa = PBXBuildFile; fileRef = 3A92068016F1CE8000D49F96 /* pjsua_cli_cmd.c */; }; 
    1610                3A92068F16F1DE7100D49F96 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A92068E16F1DE7100D49F96 /* AudioToolbox.framework */; }; 
    1711                3A92069316F1DEA500D49F96 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A92069216F1DEA500D49F96 /* CFNetwork.framework */; }; 
    1812                3ADCCD171715338D0007BE8E /* pjsua.png in Resources */ = {isa = PBXBuildFile; fileRef = 3ADCCD161715338D0007BE8E /* pjsua.png */; }; 
     13                3ADCCD231726D1920007BE8E /* pjsua_app_cli.c in Sources */ = {isa = PBXBuildFile; fileRef = 3ADCCD1E1726D1920007BE8E /* pjsua_app_cli.c */; }; 
     14                3ADCCD241726D1920007BE8E /* pjsua_app_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 3ADCCD1F1726D1920007BE8E /* pjsua_app_common.c */; }; 
     15                3ADCCD251726D1920007BE8E /* pjsua_app_config.c in Sources */ = {isa = PBXBuildFile; fileRef = 3ADCCD201726D1920007BE8E /* pjsua_app_config.c */; }; 
     16                3ADCCD261726D1920007BE8E /* pjsua_app_legacy.c in Sources */ = {isa = PBXBuildFile; fileRef = 3ADCCD211726D1920007BE8E /* pjsua_app_legacy.c */; }; 
     17                3ADCCD271726D1920007BE8E /* pjsua_app.c in Sources */ = {isa = PBXBuildFile; fileRef = 3ADCCD221726D1920007BE8E /* pjsua_app.c */; }; 
    1918                3AF0580916F050770046B835 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF0580816F050770046B835 /* UIKit.framework */; }; 
    2019                3AF0580B16F050770046B835 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF0580A16F050770046B835 /* Foundation.framework */; }; 
     
    5150 
    5251/* Begin PBXFileReference section */ 
    53                 3A00CD2A170EA6590093CE38 /* pjsua_cli.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pjsua_cli.c; path = ../../pjsua_cli.c; sourceTree = "<group>"; }; 
    54                 3A00CD2B170EA6590093CE38 /* pjsua_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pjsua_common.c; path = ../../pjsua_common.c; sourceTree = "<group>"; }; 
    55                 3A00CD2C170EA6590093CE38 /* pjsua_config.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pjsua_config.c; path = ../../pjsua_config.c; sourceTree = "<group>"; }; 
    56                 3A00CD2D170EA6590093CE38 /* pjsua_legacy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pjsua_legacy.c; path = ../../pjsua_legacy.c; sourceTree = "<group>"; }; 
    57                 3A92067F16F1CE8000D49F96 /* pjsua_app.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pjsua_app.c; path = ../../pjsua_app.c; sourceTree = "<group>"; }; 
    58                 3A92068016F1CE8000D49F96 /* pjsua_cli_cmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pjsua_cli_cmd.c; path = ../../pjsua_cli_cmd.c; sourceTree = "<group>"; }; 
    5952                3A92068E16F1DE7100D49F96 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 
    6053                3A92069216F1DEA500D49F96 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 
    6154                3ADCCD161715338D0007BE8E /* pjsua.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pjsua.png; sourceTree = "<group>"; }; 
     55                3ADCCD1E1726D1920007BE8E /* pjsua_app_cli.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pjsua_app_cli.c; sourceTree = "<group>"; }; 
     56                3ADCCD1F1726D1920007BE8E /* pjsua_app_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pjsua_app_common.c; sourceTree = "<group>"; }; 
     57                3ADCCD201726D1920007BE8E /* pjsua_app_config.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pjsua_app_config.c; sourceTree = "<group>"; }; 
     58                3ADCCD211726D1920007BE8E /* pjsua_app_legacy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pjsua_app_legacy.c; sourceTree = "<group>"; }; 
     59                3ADCCD221726D1920007BE8E /* pjsua_app.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pjsua_app.c; sourceTree = "<group>"; }; 
    6260                3AF0580416F050770046B835 /* ipjsua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ipjsua.app; sourceTree = BUILT_PRODUCTS_DIR; }; 
    6361                3AF0580816F050770046B835 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 
     
    136134                        isa = PBXGroup; 
    137135                        children = ( 
    138                                 3A00CD2A170EA6590093CE38 /* pjsua_cli.c */, 
    139                                 3A00CD2B170EA6590093CE38 /* pjsua_common.c */, 
    140                                 3A00CD2C170EA6590093CE38 /* pjsua_config.c */, 
    141                                 3A00CD2D170EA6590093CE38 /* pjsua_legacy.c */, 
    142                                 3A92067F16F1CE8000D49F96 /* pjsua_app.c */, 
    143                                 3A92068016F1CE8000D49F96 /* pjsua_cli_cmd.c */, 
     136                                3ADCCD1E1726D1920007BE8E /* pjsua_app_cli.c */, 
     137                                3ADCCD1F1726D1920007BE8E /* pjsua_app_common.c */, 
     138                                3ADCCD201726D1920007BE8E /* pjsua_app_config.c */, 
     139                                3ADCCD211726D1920007BE8E /* pjsua_app_legacy.c */, 
     140                                3ADCCD221726D1920007BE8E /* pjsua_app.c */, 
    144141                        ); 
    145142                        name = pjsua; 
     
    304301                                3AF0581916F050780046B835 /* ipjsuaAppDelegate.m in Sources */, 
    305302                                3AF0582216F050780046B835 /* ipjsuaViewController.m in Sources */, 
    306                                 3A92068416F1CE8000D49F96 /* pjsua_app.c in Sources */, 
    307                                 3A92068516F1CE8000D49F96 /* pjsua_cli_cmd.c in Sources */, 
    308                                 3A00CD2E170EA6590093CE38 /* pjsua_cli.c in Sources */, 
    309                                 3A00CD2F170EA6590093CE38 /* pjsua_common.c in Sources */, 
    310                                 3A00CD30170EA6590093CE38 /* pjsua_config.c in Sources */, 
    311                                 3A00CD31170EA6590093CE38 /* pjsua_legacy.c in Sources */, 
     303                                3ADCCD231726D1920007BE8E /* pjsua_app_cli.c in Sources */, 
     304                                3ADCCD241726D1920007BE8E /* pjsua_app_common.c in Sources */, 
     305                                3ADCCD251726D1920007BE8E /* pjsua_app_config.c in Sources */, 
     306                                3ADCCD261726D1920007BE8E /* pjsua_app_legacy.c in Sources */, 
     307                                3ADCCD271726D1920007BE8E /* pjsua_app.c in Sources */, 
    312308                        ); 
    313309                        runOnlyForDeploymentPostprocessing = 0; 
     
    410406                                        ../../../../pjnath/include, 
    411407                                        ../../../../pjmedia/include, 
     408                                        .., 
    412409                                ); 
    413410                                INFOPLIST_FILE = "ipjsua/ipjsua-Info.plist"; 
     
    443440                                        ../../../../pjnath/include, 
    444441                                        ../../../../pjmedia/include, 
     442                                        .., 
    445443                                ); 
    446444                                INFOPLIST_FILE = "ipjsua/ipjsua-Info.plist"; 
  • pjproject/trunk/pjsip-apps/src/pjsua/ios/ipjsua/ipjsuaAppDelegate.m

    r4464 r4497  
    1111#import <pjsua.h> 
    1212#import <pj/log.h> 
    13 #include "../../pjsua_common.h" 
     13 
     14#include "../../pjsua_app.h" 
     15#include "../../pjsua_app_config.h" 
    1416 
    1517#import "ipjsuaViewController.h" 
     
    1719@implementation ipjsuaAppDelegate 
    1820 
     21#define THIS_FILE       "ipjsuaAppDelegate.m" 
     22 
    1923#define KEEP_ALIVE_INTERVAL 600 
    2024 
    21 static int _argc = 4; 
    22 static char *_argv[] = {"", 
    23     "--use-cli", 
    24     "--no-cli-console", 
    25     "--cli-telnet-port=6378" 
    26 }; 
    27  
    28 ipjsuaAppDelegate              *app; 
    29 extern pj_cli_telnet_on_started on_started_cb; 
    30 extern pj_cli_on_quit           on_quit_cb; 
    31 extern pj_cli_on_destroy        on_destroy_cb; 
    32 extern pj_cli_on_restart_pjsua  on_restart_pjsua_cb; 
    33 static pj_thread_desc           a_thread_desc; 
    34 static pj_thread_t             *a_thread; 
    35  
    36 int main_func(int argc, char *argv[]); 
    37  
    38 static void cli_telnet_started(pj_cli_telnet_info *telnet_info) 
    39 { 
    40     PJ_LOG(3,("ipjsua", "Telnet to %.*s:%d", 
    41               telnet_info->ip_address.slen, telnet_info->ip_address.ptr, 
    42               telnet_info->port)); 
    43     NSString *str = [NSString stringWithFormat:@"Telnet to %.*s:%d", 
    44                      (int)telnet_info->ip_address.slen, 
    45                      telnet_info->ip_address.ptr, 
    46                      telnet_info->port]; 
     25ipjsuaAppDelegate      *app; 
     26static pjsua_app_cfg_t  app_cfg; 
     27static bool             isShuttingDown; 
     28static char           **restartArgv; 
     29static int              restartArgc; 
     30static pj_thread_desc   a_thread_desc; 
     31static pj_thread_t     *a_thread; 
     32 
     33static void displayMsg(const char *msg) 
     34{ 
     35    NSString *str = [NSString stringWithFormat:@"%s", msg]; 
    4736    [app performSelectorOnMainThread:@selector(displayMsg:) withObject:str 
    48          waitUntilDone:NO]; 
    49 } 
    50  
    51 static void cli_on_quit (pj_bool_t is_restarted) 
    52 { 
    53     PJ_LOG(3,("ipjsua", "CLI quit, restart(%d)", is_restarted)); 
    54     if (!is_restarted) { 
    55         NSString *str = [NSString stringWithFormat:@"CLI quit, " 
    56                          "telnet unavailable"]; 
    57         [app performSelectorOnMainThread:@selector(displayMsg:) withObject:str 
    58              waitUntilDone:NO]; 
    59     } 
    60 } 
    61  
    62 - (void)displayMsg:(NSString *)str { 
     37                       waitUntilDone:NO]; 
     38} 
     39 
     40static void pjsuaOnStartedCb(pj_status_t status, const char* msg) 
     41{ 
     42    char errmsg[PJ_ERR_MSG_SIZE]; 
     43     
     44    if (status != PJ_SUCCESS && (!msg || !*msg)) { 
     45        pj_strerror(status, errmsg, sizeof(errmsg)); 
     46        PJ_LOG(3,(THIS_FILE, "Error: %s", errmsg)); 
     47        msg = errmsg; 
     48    } else { 
     49        PJ_LOG(3,(THIS_FILE, "Started: %s", msg)); 
     50    } 
     51 
     52    displayMsg(msg); 
     53} 
     54 
     55static void pjsuaOnStoppedCb(pj_bool_t restart, 
     56                             int argc, char** argv) 
     57{ 
     58    PJ_LOG(3,("ipjsua", "CLI %s request", (restart? "restart" : "shutdown"))); 
     59    if (restart) { 
     60        displayMsg("Restarting.."); 
     61        pj_thread_sleep(100); 
     62        app_cfg.argc = argc; 
     63        app_cfg.argv = argv; 
     64    } else { 
     65        displayMsg("Shutting down.."); 
     66        pj_thread_sleep(100); 
     67        isShuttingDown = true; 
     68    } 
     69} 
     70 
     71static void pjsuaOnAppConfigCb(pjsua_app_config *cfg) 
     72{ 
     73    PJ_UNUSED_ARG(cfg); 
     74} 
     75 
     76- (void)displayMsg:(NSString *)str 
     77{ 
    6378    app.viewController.textLabel.text = str; 
    6479} 
    6580 
    66 - (void)start_app { 
    67     on_started_cb = &cli_telnet_started; 
    68     on_quit_cb = &cli_on_quit; 
    69     main_func(_argc, _argv); 
     81- (void)pjsuaStart 
     82{ 
     83    // TODO: read from config? 
     84    const char **argv = pjsua_app_def_argv; 
     85    int argc = PJ_ARRAY_SIZE(pjsua_app_def_argv) -1; 
     86    pj_status_t status; 
     87     
     88    isShuttingDown = false; 
     89    displayMsg("Starting.."); 
     90     
     91    pj_bzero(&app_cfg, sizeof(app_cfg)); 
     92    if (restartArgc) { 
     93        app_cfg.argc = restartArgc; 
     94        app_cfg.argv = restartArgv; 
     95    } else { 
     96        app_cfg.argc = argc; 
     97        app_cfg.argv = (char**)argv; 
     98    } 
     99    app_cfg.on_started = &pjsuaOnStartedCb; 
     100    app_cfg.on_stopped = &pjsuaOnStoppedCb; 
     101    app_cfg.on_config_init = &pjsuaOnAppConfigCb; 
     102     
     103    while (!isShuttingDown) { 
     104        status = pjsua_app_init(&app_cfg); 
     105        if (status != PJ_SUCCESS) { 
     106            char errmsg[PJ_ERR_MSG_SIZE]; 
     107            pj_strerror(status, errmsg, sizeof(errmsg)); 
     108            displayMsg(errmsg); 
     109            pjsua_app_destroy(); 
     110            return; 
     111        } 
     112     
     113        status = pjsua_app_run(PJ_TRUE); 
     114        if (status != PJ_SUCCESS) { 
     115            char errmsg[PJ_ERR_MSG_SIZE]; 
     116            pj_strerror(status, errmsg, sizeof(errmsg)); 
     117            displayMsg(errmsg); 
     118        } 
     119     
     120        pjsua_app_destroy(); 
     121    } 
     122     
     123    restartArgv = NULL; 
     124    restartArgc = 0; 
    70125} 
    71126 
     
    85140     
    86141    /* Start pjsua app thread */ 
    87     [NSThread detachNewThreadSelector:@selector(start_app) toTarget:self withObject:nil]; 
     142    [NSThread detachNewThreadSelector:@selector(pjsuaStart) toTarget:self withObject:nil]; 
    88143 
    89144    return YES; 
Note: See TracChangeset for help on using the changeset viewer.