summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-03-01 19:29:10 +0000
committerBenny Prijono <bennylp@teluu.com>2006-03-01 19:29:10 +0000
commit6b8c1eb422e7f06384c7bad0c91f7680c6b73a33 (patch)
tree333879b32dc295e05c64f1b7fbceb7354b1fca26
parentafed82d0613050254f3d877292342e7cc92bc02f (diff)
Moved pjsua to pjsip-apps
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@253 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/build/Makefile27
-rw-r--r--pjsip/build/os-win32.mak2
-rw-r--r--pjsip/build/pjsip_auth_lib.dsp122
-rw-r--r--pjsip/build/pjsua.dsp105
-rw-r--r--pjsip/include/pjsip/sip_transaction.h2
-rw-r--r--pjsip/include/pjsip/sip_ua_layer.h4
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h1
-rw-r--r--pjsip/src/pjsip/sip_endpoint.c5
-rw-r--r--pjsip/src/pjsip/sip_transaction.c36
-rw-r--r--pjsip/src/pjsip/sip_ua_layer.c47
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c11
-rw-r--r--pjsip/src/pjsua-lib/pjsua_opt.c21
-rw-r--r--pjsip/src/pjsua-lib/pjsua_reg.c70
-rw-r--r--pjsip/src/pjsua/main.c910
14 files changed, 121 insertions, 1242 deletions
diff --git a/pjsip/build/Makefile b/pjsip/build/Makefile
index fa0a7e28..099c6363 100644
--- a/pjsip/build/Makefile
+++ b/pjsip/build/Makefile
@@ -74,24 +74,12 @@ export PJSUA_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
export PJSUA_LIB_CFLAGS += $(_CFLAGS)
-###############################################################################
-# Defines for building PJSUA
-#
-export PJSUA_SRCDIR = ../src/pjsua
-export PJSUA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
- main.o
-export PJSUA_CFLAGS += $(_CFLAGS)
-export PJSUA_LDFLAGS += $(_LDFLAGS)
-export PJSUA_EXE:=../bin/pjsua-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME)$(HOST_EXE)
-
-
-
export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
###############################################################################
# Main entry
#
#
-TARGETS := pjsip pjsip-ua pjsip-simple pjsua-lib pjsua
+TARGETS := pjsip pjsip-ua pjsip-simple pjsua-lib
.PHONY: $(TARGETS)
@@ -103,7 +91,7 @@ doc:
dep: depend
distclean: realclean
-.PHONY: dep depend pjsip pjsip-ua pjsua-lib pjsua clean realclean distclean
+.PHONY: dep depend pjsip pjsip-ua pjsua-lib clean realclean distclean
pjsip:
$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $(PJSIP_LIB)
@@ -117,9 +105,6 @@ pjsip-simple:
pjsua-lib:
$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $(PJSUA_LIB_LIB)
-pjsua:
- $(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(PJSUA_EXE)
-
.PHONY: ../lib/pjsip.ko
../lib/pjsip.ko:
echo Making $@
@@ -140,19 +125,11 @@ pjsua:
echo Making $@
$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $@
-.PHONY: ../lib/pjsua.ko
-../lib/pjsua.ko:
- $(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $@
-
clean depend realclean:
$(MAKE) -f $(RULES_MAK) APP=PJSIP app=pjsip $@
$(MAKE) -f $(RULES_MAK) APP=PJSIP_UA app=pjsip-ua $@
$(MAKE) -f $(RULES_MAK) APP=PJSIP_SIMPLE app=pjsip-simple $@
$(MAKE) -f $(RULES_MAK) APP=PJSUA_LIB app=pjsua-lib $@
- $(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $@
- @if test "$@" == "depend"; then \
- echo '$(PJSUA_EXE): $(PJSIP_LIB) $(PJSIP_UA_LIB) $(PJSIP_SIMPLE) $(PJSUA_LIB_LIB) $(PJLIB_LIB) $(PJLIB_UTIL_LIB) $(PJMEDIA_LIB) $(PJMEDIA_CODEC_LIB)' >> .pjsua-$(MACHINE_NAME)-$(OS_NAME)-$(CC_NAME).depend; \
- fi
diff --git a/pjsip/build/os-win32.mak b/pjsip/build/os-win32.mak
deleted file mode 100644
index 30f422e0..00000000
--- a/pjsip/build/os-win32.mak
+++ /dev/null
@@ -1,2 +0,0 @@
-
-export LDFLAGS += -lwinmm
diff --git a/pjsip/build/pjsip_auth_lib.dsp b/pjsip/build/pjsip_auth_lib.dsp
deleted file mode 100644
index 3070234e..00000000
--- a/pjsip/build/pjsip_auth_lib.dsp
+++ /dev/null
@@ -1,122 +0,0 @@
-# Microsoft Developer Studio Project File - Name="pjsip_auth_lib" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Static Library" 0x0104
-
-CFG=pjsip_auth_lib - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "pjsip_auth_lib.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "pjsip_auth_lib.mak" CFG="pjsip_auth_lib - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "pjsip_auth_lib - Win32 Release" (based on "Win32 (x86) Static Library")
-!MESSAGE "pjsip_auth_lib - Win32 Debug" (based on "Win32 (x86) Static Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""$/pjproject/pjsip/build", RIAAAAAA"
-# PROP Scc_LocalPath "."
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "pjsip_auth_lib - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "./output/pjsip_auth_vc6_Release"
-# PROP BASE Intermediate_Dir "./output/pjsip_auth_vc6_Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "./output/pjsip_auth_vc6_Release"
-# PROP Intermediate_Dir "./output/pjsip_auth_vc6_Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /GX /O2 /I "../src" /I "../../pjsip/src" /I "../../pjlib/src" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"../lib/pjsip_auth_vc6s.lib"
-
-!ELSEIF "$(CFG)" == "pjsip_auth_lib - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "./output/pjsip_auth_vc6_Debug"
-# PROP BASE Intermediate_Dir "./output/pjsip_auth_vc6_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "./output/pjsip_auth_vc6_Debug"
-# PROP Intermediate_Dir "./output/pjsip_auth_vc6_Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../src" /I "../../pjsip/src" /I "../../pjlib/src" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LIB32=link.exe -lib
-# ADD BASE LIB32 /nologo
-# ADD LIB32 /nologo /out:"../lib/pjsip_auth_vc6sd.lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "pjsip_auth_lib - Win32 Release"
-# Name "pjsip_auth_lib - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth\sip_auth.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth\sip_auth_msg.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth\sip_auth_parser.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth\sip_auth.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth\sip_auth_msg.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\pjsip_auth\sip_auth_parser.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/pjsip/build/pjsua.dsp b/pjsip/build/pjsua.dsp
deleted file mode 100644
index 23bdfa0a..00000000
--- a/pjsip/build/pjsua.dsp
+++ /dev/null
@@ -1,105 +0,0 @@
-# Microsoft Developer Studio Project File - Name="pjsua" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=pjsua - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "pjsua.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "pjsua.mak" CFG="pjsua - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "pjsua - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "pjsua - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""$/pjproject/pjsip/build", RIAAAAAA"
-# PROP Scc_LocalPath "."
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "pjsua - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\output\pjsua-i386-win32-vc6-release"
-# PROP BASE Intermediate_Dir ".\output\pjsua-i386-win32-vc6-release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\output\pjsua-i386-win32-vc6-release"
-# PROP Intermediate_Dir ".\output\pjsua-i386-win32-vc6-release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /GX /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjmedia/include" /D "NDEBUG" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 dsound.lib dxguid.lib netapi32.lib mswsock.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /map /machine:I386 /out:"../bin/pjsua_vc6.exe" /fixed:no
-# SUBTRACT LINK32 /pdb:none /debug
-
-!ELSEIF "$(CFG)" == "pjsua - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\output\pjsua-i386-win32-vc6-debug"
-# PROP BASE Intermediate_Dir ".\output\pjsua-i386-win32-vc6-debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\output\pjsua-i386-win32-vc6-debug"
-# PROP Intermediate_Dir ".\output\pjsua-i386-win32-vc6-debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../../pjmedia/include" /D "_DEBUG" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
-# SUBTRACT CPP /YX
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 dsound.lib dxguid.lib netapi32.lib mswsock.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/pjsua_vc6d.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "pjsua - Win32 Release"
-# Name "pjsua - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\src\pjsua\main.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/pjsip/include/pjsip/sip_transaction.h b/pjsip/include/pjsip/sip_transaction.h
index 1ffcbc3c..7878ec66 100644
--- a/pjsip/include/pjsip/sip_transaction.h
+++ b/pjsip/include/pjsip/sip_transaction.h
@@ -283,7 +283,7 @@ PJ_DECL(pjsip_transaction*) pjsip_rdata_get_tsx( pjsip_rx_data *rdata );
/*
* Dump transaction layer.
*/
-PJ_DECL(void) pjsip_tsx_layer_dump(void);
+PJ_DECL(void) pjsip_tsx_layer_dump(pj_bool_t detail);
/*
* Get the string name for the state.
diff --git a/pjsip/include/pjsip/sip_ua_layer.h b/pjsip/include/pjsip/sip_ua_layer.h
index 983efb5d..4c62bec6 100644
--- a/pjsip/include/pjsip/sip_ua_layer.h
+++ b/pjsip/include/pjsip/sip_ua_layer.h
@@ -74,8 +74,10 @@ PJ_DECL(pj_status_t) pjsip_ua_destroy(void);
/**
* Dump user agent contents (e.g. all dialogs).
+ *
+ * @param detail If non-zero, list of dialogs will be printed.
*/
-PJ_DEF(void) pjsip_ua_dump(void);
+PJ_DEF(void) pjsip_ua_dump(pj_bool_t detail);
/**
* Get the endpoint instance of a user agent module.
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 09874160..c7cdc124 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -175,6 +175,7 @@ struct pjsua
/* Media: */
+ int start_rtp_port;/**< Start of RTP port to try. */
pjmedia_endpt *med_endpt; /**< Media endpoint. */
pjmedia_conf *mconf; /**< Media conference. */
pj_bool_t null_audio; /**< Null audio flag. */
diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c
index 1c90816e..97c7130f 100644
--- a/pjsip/src/pjsip/sip_endpoint.c
+++ b/pjsip/src/pjsip/sip_endpoint.c
@@ -606,6 +606,11 @@ PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt,
timeout.sec = timeout.msec = 0;
pj_timer_heap_poll( endpt->timer_heap, &timeout );
+ /* timer_heap_poll should never ever returns negative value, or otherwise
+ * ioqueue_poll() will block forever!
+ */
+ pj_assert(timeout.sec >= 0 && timeout.msec >= 0);
+
/* If caller specifies maximum time to wait, then compare the value with
* the timeout to wait from timer, and use the minimum value.
*/
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
index 631bd14c..6f8d6b0e 100644
--- a/pjsip/src/pjsip/sip_transaction.c
+++ b/pjsip/src/pjsip/sip_transaction.c
@@ -761,7 +761,7 @@ PJ_DEF(pjsip_transaction*) pjsip_rdata_get_tsx( pjsip_rx_data *rdata )
/*
* Dump transaction layer.
*/
-PJ_DEF(void) pjsip_tsx_layer_dump(void)
+PJ_DEF(void) pjsip_tsx_layer_dump(pj_bool_t detail)
{
#if PJ_LOG_MAX_LEVEL >= 3
pj_hash_iterator_t itbuf, *it;
@@ -770,21 +770,27 @@ PJ_DEF(void) pjsip_tsx_layer_dump(void)
pj_mutex_lock(mod_tsx_layer.mutex);
PJ_LOG(3, (THIS_FILE, "Dumping transaction table:"));
+ PJ_LOG(3, (THIS_FILE, " Total %d transactions",
+ pj_hash_count(mod_tsx_layer.htable)));
- it = pj_hash_first(mod_tsx_layer.htable, &itbuf);
- if (it == NULL) {
- PJ_LOG(3, (THIS_FILE, " - none - "));
- } else {
- while (it != NULL) {
- pjsip_transaction *tsx = pj_hash_this( mod_tsx_layer.htable, it);
-
- PJ_LOG(3, (THIS_FILE, " %s %s|%d|%s",
- tsx->obj_name,
- (tsx->last_tx? pjsip_tx_data_get_info(tsx->last_tx): "none"),
- tsx->status_code,
- pjsip_tsx_state_str(tsx->state)));
-
- it = pj_hash_next(mod_tsx_layer.htable, it);
+ if (detail) {
+ it = pj_hash_first(mod_tsx_layer.htable, &itbuf);
+ if (it == NULL) {
+ PJ_LOG(3, (THIS_FILE, " - none - "));
+ } else {
+ while (it != NULL) {
+ pjsip_transaction *tsx = pj_hash_this(mod_tsx_layer.htable,it);
+
+ PJ_LOG(3, (THIS_FILE, " %s %s|%d|%s",
+ tsx->obj_name,
+ (tsx->last_tx?
+ pjsip_tx_data_get_info(tsx->last_tx):
+ "none"),
+ tsx->status_code,
+ pjsip_tsx_state_str(tsx->state)));
+
+ it = pj_hash_next(mod_tsx_layer.htable, it);
+ }
}
}
diff --git a/pjsip/src/pjsip/sip_ua_layer.c b/pjsip/src/pjsip/sip_ua_layer.c
index 6fe2d551..9776ce5f 100644
--- a/pjsip/src/pjsip/sip_ua_layer.c
+++ b/pjsip/src/pjsip/sip_ua_layer.c
@@ -777,7 +777,7 @@ static void print_dialog( const char *title,
/*
* Dump user agent contents (e.g. all dialogs).
*/
-PJ_DEF(void) pjsip_ua_dump(void)
+PJ_DEF(void) pjsip_ua_dump(pj_bool_t detail)
{
#if PJ_LOG_MAX_LEVEL >= 3
pj_hash_iterator_t itbuf, *it;
@@ -785,33 +785,36 @@ PJ_DEF(void) pjsip_ua_dump(void)
pj_mutex_lock(mod_ua.mutex);
- PJ_LOG(3, (THIS_FILE, "Number of dialog sets: %u", pj_hash_count(mod_ua.dlg_table)));
- PJ_LOG(3, (THIS_FILE, "Dumping dialog sets:"));
+ PJ_LOG(3, (THIS_FILE, "Number of dialog sets: %u",
+ pj_hash_count(mod_ua.dlg_table)));
- it = pj_hash_first(mod_ua.dlg_table, &itbuf);
- for (; it != NULL; it = pj_hash_next(mod_ua.dlg_table, it)) {
- struct dlg_set *dlg_set;
- pjsip_dialog *dlg;
- const char *title;
+ if (detail && pj_hash_count(mod_ua.dlg_table)) {
+ PJ_LOG(3, (THIS_FILE, "Dumping dialog sets:"));
+ it = pj_hash_first(mod_ua.dlg_table, &itbuf);
+ for (; it != NULL; it = pj_hash_next(mod_ua.dlg_table, it)) {
+ struct dlg_set *dlg_set;
+ pjsip_dialog *dlg;
+ const char *title;
- dlg_set = pj_hash_this(mod_ua.dlg_table, it);
- if (!dlg_set || pj_list_empty(&dlg_set->dlg_list)) continue;
+ dlg_set = pj_hash_this(mod_ua.dlg_table, it);
+ if (!dlg_set || pj_list_empty(&dlg_set->dlg_list)) continue;
- /* First dialog in dialog set. */
- dlg = dlg_set->dlg_list.next;
- if (dlg->role == PJSIP_ROLE_UAC)
- title = " [out] ";
- else
- title = " [in] ";
+ /* First dialog in dialog set. */
+ dlg = dlg_set->dlg_list.next;
+ if (dlg->role == PJSIP_ROLE_UAC)
+ title = " [out] ";
+ else
+ title = " [in] ";
- print_dialog(title, dlg, dlginfo, sizeof(dlginfo));
- PJ_LOG(3,(THIS_FILE, "%s", dlginfo));
+ print_dialog(title, dlg, dlginfo, sizeof(dlginfo));
+ PJ_LOG(3,(THIS_FILE, "%s", dlginfo));
- /* Next dialog in dialog set (forked) */
- dlg = dlg->next;
- while (dlg != (pjsip_dialog*) &dlg_set->dlg_list) {
- print_dialog(" [forked] ", dlg, dlginfo, sizeof(dlginfo));
+ /* Next dialog in dialog set (forked) */
dlg = dlg->next;
+ while (dlg != (pjsip_dialog*) &dlg_set->dlg_list) {
+ print_dialog(" [forked] ", dlg, dlginfo, sizeof(dlginfo));
+ dlg = dlg->next;
+ }
}
}
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index c468f85b..775c96ba 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -58,6 +58,10 @@ void pjsua_default(void)
pjsua.sip_port = 5060;
+ /* Default we start RTP at port 4000 */
+ pjsua.start_rtp_port = 4000;
+
+
/* Default logging settings: */
pjsua.log_level = 5;
pjsua.app_log_level = 4;
@@ -138,8 +142,6 @@ static pj_status_t init_sockets(pj_bool_t sip,
pjmedia_sock_info *skinfo)
{
enum {
- RTP_START_PORT = 4000,
- RTP_RANDOM_START = 2,
RTP_RETRY = 100
};
enum {
@@ -148,11 +150,14 @@ static pj_status_t init_sockets(pj_bool_t sip,
RTCP_SOCK,
};
int i;
- static pj_uint16_t rtp_port = RTP_START_PORT;
+ static pj_uint16_t rtp_port;
pj_sock_t sock[3];
pj_sockaddr_in mapped_addr[3];
pj_status_t status = PJ_SUCCESS;
+ if (rtp_port == 0)
+ rtp_port = (pj_uint16_t)pjsua.start_rtp_port;
+
for (i=0; i<3; ++i)
sock[i] = PJ_INVALID_SOCKET;
diff --git a/pjsip/src/pjsua-lib/pjsua_opt.c b/pjsip/src/pjsua-lib/pjsua_opt.c
index bdd1a421..c8b0adac 100644
--- a/pjsip/src/pjsua-lib/pjsua_opt.c
+++ b/pjsip/src/pjsua-lib/pjsua_opt.c
@@ -82,6 +82,7 @@ static void usage(void)
puts(" --auto-play Automatically play the file (to incoming calls only)");
puts(" --auto-loop Automatically loop incoming RTP to outgoing RTP");
puts(" --auto-conf Automatically put incoming calls to conference");
+ puts(" --rtp-port=N Base port to try for RTP");
puts("");
puts("Buddy List (can be more than one):");
puts(" --add-buddy url Add the specified URL to the buddy list.");
@@ -211,7 +212,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP,
OPT_AUTO_CONF,
- OPT_PLAY_FILE,
+ OPT_PLAY_FILE, OPT_RTP_PORT,
OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS,
};
struct option long_options[] = {
@@ -243,6 +244,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
{ "auto-loop", 0, 0, OPT_AUTO_LOOP},
{ "auto-conf", 0, 0, OPT_AUTO_CONF},
{ "play-file", 1, 0, OPT_PLAY_FILE},
+ { "rtp-port", 1, 0, OPT_RTP_PORT},
{ "next-account",0,0, OPT_NEXT_ACCOUNT},
{ "next-cred", 0, 0, OPT_NEXT_CRED},
{ "max-calls", 1, 0, OPT_MAX_CALLS},
@@ -462,10 +464,19 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
pjsua.wav_file = optarg;
break;
+ case OPT_RTP_PORT:
+ pjsua.start_rtp_port = my_atoi(optarg);
+ if (pjsua.start_rtp_port < 1 || pjsua.start_rtp_port > 65535) {
+ PJ_LOG(1,(THIS_FILE,
+ "Error: rtp-port argument value (expecting 1-65535"));
+ return -1;
+ }
+
case OPT_AUTO_ANSWER:
pjsua.auto_answer = my_atoi(optarg);
if (pjsua.auto_answer < 100 || pjsua.auto_answer > 699) {
- puts("Error: invalid code in --auto-answer (expecting 100-699");
+ PJ_LOG(1,(THIS_FILE,
+ "Error: invalid code in --auto-answer (expecting 100-699"));
return -1;
}
break;
@@ -473,7 +484,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
case OPT_MAX_CALLS:
pjsua.max_calls = my_atoi(optarg);
if (pjsua.max_calls < 1 || pjsua.max_calls > 255) {
- puts("Too many calls for max-calls (1-255)");
+ PJ_LOG(1,(THIS_FILE,"Too many calls for max-calls (1-255)"));
return -1;
}
break;
@@ -577,8 +588,8 @@ void pjsua_dump(void)
pjsip_endpt_dump(pjsua.endpt, 1);
pjmedia_endpt_dump(pjsua.med_endpt);
- pjsip_tsx_layer_dump();
- pjsip_ua_dump();
+ pjsip_tsx_layer_dump(1);
+ pjsip_ua_dump(1);
/* Dump all invite sessions: */
diff --git a/pjsip/src/pjsua-lib/pjsua_reg.c b/pjsip/src/pjsua-lib/pjsua_reg.c
index e18f7cc8..1552acf6 100644
--- a/pjsip/src/pjsua-lib/pjsua_reg.c
+++ b/pjsip/src/pjsua-lib/pjsua_reg.c
@@ -86,8 +86,8 @@ static void regc_cb(struct pjsip_regc_cbparam *param)
*/
void pjsua_regc_update(int acc_index, pj_bool_t renew)
{
- pj_status_t status;
- pjsip_tx_data *tdata;
+ pj_status_t status = 0;
+ pjsip_tx_data *tdata = 0;
if (renew) {
if (pjsua.acc[acc_index].regc == NULL) {
@@ -98,7 +98,12 @@ void pjsua_regc_update(int acc_index, pj_bool_t renew)
return;
}
}
- status = pjsip_regc_register(pjsua.acc[acc_index].regc, 1, &tdata);
+ if (!pjsua.acc[acc_index].regc)
+ return;
+
+ status = pjsip_regc_register(pjsua.acc[acc_index].regc, 1,
+ &tdata);
+
} else {
if (pjsua.acc[acc_index].regc == NULL) {
PJ_LOG(3,(THIS_FILE, "Currently not registered"));
@@ -126,41 +131,44 @@ pj_status_t pjsua_regc_init(int acc_index)
{
pj_status_t status;
+ if (pjsua.acc[acc_index].reg_uri.slen == 0) {
+ PJ_LOG(3,(THIS_FILE, "Registrar URI is not specified"));
+ return PJ_SUCCESS;
+ }
+
/* initialize SIP registration if registrar is configured */
- if (pjsua.acc[acc_index].reg_uri.slen) {
- status = pjsip_regc_create( pjsua.endpt,
- &pjsua.acc[acc_index],
- &regc_cb,
- &pjsua.acc[acc_index].regc);
+ status = pjsip_regc_create( pjsua.endpt,
+ &pjsua.acc[acc_index],
+ &regc_cb,
+ &pjsua.acc[acc_index].regc);
- if (status != PJ_SUCCESS) {
- pjsua_perror(THIS_FILE, "Unable to create client registration",
- status);
- return status;
- }
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE, "Unable to create client registration",
+ status);
+ return status;
+ }
- status = pjsip_regc_init( pjsua.acc[acc_index].regc,
- &pjsua.acc[acc_index].reg_uri,
- &pjsua.acc[acc_index].local_uri,
- &pjsua.acc[acc_index].local_uri,
- 1, &pjsua.acc[acc_index].contact_uri,
- pjsua.acc[acc_index].reg_timeout);
- if (status != PJ_SUCCESS) {
- pjsua_perror(THIS_FILE,
- "Client registration initialization error",
- status);
- return status;
- }
+ status = pjsip_regc_init( pjsua.acc[acc_index].regc,
+ &pjsua.acc[acc_index].reg_uri,
+ &pjsua.acc[acc_index].local_uri,
+ &pjsua.acc[acc_index].local_uri,
+ 1, &pjsua.acc[acc_index].contact_uri,
+ pjsua.acc[acc_index].reg_timeout);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE,
+ "Client registration initialization error",
+ status);
+ return status;
+ }
- pjsip_regc_set_credentials( pjsua.acc[acc_index].regc,
- pjsua.cred_count,
- pjsua.cred_info );
+ pjsip_regc_set_credentials( pjsua.acc[acc_index].regc,
+ pjsua.cred_count,
+ pjsua.cred_info );
- pjsip_regc_set_route_set( pjsua.acc[acc_index].regc,
- &pjsua.acc[acc_index].route_set );
- }
+ pjsip_regc_set_route_set( pjsua.acc[acc_index].regc,
+ &pjsua.acc[acc_index].route_set );
return PJ_SUCCESS;
}
diff --git a/pjsip/src/pjsua/main.c b/pjsip/src/pjsua/main.c
deleted file mode 100644
index ce317078..00000000
--- a/pjsip/src/pjsua/main.c
+++ /dev/null
@@ -1,910 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <pjsua-lib/pjsua.h>
-#include <stdlib.h>
-
-
-#define THIS_FILE "main.c"
-
-/* Current dialog */
-static int current_acc;
-static int current_call = -1;
-
-
-/*
- * Find next call.
- */
-static pj_bool_t find_next_call(void)
-{
- int i;
-
- for (i=current_call+1; i<(int)pjsua.max_calls; ++i) {
- if (pjsua.calls[i].inv != NULL) {
- current_call = i;
- return PJ_TRUE;
- }
- }
-
- for (i=0; i<current_call; ++i) {
- if (pjsua.calls[i].inv != NULL) {
- current_call = i;
- return PJ_TRUE;
- }
- }
-
- current_call = -1;
- return PJ_FALSE;
-}
-
-
-/*
- * Find previous call.
- */
-static pj_bool_t find_prev_call(void)
-{
- int i;
-
- for (i=current_call-1; i>=0; --i) {
- if (pjsua.calls[i].inv != NULL) {
- current_call = i;
- return PJ_TRUE;
- }
- }
-
- for (i=pjsua.max_calls-1; i>current_call; --i) {
- if (pjsua.calls[i].inv != NULL) {
- current_call = i;
- return PJ_TRUE;
- }
- }
-
- current_call = -1;
- return PJ_FALSE;
-}
-
-
-
-/*
- * Notify UI when invite state has changed.
- */
-void pjsua_ui_inv_on_state_changed(int call_index, pjsip_event *e)
-{
- pjsua_call *call = &pjsua.calls[call_index];
-
- PJ_UNUSED_ARG(e);
-
- PJ_LOG(3,(THIS_FILE, "Call %d state changed to %s",
- call_index,
- pjsua_inv_state_names[call->inv->state]));
-
- if (call->inv->state == PJSIP_INV_STATE_DISCONNECTED) {
- call->inv = NULL;
- if ((int)call->index == current_call) {
- find_next_call();
- }
-
- } else {
-
- if (call && current_call==-1)
- current_call = call->index;
-
- }
-}
-
-/**
- * Notify UI when registration status has changed.
- */
-void pjsua_ui_regc_on_state_changed(int code)
-{
- PJ_UNUSED_ARG(code);
-
- // Log already written.
-}
-
-
-/*
- * Print buddy list.
- */
-static void print_buddy_list(void)
-{
- int i;
-
- puts("Buddy list:");
-
- if (pjsua.buddy_cnt == 0)
- puts(" -none-");
- else {
- for (i=0; i<pjsua.buddy_cnt; ++i) {
- const char *status;
-
- if (pjsua.buddies[i].sub == NULL ||
- pjsua.buddies[i].status.info_cnt==0)
- {
- status = " ? ";
- }
- else if (pjsua.buddies[i].status.info[0].basic_open)
- status = " Online";
- else
- status = "Offline";
-
- printf(" [%2d] <%s> %s\n",
- i+1, status, pjsua.buddies[i].uri.ptr);
- }
- }
- puts("");
-}
-
-
-/*
- * Print account status.
- */
-static void print_acc_status(int acc_index)
-{
- char reg_status[128];
-
- if (pjsua.acc[acc_index].regc == NULL) {
- pj_ansi_strcpy(reg_status, " -not registered to server-");
-
- } else if (pjsua.acc[acc_index].reg_last_err != PJ_SUCCESS) {
- pj_strerror(pjsua.acc[acc_index].reg_last_err, reg_status, sizeof(reg_status));
-
- } else if (pjsua.acc[acc_index].reg_last_code>=200 &&
- pjsua.acc[acc_index].reg_last_code<=699) {
-
- pjsip_regc_info info;
-
- pjsip_regc_get_info(pjsua.acc[acc_index].regc, &info);
-
- pj_snprintf(reg_status, sizeof(reg_status),
- "%s (%.*s;expires=%d)",
- pjsip_get_status_text(pjsua.acc[acc_index].reg_last_code)->ptr,
- (int)info.client_uri.slen,
- info.client_uri.ptr,
- info.next_reg);
-
- } else {
- pj_sprintf(reg_status, "in progress (%d)",
- pjsua.acc[acc_index].reg_last_code);
- }
-
- printf("[%2d] Registration status: %s\n", acc_index, reg_status);
- printf(" Online status: %s\n",
- (pjsua.acc[acc_index].online_status ? "Online" : "Invisible"));
-}
-
-/*
- * Show a bit of help.
- */
-static void keystroke_help(void)
-{
- int i;
-
- printf(">>>>\n");
-
- for (i=0; i<pjsua.acc_cnt; ++i)
- print_acc_status(i);
-
- print_buddy_list();
-
- //puts("Commands:");
- puts("+=============================================================================+");
- puts("| Call Commands: | IM & Presence: | Misc: |");
- puts("| | | |");
- puts("| m Make new call | i Send IM | o Send OPTIONS |");
- puts("| a Answer call | s Subscribe presence | rr (Re-)register |");
- puts("| h Hangup call | u Unsubscribe presence | ru Unregister |");
- puts("| ] Select next dialog | t ToGgle Online status | d Dump status |");
- puts("| [ Select previous dialog | | dc Dump config |");
- puts("| +--------------------------+-------------------+");
- puts("| H Hold call | Conference Command | |");
- puts("| v re-inVite (release hold) | cl List ports | |");
- puts("| x Xfer call | cc Connect port | |");
- puts("| # Send DTMF string | cd Disconnect port | |");
- puts("+------------------------------+--------------------------+-------------------+");
- puts("| q QUIT |");
- puts("+=============================================================================+");
- printf(">>> ");
-
-
- fflush(stdout);
-}
-
-
-/*
- * Input simple string
- */
-static pj_bool_t simple_input(const char *title, char *buf, pj_size_t len)
-{
- char *p;
-
- printf("%s (empty to cancel): ", title); fflush(stdout);
- fgets(buf, len, stdin);
-
- /* Remove trailing newlines. */
- for (p=buf; ; ++p) {
- if (*p=='\r' || *p=='\n') *p='\0';
- else if (!*p) break;
- }
-
- if (!*buf)
- return PJ_FALSE;
-
- return PJ_TRUE;
-}
-
-
-#define NO_NB -2
-struct input_result
-{
- int nb_result;
- char *uri_result;
-};
-
-
-/*
- * Input URL.
- */
-static void ui_input_url(const char *title, char *buf, int len,
- struct input_result *result)
-{
- result->nb_result = NO_NB;
- result->uri_result = NULL;
-
- print_buddy_list();
-
- printf("Choices:\n"
- " 0 For current dialog.\n"
- " -1 All %d buddies in buddy list\n"
- " [1 -%2d] Select from buddy list\n"
- " URL An URL\n"
- " <Enter> Empty input (or 'q') to cancel\n"
- , pjsua.buddy_cnt, pjsua.buddy_cnt);
- printf("%s: ", title);
-
- fflush(stdout);
- fgets(buf, len, stdin);
- len = strlen(buf);
-
- /* Left trim */
- while (isspace(*buf)) {
- ++buf;
- --len;
- }
-
- /* Remove trailing newlines */
- while (len && (buf[len-1] == '\r' || buf[len-1] == '\n'))
- buf[--len] = '\0';
-
- if (len == 0 || buf[0]=='q')
- return;
-
- if (isdigit(*buf) || *buf=='-') {
-
- int i;
-
- if (*buf=='-')
- i = 1;
- else
- i = 0;
-
- for (; i<len; ++i) {
- if (!isdigit(buf[i])) {
- puts("Invalid input");
- return;
- }
- }
-
- result->nb_result = atoi(buf);
-
- if (result->nb_result > 0 && result->nb_result <= (int)pjsua.buddy_cnt) {
- --result->nb_result;
- return;
- }
- if (result->nb_result == -1)
- return;
-
- puts("Invalid input");
- result->nb_result = NO_NB;
- return;
-
- } else {
- pj_status_t status;
-
- if ((status=pjsua_verify_sip_url(buf)) != PJ_SUCCESS) {
- pjsua_perror(THIS_FILE, "Invalid URL", status);
- return;
- }
-
- result->uri_result = buf;
- }
-}
-
-static void conf_list(void)
-{
- unsigned i, count;
- pjmedia_conf_port_info info[PJSUA_MAX_CALLS];
-
- printf("Conference ports:\n");
-
- count = PJ_ARRAY_SIZE(info);
- pjmedia_conf_get_ports_info(pjsua.mconf, &count, info);
- for (i=0; i<count; ++i) {
- char txlist[PJSUA_MAX_CALLS*4+10];
- int j;
- pjmedia_conf_port_info *port_info = &info[i];
-
- txlist[0] = '\0';
- for (j=0; j<pjsua.max_calls+PJSUA_CONF_MORE_PORTS; ++j) {
- char s[10];
- if (port_info->listener[j]) {
- pj_sprintf(s, "#%d ", j);
- pj_ansi_strcat(txlist, s);
- }
- }
- printf("Port #%02d %20.*s transmitting to: %s\n",
- port_info->slot,
- (int)port_info->name.slen,
- port_info->name.ptr,
- txlist);
-
- }
- puts("");
-}
-
-
-static void ui_console_main(void)
-{
- char menuin[10];
- char buf[128];
- struct input_result result;
-
- //keystroke_help();
-
- for (;;) {
-
- keystroke_help();
- fgets(menuin, sizeof(menuin), stdin);
-
- switch (menuin[0]) {
-
- case 'm':
- /* Make call! : */
- printf("(You currently have %d calls)\n", pjsua.call_cnt);
-
- ui_input_url("Make call", buf, sizeof(buf), &result);
- if (result.nb_result != NO_NB) {
- if (result.nb_result == -1)
- puts("You can't do that with make call!");
- else
- pjsua_make_call( current_acc,
- pjsua.buddies[result.nb_result].uri.ptr,
- NULL);
- } else if (result.uri_result)
- pjsua_make_call( current_acc, result.uri_result, NULL);
-
- break;
-
-
- case 'a':
-
- if (current_call == -1 ||
- pjsua.calls[current_call].inv->role != PJSIP_ROLE_UAS ||
- pjsua.calls[current_call].inv->state >= PJSIP_INV_STATE_CONNECTING)
- {
- puts("No pending incoming call");
- fflush(stdout);
- continue;
-
- } else {
- pj_status_t status;
- pjsip_tx_data *tdata;
-
- if (!simple_input("Answer with code (100-699)", buf, sizeof(buf)))
- continue;
-
- if (atoi(buf) < 100)
- continue;
-
- /*
- * Must check again!
- * Call may have been disconnected while we're waiting for
- * keyboard input.
- */
- if (current_call == -1) {
- puts("Call has been disconnected");
- fflush(stdout);
- continue;
- }
-
- status = pjsip_inv_answer(pjsua.calls[current_call].inv,
- atoi(buf),
- NULL, NULL, &tdata);
- if (status == PJ_SUCCESS)
- status = pjsip_inv_send_msg(pjsua.calls[current_call].inv,
- tdata, NULL);
-
- if (status != PJ_SUCCESS)
- pjsua_perror(THIS_FILE, "Unable to create/send response",
- status);
- }
-
- break;
-
-
- case 'h':
-
- if (current_call == -1) {
- puts("No current call");
- fflush(stdout);
- continue;
-
- } else {
- pjsua_call_hangup(current_call, PJSIP_SC_DECLINE);
- }
- break;
-
- case ']':
- case '[':
- /*
- * Cycle next/prev dialog.
- */
- if (menuin[0] == ']') {
- find_next_call();
-
- } else {
- find_prev_call();
- }
-
- if (current_call != -1) {
- char url[PJSIP_MAX_URL_SIZE];
- int len;
- const pjsip_uri *u;
-
- u = pjsua.calls[current_call].inv->dlg->remote.info->uri;
- len = pjsip_uri_print(0, u, url, sizeof(url)-1);
- if (len < 1) {
- pj_ansi_strcpy(url, "<uri is too long>");
- } else {
- url[len] = '\0';
- }
-
- PJ_LOG(3,(THIS_FILE,"Current dialog: %s", url));
-
- } else {
- PJ_LOG(3,(THIS_FILE,"No current dialog"));
- }
- break;
-
- case 'H':
- /*
- * Hold call.
- */
- if (current_call != -1) {
-
- pjsua_call_set_hold(current_call);
-
- } else {
- PJ_LOG(3,(THIS_FILE, "No current call"));
- }
- break;
-
- case 'v':
- /*
- * Send re-INVITE (to release hold, etc).
- */
- if (current_call != -1) {
-
- pjsua_call_reinvite(current_call);
-
- } else {
- PJ_LOG(3,(THIS_FILE, "No current call"));
- }
- break;
-
- case 'x':
- /*
- * Transfer call.
- */
- if (current_call == -1) {
-
- PJ_LOG(3,(THIS_FILE, "No current call"));
-
- } else {
- int call = current_call;
-
- ui_input_url("Transfer to URL", buf, sizeof(buf), &result);
-
- /* Check if call is still there. */
-
- if (call != current_call) {
- puts("Call has been disconnected");
- continue;
- }
-
- if (result.nb_result != NO_NB) {
- if (result.nb_result == -1)
- puts("You can't do that with transfer call!");
- else
- pjsua_call_xfer( current_call,
- pjsua.buddies[result.nb_result].uri.ptr);
-
- } else if (result.uri_result) {
- pjsua_call_xfer( current_call, result.uri_result);
- }
- }
- break;
-
- case '#':
- /*
- * Send DTMF strings.
- */
- if (current_call == -1) {
-
- PJ_LOG(3,(THIS_FILE, "No current call"));
-
- } else if (pjsua.calls[current_call].session == NULL) {
-
- PJ_LOG(3,(THIS_FILE, "Media is not established yet!"));
-
- } else {
- pj_str_t digits;
- int call = current_call;
- pj_status_t status;
-
- if (!simple_input("DTMF strings to send (0-9*#A-B)", buf,
- sizeof(buf)))
- {
- break;
- }
-
- if (call != current_call) {
- puts("Call has been disconnected");
- continue;
- }
-
- digits = pj_str(buf);
- status = pjmedia_session_dial_dtmf(pjsua.calls[current_call].session, 0,
- &digits);
- if (status != PJ_SUCCESS) {
- pjsua_perror(THIS_FILE, "Unable to send DTMF", status);
- } else {
- puts("DTMF digits enqueued for transmission");
- }
- }
- break;
-
- case 's':
- case 'u':
- /*
- * Subscribe/unsubscribe presence.
- */
- ui_input_url("(un)Subscribe presence of", buf, sizeof(buf), &result);
- if (result.nb_result != NO_NB) {
- if (result.nb_result == -1) {
- int i;
- for (i=0; i<pjsua.buddy_cnt; ++i)
- pjsua.buddies[i].monitor = (menuin[0]=='s');
- } else {
- pjsua.buddies[result.nb_result].monitor = (menuin[0]=='s');
- }
-
- pjsua_pres_refresh(current_acc);
-
- } else if (result.uri_result) {
- puts("Sorry, can only subscribe to buddy's presence, "
- "not arbitrary URL (for now)");
- }
-
- break;
-
- case 'r':
- switch (menuin[1]) {
- case 'r':
- /*
- * Re-Register.
- */
- pjsua_regc_update(current_acc, PJ_TRUE);
- break;
- case 'u':
- /*
- * Unregister
- */
- pjsua_regc_update(current_acc, PJ_FALSE);
- break;
- }
- break;
-
- case 't':
- pjsua.acc[current_acc].online_status =
- !pjsua.acc[current_acc].online_status;
- pjsua_pres_refresh(current_acc);
- break;
-
- case 'c':
- switch (menuin[1]) {
- case 'l':
- conf_list();
- break;
- case 'c':
- case 'd':
- {
- char src_port[10], dst_port[10];
- pj_status_t status;
- const char *src_title, *dst_title;
-
- conf_list();
-
- src_title = (menuin[1]=='c'?
- "Connect src port #":
- "Disconnect src port #");
- dst_title = (menuin[1]=='c'?
- "To dst port #":
- "From dst port #");
-
- if (!simple_input(src_title, src_port, sizeof(src_port)))
- break;
-
- if (!simple_input(dst_title, dst_port, sizeof(dst_port)))
- break;
-
- if (menuin[1]=='c') {
- status = pjmedia_conf_connect_port(pjsua.mconf,
- atoi(src_port),
- atoi(dst_port));
- } else {
- status = pjmedia_conf_disconnect_port(pjsua.mconf,
- atoi(src_port),
- atoi(dst_port));
- }
- if (status == PJ_SUCCESS) {
- puts("Success");
- } else {
- puts("ERROR!!");
- }
- }
- break;
- }
- break;
-
- case 'd':
- if (menuin[1] == 'c') {
- char settings[2000];
- int len;
-
- len = pjsua_dump_settings(settings, sizeof(settings));
- if (len < 1)
- PJ_LOG(3,(THIS_FILE, "Error: not enough buffer"));
- else
- PJ_LOG(3,(THIS_FILE,
- "Dumping configuration (%d bytes):\n%s\n",
- len, settings));
- } else {
- pjsua_dump();
- }
- break;
-
- case 'q':
- goto on_exit;
- }
- }
-
-on_exit:
- ;
-}
-
-
-/*****************************************************************************
- * This is a very simple PJSIP module, whose sole purpose is to display
- * incoming and outgoing messages to log. This module will have priority
- * higher than transport layer, which means:
- *
- * - incoming messages will come to this module first before reaching
- * transaction layer.
- *
- * - outgoing messages will come to this module last, after the message
- * has been 'printed' to contiguous buffer by transport layer and
- * appropriate transport instance has been decided for this message.
- *
- */
-
-/* Notification on incoming messages */
-static pj_bool_t console_on_rx_msg(pjsip_rx_data *rdata)
-{
- PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s:%d:\n"
- "%s\n"
- "--end msg--",
- rdata->msg_info.len,
- pjsip_rx_data_get_info(rdata),
- rdata->pkt_info.src_name,
- rdata->pkt_info.src_port,
- rdata->msg_info.msg_buf));
-
- /* Always return false, otherwise messages will not get processed! */
- return PJ_FALSE;
-}
-
-/* Notification on outgoing messages */
-static pj_status_t console_on_tx_msg(pjsip_tx_data *tdata)
-{
-
- /* Important note:
- * tp_info field is only valid after outgoing messages has passed
- * transport layer. So don't try to access tp_info when the module
- * has lower priority than transport layer.
- */
-
- PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s:%d:\n"
- "%s\n"
- "--end msg--",
- (tdata->buf.cur - tdata->buf.start),
- pjsip_tx_data_get_info(tdata),
- tdata->tp_info.dst_name,
- tdata->tp_info.dst_port,
- tdata->buf.start));
-
- /* Always return success, otherwise message will not get sent! */
- return PJ_SUCCESS;
-}
-
-/* The module instance. */
-static pjsip_module console_msg_logger =
-{
- NULL, NULL, /* prev, next. */
- { "mod-pjsua-log", 13 }, /* Name. */
- -1, /* Id */
- PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority */
- NULL, /* load() */
- NULL, /* start() */
- NULL, /* stop() */
- NULL, /* unload() */
- &console_on_rx_msg, /* on_rx_request() */
- &console_on_rx_msg, /* on_rx_response() */
- &console_on_tx_msg, /* on_tx_request. */
- &console_on_tx_msg, /* on_tx_response() */
- NULL, /* on_tsx_state() */
-
-};
-
-
-
-/*****************************************************************************
- * Console application custom logging:
- */
-
-
-static FILE *log_file;
-
-
-static void app_log_writer(int level, const char *buffer, int len)
-{
- /* Write to both stdout and file. */
-
- if (level <= pjsua.app_log_level)
- pj_log_write(level, buffer, len);
-
- if (log_file) {
- fwrite(buffer, len, 1, log_file);
- fflush(log_file);
- }
-}
-
-
-void app_logging_init(void)
-{
- /* Redirect log function to ours */
-
- pj_log_set_log_func( &app_log_writer );
-
- /* If output log file is desired, create the file: */
-
- if (pjsua.log_filename)
- log_file = fopen(pjsua.log_filename, "wt");
-}
-
-
-void app_logging_shutdown(void)
-{
- /* Close logging file, if any: */
-
- if (log_file) {
- fclose(log_file);
- log_file = NULL;
- }
-}
-
-/*****************************************************************************
- * Error display:
- */
-
-/*
- * Display error message for the specified error code.
- */
-void pjsua_perror(const char *sender, const char *title,
- pj_status_t status)
-{
- char errmsg[PJ_ERR_MSG_SIZE];
-
- pj_strerror(status, errmsg, sizeof(errmsg));
-
- PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status));
-}
-
-
-
-
-/*****************************************************************************
- * main():
- */
-int main(int argc, char *argv[])
-{
-
- /* Init default settings. */
- pjsua_default();
-
-
- /* Initialize pjsua (to create pool etc).
- */
- if (pjsua_init() != PJ_SUCCESS)
- return 1;
-
-
- /* Parse command line arguments: */
- if (pjsua_parse_args(argc, argv) != PJ_SUCCESS)
- return 1;
-
-
- /* Init logging: */
- app_logging_init();
-
-
- /* Register message logger to print incoming and outgoing
- * messages.
- */
- pjsip_endpt_register_module(pjsua.endpt, &console_msg_logger);
-
-
- /* Start pjsua! */
- if (pjsua_start() != PJ_SUCCESS) {
-
- pjsua_destroy();
- return 1;
- }
-
-
- /* Sleep for a while, let any messages get printed to console: */
- pj_thread_sleep(500);
-
-
- /* Start UI console main loop: */
- ui_console_main();
-
-
- /* Destroy pjsua: */
- pjsua_destroy();
-
-
- /* Close logging: */
- app_logging_shutdown();
-
-
- /* Exit... */
-
- return 0;
-}
-