Changeset 4485
- Timestamp:
- Apr 23, 2013 5:33:59 AM (12 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/pjsua
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/bb10/.project
r4482 r4485 9 9 <buildCommand> 10 10 <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> 11 <triggers>clean,full,incremental,</triggers> 11 12 <arguments> 12 13 <dictionary> … … 20 21 <dictionary> 21 22 <key>org.eclipse.cdt.make.core.autoBuildTarget</key> 22 <value>Device- Release</value>23 <value>Device-Debug</value> 23 24 </dictionary> 24 25 <dictionary> … … 40 41 <dictionary> 41 42 <key>org.eclipse.cdt.make.core.enableAutoBuild</key> 42 <value> true</value>43 <value>false</value> 43 44 </dictionary> 44 45 <dictionary> … … 52 53 <dictionary> 53 54 <key>org.eclipse.cdt.make.core.fullBuildTarget</key> 54 <value>Device- Release</value>55 <value>Device-Debug</value> 55 56 </dictionary> 56 57 <dictionary> -
pjproject/trunk/pjsip-apps/src/pjsua/bb10/PjsuaBB.pro
r4471 r4485 6 6 7 7 SOURCES += ../../pjsua_app.c \ 8 ../../pjsua_cli_cmd.c \9 8 ../../pjsua_cli.c \ 10 9 ../../pjsua_common.c \ … … 21 20 CONFIG(release, debug|release) { 22 21 # Device-Release custom configuration 22 include(../../../../pjsip.pri) 23 LIBS += -lbb 23 24 } 24 25 } -
pjproject/trunk/pjsip-apps/src/pjsua/bb10/bar-descriptor.xml
r4471 r4485 69 69 <platformArchitecture>armle-v7</platformArchitecture> 70 70 <asset path="arm/o.le-v7-g/PjsuaBB" entry="true" type="Qnx/Elf">PjsuaBB</asset> 71 <asset path="/home/bennylp/Desktop/opt/bb10/lib/libopencore-amrnb.so.0" type="Qnx/Elf">lib/libopencore-amrnb.so.0</asset> 72 <asset path="/home/bennylp/Desktop/opt/bb10/lib/libopencore-amrwb.so.0" type="Qnx/Elf">lib/libopencore-amrwb.so.0</asset> 71 73 </configuration> 72 74 <configuration name="Device-Release"> -
pjproject/trunk/pjsip-apps/src/pjsua/bb10/src/applicationui.cpp
r4482 r4485 11 11 using namespace bb::cascades; 12 12 13 #include "../../pjsua_common.h" 14 15 extern pj_cli_telnet_on_started on_started_cb; 16 extern pj_cli_on_quit on_quit_cb; 17 18 extern "C" int main_func(int argc, char *argv[]); 19 13 /* appUI singleton */ 20 14 ApplicationUI *ApplicationUI::instance_; 21 15 22 class CliThread : public QThread 23 { 24 Q_OBJECT 25 public: 26 virtual ~CliThread() {} 27 protected: 28 void run(); 29 }; 16 #include "../../pjsua_app_config.h" 30 17 31 static void bb10_show_msg(const char *msg)18 void ApplicationUI::extDisplayMsg(const char *msg) 32 19 { 33 20 /* Qt's way to invoke method from "foreign" thread */ 34 QMetaObject::invokeMethod((QObject*)ApplicationUI::instance(), "displayMsg",35 Qt::QueuedConnection,21 QMetaObject::invokeMethod((QObject*)ApplicationUI::instance(), 22 "displayMsg", Qt::AutoConnection, 36 23 Q_ARG(QString,msg)); 37 24 } 38 25 39 static void bb10_telnet_started(pj_cli_telnet_info *telnet_info) 26 27 void ApplicationUI::pjsuaOnStartedCb(pj_status_t status, const char* msg) 40 28 { 41 char msg[64];29 char errmsg[PJ_ERR_MSG_SIZE]; 42 30 43 pj_ansi_snprintf(msg, sizeof(msg), 44 "Telnet to %.*s:%d", 45 (int)telnet_info->ip_address.slen, 46 telnet_info->ip_address.ptr, 47 telnet_info->port); 31 if (status != PJ_SUCCESS && (!msg || !*msg)) { 32 pj_strerror(status, errmsg, sizeof(errmsg)); 33 PJ_LOG(3,(THIS_FILE, "Error: %s", errmsg)); 34 msg = errmsg; 35 } else { 36 PJ_LOG(3,(THIS_FILE, "Started: %s", msg)); 37 } 48 38 49 PJ_LOG(3,(THIS_FILE, "Started: %s", msg)); 50 51 bb10_show_msg(msg); 39 ApplicationUI::extDisplayMsg(msg); 52 40 } 53 41 54 static void bb10_on_quit (pj_bool_t is_restarted) 42 43 pj_bool_t ApplicationUI::pjsuaOnStoppedCb(pj_bool_t restart, 44 int argc, char** argv) 55 45 { 56 PJ_LOG(3,("ipjsua", "CLI quit, restart(%d)", is_restarted)); 57 if (!is_restarted) { 58 bb10_show_msg("Shutting down.."); 46 PJ_LOG(3,("ipjsua", "CLI %s request", (restart? "restart" : "shutdown"))); 47 if (restart) { 48 ApplicationUI::extDisplayMsg("Restarting.."); 49 pj_thread_sleep(100); 50 ApplicationUI::instance()->extRestartRequest(argc, argv); 51 } else { 52 ApplicationUI::extDisplayMsg("Shutting down.."); 53 pj_thread_sleep(100); 59 54 ApplicationUI::instance()->isShuttingDown = true; 55 60 56 bb::cascades::Application *app = bb::cascades::Application::instance(); 61 57 app->quit(); 62 58 } 59 60 return PJ_TRUE; 63 61 } 64 62 65 void CliThread::run() 63 64 void ApplicationUI::pjsuaOnAppConfigCb(pjsua_app_config *cfg) 65 { 66 PJ_UNUSED_ARG(cfg); 67 } 68 69 void ApplicationUI::extRestartRequest(int argc, char **argv) 70 { 71 restartArgc = argc; 72 restartArgv = argv; 73 QMetaObject::invokeMethod((QObject*)this, "restartPjsua", 74 Qt::QueuedConnection); 75 } 76 77 void ApplicationUI::pjsuaStart() 66 78 { 67 79 // TODO: read from config? 68 const char *argv[] = { "pjsuabb", 69 "--use-cli", 70 "--no-cli-console", 71 "--cli-telnet-port=2323", 72 "--no-vad", 73 "--add-buddy=sip:169.254.0.2", 74 "--quality=4", 75 //(char*)"--dis-codec=*", 76 //(char*)"--add-codec=g722", 77 NULL }; 78 int argc = PJ_ARRAY_SIZE(argv) -1; 79 pj_thread_desc thread_desc; 80 pj_thread_t *thread; 80 const char **argv = pjsua_app_def_argv; 81 int argc = PJ_ARRAY_SIZE(pjsua_app_def_argv) -1; 82 app_cfg_t app_cfg; 83 pj_status_t status; 81 84 82 pj_thread_register("CliThread", thread_desc, &thread); 83 // Wait UI to be created 84 pj_thread_sleep(100); 85 isShuttingDown = false; 86 displayMsg("Starting.."); 85 87 86 on_started_cb = &bb10_telnet_started; 87 on_quit_cb = &bb10_on_quit; 88 main_func(argc, (char**)argv); 88 pj_bzero(&app_cfg, sizeof(app_cfg)); 89 if (restartArgc) { 90 app_cfg.argc = restartArgc; 91 app_cfg.argv = restartArgv; 92 } else { 93 app_cfg.argc = argc; 94 app_cfg.argv = (char**)argv; 95 } 96 app_cfg.on_started = &pjsuaOnStartedCb; 97 app_cfg.on_stopped = &pjsuaOnStoppedCb; 98 app_cfg.on_config_init = &pjsuaOnAppConfigCb; 99 100 status = app_init(&app_cfg); 101 if (status != PJ_SUCCESS) { 102 char errmsg[PJ_ERR_MSG_SIZE]; 103 pj_strerror(status, errmsg, sizeof(errmsg)); 104 displayMsg(QString("Init error:") + errmsg); 105 app_destroy(); 106 return; 107 } 108 109 status = app_run(PJ_FALSE); 110 if (status != PJ_SUCCESS) { 111 char errmsg[PJ_ERR_MSG_SIZE]; 112 pj_strerror(status, errmsg, sizeof(errmsg)); 113 displayMsg(QString("Error:") + errmsg); 114 app_destroy(); 115 } 116 117 restartArgv = NULL; 118 restartArgc = 0; 119 } 120 121 void ApplicationUI::pjsuaDestroy() 122 { 123 app_destroy(); 89 124 } 90 125 91 126 ApplicationUI::ApplicationUI(bb::cascades::Application *app) 92 : QObject(app), isShuttingDown(false) 127 : QObject(app), isShuttingDown(false), restartArgv(NULL), restartArgc(0) 93 128 { 94 129 instance_ = this; 95 130 96 // create scene document from main.qml asset97 // set parent to created document to ensure it exists for the whole application lifetime98 131 QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); 99 100 // create root object for the UI101 132 AbstractPane *root = qml->createRootObject<AbstractPane>(); 102 // set created root object as a scene103 133 app->setScene(root); 104 134 … … 106 136 connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); 107 137 108 pj_init(); 109 110 // Run CLI 111 cliThread = new CliThread; 112 cliThread->start(); 138 pjsuaStart(); 113 139 } 114 140 115 141 ApplicationUI::~ApplicationUI() 116 142 { 117 pj_shutdown();118 143 instance_ = NULL; 119 144 } … … 126 151 void ApplicationUI::aboutToQuit() 127 152 { 128 static pj_thread_desc thread_desc;129 pj_thread_t *thread;130 131 if (!pj_thread_is_registered())132 pj_thread_register("UIThread", thread_desc, &thread);133 134 153 if (!isShuttingDown) { 135 154 isShuttingDown = true; 136 155 PJ_LOG(3,(THIS_FILE, "Quit signal from GUI, shutting down pjsua..")); 137 pjsua _destroy();156 pjsuaDestroy(); 138 157 } 139 158 } … … 148 167 } 149 168 150 #include "applicationui.moc" 169 void ApplicationUI::restartPjsua() 170 { 171 pjsuaDestroy(); 172 pjsuaStart(); 173 } -
pjproject/trunk/pjsip-apps/src/pjsua/bb10/src/applicationui.h
r4473 r4485 5 5 #include <QObject> 6 6 7 #include "../../pjsua_app.h" 8 7 9 namespace bb { namespace cascades { class Application; }} 8 9 class CliThread;10 10 11 11 /*! … … 24 24 static ApplicationUI *instance(); 25 25 26 /* Write msg to label (from different thread) */ 27 static void extDisplayMsg(const char *msg); 28 29 /* Restart request (from different thread) */ 30 void extRestartRequest(int argc, char **argv); 31 26 32 public slots: 27 33 void aboutToQuit(); 28 34 35 Q_INVOKABLE void restartPjsua(); 29 36 Q_INVOKABLE void displayMsg(const QString &msg); 30 37 31 38 private: 32 CliThread *cliThread;33 39 static ApplicationUI *instance_; 40 char **restartArgv; 41 int restartArgc; 42 43 /* pjsua main operations */ 44 void pjsuaStart(); 45 void pjsuaDestroy(); 46 47 /* pjsua app callbacks */ 48 static void pjsuaOnStartedCb(pj_status_t status, const char* msg); 49 static pj_bool_t pjsuaOnStoppedCb(pj_bool_t restart, int argc, char** argv); 50 static void pjsuaOnAppConfigCb(pjsua_app_config *cfg); 34 51 }; 35 52 -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r4476 r4485 1912 1912 pj_thread_join(stdout_refresh_thread); 1913 1913 pj_thread_destroy(stdout_refresh_thread); 1914 stdout_refresh_quit = PJ_FALSE; 1914 1915 } 1915 1916 return status;
Note: See TracChangeset
for help on using the changeset viewer.