Changeset 4492 for pjproject


Ignore:
Timestamp:
Apr 23, 2013 10:59:52 AM (11 years ago)
Author:
nanang
Message:

Re #1655: Fixes on WM and Symbian due to latest pjsua framework changes.

Location:
pjproject/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/build.symbian/bld.inf

    r4478 r4492  
    3333//symsndtest.mmp 
    3434pjlib_test.mmp 
     35../pjsip-apps/src/pjsua/symbian/group/pjsua.mmp 
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.h

    r4485 r4492  
    2020#define __PJSUA_APP_CONFIG_H__ 
    2121 
     22#include <pjlib.h> 
     23 
    2224/* This file defines the default app config. It's used by pjsua 
    2325 * *mobile* version only. If you're porting pjsua to new mobile 
     
    2830                                     "--use-cli", 
    2931                                     "--no-cli-console", 
     32#if defined(PJ_SYMBIAN) && PJ_SYMBIAN 
     33                                     /* Can't reuse address on E52 */ 
     34                                     "--cli-telnet-port=0", 
     35#else 
    3036                                     "--cli-telnet-port=2323", 
    31                                      "--no-vad", 
     37#endif 
    3238                                     "--quality=4", 
    3339#if defined(PJ_CONFIG_BB10) && PJ_CONFIG_BB10 
     
    3642                                     NULL }; 
    3743 
     44#define pjsua_app_def_argc (PJ_ARRAY_SIZE(pjsua_app_def_argv)-1) 
     45 
    3846 
    3947#endif  /* __PJSUA_APP_CONFIG_H__ */ 
  • pjproject/trunk/pjsip-apps/src/pjsua/symbian/group/pjsua.mmp

    r4477 r4492  
    102102SOURCEPATH              ..\.. 
    103103 
    104 SOURCE                  pjsua_cli.c pjsua_legacy.c 
    105 SOURCE                  pjsua_app.c pjsua_common.c pjsua_config.c 
     104SOURCE                  pjsua_app_cli.c pjsua_app_legacy.c 
     105SOURCE                  pjsua_app.c pjsua_app_common.c pjsua_app_config.c 
  • pjproject/trunk/pjsip-apps/src/pjsua/symbian/src/pjsuaAppUi.cpp

    r4477 r4492  
    2424 
    2525#include "../../pjsua_app.h" 
     26#include "../../pjsua_app_config.h" 
    2627 
    2728/* Global vars */ 
    2829static CpjsuaAppUi *appui = NULL; 
    2930static pj_ioqueue_t *app_ioqueue = NULL; 
    30 static int restart_argc = 0; 
    31 static char **restart_argv = NULL; 
     31static int start_argc = 0; 
     32static char **start_argv = NULL; 
     33 
     34static pj_status_t InitSymbSocket(); 
     35static void DestroySymbSocket(); 
    3236 
    3337/* Helper funtions to init/restart/destroy the pjsua */ 
    34 static void LibInitL(); 
    35 static void LibDestroyL(); 
    36 static void LibRestartL(); 
     38static void PjsuaInitL(); 
     39static void PjsuaDestroyL(); 
    3740 
    3841/* pjsua app callbacks */ 
    39 static void lib_on_started(pj_status_t status, const char* title); 
    40 static pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv); 
    41 static void lib_on_config_init(pjsua_app_config *cfg); 
     42static void PjsuaOnStarted(pj_status_t status, const char* title); 
     43static void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv); 
     44static void PjsuaOnConfig(pjsua_app_config *cfg); 
    4245 
    4346/* Helper class to schedule function execution */ 
     
    209212        Cba()->MakeVisible(EFalse); 
    210213 
    211         // Schedule Lib Init 
    212         MyTimer::NewL(100, &LibInitL); 
     214        if (InitSymbSocket() != PJ_SUCCESS) { 
     215            PutMsg("Failed to initialize Symbian network param."); 
     216        } else {         
     217            start_argc = pjsua_app_def_argc; 
     218            start_argv = (char**)pjsua_app_def_argv; 
     219 
     220            // Schedule Lib Init 
     221            MyTimer::NewL(100, &PjsuaInitL); 
     222        } 
     223         
    213224        } 
    214225 
     
    216227void CpjsuaAppUi::PrepareToExit() 
    217228{ 
    218     TRAPD(result, LibDestroyL()); 
     229    TRAPD(result, PjsuaDestroyL()); 
     230    DestroySymbSocket(); 
     231    CloseSTDLIB(); 
    219232    CAknViewAppUi::PrepareToExit(); 
    220233} 
     
    232245 
    233246/* Called when pjsua is started */ 
    234 void lib_on_started(pj_status_t status, const char* title) 
    235 { 
     247void PjsuaOnStarted(pj_status_t status, const char* title) 
     248{ 
     249    char err_msg[128]; 
     250 
     251    if (status != PJ_SUCCESS || title == NULL) { 
     252        char err_str[PJ_ERR_MSG_SIZE]; 
     253        pj_strerror(status, err_str, sizeof(err_str)); 
     254        pj_ansi_snprintf(err_msg, sizeof(err_msg), "%s: %s", 
     255                         (title?title:"App start error"), err_str); 
     256        title = err_msg; 
     257    } 
     258 
    236259    appui->PutMsg(title); 
    237260} 
    238261 
    239262/* Called when pjsua is stopped */ 
    240 pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv) 
     263void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv) 
    241264{ 
    242265    if (restart) { 
    243         restart_argc = argc; 
    244         restart_argv = argv; 
     266        start_argc = argc; 
     267        start_argv = argv; 
    245268 
    246269        // Schedule Lib Init 
    247         MyTimer::NewL(100, &LibRestartL); 
     270        MyTimer::NewL(100, &PjsuaInitL); 
    248271    } else { 
    249272        /* Destroy & quit GUI, e.g: clean up window, resources  */ 
    250273        appui->Exit(); 
    251274    } 
    252  
    253     return PJ_FALSE; 
    254275} 
    255276 
     
    257278 * We need to override some settings here. 
    258279 */ 
    259 void lib_on_config_init(pjsua_app_config *cfg) 
     280void PjsuaOnConfig(pjsua_app_config *cfg) 
    260281{ 
    261282    /* Disable threading */ 
     
    272293} 
    273294 
    274 void LibInitL() 
     295// Set Symbian OS parameters in pjlib. 
     296// This must be done before pj_init() is called. 
     297pj_status_t InitSymbSocket() 
    275298{ 
    276299    pj_symbianos_params sym_params; 
    277     char* argv[] = { 
    278         "", 
    279         "--use-cli", 
    280         "--cli-telnet-port=0", 
    281         "--no-cli-console" 
    282     }; 
    283     app_cfg_t app_cfg; 
    284     pj_status_t status; 
    285300    TInt err; 
    286  
     301     
    287302    // Initialize RSocketServ 
    288303    if ((err=aSocketServer.Connect(32)) != KErrNone) { 
    289         status = PJ_STATUS_FROM_OS(err); 
    290         goto on_return; 
     304        return PJ_STATUS_FROM_OS(err); 
    291305    } 
    292306     
     
    294308    if ((err=aConn.Open(aSocketServer)) != KErrNone) { 
    295309        aSocketServer.Close(); 
    296         status = PJ_STATUS_FROM_OS(err); 
    297         goto on_return; 
     310        return PJ_STATUS_FROM_OS(err); 
    298311    } 
    299312    if ((err=aConn.Start()) != KErrNone) { 
    300313        aConn.Close(); 
    301         aSocketServer.Close(); 
    302         status = PJ_STATUS_FROM_OS(err); 
    303         goto on_return; 
    304     } 
    305      
    306     // Set Symbian OS parameters in pjlib. 
    307     // This must be done before pj_init() is called. 
     314        aSocketServer.Close(); 
     315        return PJ_STATUS_FROM_OS(err); 
     316    } 
     317     
    308318    pj_bzero(&sym_params, sizeof(sym_params)); 
    309319    sym_params.rsocketserv = &aSocketServer; 
    310320    sym_params.rconnection = &aConn; 
    311321    pj_symbianos_set_params(&sym_params); 
    312  
     322     
     323    return PJ_SUCCESS; 
     324} 
     325 
     326 
     327void DestroySymbSocket() 
     328{ 
     329    aConn.Close(); 
     330    aSocketServer.Close(); 
     331} 
     332 
     333 
     334void PjsuaInitL() 
     335{ 
     336    pjsua_app_cfg_t app_cfg; 
     337    pj_status_t status; 
     338     
     339    PjsuaDestroyL(); 
     340     
    313341    pj_bzero(&app_cfg, sizeof(app_cfg)); 
    314     app_cfg.argc = PJ_ARRAY_SIZE(argv); 
    315     app_cfg.argv = argv; 
    316     app_cfg.on_started = &lib_on_started; 
    317     app_cfg.on_stopped = &lib_on_stopped; 
    318     app_cfg.on_config_init = &lib_on_config_init; 
     342    app_cfg.argc = start_argc; 
     343    app_cfg.argv = start_argv; 
     344    app_cfg.on_started = &PjsuaOnStarted; 
     345    app_cfg.on_stopped = &PjsuaOnStopped; 
     346    app_cfg.on_config_init = &PjsuaOnConfig; 
    319347 
    320348    appui->PutMsg("Initializing.."); 
    321     status = app_init(&app_cfg); 
     349    status = pjsua_app_init(&app_cfg); 
    322350    if (status != PJ_SUCCESS) 
    323351        goto on_return; 
    324352     
    325353    appui->PutMsg("Starting.."); 
    326     status = app_run(PJ_FALSE); 
     354    status = pjsua_app_run(PJ_FALSE); 
    327355    if (status != PJ_SUCCESS) 
    328356        goto on_return; 
     
    333361} 
    334362 
    335 void LibDestroyL() 
     363void PjsuaDestroyL() 
    336364{ 
    337365    if (app_ioqueue) { 
     
    339367        app_ioqueue = NULL; 
    340368    } 
    341     app_destroy(); 
    342     CloseSTDLIB(); 
    343 } 
    344  
    345 void LibRestartL() 
    346 { 
    347     app_cfg_t app_cfg; 
    348     pj_status_t status; 
    349      
    350     /* Destroy pjsua app first */ 
    351  
    352     if (app_ioqueue) { 
    353         pj_ioqueue_destroy(app_ioqueue); 
    354         app_ioqueue = NULL; 
    355     } 
    356     app_destroy(); 
    357  
    358     /* Reinit pjsua app */ 
    359      
    360     pj_bzero(&app_cfg, sizeof(app_cfg)); 
    361     app_cfg.argc = restart_argc; 
    362     app_cfg.argv = restart_argv; 
    363     app_cfg.on_started = &lib_on_started; 
    364     app_cfg.on_stopped = &lib_on_stopped; 
    365     app_cfg.on_config_init = &lib_on_config_init; 
    366  
    367     status = app_init(&app_cfg); 
    368     if (status != PJ_SUCCESS) { 
    369         appui->PutMsg("app_init() failed"); 
    370         return; 
    371     } 
    372          
    373     /* Run pjsua app */ 
    374  
    375     status = app_run(PJ_FALSE); 
    376     if (status != PJ_SUCCESS) { 
    377         appui->PutMsg("app_run() failed"); 
    378         return; 
    379     } 
    380 } 
     369    pjsua_app_destroy(); 
     370} 
  • pjproject/trunk/pjsip-apps/src/pjsua/wm/main_wm.c

    r4484 r4492  
    1717 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    1818 */ 
    19 #include <windows.h> 
    20  
    21 #include <pjlib.h> 
    22 #include <windows.h> 
    2319#include <winuserm.h> 
    2420#include <aygshell.h> 
    2521#include "..\pjsua_app.h" 
     22#include "..\pjsua_app_config.h" 
    2623 
    2724#define MAINWINDOWCLASS TEXT("PjsuaDlg") 
     
    4037static HBITMAP           g_hBmp; 
    4138 
    42 static int restart_argc = 0; 
    43 static char **restart_argv = NULL; 
    44  
    45 /* Helper funtions to init/restart/destroy the pjsua */ 
    46 static void LibInit(); 
    47 static void LibDestroy(); 
    48 static void LibRestart(); 
     39static int               start_argc; 
     40static char            **start_argv; 
     41 
     42/* Helper funtions to init/destroy the pjsua */ 
     43static void PjsuaInit(); 
     44static void PjsuaDestroy(); 
    4945 
    5046/* pjsua app callbacks */ 
    51 static void lib_on_started(pj_status_t status, const char* title); 
    52 static pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv); 
    53 static void lib_on_config_init(pjsua_app_config *cfg); 
     47static void PjsuaOnStarted(pj_status_t status, const char* title); 
     48static void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv); 
     49static void PjsuaOnConfig(pjsua_app_config *cfg); 
    5450 
    5551LRESULT CALLBACK DialogProc(const HWND hWnd, 
     
    8682 
    8783    case WM_APP_INIT: 
    88         LibInit(); 
     84    case WM_APP_RESTART: 
     85        PjsuaInit(); 
    8986        break; 
    9087 
    9188    case WM_APP_DESTROY: 
    92         LibDestroy(); 
    9389        PostQuitMessage(0); 
    94         break; 
    95  
    96     case WM_APP_RESTART: 
    97         LibRestart(); 
    9890        break; 
    9991 
     
    108100/* === GUI === */ 
    109101 
    110 pj_status_t gui_init() 
     102pj_status_t GuiInit() 
    111103{ 
    112104    WNDCLASS wc; 
     
    193185 
    194186    /* Create logo */ 
    195     g_hBmp = SHLoadDIBitmap(LOGO_PATH); // for jpeg, uses SHLoadImageFile() 
     187    g_hBmp = SHLoadDIBitmap(LOGO_PATH); /* for jpeg, uses SHLoadImageFile() */ 
    196188    if (g_hBmp == NULL) { 
    197189        DWORD err = GetLastError(); 
     
    228220 
    229221 
    230 pj_status_t gui_start() 
     222pj_status_t GuiStart() 
    231223{ 
    232224    MSG msg; 
     
    239231} 
    240232 
    241 void gui_destroy(void) 
     233void GuiDestroy(void) 
    242234{ 
    243235    if (g_hWndMain) { 
     
    267259 
    268260/* Called when pjsua is started */ 
    269 void lib_on_started(pj_status_t status, const char* title) 
     261void PjsuaOnStarted(pj_status_t status, const char* title) 
    270262{ 
    271263    wchar_t wtitle[128]; 
    272  
    273     PJ_UNUSED_ARG(status); 
     264    char err_msg[128]; 
     265 
     266    if (status != PJ_SUCCESS || title == NULL) { 
     267        char err_str[PJ_ERR_MSG_SIZE]; 
     268        pj_strerror(status, err_str, sizeof(err_str)); 
     269        pj_ansi_snprintf(err_msg, sizeof(err_msg), "%s: %s", 
     270                         (title?title:"App start error"), err_str); 
     271        title = err_msg; 
     272    } 
    274273 
    275274    pj_ansi_to_unicode(title, strlen(title), wtitle, PJ_ARRAY_SIZE(wtitle)); 
     
    278277 
    279278/* Called when pjsua is stopped */ 
    280 pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv) 
     279void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv) 
    281280{ 
    282281    if (restart) { 
    283         restart_argc = argc; 
    284         restart_argv = argv; 
     282        start_argc = argc; 
     283        start_argv = argv; 
    285284 
    286285        // Schedule Lib Restart 
     
    290289        PostMessage(g_hWndMain, WM_APP_DESTROY, 0, 0); 
    291290    } 
    292  
    293     return PJ_FALSE; 
    294291} 
    295292 
    296293/* Called before pjsua initializing config. */ 
    297 void lib_on_config_init(pjsua_app_config *cfg) 
     294void PjsuaOnConfig(pjsua_app_config *cfg) 
    298295{ 
    299296    PJ_UNUSED_ARG(cfg); 
    300297} 
    301298 
    302 void LibInit() 
    303 { 
    304     char* argv[] = { 
    305         "", 
    306         "--use-cli", 
    307         "--cli-telnet-port=0", 
    308         "--no-cli-console" 
    309     }; 
    310     app_cfg_t app_cfg; 
     299void PjsuaInit() 
     300{ 
     301    pjsua_app_cfg_t app_cfg; 
    311302    pj_status_t status; 
    312303 
     304    /* Destroy pjsua app first */ 
     305    pjsua_app_destroy(); 
     306 
     307    /* Init pjsua app */ 
    313308    pj_bzero(&app_cfg, sizeof(app_cfg)); 
    314     app_cfg.argc = PJ_ARRAY_SIZE(argv); 
    315     app_cfg.argv = argv; 
    316     app_cfg.on_started = &lib_on_started; 
    317     app_cfg.on_stopped = &lib_on_stopped; 
    318     app_cfg.on_config_init = &lib_on_config_init; 
     309    app_cfg.argc = start_argc; 
     310    app_cfg.argv = start_argv; 
     311    app_cfg.on_started = &PjsuaOnStarted; 
     312    app_cfg.on_stopped = &PjsuaOnStopped; 
     313    app_cfg.on_config_init = &PjsuaOnConfig; 
    319314 
    320315    SetWindowText(g_hWndLbl, _T("Initializing..")); 
    321     status = app_init(&app_cfg); 
     316    status = pjsua_app_init(&app_cfg); 
    322317    if (status != PJ_SUCCESS) 
    323318        goto on_return; 
    324319     
    325320    SetWindowText(g_hWndLbl, _T("Starting..")); 
    326     status = app_run(PJ_FALSE); 
     321    status = pjsua_app_run(PJ_FALSE); 
    327322    if (status != PJ_SUCCESS) 
    328323        goto on_return; 
     
    333328} 
    334329 
    335 void LibDestroy() 
    336 { 
    337     app_destroy(); 
    338 } 
    339  
    340 void LibRestart() 
    341 { 
    342     app_cfg_t app_cfg; 
    343     pj_status_t status; 
    344      
    345     /* Destroy pjsua app first */ 
    346  
    347     app_destroy(); 
    348  
    349     /* Reinit pjsua app */ 
    350      
    351     pj_bzero(&app_cfg, sizeof(app_cfg)); 
    352     app_cfg.argc = restart_argc; 
    353     app_cfg.argv = restart_argv; 
    354     app_cfg.on_started = &lib_on_started; 
    355     app_cfg.on_stopped = &lib_on_stopped; 
    356     app_cfg.on_config_init = &lib_on_config_init; 
    357  
    358     status = app_init(&app_cfg); 
    359     if (status != PJ_SUCCESS) { 
    360         SetWindowText(g_hWndLbl, _T("app_init() failed")); 
    361         return; 
    362     } 
    363          
    364     /* Run pjsua app */ 
    365  
    366     status = app_run(PJ_FALSE); 
    367     if (status != PJ_SUCCESS) { 
    368         SetWindowText(g_hWndLbl, _T("app_run() failed")); 
    369         return; 
    370     } 
    371 } 
    372  
     330void PjsuaDestroy() 
     331{ 
     332    pjsua_app_destroy(); 
     333} 
    373334 
    374335/* === MAIN === */ 
     
    390351    g_hInst = hInstance; 
    391352 
    392     status = gui_init(); 
     353    // Start GUI 
     354    status = GuiInit(); 
    393355    if (status != 0) 
    394356        goto on_return; 
    395357 
    396     // Start the engine 
     358    // Setup args and start pjsua 
     359    start_argc = pjsua_app_def_argc; 
     360    start_argv = (char**)pjsua_app_def_argv; 
    397361    PostMessage(g_hWndMain, WM_APP_INIT, 0, 0); 
    398362 
    399     status = gui_start(); 
     363    status = GuiStart(); 
    400364         
    401365on_return: 
    402     LibDestroy(); 
    403     gui_destroy(); 
     366    PjsuaDestroy(); 
     367    GuiDestroy(); 
    404368 
    405369    return status; 
Note: See TracChangeset for help on using the changeset viewer.