summaryrefslogtreecommitdiff
path: root/pjsip-apps/src/symbian_ua
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-05-03 19:56:21 +0000
committerBenny Prijono <bennylp@teluu.com>2007-05-03 19:56:21 +0000
commit0a2d5c3cd9d32c77fcf23976736324ebb0565d44 (patch)
treebebc99d373b81095046eda50cc6383040beb8835 /pjsip-apps/src/symbian_ua
parentabb1aee315f44c03cc3da3627a93651cdd9ca15e (diff)
Misc Symbian fixes, looks good
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1248 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/symbian_ua')
-rw-r--r--pjsip-apps/src/symbian_ua/main_symbian.cpp126
-rw-r--r--pjsip-apps/src/symbian_ua/ua.cpp62
2 files changed, 84 insertions, 104 deletions
diff --git a/pjsip-apps/src/symbian_ua/main_symbian.cpp b/pjsip-apps/src/symbian_ua/main_symbian.cpp
index 640fb2d4..cdfcd9f4 100644
--- a/pjsip-apps/src/symbian_ua/main_symbian.cpp
+++ b/pjsip-apps/src/symbian_ua/main_symbian.cpp
@@ -24,55 +24,35 @@
// Global Variables
CConsoleBase* console;
-static CActiveSchedulerWait *asw;
-// Local Functions
-
-LOCAL_C void MainL()
-{
- //
- // add your program code here, example code below
- //
- int rc = ua_main();
-
- asw->AsyncStop();
-}
-
-class MyScheduler : public CActiveScheduler
-{
-public:
- MyScheduler()
- {}
-
- void Error(TInt aError) const;
-};
-
-void MyScheduler::Error(TInt aError) const
-{
- PJ_UNUSED_ARG(aError);
-}
-
+/////////////////////////////////////
class MyTask : public CActive
{
public:
- static MyTask *NewL();
+ static MyTask *NewL(CActiveSchedulerWait *asw);
+ ~MyTask();
void Start();
protected:
- MyTask();
+ MyTask(CActiveSchedulerWait *asw);
void ConstructL();
virtual void RunL();
virtual void DoCancel();
- TInt RunError(TInt aError);
private:
RTimer timer_;
+ CActiveSchedulerWait *asw_;
};
-MyTask::MyTask()
-: CActive(EPriorityNormal)
+MyTask::MyTask(CActiveSchedulerWait *asw)
+: CActive(EPriorityNormal), asw_(asw)
+{
+}
+
+MyTask::~MyTask()
{
+ timer_.Close();
}
void MyTask::ConstructL()
@@ -81,9 +61,9 @@ void MyTask::ConstructL()
CActiveScheduler::Add(this);
}
-MyTask *MyTask::NewL()
+MyTask *MyTask::NewL(CActiveSchedulerWait *asw)
{
- MyTask *self = new (ELeave) MyTask;
+ MyTask *self = new (ELeave) MyTask(asw);
CleanupStack::PushL(self);
self->ConstructL();
@@ -100,74 +80,36 @@ void MyTask::Start()
void MyTask::RunL()
{
- MainL();
+ int rc = ua_main();
+ asw_->AsyncStop();
}
void MyTask::DoCancel()
{
}
-TInt MyTask::RunError(TInt aError)
-{
- PJ_UNUSED_ARG(aError);
- return KErrNone;
-}
-
-
LOCAL_C void DoStartL()
{
- // Create active scheduler (to run active objects)
- MyScheduler* scheduler = new (ELeave) MyScheduler;
+ CActiveScheduler *scheduler = new (ELeave) CActiveScheduler;
CleanupStack::PushL(scheduler);
CActiveScheduler::Install(scheduler);
- MyTask *task = MyTask::NewL();
+ CActiveSchedulerWait *asw = new CActiveSchedulerWait;
+ CleanupStack::PushL(asw);
+
+ MyTask *task = MyTask::NewL(asw);
task->Start();
- asw = new CActiveSchedulerWait;
asw->Start();
+ delete task;
+
+ CleanupStack::Pop(asw);
delete asw;
+
+ CActiveScheduler::Install(NULL);
CleanupStack::Pop(scheduler);
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-
-class TMyTrapHandler : public TTrapHandler
-{
-public:
- void Install();
- void Uninstall();
- virtual IMPORT_C void Trap();
- virtual IMPORT_C void UnTrap();
- virtual IMPORT_C void Leave(TInt aValue);
-
-private:
- TTrapHandler *prev_;
-};
-
-void TMyTrapHandler::Install() {
- prev_ = User::SetTrapHandler(this);
-}
-
-void TMyTrapHandler::Uninstall() {
- User::SetTrapHandler(prev_);
-}
-
-IMPORT_C void TMyTrapHandler::Trap()
-{
- prev_->Trap();
-}
-
-IMPORT_C void TMyTrapHandler::UnTrap()
-{
- prev_->UnTrap();
-}
-
-IMPORT_C void TMyTrapHandler::Leave(TInt aValue)
-{
- prev_->Leave(aValue);
+ delete scheduler;
}
@@ -176,12 +118,8 @@ IMPORT_C void TMyTrapHandler::Leave(TInt aValue)
// Global Functions
GLDEF_C TInt E32Main()
{
- TMyTrapHandler th;
-
- th.Install();
-
// Create cleanup stack
- //__UHEAP_MARK;
+ __UHEAP_MARK;
CTrapCleanup* cleanup = CTrapCleanup::New();
// Create output console
@@ -192,13 +130,13 @@ GLDEF_C TInt E32Main()
TRAPD(startError, DoStartL());
console->Printf(_L("[press any key to close]\n"));
- console->Getch();
+ //console->Getch();
delete console;
delete cleanup;
- //__UHEAP_MARKEND;
-
- th.Uninstall();
+
+ CloseSTDLIB();
+ __UHEAP_MARKEND;
return KErrNone;
}
diff --git a/pjsip-apps/src/symbian_ua/ua.cpp b/pjsip-apps/src/symbian_ua/ua.cpp
index ee84eaf2..cc59091d 100644
--- a/pjsip-apps/src/symbian_ua/ua.cpp
+++ b/pjsip-apps/src/symbian_ua/ua.cpp
@@ -46,21 +46,50 @@
//
// Destination URI (to make call, or to subscribe presence)
//
-#define SIP_DST_URI "sip:192.168.0.70:5061"
+#define SIP_DST_URI "sip:192.168.0.7:5061"
//
// Account
//
#define HAS_SIP_ACCOUNT 0 // 0 to disable registration
-#define SIP_DOMAIN "colinux"
-#define SIP_USER "bulukucing"
-#define SIP_PASSWD "netura"
+#define SIP_DOMAIN "server"
+#define SIP_USER "user"
+#define SIP_PASSWD "password"
//
// Outbound proxy for all accounts
//
#define SIP_PROXY NULL
-//#define SIP_PROXY "sip:192.168.0.1"
+//#define SIP_PROXY "sip:192.168.0.8"
+
+
+//
+// Configure nameserver if DNS SRV is to be used with both SIP
+// or STUN (for STUN see other settings below)
+//
+#define NAMESERVER NULL
+//#define NAMESERVER "62.241.163.201"
+
+//
+// STUN server
+#if 0
+ // Use this to have the STUN server resolved normally
+# define STUN_DOMAIN NULL
+# define STUN_SERVER "stun.fwdnet.net"
+#elif 0
+ // Use this to have the STUN server resolved with DNS SRV
+# define STUN_DOMAIN "iptel.org"
+# define STUN_SERVER NULL
+#else
+ // Use this to disable STUN
+# define STUN_DOMAIN NULL
+# define STUN_SERVER NULL
+#endif
+
+//
+// Use ICE?
+//
+#define USE_ICE 1
//
@@ -93,8 +122,8 @@ static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
g_call_id = call_id;
- /* Automatically answer incoming calls with 200/OK */
- pjsua_call_answer(call_id, 200, NULL, NULL);
+ /* Automatically answer incoming calls with 180/Ringing */
+ pjsua_call_answer(call_id, 180, NULL, NULL);
}
/* Callback called by the library when call's state has changed */
@@ -109,7 +138,7 @@ static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
if (call_id == g_call_id)
g_call_id = PJSUA_INVALID_ID;
- } else {
+ } else if (ci.state != PJSIP_INV_STATE_INCOMING) {
if (g_call_id == PJSUA_INVALID_ID)
g_call_id = call_id;
}
@@ -275,6 +304,18 @@ static pj_status_t app_startup()
cfg.outbound_proxy[0] = pj_str(SIP_PROXY);
}
+ if (NAMESERVER) {
+ cfg.nameserver_count = 1;
+ cfg.nameserver[0] = pj_str(NAMESERVER);
+ }
+
+ if (NAMESERVER && STUN_DOMAIN) {
+ cfg.stun_domain = pj_str(STUN_DOMAIN);
+ } else if (STUN_SERVER) {
+ cfg.stun_host = pj_str(STUN_SERVER);
+ }
+
+
pjsua_logging_config_default(&log_cfg);
log_cfg.console_level = 4;
log_cfg.cb = &log_writer;
@@ -284,6 +325,7 @@ static pj_status_t app_startup()
med_cfg.has_ioqueue = PJ_FALSE;
med_cfg.clock_rate = 8000;
med_cfg.ec_tail_len = 0;
+ med_cfg.enable_ice = USE_ICE;
status = pjsua_init(&cfg, &log_cfg, &med_cfg);
if (status != PJ_SUCCESS) {
@@ -482,6 +524,7 @@ void ConsoleUI::RunL()
Run();
}
+
////////////////////////////////////////////////////////////////////////////
int ua_main()
{
@@ -491,8 +534,7 @@ int ua_main()
status = app_startup();
if (status != PJ_SUCCESS)
return status;
-
-
+
// Run the UI
CActiveSchedulerWait *asw = new CActiveSchedulerWait;
ConsoleUI *con = new ConsoleUI(asw, console);