Re #1655: Fixes on WM and Symbian due to latest pjsua framework changes.
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@4492 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
5bc861686b
commit
cd9e89100a
|
@ -32,3 +32,4 @@ pjmedia_audiodev.mmp
|
||||||
/* Applications */
|
/* Applications */
|
||||||
//symsndtest.mmp
|
//symsndtest.mmp
|
||||||
pjlib_test.mmp
|
pjlib_test.mmp
|
||||||
|
../pjsip-apps/src/pjsua/symbian/group/pjsua.mmp
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#ifndef __PJSUA_APP_CONFIG_H__
|
#ifndef __PJSUA_APP_CONFIG_H__
|
||||||
#define __PJSUA_APP_CONFIG_H__
|
#define __PJSUA_APP_CONFIG_H__
|
||||||
|
|
||||||
|
#include <pjlib.h>
|
||||||
|
|
||||||
/* This file defines the default app config. It's used by pjsua
|
/* This file defines the default app config. It's used by pjsua
|
||||||
* *mobile* version only. If you're porting pjsua to new mobile
|
* *mobile* version only. If you're porting pjsua to new mobile
|
||||||
* platform, you should only include this file once in one of
|
* platform, you should only include this file once in one of
|
||||||
|
@ -27,14 +29,20 @@
|
||||||
const char *pjsua_app_def_argv[] = { "pjsua",
|
const char *pjsua_app_def_argv[] = { "pjsua",
|
||||||
"--use-cli",
|
"--use-cli",
|
||||||
"--no-cli-console",
|
"--no-cli-console",
|
||||||
|
#if defined(PJ_SYMBIAN) && PJ_SYMBIAN
|
||||||
|
/* Can't reuse address on E52 */
|
||||||
|
"--cli-telnet-port=0",
|
||||||
|
#else
|
||||||
"--cli-telnet-port=2323",
|
"--cli-telnet-port=2323",
|
||||||
"--no-vad",
|
#endif
|
||||||
"--quality=4",
|
"--quality=4",
|
||||||
#if defined(PJ_CONFIG_BB10) && PJ_CONFIG_BB10
|
#if defined(PJ_CONFIG_BB10) && PJ_CONFIG_BB10
|
||||||
"--add-buddy=sip:169.254.0.2",
|
"--add-buddy=sip:169.254.0.2",
|
||||||
#endif
|
#endif
|
||||||
NULL };
|
NULL };
|
||||||
|
|
||||||
|
#define pjsua_app_def_argc (PJ_ARRAY_SIZE(pjsua_app_def_argv)-1)
|
||||||
|
|
||||||
|
|
||||||
#endif /* __PJSUA_APP_CONFIG_H__ */
|
#endif /* __PJSUA_APP_CONFIG_H__ */
|
||||||
|
|
||||||
|
|
|
@ -101,5 +101,5 @@ STATICLIBRARY libresample.lib
|
||||||
|
|
||||||
SOURCEPATH ..\..
|
SOURCEPATH ..\..
|
||||||
|
|
||||||
SOURCE pjsua_cli.c pjsua_legacy.c
|
SOURCE pjsua_app_cli.c pjsua_app_legacy.c
|
||||||
SOURCE pjsua_app.c pjsua_common.c pjsua_config.c
|
SOURCE pjsua_app.c pjsua_app_common.c pjsua_app_config.c
|
||||||
|
|
|
@ -23,22 +23,25 @@
|
||||||
// ]]] end generated region [Generated Constants]
|
// ]]] end generated region [Generated Constants]
|
||||||
|
|
||||||
#include "../../pjsua_app.h"
|
#include "../../pjsua_app.h"
|
||||||
|
#include "../../pjsua_app_config.h"
|
||||||
|
|
||||||
/* Global vars */
|
/* Global vars */
|
||||||
static CpjsuaAppUi *appui = NULL;
|
static CpjsuaAppUi *appui = NULL;
|
||||||
static pj_ioqueue_t *app_ioqueue = NULL;
|
static pj_ioqueue_t *app_ioqueue = NULL;
|
||||||
static int restart_argc = 0;
|
static int start_argc = 0;
|
||||||
static char **restart_argv = NULL;
|
static char **start_argv = NULL;
|
||||||
|
|
||||||
|
static pj_status_t InitSymbSocket();
|
||||||
|
static void DestroySymbSocket();
|
||||||
|
|
||||||
/* Helper funtions to init/restart/destroy the pjsua */
|
/* Helper funtions to init/restart/destroy the pjsua */
|
||||||
static void LibInitL();
|
static void PjsuaInitL();
|
||||||
static void LibDestroyL();
|
static void PjsuaDestroyL();
|
||||||
static void LibRestartL();
|
|
||||||
|
|
||||||
/* pjsua app callbacks */
|
/* pjsua app callbacks */
|
||||||
static void lib_on_started(pj_status_t status, const char* title);
|
static void PjsuaOnStarted(pj_status_t status, const char* title);
|
||||||
static pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv);
|
static void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv);
|
||||||
static void lib_on_config_init(pjsua_app_config *cfg);
|
static void PjsuaOnConfig(pjsua_app_config *cfg);
|
||||||
|
|
||||||
/* Helper class to schedule function execution */
|
/* Helper class to schedule function execution */
|
||||||
class MyTimer : public CActive
|
class MyTimer : public CActive
|
||||||
|
@ -208,14 +211,24 @@ void CpjsuaAppUi::ConstructL()
|
||||||
StatusPane()->MakeVisible(EFalse);
|
StatusPane()->MakeVisible(EFalse);
|
||||||
Cba()->MakeVisible(EFalse);
|
Cba()->MakeVisible(EFalse);
|
||||||
|
|
||||||
// Schedule Lib Init
|
if (InitSymbSocket() != PJ_SUCCESS) {
|
||||||
MyTimer::NewL(100, &LibInitL);
|
PutMsg("Failed to initialize Symbian network param.");
|
||||||
|
} else {
|
||||||
|
start_argc = pjsua_app_def_argc;
|
||||||
|
start_argv = (char**)pjsua_app_def_argv;
|
||||||
|
|
||||||
|
// Schedule Lib Init
|
||||||
|
MyTimer::NewL(100, &PjsuaInitL);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called by Symbian GUI framework when app is about to exit */
|
/* Called by Symbian GUI framework when app is about to exit */
|
||||||
void CpjsuaAppUi::PrepareToExit()
|
void CpjsuaAppUi::PrepareToExit()
|
||||||
{
|
{
|
||||||
TRAPD(result, LibDestroyL());
|
TRAPD(result, PjsuaDestroyL());
|
||||||
|
DestroySymbSocket();
|
||||||
|
CloseSTDLIB();
|
||||||
CAknViewAppUi::PrepareToExit();
|
CAknViewAppUi::PrepareToExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,32 +244,40 @@ static RSocketServ aSocketServer;
|
||||||
static RConnection aConn;
|
static RConnection aConn;
|
||||||
|
|
||||||
/* Called when pjsua is started */
|
/* Called when pjsua is started */
|
||||||
void lib_on_started(pj_status_t status, const char* title)
|
void PjsuaOnStarted(pj_status_t status, const char* title)
|
||||||
{
|
{
|
||||||
|
char err_msg[128];
|
||||||
|
|
||||||
|
if (status != PJ_SUCCESS || title == NULL) {
|
||||||
|
char err_str[PJ_ERR_MSG_SIZE];
|
||||||
|
pj_strerror(status, err_str, sizeof(err_str));
|
||||||
|
pj_ansi_snprintf(err_msg, sizeof(err_msg), "%s: %s",
|
||||||
|
(title?title:"App start error"), err_str);
|
||||||
|
title = err_msg;
|
||||||
|
}
|
||||||
|
|
||||||
appui->PutMsg(title);
|
appui->PutMsg(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when pjsua is stopped */
|
/* Called when pjsua is stopped */
|
||||||
pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv)
|
void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (restart) {
|
if (restart) {
|
||||||
restart_argc = argc;
|
start_argc = argc;
|
||||||
restart_argv = argv;
|
start_argv = argv;
|
||||||
|
|
||||||
// Schedule Lib Init
|
// Schedule Lib Init
|
||||||
MyTimer::NewL(100, &LibRestartL);
|
MyTimer::NewL(100, &PjsuaInitL);
|
||||||
} else {
|
} else {
|
||||||
/* Destroy & quit GUI, e.g: clean up window, resources */
|
/* Destroy & quit GUI, e.g: clean up window, resources */
|
||||||
appui->Exit();
|
appui->Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return PJ_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called before pjsua initializing config.
|
/* Called before pjsua initializing config.
|
||||||
* We need to override some settings here.
|
* We need to override some settings here.
|
||||||
*/
|
*/
|
||||||
void lib_on_config_init(pjsua_app_config *cfg)
|
void PjsuaOnConfig(pjsua_app_config *cfg)
|
||||||
{
|
{
|
||||||
/* Disable threading */
|
/* Disable threading */
|
||||||
cfg->cfg.thread_cnt = 0;
|
cfg->cfg.thread_cnt = 0;
|
||||||
|
@ -271,59 +292,66 @@ void lib_on_config_init(pjsua_app_config *cfg)
|
||||||
cfg->cli_cfg.telnet_cfg.ioqueue = app_ioqueue;
|
cfg->cli_cfg.telnet_cfg.ioqueue = app_ioqueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibInitL()
|
// Set Symbian OS parameters in pjlib.
|
||||||
|
// This must be done before pj_init() is called.
|
||||||
|
pj_status_t InitSymbSocket()
|
||||||
{
|
{
|
||||||
pj_symbianos_params sym_params;
|
pj_symbianos_params sym_params;
|
||||||
char* argv[] = {
|
|
||||||
"",
|
|
||||||
"--use-cli",
|
|
||||||
"--cli-telnet-port=0",
|
|
||||||
"--no-cli-console"
|
|
||||||
};
|
|
||||||
app_cfg_t app_cfg;
|
|
||||||
pj_status_t status;
|
|
||||||
TInt err;
|
TInt err;
|
||||||
|
|
||||||
// Initialize RSocketServ
|
// Initialize RSocketServ
|
||||||
if ((err=aSocketServer.Connect(32)) != KErrNone) {
|
if ((err=aSocketServer.Connect(32)) != KErrNone) {
|
||||||
status = PJ_STATUS_FROM_OS(err);
|
return PJ_STATUS_FROM_OS(err);
|
||||||
goto on_return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open up a connection
|
// Open up a connection
|
||||||
if ((err=aConn.Open(aSocketServer)) != KErrNone) {
|
if ((err=aConn.Open(aSocketServer)) != KErrNone) {
|
||||||
aSocketServer.Close();
|
aSocketServer.Close();
|
||||||
status = PJ_STATUS_FROM_OS(err);
|
return PJ_STATUS_FROM_OS(err);
|
||||||
goto on_return;
|
|
||||||
}
|
}
|
||||||
if ((err=aConn.Start()) != KErrNone) {
|
if ((err=aConn.Start()) != KErrNone) {
|
||||||
aConn.Close();
|
aConn.Close();
|
||||||
aSocketServer.Close();
|
aSocketServer.Close();
|
||||||
status = PJ_STATUS_FROM_OS(err);
|
return PJ_STATUS_FROM_OS(err);
|
||||||
goto on_return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Symbian OS parameters in pjlib.
|
|
||||||
// This must be done before pj_init() is called.
|
|
||||||
pj_bzero(&sym_params, sizeof(sym_params));
|
pj_bzero(&sym_params, sizeof(sym_params));
|
||||||
sym_params.rsocketserv = &aSocketServer;
|
sym_params.rsocketserv = &aSocketServer;
|
||||||
sym_params.rconnection = &aConn;
|
sym_params.rconnection = &aConn;
|
||||||
pj_symbianos_set_params(&sym_params);
|
pj_symbianos_set_params(&sym_params);
|
||||||
|
|
||||||
|
return PJ_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DestroySymbSocket()
|
||||||
|
{
|
||||||
|
aConn.Close();
|
||||||
|
aSocketServer.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PjsuaInitL()
|
||||||
|
{
|
||||||
|
pjsua_app_cfg_t app_cfg;
|
||||||
|
pj_status_t status;
|
||||||
|
|
||||||
|
PjsuaDestroyL();
|
||||||
|
|
||||||
pj_bzero(&app_cfg, sizeof(app_cfg));
|
pj_bzero(&app_cfg, sizeof(app_cfg));
|
||||||
app_cfg.argc = PJ_ARRAY_SIZE(argv);
|
app_cfg.argc = start_argc;
|
||||||
app_cfg.argv = argv;
|
app_cfg.argv = start_argv;
|
||||||
app_cfg.on_started = &lib_on_started;
|
app_cfg.on_started = &PjsuaOnStarted;
|
||||||
app_cfg.on_stopped = &lib_on_stopped;
|
app_cfg.on_stopped = &PjsuaOnStopped;
|
||||||
app_cfg.on_config_init = &lib_on_config_init;
|
app_cfg.on_config_init = &PjsuaOnConfig;
|
||||||
|
|
||||||
appui->PutMsg("Initializing..");
|
appui->PutMsg("Initializing..");
|
||||||
status = app_init(&app_cfg);
|
status = pjsua_app_init(&app_cfg);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
|
||||||
appui->PutMsg("Starting..");
|
appui->PutMsg("Starting..");
|
||||||
status = app_run(PJ_FALSE);
|
status = pjsua_app_run(PJ_FALSE);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
|
||||||
|
@ -332,49 +360,11 @@ on_return:
|
||||||
appui->PutMsg("Initialization failed");
|
appui->PutMsg("Initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibDestroyL()
|
void PjsuaDestroyL()
|
||||||
{
|
{
|
||||||
if (app_ioqueue) {
|
if (app_ioqueue) {
|
||||||
pj_ioqueue_destroy(app_ioqueue);
|
pj_ioqueue_destroy(app_ioqueue);
|
||||||
app_ioqueue = NULL;
|
app_ioqueue = NULL;
|
||||||
}
|
}
|
||||||
app_destroy();
|
pjsua_app_destroy();
|
||||||
CloseSTDLIB();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LibRestartL()
|
|
||||||
{
|
|
||||||
app_cfg_t app_cfg;
|
|
||||||
pj_status_t status;
|
|
||||||
|
|
||||||
/* Destroy pjsua app first */
|
|
||||||
|
|
||||||
if (app_ioqueue) {
|
|
||||||
pj_ioqueue_destroy(app_ioqueue);
|
|
||||||
app_ioqueue = NULL;
|
|
||||||
}
|
|
||||||
app_destroy();
|
|
||||||
|
|
||||||
/* Reinit pjsua app */
|
|
||||||
|
|
||||||
pj_bzero(&app_cfg, sizeof(app_cfg));
|
|
||||||
app_cfg.argc = restart_argc;
|
|
||||||
app_cfg.argv = restart_argv;
|
|
||||||
app_cfg.on_started = &lib_on_started;
|
|
||||||
app_cfg.on_stopped = &lib_on_stopped;
|
|
||||||
app_cfg.on_config_init = &lib_on_config_init;
|
|
||||||
|
|
||||||
status = app_init(&app_cfg);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
appui->PutMsg("app_init() failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run pjsua app */
|
|
||||||
|
|
||||||
status = app_run(PJ_FALSE);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
appui->PutMsg("app_run() failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,10 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <pjlib.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include <winuserm.h>
|
#include <winuserm.h>
|
||||||
#include <aygshell.h>
|
#include <aygshell.h>
|
||||||
#include "..\pjsua_app.h"
|
#include "..\pjsua_app.h"
|
||||||
|
#include "..\pjsua_app_config.h"
|
||||||
|
|
||||||
#define MAINWINDOWCLASS TEXT("PjsuaDlg")
|
#define MAINWINDOWCLASS TEXT("PjsuaDlg")
|
||||||
#define MAINWINDOWTITLE TEXT("PJSUA")
|
#define MAINWINDOWTITLE TEXT("PJSUA")
|
||||||
|
@ -39,18 +36,17 @@ static HWND g_hWndLbl;
|
||||||
static HWND g_hWndImg;
|
static HWND g_hWndImg;
|
||||||
static HBITMAP g_hBmp;
|
static HBITMAP g_hBmp;
|
||||||
|
|
||||||
static int restart_argc = 0;
|
static int start_argc;
|
||||||
static char **restart_argv = NULL;
|
static char **start_argv;
|
||||||
|
|
||||||
/* Helper funtions to init/restart/destroy the pjsua */
|
/* Helper funtions to init/destroy the pjsua */
|
||||||
static void LibInit();
|
static void PjsuaInit();
|
||||||
static void LibDestroy();
|
static void PjsuaDestroy();
|
||||||
static void LibRestart();
|
|
||||||
|
|
||||||
/* pjsua app callbacks */
|
/* pjsua app callbacks */
|
||||||
static void lib_on_started(pj_status_t status, const char* title);
|
static void PjsuaOnStarted(pj_status_t status, const char* title);
|
||||||
static pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv);
|
static void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv);
|
||||||
static void lib_on_config_init(pjsua_app_config *cfg);
|
static void PjsuaOnConfig(pjsua_app_config *cfg);
|
||||||
|
|
||||||
LRESULT CALLBACK DialogProc(const HWND hWnd,
|
LRESULT CALLBACK DialogProc(const HWND hWnd,
|
||||||
const UINT Msg,
|
const UINT Msg,
|
||||||
|
@ -85,18 +81,14 @@ LRESULT CALLBACK DialogProc(const HWND hWnd,
|
||||||
return (LRESULT)GetStockObject(BLACK_BRUSH);
|
return (LRESULT)GetStockObject(BLACK_BRUSH);
|
||||||
|
|
||||||
case WM_APP_INIT:
|
case WM_APP_INIT:
|
||||||
LibInit();
|
case WM_APP_RESTART:
|
||||||
|
PjsuaInit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_APP_DESTROY:
|
case WM_APP_DESTROY:
|
||||||
LibDestroy();
|
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_APP_RESTART:
|
|
||||||
LibRestart();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
return DefWindowProc(hWnd, Msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +99,7 @@ LRESULT CALLBACK DialogProc(const HWND hWnd,
|
||||||
|
|
||||||
/* === GUI === */
|
/* === GUI === */
|
||||||
|
|
||||||
pj_status_t gui_init()
|
pj_status_t GuiInit()
|
||||||
{
|
{
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
HWND hWnd = NULL;
|
HWND hWnd = NULL;
|
||||||
|
@ -192,7 +184,7 @@ pj_status_t gui_init()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Create logo */
|
/* Create logo */
|
||||||
g_hBmp = SHLoadDIBitmap(LOGO_PATH); // for jpeg, uses SHLoadImageFile()
|
g_hBmp = SHLoadDIBitmap(LOGO_PATH); /* for jpeg, uses SHLoadImageFile() */
|
||||||
if (g_hBmp == NULL) {
|
if (g_hBmp == NULL) {
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
return PJ_RETURN_OS_ERROR(err);
|
return PJ_RETURN_OS_ERROR(err);
|
||||||
|
@ -227,7 +219,7 @@ pj_status_t gui_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pj_status_t gui_start()
|
pj_status_t GuiStart()
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
|
@ -238,7 +230,7 @@ pj_status_t gui_start()
|
||||||
return (msg.wParam);
|
return (msg.wParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_destroy(void)
|
void GuiDestroy(void)
|
||||||
{
|
{
|
||||||
if (g_hWndMain) {
|
if (g_hWndMain) {
|
||||||
DestroyWindow(g_hWndMain);
|
DestroyWindow(g_hWndMain);
|
||||||
|
@ -266,22 +258,29 @@ void gui_destroy(void)
|
||||||
/* === ENGINE === */
|
/* === ENGINE === */
|
||||||
|
|
||||||
/* Called when pjsua is started */
|
/* Called when pjsua is started */
|
||||||
void lib_on_started(pj_status_t status, const char* title)
|
void PjsuaOnStarted(pj_status_t status, const char* title)
|
||||||
{
|
{
|
||||||
wchar_t wtitle[128];
|
wchar_t wtitle[128];
|
||||||
|
char err_msg[128];
|
||||||
|
|
||||||
PJ_UNUSED_ARG(status);
|
if (status != PJ_SUCCESS || title == NULL) {
|
||||||
|
char err_str[PJ_ERR_MSG_SIZE];
|
||||||
|
pj_strerror(status, err_str, sizeof(err_str));
|
||||||
|
pj_ansi_snprintf(err_msg, sizeof(err_msg), "%s: %s",
|
||||||
|
(title?title:"App start error"), err_str);
|
||||||
|
title = err_msg;
|
||||||
|
}
|
||||||
|
|
||||||
pj_ansi_to_unicode(title, strlen(title), wtitle, PJ_ARRAY_SIZE(wtitle));
|
pj_ansi_to_unicode(title, strlen(title), wtitle, PJ_ARRAY_SIZE(wtitle));
|
||||||
SetWindowText(g_hWndLbl, wtitle);
|
SetWindowText(g_hWndLbl, wtitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when pjsua is stopped */
|
/* Called when pjsua is stopped */
|
||||||
pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv)
|
void PjsuaOnStopped(pj_bool_t restart, int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (restart) {
|
if (restart) {
|
||||||
restart_argc = argc;
|
start_argc = argc;
|
||||||
restart_argv = argv;
|
start_argv = argv;
|
||||||
|
|
||||||
// Schedule Lib Restart
|
// Schedule Lib Restart
|
||||||
PostMessage(g_hWndMain, WM_APP_RESTART, 0, 0);
|
PostMessage(g_hWndMain, WM_APP_RESTART, 0, 0);
|
||||||
|
@ -289,41 +288,37 @@ pj_bool_t lib_on_stopped(pj_bool_t restart, int argc, char** argv)
|
||||||
/* Destroy & quit GUI, e.g: clean up window, resources */
|
/* Destroy & quit GUI, e.g: clean up window, resources */
|
||||||
PostMessage(g_hWndMain, WM_APP_DESTROY, 0, 0);
|
PostMessage(g_hWndMain, WM_APP_DESTROY, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PJ_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called before pjsua initializing config. */
|
/* Called before pjsua initializing config. */
|
||||||
void lib_on_config_init(pjsua_app_config *cfg)
|
void PjsuaOnConfig(pjsua_app_config *cfg)
|
||||||
{
|
{
|
||||||
PJ_UNUSED_ARG(cfg);
|
PJ_UNUSED_ARG(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibInit()
|
void PjsuaInit()
|
||||||
{
|
{
|
||||||
char* argv[] = {
|
pjsua_app_cfg_t app_cfg;
|
||||||
"",
|
|
||||||
"--use-cli",
|
|
||||||
"--cli-telnet-port=0",
|
|
||||||
"--no-cli-console"
|
|
||||||
};
|
|
||||||
app_cfg_t app_cfg;
|
|
||||||
pj_status_t status;
|
pj_status_t status;
|
||||||
|
|
||||||
|
/* Destroy pjsua app first */
|
||||||
|
pjsua_app_destroy();
|
||||||
|
|
||||||
|
/* Init pjsua app */
|
||||||
pj_bzero(&app_cfg, sizeof(app_cfg));
|
pj_bzero(&app_cfg, sizeof(app_cfg));
|
||||||
app_cfg.argc = PJ_ARRAY_SIZE(argv);
|
app_cfg.argc = start_argc;
|
||||||
app_cfg.argv = argv;
|
app_cfg.argv = start_argv;
|
||||||
app_cfg.on_started = &lib_on_started;
|
app_cfg.on_started = &PjsuaOnStarted;
|
||||||
app_cfg.on_stopped = &lib_on_stopped;
|
app_cfg.on_stopped = &PjsuaOnStopped;
|
||||||
app_cfg.on_config_init = &lib_on_config_init;
|
app_cfg.on_config_init = &PjsuaOnConfig;
|
||||||
|
|
||||||
SetWindowText(g_hWndLbl, _T("Initializing.."));
|
SetWindowText(g_hWndLbl, _T("Initializing.."));
|
||||||
status = app_init(&app_cfg);
|
status = pjsua_app_init(&app_cfg);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
|
||||||
SetWindowText(g_hWndLbl, _T("Starting.."));
|
SetWindowText(g_hWndLbl, _T("Starting.."));
|
||||||
status = app_run(PJ_FALSE);
|
status = pjsua_app_run(PJ_FALSE);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
|
||||||
|
@ -332,45 +327,11 @@ on_return:
|
||||||
SetWindowText(g_hWndLbl, _T("Initialization failed"));
|
SetWindowText(g_hWndLbl, _T("Initialization failed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibDestroy()
|
void PjsuaDestroy()
|
||||||
{
|
{
|
||||||
app_destroy();
|
pjsua_app_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibRestart()
|
|
||||||
{
|
|
||||||
app_cfg_t app_cfg;
|
|
||||||
pj_status_t status;
|
|
||||||
|
|
||||||
/* Destroy pjsua app first */
|
|
||||||
|
|
||||||
app_destroy();
|
|
||||||
|
|
||||||
/* Reinit pjsua app */
|
|
||||||
|
|
||||||
pj_bzero(&app_cfg, sizeof(app_cfg));
|
|
||||||
app_cfg.argc = restart_argc;
|
|
||||||
app_cfg.argv = restart_argv;
|
|
||||||
app_cfg.on_started = &lib_on_started;
|
|
||||||
app_cfg.on_stopped = &lib_on_stopped;
|
|
||||||
app_cfg.on_config_init = &lib_on_config_init;
|
|
||||||
|
|
||||||
status = app_init(&app_cfg);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
SetWindowText(g_hWndLbl, _T("app_init() failed"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run pjsua app */
|
|
||||||
|
|
||||||
status = app_run(PJ_FALSE);
|
|
||||||
if (status != PJ_SUCCESS) {
|
|
||||||
SetWindowText(g_hWndLbl, _T("app_run() failed"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* === MAIN === */
|
/* === MAIN === */
|
||||||
|
|
||||||
int WINAPI WinMain(
|
int WINAPI WinMain(
|
||||||
|
@ -389,18 +350,21 @@ int WINAPI WinMain(
|
||||||
// store the hInstance in global
|
// store the hInstance in global
|
||||||
g_hInst = hInstance;
|
g_hInst = hInstance;
|
||||||
|
|
||||||
status = gui_init();
|
// Start GUI
|
||||||
|
status = GuiInit();
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
|
||||||
// Start the engine
|
// Setup args and start pjsua
|
||||||
|
start_argc = pjsua_app_def_argc;
|
||||||
|
start_argv = (char**)pjsua_app_def_argv;
|
||||||
PostMessage(g_hWndMain, WM_APP_INIT, 0, 0);
|
PostMessage(g_hWndMain, WM_APP_INIT, 0, 0);
|
||||||
|
|
||||||
status = gui_start();
|
status = GuiStart();
|
||||||
|
|
||||||
on_return:
|
on_return:
|
||||||
LibDestroy();
|
PjsuaDestroy();
|
||||||
gui_destroy();
|
GuiDestroy();
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue