From e56ea14ab8531ee3cec375460577d1b89bf62e26 Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Thu, 16 Jan 2014 05:30:46 +0000 Subject: Closed #1723: Merging pjsua2 branch into trunk git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4704 74dad513-b988-da41-8d7b-12977e46ad98 --- build.mak.in | 20 +- configure-android | 26 +- doc/pjsip-book/Doxyfile | 1781 +++++++++++ doc/pjsip-book/Makefile | 160 + doc/pjsip-book/account.rst | 132 + doc/pjsip-book/call.rst | 103 + doc/pjsip-book/conf.py | 256 ++ doc/pjsip-book/consider.rst | 187 ++ doc/pjsip-book/endpoint.rst | 96 + doc/pjsip-book/fetch_trac.py | 85 + doc/pjsip-book/index.rst | 36 + doc/pjsip-book/intro.rst | 33 + doc/pjsip-book/intro_pjsua2.rst | 158 + doc/pjsip-book/make.bat | 190 ++ doc/pjsip-book/media.rst | 113 + doc/pjsip-book/media_quality.rst | 11 + doc/pjsip-book/network_problems.rst | 11 + doc/pjsip-book/optimization.rst | 11 + doc/pjsip-book/presence.rst | 43 + doc/pjsip-book/reference.rst | 20 + doc/pjsip-book/samples.rst | 27 + pjlib-util/build/Makefile | 4 +- pjlib-util/build/pjlib_util.vcproj | 760 ++--- pjlib-util/build/pjlib_util_test.vcproj | 710 ++--- pjlib-util/include/pjlib-util.h | 3 + pjlib-util/include/pjlib-util/errno.h | 9 + pjlib-util/include/pjlib-util/json.h | 228 ++ pjlib-util/src/pjlib-util-test/json_test.c | 106 + pjlib-util/src/pjlib-util-test/test.c | 4 + pjlib-util/src/pjlib-util-test/test.h | 2 + pjlib-util/src/pjlib-util/errno.c | 3 + pjlib-util/src/pjlib-util/json.c | 621 ++++ pjlib/build/os-auto.mak.in | 3 +- pjlib/include/pj/compat/cc_gcc.h | 2 +- pjlib/include/pj/string.h | 9 + pjlib/include/pj/types.h | 17 +- pjlib/src/pj/string.c | 38 + pjmedia/include/pjmedia-videodev/videodev.h | 2 +- pjproject-vs8.sln | 114 +- pjsip-apps/build/Makefile | 8 + pjsip-apps/build/Samples.mak | 10 +- pjsip-apps/build/sample_debug.vcproj | 690 ++--- pjsip-apps/src/pjsua/main.c | 1 + pjsip-apps/src/pygui/account.py | 239 ++ pjsip-apps/src/pygui/accountsetting.py | 369 +++ pjsip-apps/src/pygui/application.py | 510 ++++ pjsip-apps/src/pygui/buddy.py | 152 + pjsip-apps/src/pygui/call.py | 104 + pjsip-apps/src/pygui/chat.py | 489 +++ pjsip-apps/src/pygui/chatgui.py | 420 +++ pjsip-apps/src/pygui/endpoint.py | 53 + pjsip-apps/src/pygui/log.py | 127 + pjsip-apps/src/pygui/settings.py | 362 +++ pjsip-apps/src/samples/debug.c | 32 - pjsip-apps/src/samples/debug.cpp | 32 + pjsip-apps/src/samples/pjsua2_demo.cpp | 290 ++ pjsip-apps/src/swig/Makefile | 32 + pjsip-apps/src/swig/importsym.py | 193 ++ pjsip-apps/src/swig/java/Makefile | 124 + pjsip-apps/src/swig/java/android/.classpath | 9 + pjsip-apps/src/swig/java/android/.project | 33 + .../android/.settings/org.eclipse.jdt.core.prefs | 4 + .../src/swig/java/android/AndroidManifest.xml | 44 + .../src/swig/java/android/ic_launcher-web.png | Bin 0 -> 51394 bytes pjsip-apps/src/swig/java/android/jni/Android.mk | 12 + .../src/swig/java/android/jni/Application.mk | 1 + .../src/swig/java/android/proguard-project.txt | 20 + .../src/swig/java/android/project.properties | 14 + .../java/android/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 7658 bytes .../java/android/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 3777 bytes .../android/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 12516 bytes .../android/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 24777 bytes .../src/swig/java/android/res/drawable/bkg.xml | 5 + .../swig/java/android/res/layout/activity_call.xml | 41 + .../swig/java/android/res/layout/activity_main.xml | 65 + .../java/android/res/layout/dlg_account_config.xml | 77 + .../swig/java/android/res/layout/dlg_add_buddy.xml | 24 + pjsip-apps/src/swig/java/android/res/menu/call.xml | 9 + pjsip-apps/src/swig/java/android/res/menu/main.xml | 14 + .../java/android/res/values-sw600dp/dimens.xml | 8 + .../android/res/values-sw720dp-land/dimens.xml | 9 + .../swig/java/android/res/values-v11/styles.xml | 11 + .../swig/java/android/res/values-v14/styles.xml | 12 + .../src/swig/java/android/res/values/colors.xml | 5 + .../src/swig/java/android/res/values/dimens.xml | 7 + .../src/swig/java/android/res/values/strings.xml | 9 + .../src/swig/java/android/res/values/styles.xml | 20 + .../src/org/pjsip/pjsua2/app/CallActivity.java | 146 + .../src/org/pjsip/pjsua2/app/MainActivity.java | 497 +++ .../android/src/org/pjsip/pjsua2/app/MyApp.java | 449 +++ pjsip-apps/src/swig/java/sample.java | 140 + pjsip-apps/src/swig/java/test.java | 17 + pjsip-apps/src/swig/pjsua2.i | 111 + pjsip-apps/src/swig/python/Makefile | 29 + pjsip-apps/src/swig/python/helper.mak | 20 + pjsip-apps/src/swig/python/setup.py | 118 + pjsip-apps/src/swig/python/test.py | 112 + pjsip-apps/src/swig/symbols.i | 130 + pjsip-apps/src/swig/symbols.lst | 34 + pjsip/build/Makefile | 56 +- pjsip/build/pjsua2_lib.vcproj | 3220 ++++++++++++++++++++ pjsip/docs/doxygen.cfg | 2 +- pjsip/include/pjsip-simple/evsub.h | 9 +- pjsip/include/pjsua-lib/pjsua.h | 34 +- pjsip/include/pjsua2.hpp | 29 + pjsip/include/pjsua2/account.hpp | 1557 ++++++++++ pjsip/include/pjsua2/call.hpp | 1713 +++++++++++ pjsip/include/pjsua2/config.hpp | 47 + pjsip/include/pjsua2/doxygen.hpp | 52 + pjsip/include/pjsua2/endpoint.hpp | 1322 ++++++++ pjsip/include/pjsua2/json.hpp | 116 + pjsip/include/pjsua2/media.hpp | 1162 +++++++ pjsip/include/pjsua2/persistent.hpp | 689 +++++ pjsip/include/pjsua2/presence.hpp | 296 ++ pjsip/include/pjsua2/siptypes.hpp | 910 ++++++ pjsip/include/pjsua2/types.hpp | 266 ++ pjsip/src/pjsip/sip_endpoint.c | 2 + pjsip/src/pjsua-lib/pjsua_aud.c | 3 + pjsip/src/pjsua-lib/pjsua_core.c | 60 +- pjsip/src/pjsua2-test/main.cpp | 38 + pjsip/src/pjsua2/account.cpp | 799 +++++ pjsip/src/pjsua2/call.cpp | 719 +++++ pjsip/src/pjsua2/endpoint.cpp | 1612 ++++++++++ pjsip/src/pjsua2/json.cpp | 544 ++++ pjsip/src/pjsua2/media.cpp | 779 +++++ pjsip/src/pjsua2/persistent.cpp | 227 ++ pjsip/src/pjsua2/presence.cpp | 190 ++ pjsip/src/pjsua2/siptypes.cpp | 590 ++++ pjsip/src/pjsua2/types.cpp | 95 + pjsip/src/pjsua2/util.hpp | 45 + 130 files changed, 28660 insertions(+), 1150 deletions(-) create mode 100644 doc/pjsip-book/Doxyfile create mode 100644 doc/pjsip-book/Makefile create mode 100644 doc/pjsip-book/account.rst create mode 100644 doc/pjsip-book/call.rst create mode 100644 doc/pjsip-book/conf.py create mode 100644 doc/pjsip-book/consider.rst create mode 100644 doc/pjsip-book/endpoint.rst create mode 100644 doc/pjsip-book/fetch_trac.py create mode 100644 doc/pjsip-book/index.rst create mode 100644 doc/pjsip-book/intro.rst create mode 100644 doc/pjsip-book/intro_pjsua2.rst create mode 100644 doc/pjsip-book/make.bat create mode 100644 doc/pjsip-book/media.rst create mode 100644 doc/pjsip-book/media_quality.rst create mode 100644 doc/pjsip-book/network_problems.rst create mode 100644 doc/pjsip-book/optimization.rst create mode 100644 doc/pjsip-book/presence.rst create mode 100644 doc/pjsip-book/reference.rst create mode 100644 doc/pjsip-book/samples.rst create mode 100644 pjlib-util/include/pjlib-util/json.h create mode 100644 pjlib-util/src/pjlib-util-test/json_test.c create mode 100644 pjlib-util/src/pjlib-util/json.c create mode 100644 pjsip-apps/src/pygui/account.py create mode 100644 pjsip-apps/src/pygui/accountsetting.py create mode 100644 pjsip-apps/src/pygui/application.py create mode 100644 pjsip-apps/src/pygui/buddy.py create mode 100644 pjsip-apps/src/pygui/call.py create mode 100644 pjsip-apps/src/pygui/chat.py create mode 100644 pjsip-apps/src/pygui/chatgui.py create mode 100644 pjsip-apps/src/pygui/endpoint.py create mode 100644 pjsip-apps/src/pygui/log.py create mode 100644 pjsip-apps/src/pygui/settings.py delete mode 100644 pjsip-apps/src/samples/debug.c create mode 100644 pjsip-apps/src/samples/debug.cpp create mode 100644 pjsip-apps/src/samples/pjsua2_demo.cpp create mode 100644 pjsip-apps/src/swig/Makefile create mode 100644 pjsip-apps/src/swig/importsym.py create mode 100644 pjsip-apps/src/swig/java/Makefile create mode 100644 pjsip-apps/src/swig/java/android/.classpath create mode 100644 pjsip-apps/src/swig/java/android/.project create mode 100644 pjsip-apps/src/swig/java/android/.settings/org.eclipse.jdt.core.prefs create mode 100644 pjsip-apps/src/swig/java/android/AndroidManifest.xml create mode 100644 pjsip-apps/src/swig/java/android/ic_launcher-web.png create mode 100644 pjsip-apps/src/swig/java/android/jni/Android.mk create mode 100644 pjsip-apps/src/swig/java/android/jni/Application.mk create mode 100644 pjsip-apps/src/swig/java/android/proguard-project.txt create mode 100644 pjsip-apps/src/swig/java/android/project.properties create mode 100644 pjsip-apps/src/swig/java/android/res/drawable-hdpi/ic_launcher.png create mode 100644 pjsip-apps/src/swig/java/android/res/drawable-mdpi/ic_launcher.png create mode 100644 pjsip-apps/src/swig/java/android/res/drawable-xhdpi/ic_launcher.png create mode 100644 pjsip-apps/src/swig/java/android/res/drawable-xxhdpi/ic_launcher.png create mode 100644 pjsip-apps/src/swig/java/android/res/drawable/bkg.xml create mode 100644 pjsip-apps/src/swig/java/android/res/layout/activity_call.xml create mode 100644 pjsip-apps/src/swig/java/android/res/layout/activity_main.xml create mode 100644 pjsip-apps/src/swig/java/android/res/layout/dlg_account_config.xml create mode 100644 pjsip-apps/src/swig/java/android/res/layout/dlg_add_buddy.xml create mode 100644 pjsip-apps/src/swig/java/android/res/menu/call.xml create mode 100644 pjsip-apps/src/swig/java/android/res/menu/main.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values-sw600dp/dimens.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values-sw720dp-land/dimens.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values-v11/styles.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values-v14/styles.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values/colors.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values/dimens.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values/strings.xml create mode 100644 pjsip-apps/src/swig/java/android/res/values/styles.xml create mode 100644 pjsip-apps/src/swig/java/android/src/org/pjsip/pjsua2/app/CallActivity.java create mode 100644 pjsip-apps/src/swig/java/android/src/org/pjsip/pjsua2/app/MainActivity.java create mode 100644 pjsip-apps/src/swig/java/android/src/org/pjsip/pjsua2/app/MyApp.java create mode 100644 pjsip-apps/src/swig/java/sample.java create mode 100644 pjsip-apps/src/swig/java/test.java create mode 100644 pjsip-apps/src/swig/pjsua2.i create mode 100644 pjsip-apps/src/swig/python/Makefile create mode 100644 pjsip-apps/src/swig/python/helper.mak create mode 100644 pjsip-apps/src/swig/python/setup.py create mode 100644 pjsip-apps/src/swig/python/test.py create mode 100644 pjsip-apps/src/swig/symbols.i create mode 100644 pjsip-apps/src/swig/symbols.lst create mode 100644 pjsip/build/pjsua2_lib.vcproj create mode 100644 pjsip/include/pjsua2.hpp create mode 100644 pjsip/include/pjsua2/account.hpp create mode 100644 pjsip/include/pjsua2/call.hpp create mode 100644 pjsip/include/pjsua2/config.hpp create mode 100644 pjsip/include/pjsua2/doxygen.hpp create mode 100644 pjsip/include/pjsua2/endpoint.hpp create mode 100644 pjsip/include/pjsua2/json.hpp create mode 100644 pjsip/include/pjsua2/media.hpp create mode 100644 pjsip/include/pjsua2/persistent.hpp create mode 100644 pjsip/include/pjsua2/presence.hpp create mode 100644 pjsip/include/pjsua2/siptypes.hpp create mode 100644 pjsip/include/pjsua2/types.hpp create mode 100644 pjsip/src/pjsua2-test/main.cpp create mode 100644 pjsip/src/pjsua2/account.cpp create mode 100644 pjsip/src/pjsua2/call.cpp create mode 100644 pjsip/src/pjsua2/endpoint.cpp create mode 100644 pjsip/src/pjsua2/json.cpp create mode 100644 pjsip/src/pjsua2/media.cpp create mode 100644 pjsip/src/pjsua2/persistent.cpp create mode 100644 pjsip/src/pjsua2/presence.cpp create mode 100644 pjsip/src/pjsua2/siptypes.cpp create mode 100644 pjsip/src/pjsua2/types.cpp create mode 100644 pjsip/src/pjsua2/util.hpp diff --git a/build.mak.in b/build.mak.in index 3e5215e2..021c556b 100644 --- a/build.mak.in +++ b/build.mak.in @@ -172,6 +172,13 @@ export APP_CFLAGS := -DPJ_AUTOCONF=1\ -I$(PJDIR)/pjmedia/include\ -I$(PJDIR)/pjsip/include export APP_CXXFLAGS := $(APP_CFLAGS) +# x x x x x x x x x x x x x x x x x x x x x x x x +# +# FIX THIS +# +# pjsua2 is c++ library hence maybe needs to be put in separate +# variables. it will also require -lstdc++ or -static-libstdc++ +# x x x x x x x x x x x x x x x x x x x x x x x x export APP_LDFLAGS := -L$(PJDIR)/pjlib/lib\ -L$(PJDIR)/pjlib-util/lib\ -L$(PJDIR)/pjnath/lib\ @@ -179,8 +186,19 @@ export APP_LDFLAGS := -L$(PJDIR)/pjlib/lib\ -L$(PJDIR)/pjsip/lib\ -L$(PJDIR)/third_party/lib\ $(PJ_VIDEO_LDFLAGS) \ + -static-libstdc++ \ @LDFLAGS@ -export APP_LIB_FILES = $(PJ_DIR)/pjsip/lib/libpjsua-$(LIB_SUFFIX) \ + +# x x x x x x x x x x x x x x x x x x x x x x x x +# +# FIX THIS +# +# pjsua2 is c++ library hence maybe needs to be put in separate +# variables. it will also require -lstdc++ +# x x x x x x x x x x x x x x x x x x x x x x x x +export APP_LIB_FILES = \ + $(PJ_DIR)/pjsip/lib/libpjsua2-$(LIB_SUFFIX) \ + $(PJ_DIR)/pjsip/lib/libpjsua-$(LIB_SUFFIX) \ $(PJ_DIR)/pjsip/lib/libpjsip-ua-$(LIB_SUFFIX) \ $(PJ_DIR)/pjsip/lib/libpjsip-simple-$(LIB_SUFFIX) \ $(PJ_DIR)/pjsip/lib/libpjsip-$(LIB_SUFFIX) \ diff --git a/configure-android b/configure-android index c8fc8f97..02298a97 100755 --- a/configure-android +++ b/configure-android @@ -101,8 +101,8 @@ if test "$1" = "--use-ndk-cflags"; then export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/" export LIBS="${LIBS} -lc -lgcc" export CFLAGS="${NDK_CFLAGS} ${CFLAGS}" - export CPPFLAGS="${CFLAGS}" - export CXXFLAGS="${NDK_CXXFLAGS}" + export CPPFLAGS="${CFLAGS} -fexceptions -frtti" + export CXXFLAGS="${NDK_CXXFLAGS} -fexceptions -frtti" else @@ -127,11 +127,29 @@ else export LDFLAGS="${LDFLAGS} -nostdlib -L${ANDROID_SYSROOT}/usr/lib/" export LIBS="${LIBS} -lc -lgcc" export CFLAGS="${CFLAGS} -I${ANDROID_SYSROOT}/usr/include" - export CPPFLAGS="${CFLAGS}" - export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT}" + export CPPFLAGS="${CFLAGS} -fexceptions -frtti" + export CXXFLAGS="${CXXFLAGS} -shared --sysroot=${ANDROID_SYSROOT} -fexceptions -frtti" fi +# C++ STL +# Note: STL for pjsua2 sample app is specified in pjsip-apps/src/swig/java/android/jni/Application.mk + +# gnustl +STDCPP_TC_VER=`ls -d ${ANDROID_NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/[0-9]* | sort -gr | head -1` +STDCPP_CFLAGS="-I${STDCPP_TC_VER}/include -I${STDCPP_TC_VER}/libs/armeabi/include" +STDCPP_LIBS="${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o -lgnustl_static" +STDCPP_LDFLAGS="-L${STDCPP_TC_VER}/libs/armeabi" + +# stlport +#STDCPP_CFLAGS="-I${ANDROID_NDK_ROOT}/sources/cxx-stl/stlport/stlport" +#STDCPP_LIBS="${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o -lstlport_static -ldl" +#STDCPP_LDFLAGS="-L${ANDROID_NDK_ROOT}/sources/cxx-stl/stlport/libs/armeabi" + +export CFLAGS="${CFLAGS} ${STDCPP_CFLAGS}" +export LIBS="${STDCPP_LIBS} ${LIBS}" +export LDFLAGS="${LDFLAGS} ${STDCPP_LDFLAGS}" + # Print settings if test "1" = "1"; then echo "$F: calling ./configure with env vars:" diff --git a/doc/pjsip-book/Doxyfile b/doc/pjsip-book/Doxyfile new file mode 100644 index 00000000..953d1151 --- /dev/null +++ b/doc/pjsip-book/Doxyfile @@ -0,0 +1,1781 @@ +# Doxyfile 1.7.6.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "pjsua2" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../../pjsip/include/pjsua2/media.hpp + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.hpp + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = NO + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = YES + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = DOXYGEN + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/doc/pjsip-book/Makefile b/doc/pjsip-book/Makefile new file mode 100644 index 00000000..17db6a6b --- /dev/null +++ b/doc/pjsip-book/Makefile @@ -0,0 +1,160 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +all: html + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + -rm -rf xml + -rm -rf html + +xml: Doxyfile + doxygen + +html: xml + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ThePJSIPBook.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ThePJSIPBook.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/ThePJSIPBook" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ThePJSIPBook" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: xml + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/doc/pjsip-book/account.rst b/doc/pjsip-book/account.rst new file mode 100644 index 00000000..bee82db4 --- /dev/null +++ b/doc/pjsip-book/account.rst @@ -0,0 +1,132 @@ + + +Accounts +========= +​Accounts provide identity (or identities) of the user who is currently using the application. An account has one SIP Uniform Resource Identifier (URI) associated with it. In SIP terms, the identity is used as the From header in outgoing requests. + +Account may or may not have client registration associated with it. An account is also associated with route set and some authentication credentials, which are used when sending SIP request messages using the account. An account also has presence online status, which will be reported to remote peer when they subscribe to the account's presence, or which is published to a presence server if presence publication is enabled for the account. + +At least one account MUST be created in the application, since any outgoing requests require an account context. If no user association is required, application can create a userless account by calling Account.create(). A userless account identifies local endpoint instead of a particular user, and it corresponds to a particular transport ID. + +Also one account must be set as the default account, which will be used as the account identity when pjsua fails to match the request with any accounts using the stricter matching rules. + +Subclassing the Account class +--------------------------------- +To use the Account class, normally application SHOULD create its own subclass, such as:: + + class MyAccount : public Account + { + public: + MyAccount() {} + ~MyAccount() {} + + virtual void onRegState(OnRegStateParam &prm) + { + AccountInfo ai = getInfo(); + cout << (ai.regIsActive? "*** Register: code=" : "*** Unregister: code=") + << prm.code << endl; + + } + + virtual void onIncomingCall(OnIncomingCallParam &iprm) + { + Call *call = new MyCall(*this, iprm.callId); + // Delete the call, which will also hangup the call + delete call; + } + }; + +In its subclass, application can implement the account callbacks, which is basically used to process events related to the account, such as: + +- the status of SIP registration +- incoming calls +- incoming presence subscription requests +- incoming instant message not from buddy + +Application needs to override the relevant callback methods in the derived class to handle these particular events. + +If the events are not handled, default actions will be invoked: + +- incoming calls will not be handled +- incoming presence subscription requests will be accepted +- incoming instant messages from non-buddy will be ignored + +Creating Userless Accounts +-------------------------- +A userless account identifies a particular SIP endpoint rather than a particular user. Some other SIP softphones may call this peer-to-peer mode, which means that we are calling another computer via its address rather than calling a particular user ID. + +So for example, we might identify ourselves as "sip:192.168.0.15" (a userless account) rather than, say, "sip:bennylp@pjsip.org". + +In pjsua, a userless account corresponds to a particular transport. Creating userless account is very simple, all we need is the transport ID which is returned by ​Endpoint.transportCreate() method as explained in previous chapter. + +Here's a snippet:: + + AccountConfig acc_cfg; + acc_cfg.sipConfig.transportId = tid; + MyAccount *acc = new MyAccount; + try { + acc->create(acc_cfg); + } catch(Error& err) { + cout << "Account creation error: " << err.reason << endl; + } + +Once the account is created, you can use the instance as a normal account. More will be explained later. + +Accounts created this way will have its URI derived from the transport address. For example, if the transport address is "192.168.0.15:5080", then the account's URI for UDP transport will be "sip:192.168.0.15:5080", or "sip:192.168.0.15:5080;transport=tcp" for TCP transport. + +Creating Account +---------------- +For the "normal" account, we need to configure ​AccountConfig and call ​Account.create() to create the account. + +At the very minimum, pjsua only requires the account's ID, which is an URI to identify the account (or in SIP terms, it's called Address of Record/AOR). Here's a snippet:: + + AccountConfig acc_cfg; + acc_cfg.idUri = "sip:test1@pjsip.org"; + MyAccount *acc = new MyAccount; + try { + acc->create(acc_cfg); + } catch(Error& err) { + cout << "Account creation error: " << err.reason << endl; + } + +The account created above doesn't do anything except to provide identity in the "From:" header for outgoing requests. The account will not register to SIP server or anything. + +Typically you will want the account to authenticate and register to your SIP server so that you can receive incoming calls. To do that you will need to configure some more settings in your ​AccountConfig, something like this:: + + AccountConfig acc_cfg; + acc_cfg.idUri = "sip:test1@pjsip.org"; + acc_cfg.regConfig.registrarUri = "sip:pjsip.org"; + acc_cfg.sipConfig.authCreds.push_back( AuthCredInfo("digest", "*", "test1", 0, "test1") ); + MyAccount *acc = new MyAccount; + try { + acc->create(acc_cfg); + } catch(Error& err) { + cout << "Account creation error: " << err.reason << endl; + } + +Account Configurations +----------------------- +There are many more settings that can be specified in ​AccountConfig, like: + +- AccountRegConfig, to specify registration settings, such as registrar server and retry interval. +- AccountSipConfig, to specify SIP settings, such as credential information and proxy server. +- AccountCallConfig, to specify call settings, such as whether reliable provisional response (SIP 100rel) is required. +- AccountPresConfig, to specify presence settings, such as whether presence publication (PUBLISH) is enabled. +- AccountMwiConfig, to specify MWI (Message Waiting Indication) settings. +- AccountNatConfig, to specify NAT settings, such as whether STUN or ICE is used. +- AccountMediaConfig, to specify media settings, such as Secure RTP (SRTP) related settings. +- AccountVideoConfig, to specify video settings, such as default capture and render device. + +Please see ​AccountConfig reference documentation for more info. + +Account Operations +-------------------------------------- +Some of the operations to the ​Account object: + +- add buddy objects +- set account's presence online status +- stop/start SIP registration + +Please see the reference documentation for Account for more info. Calls, presence, and buddy list will be explained in later sections. + + diff --git a/doc/pjsip-book/call.rst b/doc/pjsip-book/call.rst new file mode 100644 index 00000000..afb18cd7 --- /dev/null +++ b/doc/pjsip-book/call.rst @@ -0,0 +1,103 @@ + + +Calls +===== +Calls are represented by ​Call class. + +Subclassing the Call Class +------------------------------------ +To use the Call class, normally application SHOULD create its own subclass, such as:: + + class MyCall : public Call + { + public: + MyCall(Account &acc, int call_id = PJSUA_INVALID_ID) + : Call(acc, call_id) + { } + + ~MyCall() + { } + + // Notification when call's state has changed. + virtual void onCallState(OnCallStateParam &prm); + + // Notification when call's media state has changed. + virtual void onCallMediaState(OnCallMediaStateParam &prm); + }; + +In its subclass, application can implement the call callbacks, which is basically used to process events related to the call, such as call state change or incoming call transfer request. + +Making Outgoing Calls +-------------------------------------- +Making outgoing call is simple, just invoke ​makeCall() method of the Call object. Assuming you have the Account object as acc variable and destination URI string in dst_uri, you can initiate outgoing call with the snippet below:: + + Call *call = new MyCall(*acc); + CallOpParam prm(true); // Use default call settings + try { + call->makeCall(dest_uri, prm); + } catch(Error& err) { + } + +The snippet above creates a Call object and initiates outgoing call to dst_uri using the default call settings. Subsequent operations to the call can use the method in the ​call instance, and events to the call will be reported to the callback. More on the callback will be explained a bit later. + +Receiving Incoming Calls +-------------------------------------- +Incoming calls are reported as ​onIncomingCall() of the ​Account class. You must derive a class from the Account class to handle incoming calls. + +Below is a sample code of the callback implementation:: + + void MyAccount::onIncomingCall(OnIncomingCallParam &iprm) + { + Call *call = new MyCall(*this, iprm.callId); + CallOpParam prm; + prm.statusCode = (pjsip_status_code)200; + call->answer(prm); + } + +For incoming calls, the call instance is created in the callback parameter as shown above. Application should make sure to store the call instance during the lifetime of the call (that is until the call is disconnected). + +Call Properties +------------------- +All call properties such as state, media state, remote peer information, etc. are stored as ​CallInfo class, which can be retrieved from the call object with using getInfo() method of the Call. + +Call Disconnection +-------------------------------------- +Call disconnection event is a special event since once the callback that reports this event returns, the call is no longer valid and any operations invoked to the call object will raise error exception. Thus, it is recommended to delete the call object inside the callback. + +The call disconnection is reported in ​onCallState() method of ​Call and it can be detected as follows:: + + void MyCall::onCallState(OnCallStateParam &prm) + { + CallInfo ci = getInfo(); + if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { + /* Delete the call */ + delete this; + } + } + +Working with Call's Audio Media +------------------------------------------------- +You can only operate with the call's audio media (e.g. connecting the call to the sound device in the conference bridge) when the call's audio media is ready (or active). The changes to the call's media state is reported in ​onCallMediaState() callback, and if the call’s audio media is ready (or active) the function getMedia() will return a valid audio media. + +Below is a sample code to connect the call to the sound device when the media is active:: + + void MyCall::onCallMediaState(OnCallMediaStateParam &prm) + { + CallInfo ci = getInfo(); + // Iterate all medias + for (unsigned i = 0; i < ci.media.size(); i++) { + if (getMedia(i)) { // Check if the media is valid + AudioMedia *aud_med = getMedia(i); + // Connect the call audio media to sound device + aud_med->startTransmit(); + ->startTransmit(*aud_med); + } + } + } + +When the audio media becomes inactive (for example when the call is put on hold), there is no need to stop the audio media's transmission to/from the sound device since the call's audio media will be removed automatically from the conference bridge when it's no longer valid, and this will automatically remove all connections to/from the call. + +Call Operations +-------------------------------------- +Some of the operations to the Call object, such as making outgoing call, answering, holding, sending re-INVITE, etc. Please see the reference documentation of Call for more info. + diff --git a/doc/pjsip-book/conf.py b/doc/pjsip-book/conf.py new file mode 100644 index 00000000..e2ae3571 --- /dev/null +++ b/doc/pjsip-book/conf.py @@ -0,0 +1,256 @@ +# -*- coding: utf-8 -*- +# +# The PJSIP Book documentation build configuration file, created by +# sphinx-quickstart on Sat Nov 30 06:36:26 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ 'breathe', 'sphinx.ext.todo', 'sphinx.ext.viewcode'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'The PJSIP Book' +copyright = u'2013, Teluu Ltd.' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1.0' +# The full version, including alpha/beta/rc tags. +release = '1.0-beta' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'ThePJSIPBookdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'ThePJSIPBook.tex', u'The PJSIP Book Documentation', + u'Sauw Ming Liong, Benny Prijono', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'thepjsipbook', u'The PJSIP Book Documentation', + [u'Sauw Ming Liong', u'Benny Prijono'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'ThePJSIPBook', u'The PJSIP Book Documentation', + u'Sauw Ming Liong@*Benny Prijono', 'ThePJSIPBook', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +breathe_projects = { + "pjsua2": "xml/", +} + +breathe_default_project = "pjsua2" + +breathe_projects_source = { + "pjsua2":"../../pjsip/include/pjsua2" +} + +breathe_domain_by_extension = { + "hpp":"cpp" +} diff --git a/doc/pjsip-book/consider.rst b/doc/pjsip-book/consider.rst new file mode 100644 index 00000000..5d466707 --- /dev/null +++ b/doc/pjsip-book/consider.rst @@ -0,0 +1,187 @@ + + + +Development Considerations +************************** + +Let's review various aspects that you need to consider when developing your application. + + +Target Platforms +================ +Platform selection will affect all aspects of development, and here we will cover considerations for each platforms that we support. + +Windows Desktop +--------------- +Windows is supported from Windows 2000 up to the recent Windows 8 and beyond. All features are expected to work. 64bit support was added recently. Development is based on Visual Studio. Considerations for this platform include: + +#. because Visual Studio file format keeps changing on every release, we decided to support the lowest denominator, namely Visual Studio 2005. Unfortunately the project upgrade procedure fails on Visual Studio 2010, and we don't have any solution for that. But VS 2008 and VS 20012 work. + +MacOS X +------- +All features are expected to work. Considerations include: + +#. development with XCode is currently not supported. This is **not** to say that you cannot use XCode, but PJSIP only provides basic Makefiles and if you want to use XCode you'd need to arrange the project yourself. +#. Mac systems typically provides very good sound device, so we don't expect any problems with audio on Mac. + +Linux Desktop +------------- +All features are expected to work. Linux considerations: + +#. use our native ALSA backend instead of PortAudio because ALSA has less jitter than OSS and our backend is more lightweight than PortAudio + + +iOS for iPhone, iPad, and iPod Touch +------------------------------------ +All features except video are expected to work (video is coming soon!). Considerations for iOS: + +#. you need to use TCP transport for SIP for the background feature to work +#. IP change (for example when user is changing access point) is a feature frequently asked by developers and you can find the documentation here: http://trac.pjsip.org/repos/wiki/IPAddressChange +#. there are some specific issues for iOS 7 and beyond, please see http://trac.pjsip.org/repos/ticket/1697 +#. if SSL is needed, you need to compile OpenSSL for iOS + + +Android +------- +All features except video are expected to work (video is coming soon!). Considerations for Android: + +#. you can only use pjsua2 Java binding for this target +#. it has been reported that Android audio device is not so good in general, so some audio tuning may be needed. Echo cancellation also needs to be checked +#. this is also a new platform for us + + +Symbian +------- +Symbian has been supported for a long time but it doesn't get too many attention recently. In general all features (excluding video) are expected to work, but we're not going to do Symbian specific development anymore. Other considerations for Symbian: + +#. the MDA audio is not very good (it has high latency), so normally you'd want to use Audio Proxy Server (APS) or VoIP Audio Service (VAS) for the audio device, which we support. Using these audio backends will also provide us with high quality echo cancellation as well as low bitrate codecs such as AMR-NB, G.729, and iLBC. But VAS and APS requires purchase of Nokia development certificate to sign the app, and also since APS and VAS only run on specific device type, you need to package the app carefully and manage the deployment to cover various device types. + + +Blackberry 10 +------------- +Blackberry 10 is supported since PJSIP version 2.2. As this is a relatively new platform for us, we are currently listening to developer's feedback regarding the port. But so far it seems to be working well. Some considerations for BB10 platform include: + +#. IP change (for example when user is changing access point) is a feature frequently asked by developers and you can find the documentation here: http://trac.pjsip.org/repos/wiki/IPAddressChange + + +Windows Mobile +-------------- +This is the old Windows Mobile platform that is based on WinCE. This platform has been supported for a long time, but doesn't seem to attract any attentions recently. We expect all features except video to work, but there may be some errors every now and then because this target is not actively maintained. No new development will be done for this platform. + +Other considerations for Windows Mobile platform are: + +#. the quality of audio device on WM varies a lot, and this affects audio latency. Audio latency could go as high as hundreds of millisecond on bad hardware. +#. echo cancellation could be a problem. We can only use basic echo suppressor due to hardware limitation, and combined with bad quality of audio device, it may cause ineffective echo cancellation. This could be mitigated by setting the audio level to low. + + +Windows Phone 8 +--------------- +Windows Phone 8 (WP8) support is being added to PJSIP version 2.2 and is still under development. Specific considerations for this platform are: + +#. WP8 governs specific interaction with WP8 GUI and framework that needs to be followed by application in order to make VoIP call work seamlessly on the device. Some lightweight process will be created by WP8 framework in order for background call to work and PJSIP needs to put it's background processing in this process's context. Currently this feature is under development. + + + +Embedded Linux +-------------- +In general embedded Linux support is similar to Linux and we find no problems with it. We found some specific considerations for embedded Linux as follows: + +#. the performance of the audio device is probably the one with most issues, as some development boards have not so descent sound device that has high audio jitter (or burst) and latency. This will affect end to end audio latency and also the performance of the echo canceller. Also we found that ALSA generally works better than OSS, so if you can have ALSA up and running that will be better. Use our native ALSA backend audio device instead of PortAudio since it is simpler and lighter. + + +QNX or Other Posix Embedded OS +------------------------------ +This is not part of our officially supported OSes, but users have run PJSIP on QNX and Blackberry 10 is based on QNX too. Since QNX provides Posix API, and maybe by using the settings found in the configure-bb10 script, PJSIP should be able to run on it, but you need to develop PJMEDIA sound device wrapper for your audio device. Other than this, we don't have enough experience to comment on the platform. + + +Other Unix Desktop OSes +----------------------- +Community members, including myself, have occasionally run PJSIP on other Unix OSes such as Solaris, FreeBSD, and OpenBSD. We expect PJSIP to run on these platforms (maybe with a little kick). + + +Porting to Other Embedded OSes +------------------------------ +It is possible to port PJSIP to other embedded OSes or even directly to device without OS and people have done so. In general, the closer resemblance the new OS to existing supported OS, the easier the porting job will be. The good thing is, PJSIP has been made to be very very portable, and system dependent features are localized in PJLIB and PJMEDIA audio device, so the effort is more quantifiable. Once you are able to successfully run *pjlib-test*, you are more or less there with your porting effort. Other than that, if you really want to port PJSIP to new platform, you probably already know what you're doing. + + + +Which API to Use +================ + +PJSIP, PJMEDIA, and PJNATH Level +-------------------------------- +At the lowest level we have the individual PJSIP **C** libraries, which consist of PJSIP, PJMEDIA, and PJNATH, with PJLIB-UTIL and PJLIB as support libraries. This level provides the most flexibility, but it's also the hardest to use. The only reason you'd want to use this level is if: + +#. you only need the individual library (say, PJNATH) +#. you need to be very very tight in footprint (say when things need to be measured in Kilobytes instead of Megabytes) +#. you are **not** developing a SIP client + +Use the corresponding PJSIP, PJMEDIA, PJNATH manuals from http://trac.pjsip.org/repos/ for information on how to use the libraries. If you use PJSIP, the PJSIP Developer's Guide (PDF) from that page provides in-depth information about PJSIP library. + +PJSUA-LIB API +------------- +Next up is PJSUA-LIB API that combines all those libraries into a high level, integrated client user agent library written in C. This is the library that most PJSIP users use, and the highest level abstraction before pjsua2 was created. + +Motivations for using PJSUA-LIB library includes: + +#. developing client application (PJSUA-LIB is optimized for developing client app) +#. better efficiency than higher level API + + +pjsua2 C++ API +-------------- +pjsua2 is a new, objected oriented, C++ API created on top of PJSUA-LIB. The API is different than PJSUA-LIB, but it should be even easier to use and it should have better documentation too (such as this book). The pjsua2 API removes most cruxes typically associated with PJSIP, such as the pool and pj_str_t, and add new features such as object persistence so you can save your configs to a file, for example. All data structures are rewritten for more clarity. + +A C++ application can use pjsua2 natively, while at the same time still has access to the lower level objects if it needs to. This means that the C++ application should not loose any information from using the C++ abstraction, compared to if it is using PJSUA-LIB directly. The C++ application also should not loose the ability to extend the library. It would still be able to register a custom PJSIP module, pjmedia_port, pjmedia_transport, and so on. + +Benefits of using pjsua2 C++ API include: + +#. cleaner object oriented API +#. uniform API for higher level language such as Java and Python +#. persistence API +#. the ability to access PJSUA-LIB and lower level libraries when needed (including the ability to extend the libraries, for example creating custom PJSIP module, pjmedia_port, pjmedia_transport, etc.) + + +Some considerations on pjsua2 C++ API are: +#. instead of returning error, the API uses exception for error reporting +#. pjsua2 uses standard C++ library +#. the performance penalty due to the API abstraction should be negligible on typical modern device + + + +pjsua2 API for Java, Python, and Others +--------------------------------------- +The pjsua2 API is also available for non-native code via SWIG binding. Configurations for Java and Python are provided with the distribution. Thanks to SWIG, other language bindings may be generated relatively easily. + +The pjsua2 API for non-native code is effectively the same as pjsua2 C++ API. However, unlike C++, you cannot access PJSUA-LIB and the underlying C libraries from the scripting language, hence you are limited to what pjsua2 provides. + +You can use this API if native application development is not available in target platform (such as Android), or if you prefer to develop with non-native code instead of C/C++. + + + + +Network and Infrastructure Considerations +========================================= + +NAT Issues +---------- + + +TCP Requirement +--------------- +If you support iOS devices in your service, you need to use TCP, because only TCP will work on iOS device when it is in background mode. This means your infrastructure needs to support TCP. + + +Sound Device +============ + +Latency +------- + + +Echo Cancellation +----------------- + + + + diff --git a/doc/pjsip-book/endpoint.rst b/doc/pjsip-book/endpoint.rst new file mode 100644 index 00000000..1152307e --- /dev/null +++ b/doc/pjsip-book/endpoint.rst @@ -0,0 +1,96 @@ + + +Endpoint +************ +The ​Endpoint class is a singleton class, and application MUST create one and at most one of this class instance before it can do anything else. This class is the core class of PJSUA2, and it provides the following functions: + +- Starting up and shutting down +- Customization of configurations, such as core UA (User Agent) SIP configuration, media configuration, and logging configuration + +This section will describe the functions above. + +To use the Endpoint class, normally application does not need to subclass it unless: + +- application wants to implement/override Endpoint’s callback methods to get the events such as transport state change or NAT detection completion, or +- application schedules a timer using Endpoint.utilTimerSchedule() API. In this case, application needs to implement the onTimer() callback to get the notification when the timer expires. + +Instantiating the Endpoint +-------------------------- +Before anything else, you must instantiate the Endpoint class:: + + Endpoint *ep = new Endpoint; + +Once the endpoint is instantiated, you can retrieve the Endpoint instance using Endpoint.instance() static method. + +Creating the Library +---------------------- +Create the library by calling its libCreate() method:: + + try { + ep->libCreate(); + } catch(Error& err) { + cout << "Startup error: " << err.reason << endl; + } + +The libCreate() method will raise exception if error occurs, so we need to trap the exception using try/catch clause as above. + +Initializing the Library and Configuring the Settings +---------------------------------------------------------------------------- + +The EpConfig class provides endpoint configuration which allows the customization of the following settings: + +- UAConfig, to specify core SIP user agent settings. +- MediaConfig, to specify various media settings, including ICE and TURN. +- LogConfig, to customize logging settings. + +To customize the settings, create instance of EpConfig class and specify them during the endpoint initialization (will be explained more later), for example:: + + EpConfig ep_cfg; + ep_cfg.logConfig.level = 5; + ep_cfg.uaConfig.maxCalls = 4; + ep_cfg.mediaConfig.sndClockRate = 16000; + +Next, you can initialize the library by calling libInit():: + + try { + EpConfig ep_cfg; + // Specify customization of settings in ep_cfg + ep->libInit(ep_cfg); + } catch(Error& err) { + cout << "Initialization error: " << err.reason << endl; + } + +The snippet above initializes the library with the default settings. + +Creating One or More Transports +-------------------------------------------------- +Application needs to create one or more ​transports before it can send or receive SIP messages:: + + try { + TransportConfig tcfg; + tcfg.port = 5060; + TransportId tid = ep->transportCreate(PJSIP_TRANSPORT_UDP, tcfg); + } catch(Error& err) { + cout << "Transport creation error: " << err.reason << endl; + } + +The transportCreate() method returns the newly created ​Transport ID and it takes the transport type and ​TransportConfig object to customize the transport settings like bound address and listening port number. Without this, by default the transport will be bound to INADDR_ANY and any available port. + +There is no real use of the ​Transport ID, except to create userless account (with ​Account.create(), as will be explained later), and perhaps to display the list of transports to user if the application wants it. + +Starting the Library +-------------------- +Now we're ready to start the library. We need to start the library to finalize the initialization phase, e.g. to complete the initial STUN address resolution, initialize/start the sound device, etc. To start the library, call ​libStart() method:: + + try { + ep->libStart(); + } catch(Error& err) { + cout << "Startup error: " << err.reason << endl; + } + +Shutting Down the Library +-------------------------------------- +Once the application exits, the library needs to be shutdown so that resources can be released back to the operating system. This is done by deleting the Endpoint instance, which will internally call ​libDestroy():: + + delete ep; + diff --git a/doc/pjsip-book/fetch_trac.py b/doc/pjsip-book/fetch_trac.py new file mode 100644 index 00000000..3c754624 --- /dev/null +++ b/doc/pjsip-book/fetch_trac.py @@ -0,0 +1,85 @@ +import urllib2 +import sys + +def fetch_rst(url): + print 'Fetching %s..' % url + req = urllib2.Request(url) + + fd = urllib2.urlopen(req, timeout=30) + body = fd.read() + + pos = body.find("{{{") + if pos >= 0: + body = body[pos+4:] + + pos = body.find("}}}") + if pos >= 0: + body = body[:pos] + + pos = body.find("#!rst") + if pos >= 0: + body = body[pos+6:] + + pos = url.rfind("/") + if pos >= 0: + filename = url[pos+1:] + else: + filename = url + + pos = filename.find('?') + if pos >= 0: + filename = filename[:pos] + + filename += ".rst" + f = open(filename, 'w') + f.write(body) + f.close() + + +def process_index(index): + pages = [] + + f = open(index + '.rst', 'r') + line = f.readline() + while line: + if line.find('toctree::') >= 0: + break + line = f.readline() + + if line.find('toctree::') < 0: + return [] + # Skip directive (or whatever it's called + line = f.readline().strip() + while line and line[0] == ':': + line = f.readline().strip() + # Skip empty lines + line = f.readline().strip() + while not line: + line = f.readline().strip() + # Parse names + while line: + pages.append(line) + line = f.readline().strip() + + f.close() + + return pages + + +if __name__ == '__main__': + print "** Warning: This will overwrite ALL RST files in current directory. Continue? [n] ", + if sys.stdin.readline().strip() != 'y': + sys.exit(0) + + url_format = 'http://trac.pjsip.org/repos/wiki/pjsip-doc/%s?format=txt' + + index = url_format % ('index') + fetch_rst(index) + + pages = process_index('index') + for page in pages: + url = url_format % (page) + fetch_rst(url) + + print 'Done.' + \ No newline at end of file diff --git a/doc/pjsip-book/index.rst b/doc/pjsip-book/index.rst new file mode 100644 index 00000000..4ffce9ef --- /dev/null +++ b/doc/pjsip-book/index.rst @@ -0,0 +1,36 @@ + +.. The PJSIP Book documentation master file, created by + sphinx-quickstart on Sat Nov 30 06:36:26 2013. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to The PJSIP Book's documentation! +========================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + intro + consider + intro_pjsua2 + endpoint + account + media + call + presence + samples + optimization + media_quality + network_problems + reference + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/pjsip-book/intro.rst b/doc/pjsip-book/intro.rst new file mode 100644 index 00000000..69e63035 --- /dev/null +++ b/doc/pjsip-book/intro.rst @@ -0,0 +1,33 @@ + + +Introduction to PJSUA2 +******************************* +This documentation is intended for developers looking to develop Session Initiation Protocol (SIP) based client application. Some knowledge on SIP is definitely required, and of course some programming experience. Prior knowledge of PJSUA C API is not needed, although it will probably help. + +This PJSUA2 module provides very high level API to do SIP calls, presence, and instant messaging, as well as handling media and NAT traversal. Knowledge of SIP protocol details (such as the grammar, transaction, dialog, and whatnot) are not required, however you should know how SIP works in general and particularly how to configure SIP clients to, e.g. register to a SIP provider, specify SIP URI to make call to, and so on, to use the module. + +Getting Started with PJSIP +============================== +To begin using PJSIP +http://trac.pjsip.org/repos/wiki/Getting-Started + +PJSIP Info and Documentation +================================ +PJSIP General Wiki: +http://trac.pjsip.org/repos/wiki + +PJSIP FAQ: +http://trac.pjsip.org/repos/wiki/FAQ + +PJSIP Reference Manual: +http://trac.pjsip.org/repos/wiki - Reference Manual + +Building PJSUA2 +================= +PJSUA2 API declaration can be found in pjproject/pjsip/include/pjsua2 while the source codes are located in pjproject/pjsip/src/pjsua2. It will be automatically built when you compile PJSIP. + +PJSUA2 Language Binding Support +=================================== +Optional if you want to: +​SWIG (minimum version 2.0.5) + diff --git a/doc/pjsip-book/intro_pjsua2.rst b/doc/pjsip-book/intro_pjsua2.rst new file mode 100644 index 00000000..d3430f20 --- /dev/null +++ b/doc/pjsip-book/intro_pjsua2.rst @@ -0,0 +1,158 @@ + +PJSUA2-High Level API +****************************** +PJSUA2 is an object-oriented abstraction above ​PJSUA API. It provides high level API for constructing ​Session Initiation Protocol (SIP) multimedia user agent applications (a.k.a Voice over IP/VoIP softphones). It wraps together the signaling, media, and NAT traversal functionality into easy to use call control API, account management, buddy list management, presence, and instant messaging, along with multimedia features such as local conferencing, file streaming, local playback, and voice recording, and powerful NAT traversal techniques utilizing ​STUN, ​TURN, and ​ICE. + +PJSUA2 is implemented on top of PJSUA-LIB API. The SIP and media features and object modelling follows what PJSUA-LIB provides (for example, we still have accounts, call, buddy, and so on), but the API to access them is different. These features will be described later in this chapter. PJSUA2 is a C++ library, which you can find under ``pjsip`` directory in the PJSIP distribution. The C++ library can be used by native C++ applications directly. But PJSUA2 is not just a C++ library. From the beginning, it has been designed to be accessible from high level non-native languages such as Java and Python. This is achieved by SWIG binding. And thanks to SWIG, binding to other languages can be added relatively easily in the future. + + +PJSUA2 Main Classes +====================== +Here are the main classes of the PJSUA2: + +Endpoint +-------------- +This is the main class of PJSUA2. You need to instantiate one and exactly one of this class, and from the instance you can then initialize and start the library. + +Account +------------- +An account specifies the identity of the person (or endpoint) on one side of SIP conversation. At least one account instance needs to be created before anything else, and from the account instance you can start making/receiving calls as well as adding buddies. + +Media +---------- +This class represents a media element which is capable to either produce media or takes media. + +Call +------ +This class is used to manipulate calls, such as to answer the call, hangup the call, put the call on hold, transfer the call, etc. + +Buddy +--------- +This class represents a remote buddy (a person, or a SIP endpoint). You can subscribe to presence status of a buddy to know whether the buddy is online/offline/etc., and you can send and receive instant messages to/from the buddy. + +General Concepts +================== +Class Usage Patterns +--------------------- +With the methods of the main classes above, you will be able to invoke various operations to the object quite easily. But how can we get events/notifications from these classes? Each of the main classes above (except Media) will get their events in the callback methods. So to handle these events, just derive a class from the corresponding class (​Endpoint, Call, Account, or Buddy) and implement/override the relevant method (depending on which event you want to handle). More will be explained in later sections. + +Objects Persistence +--------------------- +PJSUA2 includes PersistentObject class to provide functionality to read/write data from/to a document (string or file). The data can be simple data types such as boolean, number, string, and string arrays, or a user defined object. Currently the implementation supports reading and writing from/to JSON document, but the framework allows application to extend the API to support other document formats. + +As such, classes which inherit from PersistentObject, such as EpConfig (endpoint configuration), AccountConfig (account configuration), and BuddyConfig (buddy configuration) can be loaded/saved from/to a file. Here’s an example to save a config to a file: + +.. code-block:: c++ + + EpConfig epCfg; + JsonDocument jDoc; + epCfg.uaConfig.maxCalls = 61; + epCfg.uaConfig.userAgent = "Just JSON Test"; + jDoc.writeObject(epCfg); + jDoc.saveFile(“jsontest.js”); + +To load from the file: + +.. code-block:: c++ + + EpConfig epCfg; + JsonDocument jDoc; + jDoc.loadFile("jsontest.js"); + jDoc.readObject(epCfg); + +Error Handling +--------------- +We use exceptions as means to report error, as this would make the program flows more naturally. Operations which yield error will raise ​Error exception. If you prefer to display the error in more structured manner, the ​Error class has several members to explain the error, such as the operation name that raised the error, the error code, and the error message itself. + +Asynchronous Operations +------------------------- +If you have developed applications with PJSIP, you'll know about this already. In PJSIP, all operations that involve sending and receiving SIP messages are asynchronous, meaning that the function that invokes the operation will complete immediately, and you will be given the completion status as callbacks. + +Take a look for example the ​makeCall() method of the Call class. This function is used to initiate outgoing call to a destination. When this function returns successfully, it does not mean that the call has been established, but rather it means that the call has been initiated successfully. You will be given the report of the call progress and/or completion in the ​onCallState() callback method of ​Call class. + +Threading +---------- +For platforms that require polling, the PJSUA2 module provides its own worker thread to poll PJSIP, so it is not necessary to instantiate own your polling thread. Having said that the application should be prepared to have the callbacks called by different thread than the main thread. The PJSUA2 module should be thread safe. + + +Using in C++ Application +======================== +As mentioned in previous chapter, A C++ application can use *pjsua2* natively, while at the same time still has access to the lower level objects and the ability to extend the libraries if it needs to. Using the API will be exactly the same as the API reference that is written in this book. + +Here is a sample complete C++ application to give you some idea about the API. The snippet below initializes the library and creates an account that registers to our pjsip.org SIP server. + +.. code-block:: c++ + + #include + #include + + using namespace pj; + + // Subclass to extend the Account and get notifications etc. + class MyAccount : public Account { + public: + virtual void onRegState(OnRegStateParam &prm) { + AccountInfo ai = getInfo(); + std::cout << (ai.regIsActive? "*** Register:" : "*** Unregister:") + << " code=" << prm.code << std::endl; + } + }; + + int main() + { + Endpoint ep; + + ep.libCreate(); + + // Initialize endpoint + EpConfig ep_cfg; + ep_cfg.uaConfig.userAgent = "pjsua2-hello"; + ep.libInit( ep_cfg ); + + // Create SIP transport. Error handling sample is shown + TransportConfig tcfg; + tcfg.port = 5060; + try { + ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg); + } catch (Error &err) { + std::cout << err.info() << std::endl; + return 1; + } + + // Start the library (worker threads etc) + ep.libStart(); + std::cout << "*** PJSUA2 STARTED ***" << std::endl; + + // Configure an AccountConfig + AccountConfig acfg; + acfg.idUri = "sip:test@pjsip.org"; + acfg.regConfig.registrarUri = "sip:pjsip.org"; + AuthCredInfo cred("digest", "*", "test", 0, "secret"); + acfg.sipConfig.authCreds.push_back( cred ); + + // Create the account + MyAccount *acc = new MyAccount; + acc->create(acfg); + + // Here we don't have anything else to do.. + pj_thread_sleep(10000); + + // Delete the account. This will unregister from server + delete acc; + + // This will implicitly shutdown the library + return 0; + } + + +Using in Python Application +=========================== + + + +Using in Java Application +========================= + + + + diff --git a/doc/pjsip-book/make.bat b/doc/pjsip-book/make.bat new file mode 100644 index 00000000..564b4bd8 --- /dev/null +++ b/doc/pjsip-book/make.bat @@ -0,0 +1,190 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\ThePJSIPBook.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\ThePJSIPBook.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/doc/pjsip-book/media.rst b/doc/pjsip-book/media.rst new file mode 100644 index 00000000..5dc4d1bf --- /dev/null +++ b/doc/pjsip-book/media.rst @@ -0,0 +1,113 @@ + + +Media +===== +Media objects are objects that are capable to either produce media or takes media. In ​PJMEDIA terms, these objects are implemented as media ports (​pjmedia_port). + +An important subclass of Media is AudioMedia which represents audio media. There are several type of audio media objects supported in PJSUA2: + +- CallAudioMedia, to transmit and receive audio to/from remote person. +- AudioMediaPlayer, to play WAV file(s). +- AudioMediaRecorder, to record audio to a WAV file. + +More media objects may be added in the future. + +The Audio Conference Bridge +---------------------------- +The conference bridge provides a simple but yet powerful concept to manage audio flow between the audio medias. The principle is very simple, that is you connect audio source to audio destination, and the bridge will make the audio flows from the source to destination, and that's it. If more than one sources are transmitting to the same destination, then the audio from the sources will be mixed. If one source is transmitting to more than one destinations, the bridge will take care of duplicating the audio from the source to the multiple destinations. + +In ​PJSUA2, all audio media objects are plugged-in to the central conference bridge for easier manipulation. A plugged-in audio media will not be connected to anything, so media will not flow from/to any objects. An audio media source can start/stop the transmission to a destination by using the API AudioMedia.startTransmit() / AudioMedia.stopTransmit(). + +An audio media object plugged-in to the conference bridge will be given a port ID number that identifies the object in the bridge. Application can use the API AudioMedia.getPortId() to retrieve the port ID. Normally, application should not need to worry about the port ID (as all will be taken care of by the bridge) unless application want to create its own custom audio media. + +Playing a WAV File +++++++++++++++++++ +To playback the WAV file to the speaker, just start the transmission of the WAV playback object to the sound device:: + + AudioMediaPlayer player; + try { + player.createPlayer(“file.wav”); + player.startTransmit(); + } catch(Error& err) { + } + +Once you're done with the playback, just stop the transmission n to stop the playback:: + + try { + player.stopTransmit(); + } catch(Error& err) { + } + +Recording to WAV File ++++++++++++++++++++++ +Or if you want to record the microphone to the WAV file, simply do this:: + + AudioMediaRecorder recorder; + try { + recorder.createRecorder(“file.wav”); + .startTransmit(recorder); + } catch(Error& err) { + } + +And the media will flow from the sound device to the WAV record file. As usual, to stop or pause recording, just stop the transmission:: + + try { + .stopTransmit(recorder); + } catch(Error& err) { + } + +(Note that stopping the transmission to the WAV recorder as above does not close the WAV file, and you can resume recording by connecting a source to the WAV recorder again. You cannot playback the recorded WAV file before you close it.) + +Looping Audio ++++++++++++++ +If you want, you can loop the audio of a media object to itself (i.e. the audio received from the object will be transmitted to itself). For example, you can loop the audio of the sound device with:: + + .startTransmit(); + +With the above connection, audio received from the microphone will be played back to the speaker. This is useful to test whether the microphone and speaker are working properly. + +You can loop-back audio from any objects, as long as the object has bidirectional media. That means you can loop the call's audio media, so that audio received from the remote person will be transmitted back to her/him. But you can't loop the WAV player or recorder since these objects can only play or record and not both. + +Normal Call ++++++++++++ + +A single call can has several audio medias. Application can retrieve the audio media by using the API Call.getMedia():: + + AudioMedia *aud_med = (AudioMedia *)call.getMedia(0); + +In the above, we assume that the audio media is located in index 0. Of course on a real application, we should iterate the medias to find the correct media index by checking whether the media returned by getMedia() is valid. More on this will be explained later in the Call section. Then for a normal call, we would want to establish bidirectional audio with the remote person, which can be done easily by connecting the sound device and the call audio media and vice versa:: + + // This will connect the sound device/mic to the call audio media + ->startTransmit(*aud_med); + + // And this will connect the call audio media to the sound device/speaker + aud_med->startTransmit(); + +Second Call ++++++++++++ +Suppose we want to talk with two remote parties at the same time. Since we already have bidirectional media connection with one party, we just need to add bidirectional connection with the other party using the code below:: + + AudioMedia *aud_med2 = (AudioMedia *)call2.getMedia(0); + ->startTransmit(*aud_med2); + aud_med2->startTransmit(); + +Now we can talk to both parties at the same time, and we will hear audio from either party. But at this stage, the remote parties can't talk or hear each other (i.e. we're not in full conference mode yet). + +Conference Call ++++++++++++++++ +To enable both parties talk to each other, just establish bidirectional media between them:: + + aud_med->startTransmit(*aud_med2); + aud_med2->startTransmit(*aud_med); + +Now the three parties (us and both remote parties) will be able to talk to each other. + +Recording the Conference +++++++++++++++++++++++++ + +While doing the conference, it perfectly makes sense to want to record the conference to a WAV file, and all we need to do is to connect the microphone and both calls to the WAV recorder:: + + ->startTransmit(recorder); + aud_med->startTransmit(recorder); + aud_med2->startTransmit(recorder); + diff --git a/doc/pjsip-book/media_quality.rst b/doc/pjsip-book/media_quality.rst new file mode 100644 index 00000000..ad81557c --- /dev/null +++ b/doc/pjsip-book/media_quality.rst @@ -0,0 +1,11 @@ + + +Media Quality +************* + +Audio Quality +============= + +Video Quality +============= + diff --git a/doc/pjsip-book/network_problems.rst b/doc/pjsip-book/network_problems.rst new file mode 100644 index 00000000..c16ef0b3 --- /dev/null +++ b/doc/pjsip-book/network_problems.rst @@ -0,0 +1,11 @@ + + +Network Problems +**************** + +IP Address Change +================= + +Blocked/Filtered Network +======================== + diff --git a/doc/pjsip-book/optimization.rst b/doc/pjsip-book/optimization.rst new file mode 100644 index 00000000..ad0932ed --- /dev/null +++ b/doc/pjsip-book/optimization.rst @@ -0,0 +1,11 @@ + + +General Configuration Optimization +********************************** + +PJSUA2 Settings +=============== + +CPU Optimization +================ + diff --git a/doc/pjsip-book/presence.rst b/doc/pjsip-book/presence.rst new file mode 100644 index 00000000..ab544cce --- /dev/null +++ b/doc/pjsip-book/presence.rst @@ -0,0 +1,43 @@ + + +Buddy (Presence) +================ +This class represents a remote buddy (a person, or a SIP endpoint). +To use the Buddy class, application DOES NOT need to subclass it unless application wants to get the notifications on buddy state change. + +Subscribe to Buddy's Presence Status +--------------------------------------------------------- +To subscribe to buddy's presence status, you need to add a buddy object, install callback to handle buddy's event, and start subscribing to buddy's presence status. The snippet below shows a sample code to achieve these:: + + class MyBuddyCallback(pjsua.BuddyCallback): + def __init__(self, buddy=None): + pjsua.BuddyCallback.__init__(self, buddy) + + def on_state(self): + print "Buddy", self.buddy.info().uri, "is", + print self.buddy.info().online_text + + try: + uri = '"Alice" ' + buddy = acc.add_buddy(uri, cb=MyBuddyCallback()) + buddy.subscribe() + + except pjsua.Error, err: + print 'Error adding buddy:', err + +For more information please see ​Buddy class and ​BuddyCallback class reference documentation. + +Responding to Presence Subscription Request + +By default, incoming presence subscription to an account will be accepted automatically. You will probably want to change this behavior, for example only to automatically accept subscription if it comes from one of the buddy in the buddy list, and for anything else prompt the user if he/she wants to accept the request. + +This can be done by implementing the ​on_incoming_subscribe() method of the ​AccountCallback class. + +Changing Account's Presence Status + +The ​Account class provides two methods to change account's presence status: + +​set_basic_status() can be used to set basic account's presence status (i.e. available or not available). +​set_presence_status() can be used to set both the basic presence status and some extended information (e.g. busy, away, on the phone, etc.). +When the presence status is changed, the account will publish the new status to all of its presence subscriber, either with PUBLISH request or SUBSCRIBE request, or both, depending on account configuration. + diff --git a/doc/pjsip-book/reference.rst b/doc/pjsip-book/reference.rst new file mode 100644 index 00000000..c595269d --- /dev/null +++ b/doc/pjsip-book/reference.rst @@ -0,0 +1,20 @@ + + +PJSUA2 API Reference Manuals +**************************** + +Endpoint +======== + +Account +======= + +Media +===== + +Call +==== + +Buddy +===== + diff --git a/doc/pjsip-book/samples.rst b/doc/pjsip-book/samples.rst new file mode 100644 index 00000000..3c951ede --- /dev/null +++ b/doc/pjsip-book/samples.rst @@ -0,0 +1,27 @@ + + +PJSUA2 Sample Applications +*********************************** + +Sample Apps +=========== + +Python GUI +------------------ +It requires Python 2.7 and above. + +Android & Java +----------------------------- + +C++ +----------------------------- + +Miscellaneous +=================== + +How to dump call stats +----------------------------- + +How to … +----------------------------- + diff --git a/pjlib-util/build/Makefile b/pjlib-util/build/Makefile index 33c82879..7dc1a82b 100644 --- a/pjlib-util/build/Makefile +++ b/pjlib-util/build/Makefile @@ -38,7 +38,7 @@ export PJLIB_UTIL_SRCDIR = ../src/pjlib-util export PJLIB_UTIL_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ base64.o cli.o cli_console.o cli_telnet.o crc32.o errno.o dns.o \ dns_dump.o dns_server.o getopt.o hmac_md5.o hmac_sha1.o \ - http_client.o md5.o pcap.o resolver.o scanner.o sha1.o \ + http_client.o json.o md5.o pcap.o resolver.o scanner.o sha1.o \ srv_resolver.o string.o stun_simple.o \ stun_simple_client.o xml.o export PJLIB_UTIL_CFLAGS += $(_CFLAGS) @@ -50,7 +50,7 @@ export PJLIB_UTIL_LDFLAGS += $(PJLIB_LDLIB) $(_LDFLAGS) # export UTIL_TEST_SRCDIR = ../src/pjlib-util-test export UTIL_TEST_OBJS += xml.o encryption.o stun.o resolver_test.o test.o \ - http_client.o + json_test.o http_client.o export UTIL_TEST_CFLAGS += $(_CFLAGS) export UTIL_TEST_CXXFLAGS += $(_CXXFLAGS) export UTIL_TEST_LDFLAGS += $(PJLIB_UTIL_LDLIB) $(PJLIB_LDLIB) $(_LDFLAGS) diff --git a/pjlib-util/build/pjlib_util.vcproj b/pjlib-util/build/pjlib_util.vcproj index 6872cabc..a00959d2 100644 --- a/pjlib-util/build/pjlib_util.vcproj +++ b/pjlib-util/build/pjlib_util.vcproj @@ -285,12 +285,11 @@ /> + + @@ -382,7 +390,7 @@ /> - - + + + + - - @@ -698,7 +706,7 @@ /> + + @@ -909,9 +923,9 @@ /> @@ -975,9 +989,9 @@ /> + + @@ -1131,7 +1154,7 @@ /> - - + + + + - - @@ -1447,7 +1469,7 @@ /> + + - - - - - - - - + + @@ -4312,17 +4316,15 @@ /> + + + - - - + + diff --git a/pjlib-util/build/pjlib_util_test.vcproj b/pjlib-util/build/pjlib_util_test.vcproj index e810251e..ff871ca8 100644 --- a/pjlib-util/build/pjlib_util_test.vcproj +++ b/pjlib-util/build/pjlib_util_test.vcproj @@ -306,12 +306,11 @@ /> - @@ -361,22 +357,24 @@ Name="VCBscMakeTool" /> - - @@ -413,7 +411,7 @@ + @@ -491,27 +493,24 @@ Name="VCBscMakeTool" /> - - - @@ -564,25 +557,26 @@ Name="VCBscMakeTool" /> - - - @@ -632,24 +623,27 @@ Name="VCBscMakeTool" /> - - + @@ -696,24 +696,22 @@ Name="VCBscMakeTool" /> - - @@ -750,7 +748,7 @@ - @@ -835,22 +826,24 @@ Name="VCBscMakeTool" /> - - @@ -982,9 +975,9 @@ /> @@ -1048,9 +1041,9 @@ /> - @@ -1173,22 +1163,24 @@ Name="VCBscMakeTool" /> - - @@ -1225,7 +1217,7 @@ + @@ -1303,27 +1299,24 @@ Name="VCBscMakeTool" /> - - - @@ -1376,25 +1363,26 @@ Name="VCBscMakeTool" /> - - - @@ -1444,24 +1429,27 @@ Name="VCBscMakeTool" /> - - + @@ -1508,24 +1501,22 @@ Name="VCBscMakeTool" /> - - @@ -1562,7 +1553,7 @@ - @@ -1646,24 +1631,27 @@ Name="VCBscMakeTool" /> - - + @@ -1710,26 +1701,24 @@ Name="VCBscMakeTool" /> - - + @@ -1908,26 +1904,24 @@ Name="VCBscMakeTool" /> - - + @@ -2106,26 +2104,24 @@ Name="VCBscMakeTool" /> - - + @@ -2304,26 +2306,24 @@ Name="VCBscMakeTool" /> - - + + @@ -3296,16 +3300,15 @@ /> +/* JSON */ +#include + /* Old STUN */ #include diff --git a/pjlib-util/include/pjlib-util/errno.h b/pjlib-util/include/pjlib-util/errno.h index e224c6a9..8fa99b1b 100644 --- a/pjlib-util/include/pjlib-util/errno.h +++ b/pjlib-util/include/pjlib-util/errno.h @@ -117,6 +117,15 @@ #define PJLIB_UTIL_EINXML (PJLIB_UTIL_ERRNO_START+20) /* 320020 */ +/************************************************************ + * JSON ERROR + ***********************************************************/ +/** + * @hideinitializer + * General invalid JSON message. + */ +#define PJLIB_UTIL_EINJSON (PJLIB_UTIL_ERRNO_START+30) /* 320030 */ + /************************************************************ * DNS ERROR diff --git a/pjlib-util/include/pjlib-util/json.h b/pjlib-util/include/pjlib-util/json.h new file mode 100644 index 00000000..56d55b46 --- /dev/null +++ b/pjlib-util/include/pjlib-util/json.h @@ -0,0 +1,228 @@ +/* $Id$ */ +/* + * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) + * + * 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 + */ +#ifndef __PJLIB_UTIL_JSON_H__ +#define __PJLIB_UTIL_JSON_H__ + + +/** + * @file json.h + * @brief PJLIB JSON Implementation + */ + +#include +#include +#include + +PJ_BEGIN_DECL + +/** + * @defgroup PJ_JSON JSON Writer and Loader + * @ingroup PJ_FILE_FMT + * @{ + * This API implements JSON file format according to RFC 4627. It can be used + * to parse, write, and manipulate JSON documents. + */ + +/** + * Type of JSON value. + */ +typedef enum pj_json_val_type +{ + PJ_JSON_VAL_NULL, /**< Null value (null) */ + PJ_JSON_VAL_BOOL, /**< Boolean value (true, false) */ + PJ_JSON_VAL_NUMBER, /**< Numeric (float or fixed point) */ + PJ_JSON_VAL_STRING, /**< Literal string value. */ + PJ_JSON_VAL_ARRAY, /**< Array */ + PJ_JSON_VAL_OBJ /**< Object. */ +} pj_json_val_type; + +/* Forward declaration for JSON element */ +typedef struct pj_json_elem pj_json_elem; + +/** + * JSON list to store child elements. + */ +typedef struct pj_json_list +{ + PJ_DECL_LIST_MEMBER(pj_json_elem); +} pj_json_list; + +/** + * This represents JSON element. A JSON element is basically a name/value + * pair, where the name is a string and the value can be one of null, boolean + * (true and false constants), number, string, array (containing zero or more + * elements), or object. An object can be viewed as C struct, that is a + * compound element containing other elements, each having name/value pair. + */ +struct pj_json_elem +{ + PJ_DECL_LIST_MEMBER(pj_json_elem); + pj_str_t name; /**< ELement name. */ + pj_json_val_type type; /**< Element type. */ + union + { + pj_bool_t is_true; /**< Boolean value. */ + float num; /**< Number value. */ + pj_str_t str; /**< String value. */ + pj_json_list children; /**< Object and array children */ + } value; /**< Element value. */ +}; + +/** + * Structure to be specified to pj_json_parse() to be filled with additional + * info when parsing failed. + */ +typedef struct pj_json_err_info +{ + unsigned line; /**< Line location of the error */ + unsigned col; /**< Column location of the error */ + int err_char; /**< The offending character. */ +} pj_json_err_info; + +/** + * Type of function callback to write JSON document in pj_json_writef(). + * + * @param s The string to be written to the document. + * @param size The length of the string + * @param user_data User data that was specified to pj_json_writef() + * + * @return If the callback returns non-PJ_SUCCESS, it will + * stop the pj_json_writef() function and this error + * will be returned to caller. + */ +typedef pj_status_t (*pj_json_writer)(const char *s, + unsigned size, + void *user_data); + +/** + * Initialize null element. + * + * @param el The element. + * @param name Name to be given to the element, or NULL. + */ +PJ_DECL(void) pj_json_elem_null(pj_json_elem *el, pj_str_t *name); + +/** + * Initialize boolean element with the specified value. + * + * @param el The element. + * @param name Name to be given to the element, or NULL. + * @param val The value. + */ +PJ_DECL(void) pj_json_elem_bool(pj_json_elem *el, pj_str_t *name, + pj_bool_t val); + +/** + * Initialize number element with the specified value. + * + * @param el The element. + * @param name Name to be given to the element, or NULL. + * @param val The value. + */ +PJ_DECL(void) pj_json_elem_number(pj_json_elem *el, pj_str_t *name, + float val); + +/** + * Initialize string element with the specified value. + * + * @param el The element. + * @param name Name to be given to the element, or NULL. + * @param val The value. + */ +PJ_DECL(void) pj_json_elem_string(pj_json_elem *el, pj_str_t *name, + pj_str_t *val); + +/** + * Initialize element as an empty array + * + * @param el The element. + * @param name Name to be given to the element, or NULL. + */ +PJ_DECL(void) pj_json_elem_array(pj_json_elem *el, pj_str_t *name); + +/** + * Initialize element as an empty object + * + * @param el The element. + * @param name Name to be given to the element, or NULL. + */ +PJ_DECL(void) pj_json_elem_obj(pj_json_elem *el, pj_str_t *name); + +/** + * Add an element to an object or array. + * + * @param el The object or array element. + * @param child Element to be added to the object or array. + */ +PJ_DECL(void) pj_json_elem_add(pj_json_elem *el, pj_json_elem *child); + +/** + * Parse a JSON document in the buffer. The buffer MUST be NULL terminated, + * or if not then it must have enough size to put the NULL character. + * + * @param pool The pool to allocate memory for creating elements. + * @param buffer String buffer containing JSON document. + * @param size Size of the document. + * @param err_info Optional structure to be filled with info when + * parsing failed. + * + * @return The root element from the document. + */ +PJ_DECL(pj_json_elem*) pj_json_parse(pj_pool_t *pool, + char *buffer, + unsigned *size, + pj_json_err_info *err_info); + +/** + * Write the specified element to the string buffer. + * + * @param elem The element to be written. + * @param buffer Output buffer. + * @param size On input, it must be set to the size of the buffer. + * Upon successful return, this will be set to + * the length of the written string. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pj_json_write(const pj_json_elem *elem, + char *buffer, unsigned *size); + +/** + * Incrementally write the element to arbitrary medium using the specified + * callback to write the document chunks. + * + * @param elem The element to be written. + * @param writer Callback function which will be called to write + * text chunks. + * @param user_data Arbitrary user data which will be given back when + * calling the callback. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pj_json_writef(const pj_json_elem *elem, + pj_json_writer writer, + void *user_data); + +/** + * @} + */ + +PJ_END_DECL + +#endif /* __PJLIB_UTIL_JSON_H__ */ diff --git a/pjlib-util/src/pjlib-util-test/json_test.c b/pjlib-util/src/pjlib-util-test/json_test.c new file mode 100644 index 00000000..cd9a8138 --- /dev/null +++ b/pjlib-util/src/pjlib-util-test/json_test.c @@ -0,0 +1,106 @@ +/* $Id$ */ +/* + * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) + * + * 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 "test.h" + +#define THIS_FILE "json_test.c" + +#if INCLUDE_JSON_TEST + +#include +#include +#include + +static char json_doc1[] = +"{\ + \"Object\": {\ + \"Integer\": 800,\ + \"Negative\": -12,\ + \"Float\": -7.2,\ + \"String\": \"A\\tString with tab\",\ + \"Object2\": {\ + \"True\": true,\ + \"False\": false,\ + \"Null\": null\ + },\ + \"Array1\": [116, false, \"string\", {}],\ + \"Array2\": [\ + {\ + \"Float\": 123.,\ + },\ + {\ + \"Float\": 123.,\ + }\ + ]\ + },\ + \"Integer\": 800,\ + \"Array1\": [116, false, \"string\"]\ +}\ +"; + +static int json_verify_1() +{ + pj_pool_t *pool; + pj_json_elem *elem; + char *out_buf; + unsigned size; + pj_json_err_info err; + + pool = pj_pool_create(mem, "json", 1000, 1000, NULL); + + size = strlen(json_doc1); + elem = pj_json_parse(pool, json_doc1, &size, &err); + if (!elem) { + PJ_LOG(1, (THIS_FILE, " Error: json_verify_1() parse error")); + goto on_error; + } + + size = strlen(json_doc1) * 2; + out_buf = pj_pool_alloc(pool, size); + + if (pj_json_write(elem, out_buf, &size)) { + PJ_LOG(1, (THIS_FILE, " Error: json_verify_1() write error")); + goto on_error; + } + + PJ_LOG(3,(THIS_FILE, "Json document:\n%s", out_buf)); + pj_pool_release(pool); + return 0; + +on_error: + pj_pool_release(pool); + return 10; +} + + +int json_test(void) +{ + int rc; + + rc = json_verify_1(); + if (rc) + return rc; + + return 0; +} + + + +#else +int json_dummy; +#endif diff --git a/pjlib-util/src/pjlib-util-test/test.c b/pjlib-util/src/pjlib-util-test/test.c index feb2c011..223d57d8 100644 --- a/pjlib-util/src/pjlib-util-test/test.c +++ b/pjlib-util/src/pjlib-util-test/test.c @@ -72,6 +72,10 @@ static int test_inner(void) DO_TEST(xml_test()); #endif +#if INCLUDE_JSON_TEST + DO_TEST(json_test()); +#endif + #if INCLUDE_ENCRYPTION_TEST DO_TEST(encryption_test()); DO_TEST(encryption_benchmark()); diff --git a/pjlib-util/src/pjlib-util-test/test.h b/pjlib-util/src/pjlib-util-test/test.h index 37b1d909..b0e77c78 100644 --- a/pjlib-util/src/pjlib-util-test/test.h +++ b/pjlib-util/src/pjlib-util-test/test.h @@ -20,12 +20,14 @@ #include #define INCLUDE_XML_TEST 1 +#define INCLUDE_JSON_TEST 1 #define INCLUDE_ENCRYPTION_TEST 1 #define INCLUDE_STUN_TEST 1 #define INCLUDE_RESOLVER_TEST 1 #define INCLUDE_HTTP_CLIENT_TEST 1 extern int xml_test(void); +extern int json_test(void); extern int encryption_test(); extern int encryption_benchmark(); extern int stun_test(); diff --git a/pjlib-util/src/pjlib-util/errno.c b/pjlib-util/src/pjlib-util/errno.c index 29bd765b..ee1061ed 100644 --- a/pjlib-util/src/pjlib-util/errno.c +++ b/pjlib-util/src/pjlib-util/errno.c @@ -51,6 +51,9 @@ static const struct /* XML errors */ PJ_BUILD_ERR( PJLIB_UTIL_EINXML, "Invalid XML message" ), + /* JSON errors */ + PJ_BUILD_ERR( PJLIB_UTIL_EINJSON, "Invalid JSON document" ), + /* DNS errors */ PJ_BUILD_ERR( PJLIB_UTIL_EDNSQRYTOOSMALL, "DNS query packet buffer is too small"), PJ_BUILD_ERR( PJLIB_UTIL_EDNSINSIZE, "Invalid DNS packet length"), diff --git a/pjlib-util/src/pjlib-util/json.c b/pjlib-util/src/pjlib-util/json.c new file mode 100644 index 00000000..7224d3ed --- /dev/null +++ b/pjlib-util/src/pjlib-util/json.c @@ -0,0 +1,621 @@ +/* $Id$ */ +/* + * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) + * + * 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 +#include +#include +#include +#include +#include +#include + +#define EL_INIT(p_el, nm, typ) do { \ + if (nm) { \ + p_el->name = *nm; \ + } else { \ + p_el->name.ptr = (char*)""; \ + p_el->name.slen = 0; \ + } \ + p_el->type = typ; \ + } while (0) + +struct write_state; +struct parse_state; + +#define NO_NAME 1 + +static pj_status_t elem_write(const pj_json_elem *elem, + struct write_state *st, + unsigned flags); +static pj_json_elem* parse_elem_throw(struct parse_state *st, + pj_json_elem *elem); + + +PJ_DEF(void) pj_json_elem_null(pj_json_elem *el, pj_str_t *name) +{ + EL_INIT(el, name, PJ_JSON_VAL_NULL); +} + +PJ_DEF(void) pj_json_elem_bool(pj_json_elem *el, pj_str_t *name, + pj_bool_t val) +{ + EL_INIT(el, name, PJ_JSON_VAL_BOOL); + el->value.is_true = val; +} + +PJ_DEF(void) pj_json_elem_number(pj_json_elem *el, pj_str_t *name, + float val) +{ + EL_INIT(el, name, PJ_JSON_VAL_NUMBER); + el->value.num = val; +} + +PJ_DEF(void) pj_json_elem_string( pj_json_elem *el, pj_str_t *name, + pj_str_t *value) +{ + EL_INIT(el, name, PJ_JSON_VAL_STRING); + el->value.str = *value; +} + +PJ_DEF(void) pj_json_elem_array(pj_json_elem *el, pj_str_t *name) +{ + EL_INIT(el, name, PJ_JSON_VAL_ARRAY); + pj_list_init(&el->value.children); +} + +PJ_DEF(void) pj_json_elem_obj(pj_json_elem *el, pj_str_t *name) +{ + EL_INIT(el, name, PJ_JSON_VAL_OBJ); + pj_list_init(&el->value.children); +} + +PJ_DEF(void) pj_json_elem_add(pj_json_elem *el, pj_json_elem *child) +{ + pj_assert(el->type == PJ_JSON_VAL_OBJ || el->type == PJ_JSON_VAL_ARRAY); + pj_list_push_back(&el->value.children, child); +} + +struct parse_state +{ + pj_pool_t *pool; + pj_scanner scanner; + pj_json_err_info *err_info; + pj_cis_t float_spec; /* numbers with dot! */ +}; + +static pj_status_t parse_children(struct parse_state *st, + pj_json_elem *parent) +{ + char end_quote = (parent->type == PJ_JSON_VAL_ARRAY)? ']' : '}'; + + pj_scan_get_char(&st->scanner); + + while (*st->scanner.curptr != end_quote) { + pj_json_elem *child; + + while (*st->scanner.curptr == ',') + pj_scan_get_char(&st->scanner); + + if (*st->scanner.curptr == end_quote) + break; + + child = parse_elem_throw(st, NULL); + if (!child) + return PJLIB_UTIL_EINJSON; + + pj_json_elem_add(parent, child); + } + + pj_scan_get_char(&st->scanner); + return PJ_SUCCESS; +} + +/* Return 0 if success or the index of the invalid char in the string */ +static unsigned parse_quoted_string(struct parse_state *st, + pj_str_t *output) +{ + pj_str_t token; + char *op, *ip, *iend; + + pj_scan_get_quote(&st->scanner, '"', '"', &token); + + /* Remove the quote characters */ + token.ptr++; + token.slen-=2; + + if (pj_strchr(&token, '\\') == NULL) { + *output = token; + return 0; + } + + output->ptr = op = pj_pool_alloc(st->pool, token.slen); + + ip = token.ptr; + iend = token.ptr + token.slen; + + while (ip != iend) { + if (*ip == '\\') { + ++ip; + if (ip==iend) { + goto on_error; + } + if (*ip == 'u') { + ip++; + if (iend - ip < 4) { + ip = iend -1; + goto on_error; + } + /* Only use the last two hext digits because we're on + * ASCII */ + *op++ = (char)(pj_hex_digit_to_val(ip[2]) * 16 + + pj_hex_digit_to_val(ip[3])); + ip += 4; + } else if (*ip=='"' || *ip=='\\' || *ip=='/') { + *op++ = *ip++; + } else if (*ip=='b') { + *op++ = '\b'; + ip++; + } else if (*ip=='f') { + *op++ = '\f'; + ip++; + } else if (*ip=='n') { + *op++ = '\n'; + ip++; + } else if (*ip=='r') { + *op++ = '\r'; + ip++; + } else if (*ip=='t') { + *op++ = '\t'; + ip++; + } else { + goto on_error; + } + } else { + *op++ = *ip++; + } + } + + output->slen = op - output->ptr; + return 0; + +on_error: + output->slen = op - output->ptr; + return ip - token.ptr; +} + +static pj_json_elem* parse_elem_throw(struct parse_state *st, + pj_json_elem *elem) +{ + pj_str_t name = {NULL, 0}, value = {NULL, 0}; + pj_str_t token; + + if (!elem) + elem = pj_pool_alloc(st->pool, sizeof(*elem)); + + /* Parse name */ + if (*st->scanner.curptr == '"') { + pj_scan_get_char(&st->scanner); + pj_scan_get_until_ch(&st->scanner, '"', &token); + pj_scan_get_char(&st->scanner); + + if (*st->scanner.curptr == ':') { + pj_scan_get_char(&st->scanner); + name = token; + } else { + value = token; + } + } + + if (value.slen) { + /* Element with string value and no name */ + pj_json_elem_string(elem, &name, &value); + return elem; + } + + /* Parse value */ + if (pj_cis_match(&st->float_spec, *st->scanner.curptr) || + *st->scanner.curptr == '-') + { + float val; + pj_bool_t neg = PJ_FALSE; + + if (*st->scanner.curptr == '-') { + pj_scan_get_char(&st->scanner); + neg = PJ_TRUE; + } + + pj_scan_get(&st->scanner, &st->float_spec, &token); + val = pj_strtof(&token); + if (neg) val = -val; + + pj_json_elem_number(elem, &name, val); + + } else if (*st->scanner.curptr == '"') { + unsigned err; + char *start = st->scanner.curptr; + + err = parse_quoted_string(st, &token); + if (err) { + st->scanner.curptr = start + err; + return NULL; + } + + pj_json_elem_string(elem, &name, &token); + + } else if (pj_isalpha(*st->scanner.curptr)) { + + if (pj_scan_strcmp(&st->scanner, "false", 5)==0) { + pj_json_elem_bool(elem, &name, PJ_FALSE); + pj_scan_advance_n(&st->scanner, 5, PJ_TRUE); + } else if (pj_scan_strcmp(&st->scanner, "true", 4)==0) { + pj_json_elem_bool(elem, &name, PJ_TRUE); + pj_scan_advance_n(&st->scanner, 4, PJ_TRUE); + } else if (pj_scan_strcmp(&st->scanner, "null", 4)==0) { + pj_json_elem_null(elem, &name); + pj_scan_advance_n(&st->scanner, 4, PJ_TRUE); + } else { + return NULL; + } + + } else if (*st->scanner.curptr == '[') { + pj_json_elem_array(elem, &name); + if (parse_children(st, elem) != PJ_SUCCESS) + return NULL; + + } else if (*st->scanner.curptr == '{') { + pj_json_elem_obj(elem, &name); + if (parse_children(st, elem) != PJ_SUCCESS) + return NULL; + + } else { + return NULL; + } + + return elem; +} + +static void on_syntax_error(pj_scanner *scanner) +{ + PJ_UNUSED_ARG(scanner); + PJ_THROW(11); +} + +PJ_DEF(pj_json_elem*) pj_json_parse(pj_pool_t *pool, + char *buffer, + unsigned *size, + pj_json_err_info *err_info) +{ + pj_cis_buf_t cis_buf; + struct parse_state st; + pj_json_elem *root; + PJ_USE_EXCEPTION; + + PJ_ASSERT_RETURN(pool && buffer && size, NULL); + + if (!*size) + return NULL; + + pj_bzero(&st, sizeof(st)); + st.pool = pool; + st.err_info = err_info; + pj_scan_init(&st.scanner, buffer, *size, + PJ_SCAN_AUTOSKIP_WS | PJ_SCAN_AUTOSKIP_NEWLINE, + &on_syntax_error); + pj_cis_buf_init(&cis_buf); + pj_cis_init(&cis_buf, &st.float_spec); + pj_cis_add_str(&st.float_spec, ".0123456789"); + + PJ_TRY { + root = parse_elem_throw(&st, NULL); + } + PJ_CATCH_ANY { + root = NULL; + } + PJ_END + + if (!root && err_info) { + err_info->line = st.scanner.line; + err_info->col = pj_scan_get_col(&st.scanner) + 1; + err_info->err_char = *st.scanner.curptr; + } + + *size = (buffer + *size) - st.scanner.curptr; + + pj_scan_fini(&st.scanner); + + return root; +} + +struct buf_writer_data +{ + char *pos; + unsigned size; +}; + +static pj_status_t buf_writer(const char *s, + unsigned size, + void *user_data) +{ + struct buf_writer_data *buf_data = (struct buf_writer_data*)user_data; + if (size+1 >= buf_data->size) + return PJ_ETOOBIG; + + pj_memcpy(buf_data->pos, s, size); + buf_data->pos += size; + buf_data->size -= size; + + return PJ_SUCCESS; +} + +PJ_DEF(pj_status_t) pj_json_write(const pj_json_elem *elem, + char *buffer, unsigned *size) +{ + struct buf_writer_data buf_data; + pj_status_t status; + + PJ_ASSERT_RETURN(elem && buffer && size, PJ_EINVAL); + + buf_data.pos = buffer; + buf_data.size = *size; + + status = pj_json_writef(elem, &buf_writer, &buf_data); + if (status != PJ_SUCCESS) + return status; + + *buf_data.pos = '\0'; + *size = (unsigned)(buf_data.pos - buffer); + return PJ_SUCCESS; +} + +#define MAX_INDENT 100 +#ifndef PJ_JSON_NAME_MIN_LEN +# define PJ_JSON_NAME_MIN_LEN 20 +#endif +#define ESC_BUF_LEN 64 +#ifndef PJ_JSON_INDENT_SIZE +# define PJ_JSON_INDENT_SIZE 3 +#endif + +struct write_state +{ + pj_json_writer writer; + void *user_data; + char indent_buf[MAX_INDENT]; + int indent; + char space[PJ_JSON_NAME_MIN_LEN]; +}; + +#define CHECK(expr) do { \ + status=expr; if (status!=PJ_SUCCESS) return status; } \ + while (0) + +static pj_status_t write_string_escaped(const pj_str_t *value, + struct write_state *st) +{ + const char *ip = value->ptr; + const char *iend = value->ptr + value->slen; + char buf[ESC_BUF_LEN]; + char *op = buf; + char *oend = buf + ESC_BUF_LEN; + pj_status_t status; + + while (ip != iend) { + /* Write to buffer to speedup writing instead of calling + * the callback one by one for each character. + */ + while (ip != iend && op != oend) { + if (oend - op < 2) + break; + + if (*ip == '"') { + *op++ = '\\'; + *op++ = '"'; + ip++; + } else if (*ip == '\\') { + *op++ = '\\'; + *op++ = '\\'; + ip++; + } else if (*ip == '/') { + *op++ = '\\'; + *op++ = '/'; + ip++; + } else if (*ip == '\b') { + *op++ = '\\'; + *op++ = 'b'; + ip++; + } else if (*ip == '\f') { + *op++ = '\\'; + *op++ = 'f'; + ip++; + } else if (*ip == '\n') { + *op++ = '\\'; + *op++ = 'n'; + ip++; + } else if (*ip == '\r') { + *op++ = '\\'; + *op++ = 'r'; + ip++; + } else if (*ip == '\t') { + *op++ = '\\'; + *op++ = 't'; + ip++; + } else if ((*ip >= 32 && *ip < 127)) { + /* unescaped */ + *op++ = *ip++; + } else { + /* escaped */ + if (oend - op < 6) + break; + *op++ = '\\'; + *op++ = 'u'; + *op++ = '0'; + *op++ = '0'; + pj_val_to_hex_digit(*ip, op); + op+=2; + ip++; + } + } + + CHECK( st->writer( buf, op-buf, st->user_data) ); + op = buf; + } + + return PJ_SUCCESS; +} + +static pj_status_t write_children(const pj_json_list *list, + const char quotes[2], + struct write_state *st) +{ + unsigned flags = (quotes[0]=='[') ? NO_NAME : 0; + pj_status_t status; + + //CHECK( st->writer( st->indent_buf, st->indent, st->user_data) ); + CHECK( st->writer( "es[0], 1, st->user_data) ); + CHECK( st->writer( " ", 1, st->user_data) ); + + if (!pj_list_empty(list)) { + pj_bool_t indent_added = PJ_FALSE; + pj_json_elem *child = list->next; + + if (child->name.slen == 0) { + /* Simple list */ + while (child != (pj_json_elem*)list) { + status = elem_write(child, st, flags); + if (status != PJ_SUCCESS) + return status; + + if (child->next != (pj_json_elem*)list) + CHECK( st->writer( ", ", 2, st->user_data) ); + child = child->next; + } + } else { + if (st->indent < sizeof(st->indent_buf)) { + st->indent += PJ_JSON_INDENT_SIZE; + indent_added = PJ_TRUE; + } + CHECK( st->writer( "\n", 1, st->user_data) ); + while (child != (pj_json_elem*)list) { + status = elem_write(child, st, flags); + if (status != PJ_SUCCESS) + return status; + + if (child->next != (pj_json_elem*)list) + CHECK( st->writer( ",\n", 2, st->user_data) ); + else + CHECK( st->writer( "\n", 1, st->user_data) ); + child = child->next; + } + if (indent_added) { + st->indent -= PJ_JSON_INDENT_SIZE; + } + CHECK( st->writer( st->indent_buf, st->indent, st->user_data) ); + } + } + CHECK( st->writer( "es[1], 1, st->user_data) ); + + return PJ_SUCCESS; +} + +static pj_status_t elem_write(const pj_json_elem *elem, + struct write_state *st, + unsigned flags) +{ + pj_status_t status; + + if (elem->name.slen) { + CHECK( st->writer( st->indent_buf, st->indent, st->user_data) ); + if ((flags & NO_NAME)==0) { + CHECK( st->writer( "\"", 1, st->user_data) ); + CHECK( write_string_escaped(&elem->name, st) ); + CHECK( st->writer( "\": ", 3, st->user_data) ); + if (elem->name.slen < PJ_JSON_NAME_MIN_LEN /*&& + elem->type != PJ_JSON_VAL_OBJ && + elem->type != PJ_JSON_VAL_ARRAY*/) + { + CHECK( st->writer( st->space, + PJ_JSON_NAME_MIN_LEN - elem->name.slen, + st->user_data) ); + } + } + } + + switch (elem->type) { + case PJ_JSON_VAL_NULL: + CHECK( st->writer( "null", 4, st->user_data) ); + break; + case PJ_JSON_VAL_BOOL: + if (elem->value.is_true) + CHECK( st->writer( "true", 4, st->user_data) ); + else + CHECK( st->writer( "false", 5, st->user_data) ); + break; + case PJ_JSON_VAL_NUMBER: + { + char num_buf[65]; + int len; + + if (elem->value.num == (int)elem->value.num) + len = pj_ansi_snprintf(num_buf, sizeof(num_buf), "%d", + (int)elem->value.num); + else + len = pj_ansi_snprintf(num_buf, sizeof(num_buf), "%f", + elem->value.num); + + if (len < 0 || len >= sizeof(num_buf)) + return PJ_ETOOBIG; + CHECK( st->writer( num_buf, len, st->user_data) ); + } + break; + case PJ_JSON_VAL_STRING: + CHECK( st->writer( "\"", 1, st->user_data) ); + CHECK( write_string_escaped( &elem->value.str, st) ); + CHECK( st->writer( "\"", 1, st->user_data) ); + break; + case PJ_JSON_VAL_ARRAY: + CHECK( write_children(&elem->value.children, "[]", st) ); + break; + case PJ_JSON_VAL_OBJ: + CHECK( write_children(&elem->value.children, "{}", st) ); + break; + default: + pj_assert(!"Unhandled value type"); + } + + return PJ_SUCCESS; +} + +#undef CHECK + +PJ_DEF(pj_status_t) pj_json_writef( const pj_json_elem *elem, + pj_json_writer writer, + void *user_data) +{ + struct write_state st; + + PJ_ASSERT_RETURN(elem && writer, PJ_EINVAL); + + st.writer = writer; + st.user_data = user_data, + st.indent = 0; + pj_memset(st.indent_buf, ' ', MAX_INDENT); + pj_memset(st.space, ' ', PJ_JSON_NAME_MIN_LEN); + + return elem_write(elem, &st, 0); +} + diff --git a/pjlib/build/os-auto.mak.in b/pjlib/build/os-auto.mak.in index 3f35dce6..1c7e330e 100644 --- a/pjlib/build/os-auto.mak.in +++ b/pjlib/build/os-auto.mak.in @@ -23,7 +23,8 @@ export TEST_OBJS += @ac_main_obj@ # # Additional LDFLAGS for pjlib-test # -export TEST_LDFLAGS += @LDFLAGS@ @LIBS@ +# Disabled, as this causes duplicated LDFLAGS, which may raise linking errors +#export TEST_LDFLAGS += @LDFLAGS@ @LIBS@ # # TARGETS are make targets in the Makefile, to be executed for this given diff --git a/pjlib/include/pj/compat/cc_gcc.h b/pjlib/include/pj/compat/cc_gcc.h index df257029..37f361b0 100644 --- a/pjlib/include/pj/compat/cc_gcc.h +++ b/pjlib/include/pj/compat/cc_gcc.h @@ -63,7 +63,7 @@ #endif #define PJ_INT64(val) val##LL -#define PJ_UINT64(val) val##LLU +#define PJ_UINT64(val) val##ULL #define PJ_INT64_FMT "L" diff --git a/pjlib/include/pj/string.h b/pjlib/include/pj/string.h index 525b4c05..57c496f3 100644 --- a/pjlib/include/pj/string.h +++ b/pjlib/include/pj/string.h @@ -574,6 +574,15 @@ PJ_DECL(unsigned long) pj_strtoul(const pj_str_t *str); PJ_DECL(unsigned long) pj_strtoul2(const pj_str_t *str, pj_str_t *endptr, unsigned base); +/** + * Convert string to float. + * + * @param str the string. + * + * @return the value. + */ +PJ_DECL(float) pj_strtof(const pj_str_t *str); + /** * Utility to convert unsigned integer to string. Note that the * string will be NULL terminated. diff --git a/pjlib/include/pj/types.h b/pjlib/include/pj/types.h index 420ddd9b..0e0e2d9a 100644 --- a/pjlib/include/pj/types.h +++ b/pjlib/include/pj/types.h @@ -86,15 +86,18 @@ typedef int pj_bool_t; # define PJ_T(literal_str) literal_str #endif +/** Some constants */ +enum pj_constants_ +{ + /** Status is OK. */ + PJ_SUCCESS=0, -/** Status is OK. */ -#define PJ_SUCCESS 0 - -/** True value. */ -#define PJ_TRUE 1 + /** True value. */ + PJ_TRUE=1, -/** False value. */ -#define PJ_FALSE 0 + /** False value. */ + PJ_FALSE=0 +}; /** * File offset type. diff --git a/pjlib/src/pj/string.c b/pjlib/src/pj/string.c index 5610c907..d62b674a 100644 --- a/pjlib/src/pj/string.c +++ b/pjlib/src/pj/string.c @@ -175,6 +175,44 @@ PJ_DEF(unsigned long) pj_strtoul2(const pj_str_t *str, pj_str_t *endptr, return value; } +PJ_DEF(float) pj_strtof(const pj_str_t *str) +{ + pj_str_t part; + char *pdot; + float val; + + if (str->slen == 0) + return 0; + + pdot = (char*)pj_memchr(str->ptr, '.', str->slen); + part.ptr = str->ptr; + part.slen = pdot ? pdot - str->ptr : str->slen; + + if (part.slen) + val = (float)pj_strtol(&part); + else + val = 0; + + if (pdot) { + part.ptr = pdot + 1; + part.slen = (str->ptr + str->slen - pdot - 1); + if (part.slen) { + pj_str_t endptr; + float fpart, fdiv; + int i; + fpart = (float)pj_strtoul2(&part, &endptr, 10); + fdiv = 1.0; + for (i=0; i<(part.slen - endptr.slen); ++i) + fdiv = fdiv * 10; + if (val >= 0) + val += (fpart / fdiv); + else + val -= (fpart / fdiv); + } + } + return val; +} + PJ_DEF(int) pj_utoa(unsigned long val, char *buf) { return pj_utoa_pad(val, buf, 0, 0); diff --git a/pjmedia/include/pjmedia-videodev/videodev.h b/pjmedia/include/pjmedia-videodev/videodev.h index 9238e0e3..d7def15b 100644 --- a/pjmedia/include/pjmedia-videodev/videodev.h +++ b/pjmedia/include/pjmedia-videodev/videodev.h @@ -131,7 +131,7 @@ typedef enum pjmedia_vid_dev_wnd_flag /** * Device index constants. */ -enum +enum pjmedia_vid_dev_std_index { /** * Constant to denote default capture device diff --git a/pjproject-vs8.sln b/pjproject-vs8.sln index f7547c4c..6d4c572b 100644 --- a/pjproject-vs8.sln +++ b/pjproject-vs8.sln @@ -35,6 +35,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample_debug", "pjsip-apps\build\sample_debug.vcproj", "{A0F1AA62-0F6F-420D-B09A-AC04B6862821}" ProjectSection(ProjectDependencies) = postProject {23D7679C-764C-4E02-8B29-BB882CEEEFE2} = {23D7679C-764C-4E02-8B29-BB882CEEEFE2} + {B82CDD25-6903-430E-BD38-D8129A2015C1} = {B82CDD25-6903-430E-BD38-D8129A2015C1} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pjnath", "pjnath\build\pjnath.vcproj", "{A5D9AA24-08ED-48B9-BD65-F0A25E96BFC4}" @@ -100,6 +101,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pjsip_test", "pjsip\build\p EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpjproject", "pjsip-apps\build\libpjproject.vcproj", "{23D7679C-764C-4E02-8B29-BB882CEEEFE2}" ProjectSection(ProjectDependencies) = postProject + {B82CDD25-6903-430E-BD38-D8129A2015C1} = {B82CDD25-6903-430E-BD38-D8129A2015C1} {2BB84911-C1B4-4747-B93D-36AA82CC5031} = {2BB84911-C1B4-4747-B93D-36AA82CC5031} {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} {2A3F241E-682C-47E1-9543-DC28708B406A} = {2A3F241E-682C-47E1-9543-DC28708B406A} @@ -116,10 +118,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpjproject", "pjsip-apps\ {B8719FD5-E8A6-4A36-943C-891D07F5DD21} = {B8719FD5-E8A6-4A36-943C-891D07F5DD21} {DA0E03ED-53A7-4050-8A85-90541C5509F8} = {DA0E03ED-53A7-4050-8A85-90541C5509F8} {B5FE16F8-3EDB-4110-BD80-B4238CC01E8D} = {B5FE16F8-3EDB-4110-BD80-B4238CC01E8D} + {9CA0FDFB-2172-41FC-B7F1-5CE915EDCB37} = {9CA0FDFB-2172-41FC-B7F1-5CE915EDCB37} {E53AA5FF-B737-40AA-BD13-387EFA99023D} = {E53AA5FF-B737-40AA-BD13-387EFA99023D} {A1989FF3-9894-40F4-B5A6-6EA364476E45} = {A1989FF3-9894-40F4-B5A6-6EA364476E45} {F0DBAA03-1BA3-4E3B-A2CA-727E3D3AB858} = {F0DBAA03-1BA3-4E3B-A2CA-727E3D3AB858} - {9CA0FDFB-2172-41FC-B7F1-5CE915EDCB37} = {9CA0FDFB-2172-41FC-B7F1-5CE915EDCB37} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python_pjsua", "pjsip-apps\build\python_pjsua.vcproj", "{0C91838B-3372-40B4-A764-DE075A4BC94B}" @@ -136,6 +138,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pjmedia_videodev", "pjmedia EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbaseclasses", "third_party\build\baseclasses\libbaseclasses.vcproj", "{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pjsua2_lib", "pjsip\build\pjsua2_lib.vcproj", "{B82CDD25-6903-430E-BD38-D8129A2015C1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4) @@ -3172,6 +3176,114 @@ Global {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release-Static|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release|Win32 {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release-Static|x64.ActiveCfg = Release-Static|x64 {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release-Static|x64.Build.0 = Release-Static|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Pocket PC 2003 (ARMV4).Deploy.0 = Debug|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Smartphone 2003 (ARMV4).Build.0 = Debug|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Smartphone 2003 (ARMV4).Deploy.0 = Debug|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Win32.ActiveCfg = Debug|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Win32.Build.0 = Debug|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Debug|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|x64.ActiveCfg = Debug|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug|x64.Build.0 = Debug|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Pocket PC 2003 (ARMV4).ActiveCfg = Debug-Dynamic|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Pocket PC 2003 (ARMV4).Build.0 = Debug-Dynamic|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Pocket PC 2003 (ARMV4).Deploy.0 = Debug-Dynamic|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Smartphone 2003 (ARMV4).ActiveCfg = Debug-Dynamic|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Smartphone 2003 (ARMV4).Build.0 = Debug-Dynamic|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Smartphone 2003 (ARMV4).Deploy.0 = Debug-Dynamic|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Win32.ActiveCfg = Debug-Dynamic|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Win32.Build.0 = Debug-Dynamic|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Debug-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|x64.ActiveCfg = Debug-Dynamic|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Dynamic|x64.Build.0 = Debug-Dynamic|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Pocket PC 2003 (ARMV4).ActiveCfg = Debug-Static|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Pocket PC 2003 (ARMV4).Build.0 = Debug-Static|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Pocket PC 2003 (ARMV4).Deploy.0 = Debug-Static|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Smartphone 2003 (ARMV4).ActiveCfg = Debug-Static|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Smartphone 2003 (ARMV4).Build.0 = Debug-Static|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Smartphone 2003 (ARMV4).Deploy.0 = Debug-Static|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Win32.ActiveCfg = Debug-Static|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Win32.Build.0 = Debug-Static|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Debug-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|x64.ActiveCfg = Debug-Static|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Debug-Static|x64.Build.0 = Debug-Static|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Pocket PC 2003 (ARMV4).Deploy.0 = Release|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Smartphone 2003 (ARMV4).Build.0 = Release|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Smartphone 2003 (ARMV4).Deploy.0 = Release|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Win32.ActiveCfg = Release|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Win32.Build.0 = Release|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Release|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|x64.ActiveCfg = Release|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release|x64.Build.0 = Release|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Pocket PC 2003 (ARMV4).ActiveCfg = Release-Dynamic|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Pocket PC 2003 (ARMV4).Build.0 = Release-Dynamic|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Pocket PC 2003 (ARMV4).Deploy.0 = Release-Dynamic|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Smartphone 2003 (ARMV4).ActiveCfg = Release-Dynamic|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Smartphone 2003 (ARMV4).Build.0 = Release-Dynamic|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Smartphone 2003 (ARMV4).Deploy.0 = Release-Dynamic|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Win32.ActiveCfg = Release-Dynamic|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Win32.Build.0 = Release-Dynamic|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Release-Dynamic|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|x64.ActiveCfg = Release-Dynamic|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Dynamic|x64.Build.0 = Release-Dynamic|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Pocket PC 2003 (ARMV4).ActiveCfg = Release-Static|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Pocket PC 2003 (ARMV4).Build.0 = Release-Static|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Pocket PC 2003 (ARMV4).Deploy.0 = Release-Static|Pocket PC 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Smartphone 2003 (ARMV4).ActiveCfg = Release-Static|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Smartphone 2003 (ARMV4).Build.0 = Release-Static|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Smartphone 2003 (ARMV4).Deploy.0 = Release-Static|Smartphone 2003 (ARMV4) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Win32.ActiveCfg = Release-Static|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Win32.Build.0 = Release-Static|Win32 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 5.0 Smartphone SDK (ARMV4I).ActiveCfg = Release-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Release-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Release-Static|Windows Mobile 6 Professional SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release-Static|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Release-Static|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Release-Static|Windows Mobile 6 Standard SDK (ARMV4I) + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|x64.ActiveCfg = Release-Static|x64 + {B82CDD25-6903-430E-BD38-D8129A2015C1}.Release-Static|x64.Build.0 = Release-Static|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/pjsip-apps/build/Makefile b/pjsip-apps/build/Makefile index 71fb151e..c776de10 100644 --- a/pjsip-apps/build/Makefile +++ b/pjsip-apps/build/Makefile @@ -62,10 +62,18 @@ export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT # Main entry # # +# x x x x x x x x x x x x x x x x x x x x x x x x +# +# FIX THIS +# +# x x x x x x x x x x x x x x x x x x x x x x x x TARGETS := $(BINDIR)/$(PJSUA_EXE) $(BINDIR)/$(PJSYSTEST_EXE) samples all: $(TARGETS) +swig: + $(MAKE) -C ../src/swig + doc: dep: depend diff --git a/pjsip-apps/build/Samples.mak b/pjsip-apps/build/Samples.mak index 57daa8bf..6e9ca386 100644 --- a/pjsip-apps/build/Samples.mak +++ b/pjsip-apps/build/Samples.mak @@ -48,13 +48,21 @@ SAMPLES := auddemo \ EXES := $(foreach file, $(SAMPLES), $(file)$(HOST_EXE)) +PJSUA2_SAMPLES := pjsua2_demo + +PJSUA2_EXES := $(foreach file, $(PJSUA2_SAMPLES), $(file)$(HOST_EXE)) + .PHONY: $(EXES) +.PHONY: $(PJSUA2_EXES) -all: $(EXES) +all: $(EXES) $(PJSUA2_EXES) $(EXES): $(MAKE) --no-print-directory -f $(RULES_MAK) SAMPLE_SRCDIR=$(SRCDIR) SAMPLE_OBJS=$@.o SAMPLE_CFLAGS="$(_CFLAGS)" SAMPLE_LDFLAGS="$(_LDFLAGS)" SAMPLE_EXE=$@ APP=SAMPLE app=sample $(subst /,$(HOST_PSEP),$(BINDIR)/$@) +$(PJSUA2_EXES): + $(MAKE) --no-print-directory -f $(RULES_MAK) SAMPLE_SRCDIR=$(SRCDIR) SAMPLE_OBJS=$@.o SAMPLE_CFLAGS="$(_CFLAGS)" SAMPLE_LDFLAGS="$(_LDFLAGS) -lstdc++" SAMPLE_EXE=$@ APP=SAMPLE app=sample $(subst /,$(HOST_PSEP),$(BINDIR)/$@) + depend: clean: diff --git a/pjsip-apps/build/sample_debug.vcproj b/pjsip-apps/build/sample_debug.vcproj index 1f7331f2..1f821e47 100644 --- a/pjsip-apps/build/sample_debug.vcproj +++ b/pjsip-apps/build/sample_debug.vcproj @@ -311,12 +311,12 @@ /> - @@ -367,22 +363,24 @@ Name="VCBscMakeTool" /> - - + @@ -499,27 +501,25 @@ Name="VCBscMakeTool" /> - - - @@ -572,25 +566,27 @@ Name="VCBscMakeTool" /> - - - @@ -641,25 +633,27 @@ Name="VCBscMakeTool" /> - - + @@ -706,24 +706,22 @@ Name="VCBscMakeTool" /> - - - @@ -847,22 +838,24 @@ Name="VCBscMakeTool" /> - - - @@ -1190,22 +1180,24 @@ Name="VCBscMakeTool" /> - - + @@ -1322,27 +1318,25 @@ Name="VCBscMakeTool" /> - - - @@ -1396,25 +1383,27 @@ Name="VCBscMakeTool" /> - - - @@ -1465,25 +1450,27 @@ Name="VCBscMakeTool" /> - - + @@ -1530,24 +1523,22 @@ Name="VCBscMakeTool" /> - - - @@ -1670,25 +1655,27 @@ Name="VCBscMakeTool" /> - - + @@ -1735,24 +1726,22 @@ Name="VCBscMakeTool" /> - - + @@ -1936,24 +1932,22 @@ Name="VCBscMakeTool" /> - - + @@ -2137,24 +2135,22 @@ Name="VCBscMakeTool" /> - - + @@ -2338,24 +2340,22 @@ Name="VCBscMakeTool" /> - - = 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import random +import pjsua2 as pj +import _pjsua2 +import accountsetting +import application +import call +import chat as ch + +# Account class +class Account(pj.Account): + """ + High level Python Account object, derived from pjsua2's Account object. + """ + def __init__(self, app): + pj.Account.__init__(self) + self.app = app + self.randId = random.randint(1, 9999) + self.cfg = pj.AccountConfig() + self.cfgChanged = False + self.buddyList = [] + self.chatList = [] + self.deleting = False + + def findChat(self, uri_str): + uri = ch.ParseSipUri(uri_str) + if not uri: return None + + for chat in self.chatList: + if chat.isUriParticipant(uri) and chat.isPrivate(): + return chat + return None + + def newChat(self, uri_str): + uri = ch.ParseSipUri(uri_str) + if not uri: return None + + chat = ch.Chat(self.app, self, uri) + self.chatList.append(chat) + self.app.updateWindowMenu() + return chat + + def statusText(self): + status = '?' + if self.isValid(): + ai = self.getInfo() + if ai.regLastErr: + status = self.app.ep.utilStrError(ai.regLastErr) + elif ai.regIsActive: + if ai.onlineStatus: + if len(ai.onlineStatusText): + status = ai.onlineStatusText + else: + status = "Online" + else: + status = "Registered" + else: + if ai.regIsConfigured: + if ai.regStatus/100 == 2: + status = "Unregistered" + else: + status = ai.regStatusText + else: + status = "Doesn't register" + else: + status = '- not created -' + return status + + def onRegState(self, prm): + self.app.updateAccount(self) + + def onIncomingCall(self, prm): + c = call.Call(self, call_id=prm.callId) + call_prm = pj.CallOpParam() + call_prm.statusCode = 180 + c.answer(call_prm) + ci = c.getInfo() + msg = "Incoming call for account '%s'" % self.cfg.idUri + if msgbox.askquestion(msg, "Accept call from '%s'?" % (ci.remoteUri), default=msgbox.YES) == u'yes': + call_prm.statusCode = 200 + c.answer(call_prm) + + # find/create chat instance + chat = self.findChat(ci.remoteUri) + if not chat: chat = self.newChat(ci.remoteUri) + + chat.showWindow() + chat.registerCall(ci.remoteUri, c) + chat.updateCallState(c, ci) + else: + c.hangup(call_prm) + + def onInstantMessage(self, prm): + chat = self.findChat(prm.fromUri) + if not chat: chat = self.newChat(prm.fromUri) + + chat.showWindow() + chat.addMessage(prm.fromUri, prm.msgBody) + + def onInstantMessageStatus(self, prm): + if prm.code/100 == 2: return + + chat = self.findChat(prm.toUri) + if not chat: + print "=== IM status to '%s' cannot find chat" % prm.toUri + return + + chat.addMessage(None, "Failed sending message to '%s': %s" % (prm.toUri, prm.reason)) + + def onTypingIndication(self, prm): + chat = self.findChat(prm.fromUri) + if not chat: + print "=== Incoming typing indication from '%s' cannot find chat" % prm.fromUri + return + + chat.setTypingIndication(prm.fromUri, prm.isTyping) + + +# Account frame, to list accounts +class AccountListFrame(ttk.Frame): + """ + This implements a Frame which contains account list and buttons to operate + on them (Add, Modify, Delete, etc.). + """ + def __init__(self, parent, app, acc_list = []): + ttk.Frame.__init__(self, parent, name='acclist') + self.app = app + self.accList = acc_list + self.accDeletedList = [] + self.pack(expand='yes', fill='both') + self._createWidgets() + for acc in self.accList: + self._showAcc(acc) + + def _createWidgets(self): + self.tv = ttk.Treeview(self, columns=('ID', 'Registrar', 'Default'), selectmode='browse') + self.tv.heading('#0', text='Priority') + self.tv.heading(0, text='ID') + self.tv.heading(1, text='Registrar') + self.tv.heading(2, text='Default?') + self.tv.column('#0', width=60) + self.tv.column(0, width=300) + self.tv.column(1, width=200) + self.tv.column(2, width=60) + self.tv.grid(column=0, row=0, rowspan=4, padx=5, pady=5) + + ttk.Button(self, text='Add..', command=self._onBtnAdd).grid(column=1, row=0, padx=5) + ttk.Button(self, text='Settings..', command=self._onBtnSettings).grid(column=1, row=1) + ttk.Button(self, text='Set Default', command=self._onBtnSetDefault).grid(column=1, row=2) + ttk.Button(self, text='Delete..', command=self._onBtnDelete).grid(column=1, row=3) + + def _showAcc(self, acc): + is_default = 'Yes' if acc.isValid() and acc.isDefault() else '' + values = (acc.cfg.idUri, acc.cfg.regConfig.registrarUri, is_default) + self.tv.insert('', 0, str(acc.randId), open=True, text=str(acc.cfg.priority), values=values) + + def updateAccount(self, acc): + is_default = 'Yes' if acc.isValid() and acc.isDefault() else '' + values = (acc.cfg.idUri, acc.cfg.regConfig.registrarUri, is_default) + self.tv.item(str(acc.randId), text=str(acc.cfg.priority), values=values) + + def _getSelectedAcc(self): + items = self.tv.selection() + if not items: + return None + iid = int(items[0]) + return [acc for acc in self.accList if acc.randId==iid][0] + + def _onBtnAdd(self): + cfg = pj.AccountConfig() + dlg = accountsetting.Dialog(self.master, cfg) + if dlg.doModal(): + acc = Account(self.app) + acc.cfg = cfg + self._showAcc(acc) + self.accList.append(acc) + self.cfgChanged = True + + def _onBtnSettings(self): + acc = self._getSelectedAcc() + if not acc: + return + dlg = accountsetting.Dialog(self.master, acc.cfg) + if dlg.doModal(): + self.updateAccount(acc) + self.cfgChanged = True + + def _onBtnDelete(self): + acc = self._getSelectedAcc() + if not acc: + return + msg = "Do you really want to delete account '%s'" % acc.cfg.idUri + if msgbox.askquestion('Delete account?', msg, default=msgbox.NO) != u'yes': + return + self.accList.remove(acc) + self.accDeletedList.append(acc) + self.tv.delete( (str(acc.randId),) ) + + def _onBtnSetDefault(self): + acc = self._getSelectedAcc() + if not acc: + return + if acc.isValid(): + acc.setDefault() + for acc in self.accList: + self.updateAccount(acc) + + +if __name__ == '__main__': + application.main() diff --git a/pjsip-apps/src/pygui/accountsetting.py b/pjsip-apps/src/pygui/accountsetting.py new file mode 100644 index 00000000..309c7346 --- /dev/null +++ b/pjsip-apps/src/pygui/accountsetting.py @@ -0,0 +1,369 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import pjsua2 as pj +import endpoint +import application + +class Dialog(tk.Toplevel): + """ + This implements account settings dialog to manipulate account settings. + """ + def __init__(self, parent, cfg): + tk.Toplevel.__init__(self, parent) + self.transient(parent) + self.parent = parent + self.geometry("+100+100") + self.title('Account settings') + + self.frm = ttk.Frame(self) + self.frm.pack(expand='yes', fill='both') + + self.isOk = False + self.cfg = cfg + + self.createWidgets() + + def doModal(self): + if self.parent: + self.parent.wait_window(self) + else: + self.wait_window(self) + return self.isOk + + def createWidgets(self): + # The notebook + self.frm.rowconfigure(0, weight=1) + self.frm.rowconfigure(1, weight=0) + self.frm.columnconfigure(0, weight=1) + self.frm.columnconfigure(1, weight=1) + self.wTab = ttk.Notebook(self.frm) + self.wTab.grid(column=0, row=0, columnspan=2, padx=10, pady=10, ipadx=20, ipady=20, sticky=tk.N+tk.S+tk.W+tk.E) + + # Main buttons + btnOk = ttk.Button(self.frm, text='Ok', command=self.onOk) + btnOk.grid(column=0, row=1, sticky=tk.E, padx=20, pady=10) + btnCancel = ttk.Button(self.frm, text='Cancel', command=self.onCancel) + btnCancel.grid(column=1, row=1, sticky=tk.W, padx=20, pady=10) + + # Tabs + self.createBasicTab() + self.createSipTab() + self.createMediaTab() + self.createMediaNatTab() + + def createBasicTab(self): + # Prepare the variables to set/receive values from GUI + self.cfgPriority = tk.IntVar(value=self.cfg.priority) + self.cfgAccId = tk.StringVar(value=self.cfg.idUri) + self.cfgRegistrar = tk.StringVar(value=self.cfg.regConfig.registrarUri) + self.cfgRegisterOnAdd = tk.IntVar(value=self.cfg.regConfig.registerOnAdd) + self.cfgUsername = tk.StringVar() + self.cfgPassword = tk.StringVar() + if len(self.cfg.sipConfig.authCreds): + self.cfgUsername.set( self.cfg.sipConfig.authCreds[0].username ) + self.cfgPassword.set( self.cfg.sipConfig.authCreds[0].data ) + self.cfgProxy = tk.StringVar() + if len(self.cfg.sipConfig.proxies): + self.cfgProxy.set( self.cfg.sipConfig.proxies[0] ) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + ttk.Label(frm, text='Priority:').grid(row=row, column=0, sticky=tk.E, pady=2) + tk.Spinbox(frm, from_=0, to=9, textvariable=self.cfgPriority, width=2).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='ID (URI):').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgAccId, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Registrar URI:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgRegistrar, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Checkbutton(frm, text='Register on add', variable=self.cfgRegisterOnAdd).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='Optional proxy URI:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgProxy, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Auth username:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgUsername, width=16).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Password:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgPassword, show='*', width=16).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + + self.wTab.add(frm, text='Basic Settings') + + + def createSipTab(self): + # Prepare the variables to set/receive values from GUI + self.cfgPrackUse = tk.IntVar(value=self.cfg.callConfig.prackUse) + self.cfgTimerUse = tk.IntVar(value=self.cfg.callConfig.timerUse) + self.cfgTimerExpires = tk.IntVar(value=self.cfg.callConfig.timerSessExpiresSec) + self.cfgPublish = tk.BooleanVar(value=self.cfg.presConfig.publishEnabled) + self.cfgMwiEnabled = tk.BooleanVar(value=self.cfg.mwiConfig.enabled) + self.cfgEnableContactRewrite = tk.BooleanVar(value=self.cfg.natConfig.contactRewriteUse != 0) + self.cfgEnableViaRewrite = tk.BooleanVar(value=self.cfg.natConfig.viaRewriteUse != 0) + self.cfgEnableSdpRewrite = tk.BooleanVar(value=self.cfg.natConfig.sdpNatRewriteUse != 0) + self.cfgEnableSipOutbound = tk.BooleanVar(value=self.cfg.natConfig.sipOutboundUse != 0) + self.cfgKaInterval = tk.IntVar(value=self.cfg.natConfig.udpKaIntervalSec) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + ttk.Label(frm, text='100rel/PRACK:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='Only offer PRACK', value=pj.PJSUA_100REL_NOT_USED, variable=self.cfgPrackUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Offer and use if remote supports', value=pj.PJSUA_100REL_OPTIONAL, variable=self.cfgPrackUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Required', value=pj.PJSUA_100REL_MANDATORY, variable=self.cfgPrackUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Session Timer:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='Not offered', value=pj.PJSUA_SIP_TIMER_INACTIVE, variable=self.cfgTimerUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Optional', value=pj.PJSUA_SIP_TIMER_OPTIONAL, variable=self.cfgTimerUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Required', value=pj.PJSUA_SIP_TIMER_REQUIRED, variable=self.cfgTimerUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text="Always use", value=pj.PJSUA_SIP_TIMER_ALWAYS, variable=self.cfgTimerUse).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Session Timer Expiration:').grid(row=row, column=0, sticky=tk.E, pady=2) + tk.Spinbox(frm, from_=90, to=7200, textvariable=self.cfgTimerExpires, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(seconds)').grid(row=row, column=1, sticky=tk.E) + row += 1 + ttk.Label(frm, text='Presence:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Enable PUBLISH', variable=self.cfgPublish).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='Message Waiting Indication:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Enable MWI', variable=self.cfgMwiEnabled).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='NAT Traversal:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Enable Contact Rewrite', variable=self.cfgEnableContactRewrite).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='Enable Via Rewrite', variable=self.cfgEnableViaRewrite).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='Enable SDP IP Address Rewrite', variable=self.cfgEnableSdpRewrite).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='Enable SIP Outbound Extension', variable=self.cfgEnableSipOutbound).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='UDP Keep-Alive Interval:').grid(row=row, column=0, sticky=tk.E, pady=2) + tk.Spinbox(frm, from_=0, to=3600, textvariable=self.cfgKaInterval, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(seconds) Zero to disable.').grid(row=row, column=1, sticky=tk.E) + + + self.wTab.add(frm, text='SIP Features') + + def createMediaTab(self): + # Prepare the variables to set/receive values from GUI + self.cfgMedPort = tk.IntVar(value=self.cfg.mediaConfig.transportConfig.port) + self.cfgMedPortRange = tk.IntVar(value=self.cfg.mediaConfig.transportConfig.portRange) + self.cfgMedLockCodec = tk.BooleanVar(value=self.cfg.mediaConfig.lockCodecEnabled) + self.cfgMedSrtp = tk.IntVar(value=self.cfg.mediaConfig.srtpUse) + self.cfgMedSrtpSecure = tk.IntVar(value=self.cfg.mediaConfig.srtpSecureSignaling) + self.cfgMedIpv6 = tk.BooleanVar(value=self.cfg.mediaConfig.ipv6Use==pj.PJSUA_IPV6_ENABLED) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=21) + row = 0 + ttk.Label(frm, text='Secure RTP (SRTP):').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='Disable', value=pj.PJMEDIA_SRTP_DISABLED, variable=self.cfgMedSrtp).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Mandatory', value=pj.PJMEDIA_SRTP_MANDATORY, variable=self.cfgMedSrtp).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Optional (non-standard)', value=pj.PJMEDIA_SRTP_OPTIONAL, variable=self.cfgMedSrtp).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='SRTP signaling:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='Does not require secure signaling', value=0, variable=self.cfgMedSrtpSecure).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Require secure next hop (TLS)', value=1, variable=self.cfgMedSrtpSecure).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Require secure end-to-end (SIPS)', value=2, variable=self.cfgMedSrtpSecure).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='RTP transport start port:').grid(row=row, column=0, sticky=tk.E, pady=2) + tk.Spinbox(frm, from_=0, to=65535, textvariable=self.cfgMedPort, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(0: any)').grid(row=row, column=1, sticky=tk.E, pady=2) + row += 1 + ttk.Label(frm, text='Port range:').grid(row=row, column=0, sticky=tk.E, pady=2) + tk.Spinbox(frm, from_=0, to=65535, textvariable=self.cfgMedPortRange, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(0: not limited)').grid(row=row, column=1, sticky=tk.E, pady=2) + row += 1 + ttk.Label(frm, text='Lock codec:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Enable', variable=self.cfgMedLockCodec).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='Use IPv6:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Yes', variable=self.cfgMedIpv6).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + + self.wTab.add(frm, text='Media settings') + + def createMediaNatTab(self): + # Prepare the variables to set/receive values from GUI + self.cfgSipUseStun = tk.IntVar(value = self.cfg.natConfig.sipStunUse) + self.cfgMediaUseStun = tk.IntVar(value = self.cfg.natConfig.mediaStunUse) + self.cfgIceEnabled = tk.BooleanVar(value = self.cfg.natConfig.iceEnabled) + self.cfgIceAggressive = tk.BooleanVar(value = self.cfg.natConfig.iceAggressiveNomination) + self.cfgAlwaysUpdate = tk.BooleanVar(value = True if self.cfg.natConfig.iceAlwaysUpdate else False) + self.cfgIceNoHostCands = tk.BooleanVar(value = True if self.cfg.natConfig.iceMaxHostCands == 0 else False) + self.cfgTurnEnabled = tk.BooleanVar(value = self.cfg.natConfig.turnEnabled) + self.cfgTurnServer = tk.StringVar(value = self.cfg.natConfig.turnServer) + self.cfgTurnConnType = tk.IntVar(value = self.cfg.natConfig.turnConnType) + self.cfgTurnUser = tk.StringVar(value = self.cfg.natConfig.turnUserName) + self.cfgTurnPasswd = tk.StringVar(value = self.cfg.natConfig.turnPassword) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + ttk.Label(frm, text='SIP STUN Usage:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='Default', value=pj.PJSUA_STUN_USE_DEFAULT, variable=self.cfgSipUseStun).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Disable', value=pj.PJSUA_STUN_USE_DISABLED, variable=self.cfgSipUseStun).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Media STUN Usage:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='Default', value=pj.PJSUA_STUN_USE_DEFAULT, variable=self.cfgMediaUseStun).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='Disable', value=pj.PJSUA_STUN_USE_DISABLED, variable=self.cfgMediaUseStun).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='ICE:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Enable', variable=self.cfgIceEnabled).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='Use aggresive nomination', variable=self.cfgIceAggressive).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='Always re-INVITE after negotiation', variable=self.cfgAlwaysUpdate).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='Disable host candidates', variable=self.cfgIceNoHostCands).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='TURN:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Checkbutton(frm, text='Enable', variable=self.cfgTurnEnabled).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='TURN server:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgTurnServer, width=20).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='host[:port]').grid(row=row, column=1, sticky=tk.E, pady=6) + row += 1 + ttk.Label(frm, text='TURN connection:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Radiobutton(frm, text='UDP', value=pj.PJ_TURN_TP_UDP, variable=self.cfgTurnConnType).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Radiobutton(frm, text='TCP', value=pj.PJ_TURN_TP_TCP, variable=self.cfgTurnConnType).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='TURN username:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgTurnUser, width=16).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='TURN password:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgTurnPasswd, show='*', width=16).grid(row=row, column=1, sticky=tk.W, padx=6) + + self.wTab.add(frm, text='NAT settings') + + def onOk(self): + # Check basic settings + errors = ""; + if not self.cfgAccId.get(): + errors += "Account ID is required\n" + if self.cfgAccId.get(): + if not endpoint.validateSipUri(self.cfgAccId.get()): + errors += "Invalid SIP ID URI: '%s'\n" % (self.cfgAccId.get()) + if self.cfgRegistrar.get(): + if not endpoint.validateSipUri(self.cfgRegistrar.get()): + errors += "Invalid SIP registrar URI: '%s'\n" % (self.cfgRegistrar.get()) + if self.cfgProxy.get(): + if not endpoint.validateSipUri(self.cfgProxy.get()): + errors += "Invalid SIP proxy URI: '%s'\n" % (self.cfgProxy.get()) + if self.cfgTurnEnabled.get(): + if not self.cfgTurnServer.get(): + errors += "TURN server is required\n" + if errors: + msgbox.showerror("Error detected:", errors) + return + + # Basic settings + self.cfg.priority = self.cfgPriority.get() + self.cfg.idUri = self.cfgAccId.get() + self.cfg.regConfig.registrarUri = self.cfgRegistrar.get() + self.cfg.regConfig.registerOnAdd = self.cfgRegisterOnAdd.get() + while len(self.cfg.sipConfig.authCreds): + self.cfg.sipConfig.authCreds.pop() + if self.cfgUsername.get(): + cred = pj.AuthCredInfo() + cred.scheme = "digest" + cred.realm = "*" + cred.username = self.cfgUsername.get() + cred.data = self.cfgPassword.get() + self.cfg.sipConfig.authCreds.append(cred) + while len(self.cfg.sipConfig.proxies): + self.cfg.sipConfig.proxies.pop() + if self.cfgProxy.get(): + self.cfg.sipConfig.proxies.append(self.cfgProxy.get()) + + # SIP features + self.cfg.callConfig.prackUse = self.cfgPrackUse.get() + self.cfg.callConfig.timerUse = self.cfgTimerUse.get() + self.cfg.callConfig.timerSessExpiresSec = self.cfgTimerExpires.get() + self.cfg.presConfig.publishEnabled = self.cfgPublish.get() + self.cfg.mwiConfig.enabled = self.cfgMwiEnabled.get() + self.cfg.natConfig.contactRewriteUse = 1 if self.cfgEnableContactRewrite.get() else 0 + self.cfg.natConfig.viaRewriteUse = 1 if self.cfgEnableViaRewrite.get() else 0 + self.cfg.natConfig.sdpNatRewriteUse = 1 if self.cfgEnableSdpRewrite.get() else 0 + self.cfg.natConfig.sipOutboundUse = 1 if self.cfgEnableSipOutbound.get() else 0 + self.cfg.natConfig.udpKaIntervalSec = self.cfgKaInterval.get() + + # Media + self.cfg.mediaConfig.transportConfig.port = self.cfgMedPort.get() + self.cfg.mediaConfig.transportConfig.portRange = self.cfgMedPortRange.get() + self.cfg.mediaConfig.lockCodecEnabled = self.cfgMedLockCodec.get() + self.cfg.mediaConfig.srtpUse = self.cfgMedSrtp.get() + self.cfg.mediaConfig.srtpSecureSignaling = self.cfgMedSrtpSecure.get() + self.cfg.mediaConfig.ipv6Use = pj.PJSUA_IPV6_ENABLED if self.cfgMedIpv6.get() else pj.PJSUA_IPV6_DISABLED + + # NAT + self.cfg.natConfig.sipStunUse = self.cfgSipUseStun.get() + self.cfg.natConfig.mediaStunUse = self.cfgMediaUseStun.get() + self.cfg.natConfig.iceEnabled = self.cfgIceEnabled.get() + self.cfg.natConfig.iceAggressiveNomination = self.cfgIceAggressive .get() + self.cfg.natConfig.iceAlwaysUpdate = self.cfgAlwaysUpdate.get() + self.cfg.natConfig.iceMaxHostCands = 0 if self.cfgIceNoHostCands.get() else -1 + self.cfg.natConfig.turnEnabled = self.cfgTurnEnabled.get() + self.cfg.natConfig.turnServer = self.cfgTurnServer.get() + self.cfg.natConfig.turnConnType = self.cfgTurnConnType.get() + self.cfg.natConfig.turnUserName = self.cfgTurnUser.get() + self.cfg.natConfig.turnPasswordType = 0 + self.cfg.natConfig.turnPassword = self.cfgTurnPasswd.get() + + self.isOk = True + self.destroy() + + def onCancel(self): + self.destroy() + + +if __name__ == '__main__': + application.main() diff --git a/pjsip-apps/src/pygui/application.py b/pjsip-apps/src/pygui/application.py new file mode 100644 index 00000000..0dd5fa50 --- /dev/null +++ b/pjsip-apps/src/pygui/application.py @@ -0,0 +1,510 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import pjsua2 as pj +import log +import accountsetting +import account +import buddy +import endpoint +import settings + +import os +import traceback + + +class Application(ttk.Frame): + """ + The Application main frame. + """ + def __init__(self): + ttk.Frame.__init__(self, name='application', width=300, height=500) + self.pack(expand='yes', fill='both') + self.master.title('pjsua2 Demo') + self.master.geometry('500x500+100+100') + + # Logger + self.logger = log.Logger() + + # Accounts + self.accList = [] + + # GUI variables + self.showLogWindow = tk.IntVar(value=0) + self.quitting = False + + # Construct GUI + self._createWidgets() + + # Log window + self.logWindow = log.LogWindow(self) + self._onMenuShowHideLogWindow() + + # Instantiate endpoint + self.ep = endpoint.Endpoint() + self.ep.libCreate() + + # Default config + self.appConfig = settings.AppConfig() + self.appConfig.epConfig.uaConfig.threadCnt = 0; + self.appConfig.epConfig.uaConfig.mainThreadOnly = True + self.appConfig.epConfig.logConfig.writer = self.logger + self.appConfig.epConfig.logConfig.filename = "pygui.log" + self.appConfig.epConfig.logConfig.fileFlags = pj.PJ_O_APPEND + self.appConfig.epConfig.logConfig.level = 5 + self.appConfig.epConfig.logConfig.consoleLevel = 5 + + def saveConfig(self, filename='pygui.js'): + # Save disabled accounts since they are not listed in self.accList + disabled_accs = [ac for ac in self.appConfig.accounts if not ac.enabled] + self.appConfig.accounts = [] + + # Get account configs from active accounts + for acc in self.accList: + acfg = settings.AccConfig() + acfg.enabled = True + acfg.config = acc.cfg + for bud in acc.buddyList: + acfg.buddyConfigs.append(bud.cfg) + self.appConfig.accounts.append(acfg) + + # Put back disabled accounts + self.appConfig.accounts.extend(disabled_accs) + # Save + self.appConfig.saveFile(filename) + + def start(self, cfg_file='pygui.js'): + # Load config + if cfg_file and os.path.exists(cfg_file): + self.appConfig.loadFile(cfg_file) + + self.appConfig.epConfig.uaConfig.threadCnt = 0; + self.appConfig.epConfig.uaConfig.mainThreadOnly = True + self.appConfig.epConfig.logConfig.writer = self.logger + self.appConfig.epConfig.logConfig.level = 5 + self.appConfig.epConfig.logConfig.consoleLevel = 5 + + # Initialize library + self.appConfig.epConfig.uaConfig.userAgent = "pygui-" + self.ep.libVersion().full; + self.ep.libInit(self.appConfig.epConfig) + self.master.title('pjsua2 Demo version ' + self.ep.libVersion().full) + + # Create transports + if self.appConfig.udp.enabled: + self.ep.transportCreate(self.appConfig.udp.type, self.appConfig.udp.config) + if self.appConfig.tcp.enabled: + self.ep.transportCreate(self.appConfig.tcp.type, self.appConfig.tcp.config) + if self.appConfig.tls.enabled: + self.ep.transportCreate(self.appConfig.tls.type, self.appConfig.tls.config) + + # Add accounts + for cfg in self.appConfig.accounts: + if cfg.enabled: + self._createAcc(cfg.config) + acc = self.accList[-1] + for buddy_cfg in cfg.buddyConfigs: + self._createBuddy(acc, buddy_cfg) + + # Start library + self.ep.libStart() + + # Start polling + self._onTimer() + + def updateAccount(self, acc): + if acc.deleting: + return # ignore + iid = str(acc.randId) + text = acc.cfg.idUri + status = acc.statusText() + + values = (status,) + if self.tv.exists(iid): + self.tv.item(iid, text=text, values=values) + else: + self.tv.insert('', 'end', iid, open=True, text=text, values=values) + + def updateBuddy(self, bud): + iid = 'buddy' + str(bud.randId) + text = bud.cfg.uri + status = bud.statusText() + + values = (status,) + if self.tv.exists(iid): + self.tv.item(iid, text=text, values=values) + else: + self.tv.insert(str(bud.account.randId), 'end', iid, open=True, text=text, values=values) + + def _createAcc(self, acc_cfg): + acc = account.Account(self) + acc.cfg = acc_cfg + self.accList.append(acc) + self.updateAccount(acc) + acc.create(acc.cfg) + acc.cfgChanged = False + self.updateAccount(acc) + + def _createBuddy(self, acc, buddy_cfg): + bud = buddy.Buddy(self) + bud.cfg = buddy_cfg + bud.account = acc + bud.create(acc, bud.cfg) + self.updateBuddy(bud) + acc.buddyList.append(bud) + + def _createWidgets(self): + self._createAppMenu() + + # Main pane, a Treeview + self.tv = ttk.Treeview(self, columns=('Status'), show='tree') + self.tv.pack(side='top', fill='both', expand='yes', padx=5, pady=5) + + self._createContextMenu() + + # Handle close event + self.master.protocol("WM_DELETE_WINDOW", self._onClose) + + def _createAppMenu(self): + # Main menu bar + top = self.winfo_toplevel() + self.menubar = tk.Menu() + top.configure(menu=self.menubar) + + # File menu + file_menu = tk.Menu(self.menubar, tearoff=False) + self.menubar.add_cascade(label="File", menu=file_menu) + file_menu.add_command(label="Add account..", command=self._onMenuAddAccount) + file_menu.add_checkbutton(label="Show/hide log window", command=self._onMenuShowHideLogWindow, variable=self.showLogWindow) + file_menu.add_separator() + file_menu.add_command(label="Settings...", command=self._onMenuSettings) + file_menu.add_command(label="Save Settings", command=self._onMenuSaveSettings) + file_menu.add_separator() + file_menu.add_command(label="Quit", command=self._onMenuQuit) + + # Window menu + self.window_menu = tk.Menu(self.menubar, tearoff=False) + self.menubar.add_cascade(label="Window", menu=self.window_menu) + + # Help menu + help_menu = tk.Menu(self.menubar, tearoff=False) + self.menubar.add_cascade(label="Help", menu=help_menu) + help_menu.add_command(label="About", underline=2, command=self._onMenuAbout) + + def _showChatWindow(self, chat_inst): + chat_inst.showWindow() + + def updateWindowMenu(self): + # Chat windows + self.window_menu.delete(0, tk.END) + for acc in self.accList: + for c in acc.chatList: + cmd = lambda arg=c: self._showChatWindow(arg) + self.window_menu.add_command(label=c.title, command=cmd) + + def _createContextMenu(self): + top = self.winfo_toplevel() + + # Create Account context menu + self.accMenu = tk.Menu(top, tearoff=False) + # Labels, must match with _onAccContextMenu() + labels = ['Unregister', 'Reregister', 'Add buddy...', '-', + 'Online', 'Invisible', 'Away', 'Busy', '-', + 'Settings...', '-', + 'Delete...'] + for label in labels: + if label=='-': + self.accMenu.add_separator() + else: + cmd = lambda arg=label: self._onAccContextMenu(arg) + self.accMenu.add_command(label=label, command=cmd) + + # Create Buddy context menu + # Labels, must match with _onBuddyContextMenu() + self.buddyMenu = tk.Menu(top, tearoff=False) + labels = ['Audio call', 'Send instant message', '-', + 'Subscribe', 'Unsubscribe', '-', + 'Settings...', '-', + 'Delete...'] + + for label in labels: + if label=='-': + self.buddyMenu.add_separator() + else: + cmd = lambda arg=label: self._onBuddyContextMenu(arg) + self.buddyMenu.add_command(label=label, command=cmd) + + if (top.tk.call('tk', 'windowingsystem')=='aqua'): + self.tv.bind('<2>', self._onTvRightClick) + self.tv.bind('', self._onTvRightClick) + else: + self.tv.bind('<3>', self._onTvRightClick) + self.tv.bind('', self._onTvDoubleClick) + + def _getSelectedAccount(self): + items = self.tv.selection() + if not items: + return None + try: + iid = int(items[0]) + except: + return None + accs = [acc for acc in self.accList if acc.randId==iid] + if not accs: + return None + return accs[0] + + def _getSelectedBuddy(self): + items = self.tv.selection() + if not items: + return None + try: + iid = int(items[0][5:]) + iid_parent = int(self.tv.parent(items[0])) + except: + return None + + accs = [acc for acc in self.accList if acc.randId==iid_parent] + if not accs: + return None + + buds = [b for b in accs[0].buddyList if b.randId==iid] + if not buds: + return None + + return buds[0] + + def _onTvRightClick(self, event): + iid = self.tv.identify_row(event.y) + #iid = self.tv.identify('item', event.x, event.y) + if iid: + self.tv.selection_set( (iid,) ) + acc = self._getSelectedAccount() + if acc: + self.accMenu.post(event.x_root, event.y_root) + else: + # A buddy is selected + self.buddyMenu.post(event.x_root, event.y_root) + + def _onTvDoubleClick(self, event): + iid = self.tv.identify_row(event.y) + if iid: + self.tv.selection_set( (iid,) ) + acc = self._getSelectedAccount() + if acc: + self.cfgChanged = False + dlg = accountsetting.Dialog(self.master, acc.cfg) + if dlg.doModal(): + self.updateAccount(acc) + acc.modify(acc.cfg) + else: + bud = self._getSelectedBuddy() + acc = bud.account + chat = acc.findChat(bud.cfg.uri) + if not chat: + chat = acc.newChat(bud.cfg.uri) + chat.showWindow() + + def _onAccContextMenu(self, label): + acc = self._getSelectedAccount() + if not acc: + return + + if label=='Unregister': + acc.setRegistration(False) + elif label=='Reregister': + acc.setRegistration(True) + elif label=='Online': + ps = pj.PresenceStatus() + ps.status = pj.PJSUA_BUDDY_STATUS_ONLINE + acc.setOnlineStatus(ps) + elif label=='Invisible': + ps = pj.PresenceStatus() + ps.status = pj.PJSUA_BUDDY_STATUS_OFFLINE + acc.setOnlineStatus(ps) + elif label=='Away': + ps = pj.PresenceStatus() + ps.status = pj.PJSUA_BUDDY_STATUS_ONLINE + ps.activity = pj.PJRPID_ACTIVITY_AWAY + ps.note = "Away" + acc.setOnlineStatus(ps) + elif label=='Busy': + ps = pj.PresenceStatus() + ps.status = pj.PJSUA_BUDDY_STATUS_ONLINE + ps.activity = pj.PJRPID_ACTIVITY_BUSY + ps.note = "Busy" + acc.setOnlineStatus(ps) + elif label=='Settings...': + self.cfgChanged = False + dlg = accountsetting.Dialog(self.master, acc.cfg) + if dlg.doModal(): + self.updateAccount(acc) + acc.modify(acc.cfg) + elif label=='Delete...': + msg = "Do you really want to delete account '%s'?" % acc.cfg.idUri + if msgbox.askquestion('Delete account?', msg, default=msgbox.NO) != u'yes': + return + iid = str(acc.randId) + self.accList.remove(acc) + acc.setRegistration(False) + acc.deleting = True + del acc + self.tv.delete( (iid,) ) + elif label=='Add buddy...': + cfg = pj.BuddyConfig() + dlg = buddy.SettingDialog(self.master, cfg) + if dlg.doModal(): + self._createBuddy(acc, cfg) + else: + assert not ("Unknown menu " + label) + + def _onBuddyContextMenu(self, label): + bud = self._getSelectedBuddy() + if not bud: + return + acc = bud.account + + if label=='Audio call': + chat = acc.findChat(bud.cfg.uri) + if not chat: chat = acc.newChat(bud.cfg.uri) + chat.showWindow() + chat.startCall() + elif label=='Send instant message': + chat = acc.findChat(bud.cfg.uri) + if not chat: chat = acc.newChat(bud.cfg.uri) + chat.showWindow(True) + elif label=='Subscribe': + bud.subscribePresence(True) + elif label=='Unsubscribe': + bud.subscribePresence(False) + elif label=='Settings...': + subs = bud.cfg.subscribe + uri = bud.cfg.uri + dlg = buddy.SettingDialog(self.master, bud.cfg) + if dlg.doModal(): + self.updateBuddy(bud) + # URI updated? + if uri != bud.cfg.uri: + cfg = bud.cfg + # del old + iid = 'buddy' + str(bud.randId) + acc.buddyList.remove(bud) + del bud + self.tv.delete( (iid,) ) + # add new + self._createBuddy(acc, cfg) + # presence subscribe setting updated + elif subs != bud.cfg.subscribe: + bud.subscribePresence(bud.cfg.subscribe) + elif label=='Delete...': + msg = "Do you really want to delete buddy '%s'?" % bud.cfg.uri + if msgbox.askquestion('Delete buddy?', msg, default=msgbox.NO) != u'yes': + return + iid = 'buddy' + str(bud.randId) + acc.buddyList.remove(bud) + del bud + self.tv.delete( (iid,) ) + else: + assert not ("Unknown menu " + label) + + def _onTimer(self): + if not self.quitting: + self.ep.libHandleEvents(10) + if not self.quitting: + self.master.after(50, self._onTimer) + + def _onClose(self): + self.saveConfig() + self.quitting = True + self.ep.libDestroy() + self.ep = None + self.update() + self.quit() + + def _onMenuAddAccount(self): + cfg = pj.AccountConfig() + dlg = accountsetting.Dialog(self.master, cfg) + if dlg.doModal(): + self._createAcc(cfg) + + def _onMenuShowHideLogWindow(self): + if self.showLogWindow.get(): + self.logWindow.deiconify() + else: + self.logWindow.withdraw() + + def _onMenuSettings(self): + dlg = settings.Dialog(self, self.appConfig) + if dlg.doModal(): + msgbox.showinfo(self.master.title(), 'You need to restart for new settings to take effect') + + def _onMenuSaveSettings(self): + self.saveConfig() + + def _onMenuQuit(self): + self._onClose() + + def _onMenuAbout(self): + msgbox.showinfo(self.master.title(), 'About') + + +class ExceptionCatcher: + """Custom Tk exception catcher, mainly to display more information + from pj.Error exception + """ + def __init__(self, func, subst, widget): + self.func = func + self.subst = subst + self.widget = widget + def __call__(self, *args): + try: + if self.subst: + args = apply(self.subst, args) + return apply(self.func, args) + except pj.Error, error: + print 'Exception:' + print ' ', error.info() + print 'Traceback:' + print traceback.print_stack() + log.writeLog2(1, 'Exception: ' + error.info() + '\n') + except Exception, error: + print 'Exception:' + print ' ', str(error) + print 'Traceback:' + print traceback.print_stack() + log.writeLog2(1, 'Exception: ' + str(error) + '\n') + +def main(): + #tk.CallWrapper = ExceptionCatcher + app = Application() + app.start() + app.mainloop() + +if __name__ == '__main__': + main() diff --git a/pjsip-apps/src/pygui/buddy.py b/pjsip-apps/src/pygui/buddy.py new file mode 100644 index 00000000..33537fc0 --- /dev/null +++ b/pjsip-apps/src/pygui/buddy.py @@ -0,0 +1,152 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import random +import pjsua2 as pj +import endpoint +import application + +# Buddy class +class Buddy(pj.Buddy): + """ + High level Python Buddy object, derived from pjsua2's Buddy object. + """ + def __init__(self, app): + pj.Buddy.__init__(self) + self.app = app + self.randId = random.randint(1, 9999) + self.cfg = None + self.account = None + + def statusText(self): + bi = self.getInfo() + status = '' + if bi.subState == pj.PJSIP_EVSUB_STATE_ACTIVE: + if bi.presStatus.status == pj.PJSUA_BUDDY_STATUS_ONLINE: + status = bi.presStatus.statusText + if not status: + status = 'Online' + elif bi.presStatus.status == pj.PJSUA_BUDDY_STATUS_OFFLINE: + status = 'Offline' + else: + status = 'Unknown' + return status + + def onBuddyState(self): + self.app.updateBuddy(self) + +class SettingDialog(tk.Toplevel): + """ + This implements buddy settings dialog to manipulate buddy settings. + """ + def __init__(self, parent, cfg): + tk.Toplevel.__init__(self, parent) + self.transient(parent) + self.parent = parent + self.geometry("+100+100") + self.title('Buddy settings') + + self.frm = ttk.Frame(self) + self.frm.pack(expand='yes', fill='both') + + self.isOk = False + self.cfg = cfg + + self.createWidgets() + + def doModal(self): + if self.parent: + self.parent.wait_window(self) + else: + self.wait_window(self) + return self.isOk + + def createWidgets(self): + # The notebook + self.frm.rowconfigure(0, weight=1) + self.frm.rowconfigure(1, weight=0) + self.frm.columnconfigure(0, weight=1) + self.frm.columnconfigure(1, weight=1) + self.wTab = ttk.Notebook(self.frm) + self.wTab.grid(column=0, row=0, columnspan=2, padx=5, pady=5, sticky=tk.N+tk.S+tk.W+tk.E) + + # Main buttons + btnOk = ttk.Button(self.frm, text='Ok', command=self.onOk) + btnOk.grid(column=0, row=1, sticky=tk.E, padx=20, pady=10) + btnCancel = ttk.Button(self.frm, text='Cancel', command=self.onCancel) + btnCancel.grid(column=1, row=1, sticky=tk.W, padx=20, pady=10) + + # Tabs + self.createBasicTab() + + def createBasicTab(self): + # Prepare the variables to set/receive values from GUI + self.cfgUri = tk.StringVar() + self.cfgUri.set( self.cfg.uri ) + self.cfgSubscribe = tk.IntVar() + self.cfgSubscribe.set(self.cfg.subscribe) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + ttk.Label(frm, text='URI:').grid(row=row, column=0, sticky=tk.E, pady=2) + ttk.Entry(frm, textvariable=self.cfgUri, width=40).grid(row=row, column=1, sticky=tk.W+tk.E, padx=6) + row += 1 + ttk.Checkbutton(frm, text='Subscribe presence', variable=self.cfgSubscribe).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + + self.wTab.add(frm, text='Basic Settings') + + + def onOk(self): + # Check basic settings + errors = ""; + if self.cfgUri.get(): + if not endpoint.validateSipUri(self.cfgUri.get()): + errors += "Invalid Buddy URI: '%s'\n" % (self.cfgUri.get()) + + if errors: + msgbox.showerror("Error detected:", errors) + return + + # Basic settings + self.cfg.uri = self.cfgUri.get() + self.cfg.subscribe = self.cfgSubscribe.get() + + self.isOk = True + self.destroy() + + def onCancel(self): + self.destroy() + + +if __name__ == '__main__': + application.main() diff --git a/pjsip-apps/src/pygui/call.py b/pjsip-apps/src/pygui/call.py new file mode 100644 index 00000000..35bf698c --- /dev/null +++ b/pjsip-apps/src/pygui/call.py @@ -0,0 +1,104 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import random +import pjsua2 as pj +import application +import endpoint as ep + +# Call class +class Call(pj.Call): + """ + High level Python Call object, derived from pjsua2's Call object. + """ + def __init__(self, acc, peer_uri='', chat=None, call_id = pj.PJSUA_INVALID_ID): + pj.Call.__init__(self, acc, call_id) + self.acc = acc + self.peerUri = peer_uri + self.chat = chat + self.connected = False + self.onhold = False + + def onCallState(self, prm): + ci = self.getInfo() + self.connected = ci.state == pj.PJSIP_INV_STATE_CONFIRMED + if self.chat: + self.chat.updateCallState(self, ci) + + def onCallMediaState(self, prm): + ci = self.getInfo() + for mi in ci.media: + if mi.type == pj.PJMEDIA_TYPE_AUDIO and \ + (mi.status == pj.PJSUA_CALL_MEDIA_ACTIVE or \ + mi.status == pj.PJSUA_CALL_MEDIA_REMOTE_HOLD): + m = self.getMedia(mi.index) + am = pj.AudioMedia.typecastFromMedia(m) + # connect ports + ep.Endpoint.instance.audDevManager().getCaptureDevMedia().startTransmit(am) + am.startTransmit(ep.Endpoint.instance.audDevManager().getPlaybackDevMedia()) + + if mi.status == pj.PJSUA_CALL_MEDIA_REMOTE_HOLD and not self.onhold: + self.chat.addMessage(None, "'%s' sets call onhold" % (self.peerUri)) + self.onhold = True + elif mi.status == pj.PJSUA_CALL_MEDIA_ACTIVE and self.onhold: + self.chat.addMessage(None, "'%s' sets call active" % (self.peerUri)) + self.onhold = False + + def onInstantMessage(self, prm): + # chat instance should have been initalized + if not self.chat: return + + self.chat.addMessage(self.peerUri, prm.msgBody) + self.chat.showWindow() + + def onInstantMessageStatus(self, prm): + if prm.code/100 == 2: return + # chat instance should have been initalized + if not self.chat: return + + self.chat.addMessage(None, "Failed sending message to '%s' (%d): %s" % (self.peerUri, prm.code, prm.reason)) + + def onTypingIndication(self, prm): + # chat instance should have been initalized + if not self.chat: return + + self.chat.setTypingIndication(self.peerUri, prm.isTyping) + + def onDtmfDigit(self, prm): + #msgbox.showinfo("pygui", 'Got DTMF:' + prm.digit) + pass + + def onCallMediaTransportState(self, prm): + #msgbox.showinfo("pygui", "Media transport state") + pass + + +if __name__ == '__main__': + application.main() diff --git a/pjsip-apps/src/pygui/chat.py b/pjsip-apps/src/pygui/chat.py new file mode 100644 index 00000000..760af1c7 --- /dev/null +++ b/pjsip-apps/src/pygui/chat.py @@ -0,0 +1,489 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk +else: + import Tkinter as tk + import ttk + +import buddy +import call +import chatgui as gui +import endpoint as ep +import pjsua2 as pj +import re + +SipUriRegex = re.compile('(sip|sips):([^:;>\@]*)@?([^:;>]*):?([^:;>]*)') +ConfIdx = 1 + +# Simple SIP uri parser, input URI must have been validated +def ParseSipUri(sip_uri_str): + m = SipUriRegex.search(sip_uri_str) + if not m: + assert(0) + return None + + scheme = m.group(1) + user = m.group(2) + host = m.group(3) + port = m.group(4) + if host == '': + host = user + user = '' + + return SipUri(scheme.lower(), user, host.lower(), port) + +class SipUri: + def __init__(self, scheme, user, host, port): + self.scheme = scheme + self.user = user + self.host = host + self.port = port + + def __cmp__(self, sip_uri): + if self.scheme == sip_uri.scheme and self.user == sip_uri.user and self.host == sip_uri.host: + # don't check port, at least for now + return 0 + return -1 + + def __str__(self): + s = self.scheme + ':' + if self.user: s += self.user + '@' + s += self.host + if self.port: s+= ':' + self.port + return s + +class Chat(gui.ChatObserver): + def __init__(self, app, acc, uri, call_inst=None): + self._app = app + self._acc = acc + self.title = '' + + global ConfIdx + self.confIdx = ConfIdx + ConfIdx += 1 + + # each participant call/buddy instances are stored in call list + # and buddy list with same index as in particpant list + self._participantList = [] # list of SipUri + self._callList = [] # list of Call + self._buddyList = [] # list of Buddy + + self._gui = gui.ChatFrame(self) + self.addParticipant(uri, call_inst) + + def _updateGui(self): + if self.isPrivate(): + self.title = str(self._participantList[0]) + else: + self.title = 'Conference #%d (%d participants)' % (self.confIdx, len(self._participantList)) + self._gui.title(self.title) + self._app.updateWindowMenu() + + def _getCallFromUriStr(self, uri_str, op = ''): + uri = ParseSipUri(uri_str) + if uri not in self._participantList: + print "=== %s cannot find participant with URI '%s'" % (op, uri_str) + return None + idx = self._participantList.index(uri) + if idx < len(self._callList): + return self._callList[idx] + return None + + def _getActiveMediaIdx(self, thecall): + ci = thecall.getInfo() + for mi in ci.media: + if mi.type == pj.PJMEDIA_TYPE_AUDIO and \ + (mi.status != pj.PJSUA_CALL_MEDIA_NONE and \ + mi.status != pj.PJSUA_CALL_MEDIA_ERROR): + return mi.index + return -1 + + def _getAudioMediaFromUriStr(self, uri_str): + c = self._getCallFromUriStr(uri_str) + if not c: return None + + idx = self._getActiveMediaIdx(c) + if idx < 0: return None + + m = c.getMedia(idx) + am = pj.AudioMedia.typecastFromMedia(m) + return am + + def _sendTypingIndication(self, is_typing, sender_uri_str=''): + sender_uri = ParseSipUri(sender_uri_str) if sender_uri_str else None + type_ind_param = pj.SendTypingIndicationParam() + type_ind_param.isTyping = is_typing + for idx, p in enumerate(self._participantList): + # don't echo back to the original sender + if sender_uri and p == sender_uri: + continue + + # send via call, if any, or buddy + sender = None + if self._callList[idx] and self._callList[idx].connected: + sender = self._callList[idx] + else: + sender = self._buddyList[idx] + assert(sender) + + try: + sender.sendTypingIndication(type_ind_param) + except: + pass + + def _sendInstantMessage(self, msg, sender_uri_str=''): + sender_uri = ParseSipUri(sender_uri_str) if sender_uri_str else None + send_im_param = pj.SendInstantMessageParam() + send_im_param.content = str(msg) + for idx, p in enumerate(self._participantList): + # don't echo back to the original sender + if sender_uri and p == sender_uri: + continue + + # send via call, if any, or buddy + sender = None + if self._callList[idx] and self._callList[idx].connected: + sender = self._callList[idx] + else: + sender = self._buddyList[idx] + assert(sender) + + try: + sender.sendInstantMessage(send_im_param) + except: + # error will be handled via Account::onInstantMessageStatus() + pass + + def isPrivate(self): + return len(self._participantList) <= 1 + + def isUriParticipant(self, uri): + return uri in self._participantList + + def registerCall(self, uri_str, call_inst): + uri = ParseSipUri(uri_str) + try: + idx = self._participantList.index(uri) + bud = self._buddyList[idx] + self._callList[idx] = call_inst + call_inst.chat = self + call_inst.peerUri = bud.cfg.uri + except: + assert(0) # idx must be found! + + def showWindow(self, show_text_chat = False): + self._gui.bringToFront() + if show_text_chat: + self._gui.textShowHide(True) + + def addParticipant(self, uri, call_inst=None): + # avoid duplication + if self.isUriParticipant(uri): return + + uri_str = str(uri) + + # find buddy, create one if not found (e.g: for IM/typing ind), + # it is a temporary one and not really registered to acc + bud = None + try: + bud = self._acc.findBuddy(uri_str) + except: + bud = buddy.Buddy(None) + bud_cfg = pj.BuddyConfig() + bud_cfg.uri = uri_str + bud_cfg.subscribe = False + bud.create(self._acc, bud_cfg) + bud.cfg = bud_cfg + bud.account = self._acc + + # update URI from buddy URI + uri = ParseSipUri(bud.cfg.uri) + + # add it + self._participantList.append(uri) + self._callList.append(call_inst) + self._buddyList.append(bud) + self._gui.addParticipant(str(uri)) + self._updateGui() + + def kickParticipant(self, uri): + if (not uri) or (uri not in self._participantList): + assert(0) + return + + idx = self._participantList.index(uri) + del self._participantList[idx] + del self._callList[idx] + del self._buddyList[idx] + self._gui.delParticipant(str(uri)) + + if self._participantList: + self._updateGui() + else: + self.onCloseWindow() + + def addMessage(self, from_uri_str, msg): + if from_uri_str: + # print message on GUI + msg = from_uri_str + ': ' + msg + self._gui.textAddMessage(msg) + # now relay to all participants + self._sendInstantMessage(msg, from_uri_str) + else: + self._gui.textAddMessage(msg, False) + + def setTypingIndication(self, from_uri_str, is_typing): + # notify GUI + self._gui.textSetTypingIndication(from_uri_str, is_typing) + # now relay to all participants + self._sendTypingIndication(is_typing, from_uri_str) + + def startCall(self): + self._gui.enableAudio() + call_param = pj.CallOpParam() + call_param.opt.audioCount = 1 + call_param.opt.videoCount = 0 + fails = [] + for idx, p in enumerate(self._participantList): + # just skip if call is instantiated + if self._callList[idx]: + continue + + uri_str = str(p) + c = call.Call(self._acc, uri_str, self) + self._callList[idx] = c + self._gui.audioUpdateState(uri_str, gui.AudioState.INITIALIZING) + + try: + c.makeCall(uri_str, call_param) + except: + self._callList[idx] = None + self._gui.audioUpdateState(uri_str, gui.AudioState.FAILED) + fails.append(p) + + for p in fails: + # kick participants with call failure, but spare the last (avoid zombie chat) + if not self.isPrivate(): + self.kickParticipant(p) + + def stopCall(self): + for idx, p in enumerate(self._participantList): + self._gui.audioUpdateState(str(p), gui.AudioState.DISCONNECTED) + c = self._callList[idx] + if c: + c.hangup(pj.CallOpParam()) + + def updateCallState(self, thecall, info = None): + # info is optional here, just to avoid calling getInfo() twice (in the caller and here) + if not info: info = thecall.getInfo() + + if info.state < pj.PJSIP_INV_STATE_CONFIRMED: + self._gui.audioUpdateState(thecall.peerUri, gui.AudioState.INITIALIZING) + elif info.state == pj.PJSIP_INV_STATE_CONFIRMED: + self._gui.audioUpdateState(thecall.peerUri, gui.AudioState.CONNECTED) + med_idx = self._getActiveMediaIdx(thecall) + si = thecall.getStreamInfo(med_idx) + stats_str = "Audio codec: %s/%s\n..." % (si.codecName, si.codecClockRate) + self._gui.audioSetStatsText(thecall.peerUri, stats_str) + elif info.state == pj.PJSIP_INV_STATE_DISCONNECTED: + if info.lastStatusCode/100 != 2: + self._gui.audioUpdateState(thecall.peerUri, gui.AudioState.FAILED) + else: + self._gui.audioUpdateState(thecall.peerUri, gui.AudioState.DISCONNECTED) + + # reset entry in the callList + try: + idx = self._callList.index(thecall) + if idx >= 0: self._callList[idx] = None + except: + pass + + self.addMessage(None, "Call to '%s' disconnected: %s" % (thecall.peerUri, info.lastReason)) + + # kick the disconnected participant, but the last (avoid zombie chat) + if not self.isPrivate(): + self.kickParticipant(ParseSipUri(thecall.peerUri)) + + + # ** callbacks from GUI (ChatObserver implementation) ** + + # Text + def onSendMessage(self, msg): + self._sendInstantMessage(msg) + + def onStartTyping(self): + self._sendTypingIndication(True) + + def onStopTyping(self): + self._sendTypingIndication(False) + + # Audio + def onHangup(self, peer_uri_str): + c = self._getCallFromUriStr(peer_uri_str, "onHangup()") + if not c: return + call_param = pj.CallOpParam() + c.hangup(call_param) + + def onHold(self, peer_uri_str): + c = self._getCallFromUriStr(peer_uri_str, "onHold()") + if not c: return + call_param = pj.CallOpParam() + c.setHold(call_param) + + def onUnhold(self, peer_uri_str): + c = self._getCallFromUriStr(peer_uri_str, "onUnhold()") + if not c: return + + call_param = pj.CallOpParam() + call_param.opt.audioCount = 1 + call_param.opt.videoCount = 0 + call_param.opt.flag |= pj.PJSUA_CALL_UNHOLD + c.reinvite(call_param) + + def onRxMute(self, peer_uri_str, mute): + am = self._getAudioMediaFromUriStr(peer_uri_str) + if not am: return + if mute: + am.stopTransmit(ep.Endpoint.instance.audDevManager().getPlaybackDevMedia()) + self.addMessage(None, "Muted audio from '%s'" % (peer_uri_str)) + else: + am.startTransmit(ep.Endpoint.instance.audDevManager().getPlaybackDevMedia()) + self.addMessage(None, "Unmuted audio from '%s'" % (peer_uri_str)) + + def onRxVol(self, peer_uri_str, vol_pct): + am = self._getAudioMediaFromUriStr(peer_uri_str) + if not am: return + # pjsua volume range = 0:mute, 1:no adjustment, 2:100% louder + am.adjustRxLevel(vol_pct/50.0) + self.addMessage(None, "Adjusted volume level audio from '%s'" % (peer_uri_str)) + + def onTxMute(self, peer_uri_str, mute): + am = self._getAudioMediaFromUriStr(peer_uri_str) + if not am: return + if mute: + ep.Endpoint.instance.audDevManager().getCaptureDevMedia().stopTransmit(am) + self.addMessage(None, "Muted audio to '%s'" % (peer_uri_str)) + else: + ep.Endpoint.instance.audDevManager().getCaptureDevMedia().startTransmit(am) + self.addMessage(None, "Unmuted audio to '%s'" % (peer_uri_str)) + + # Chat room + def onAddParticipant(self): + buds = [] + dlg = AddParticipantDlg(None, self._app, buds) + if dlg.doModal(): + for bud in buds: + uri = ParseSipUri(bud.cfg.uri) + self.addParticipant(uri) + if not self.isPrivate(): + self.startCall() + + def onStartAudio(self): + self.startCall() + + def onStopAudio(self): + self.stopCall() + + def onCloseWindow(self): + self.stopCall() + # will remove entry from list eventually destroy this chat? + if self in self._acc.chatList: self._acc.chatList.remove(self) + self._app.updateWindowMenu() + # destroy GUI + self._gui.destroy() + + +class AddParticipantDlg(tk.Toplevel): + """ + List of buddies + """ + def __init__(self, parent, app, bud_list): + tk.Toplevel.__init__(self, parent) + self.title('Add participants..') + self.transient(parent) + self.parent = parent + self._app = app + self.buddyList = bud_list + + self.isOk = False + + self.createWidgets() + + def doModal(self): + if self.parent: + self.parent.wait_window(self) + else: + self.wait_window(self) + return self.isOk + + def createWidgets(self): + # buddy list + list_frame = ttk.Frame(self) + list_frame.pack(side=tk.TOP, fill=tk.BOTH, expand=1, padx=20, pady=20) + #scrl = ttk.Scrollbar(self, orient=tk.VERTICAL, command=list_frame.yview) + #list_frame.config(yscrollcommand=scrl.set) + #scrl.pack(side=tk.RIGHT, fill=tk.Y) + + # draw buddy list + self.buddies = [] + for acc in self._app.accList: + self.buddies.append((0, acc.cfg.idUri)) + for bud in acc.buddyList: + self.buddies.append((1, bud)) + + self.bud_var = [] + for idx,(flag,bud) in enumerate(self.buddies): + self.bud_var.append(tk.IntVar()) + if flag==0: + s = ttk.Separator(list_frame, orient=tk.HORIZONTAL) + s.pack(fill=tk.X) + l = tk.Label(list_frame, anchor=tk.W, text="Account '%s':" % (bud)) + l.pack(fill=tk.X) + else: + c = tk.Checkbutton(list_frame, anchor=tk.W, text=bud.cfg.uri, variable=self.bud_var[idx]) + c.pack(fill=tk.X) + s = ttk.Separator(list_frame, orient=tk.HORIZONTAL) + s.pack(fill=tk.X) + + # Ok/cancel buttons + tail_frame = ttk.Frame(self) + tail_frame.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1) + + btnOk = ttk.Button(tail_frame, text='Ok', default=tk.ACTIVE, command=self.onOk) + btnOk.pack(side=tk.LEFT, padx=20, pady=10) + btnCancel = ttk.Button(tail_frame, text='Cancel', command=self.onCancel) + btnCancel.pack(side=tk.RIGHT, padx=20, pady=10) + + def onOk(self): + self.buddyList[:] = [] + for idx,(flag,bud) in enumerate(self.buddies): + if not flag: continue + if self.bud_var[idx].get() and not (bud in self.buddyList): + self.buddyList.append(bud) + + self.isOk = True + self.destroy() + + def onCancel(self): + self.destroy() diff --git a/pjsip-apps/src/pygui/chatgui.py b/pjsip-apps/src/pygui/chatgui.py new file mode 100644 index 00000000..bb58e286 --- /dev/null +++ b/pjsip-apps/src/pygui/chatgui.py @@ -0,0 +1,420 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import ttk + import tkMessageBox as msgbox + + +class TextObserver: + def onSendMessage(self, msg): + pass + def onStartTyping(self): + pass + def onStopTyping(self): + pass + +class TextFrame(ttk.Frame): + def __init__(self, master, observer): + ttk.Frame.__init__(self, master) + self._observer = observer + self._isTyping = False + self._createWidgets() + + def _onSendMessage(self, event): + send_text = self._typingBox.get("1.0", tk.END).strip() + if send_text == '': + return + + self.addMessage('me: ' + send_text) + self._typingBox.delete("0.0", tk.END) + self._onTyping(None) + + # notify app for sending message + self._observer.onSendMessage(send_text) + + def _onTyping(self, event): + # notify app for typing indication + is_typing = self._typingBox.get("1.0", tk.END).strip() != '' + if is_typing != self._isTyping: + self._isTyping = is_typing + if is_typing: + self._observer.onStartTyping() + else: + self._observer.onStopTyping() + + def _createWidgets(self): + self.rowconfigure(0, weight=1) + self.rowconfigure(1, weight=0) + self.rowconfigure(2, weight=0) + self.columnconfigure(0, weight=1) + self.columnconfigure(1, weight=0) + + self._text = tk.Text(self, width=50, height=30, font=("Arial", "10")) + self._text.grid(row=0, column=0, sticky='nswe') + self._text.config(state=tk.DISABLED) + self._text.tag_config("info", foreground="darkgray", font=("Arial", "9", "italic")) + + scrl = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self._text.yview) + self._text.config(yscrollcommand=scrl.set) + scrl.grid(row=0, column=1, sticky='nsw') + + self._typingBox = tk.Text(self, width=50, height=1, font=("Arial", "10")) + self._typingBox.grid(row=1, columnspan=2, sticky='we', pady=0) + + self._statusBar = tk.Label(self, anchor='w', font=("Arial", "8", "italic")) + self._statusBar.grid(row=2, columnspan=2, sticky='we') + + self._typingBox.bind('', self._onSendMessage) + self._typingBox.bind("", self._onTyping) + self._typingBox.focus_set() + + def addMessage(self, msg, is_chat = True): + self._text.config(state=tk.NORMAL) + if is_chat: + self._text.insert(tk.END, msg+'\r\n') + else: + self._text.insert(tk.END, msg+'\r\n', 'info') + self._text.config(state=tk.DISABLED) + self._text.yview(tk.END) + + def setTypingIndication(self, who, is_typing): + if is_typing: + self._statusBar['text'] = "'%s' is typing.." % (who) + else: + self._statusBar['text'] = '' + +class AudioState: + NULL, INITIALIZING, CONNECTED, DISCONNECTED, FAILED = range(5) + +class AudioObserver: + def onHangup(self, peer_uri): + pass + def onHold(self, peer_uri): + pass + def onUnhold(self, peer_uri): + pass + def onRxMute(self, peer_uri, is_muted): + pass + def onRxVol(self, peer_uri, vol_pct): + pass + def onTxMute(self, peer_uri, is_muted): + pass + + +class AudioFrame(ttk.Labelframe): + def __init__(self, master, peer_uri, observer): + ttk.Labelframe.__init__(self, master, text=peer_uri) + self.peerUri = peer_uri + self._observer = observer + self._initFrame = None + self._callFrame = None + self._rxMute = False + self._txMute = False + self._state = AudioState.NULL + + self._createInitWidgets() + self._createWidgets() + + def updateState(self, state): + if self._state == state: + return + + if state == AudioState.INITIALIZING: + self._callFrame.pack_forget() + self._initFrame.pack(fill=tk.BOTH) + self._btnCancel.pack(side=tk.TOP) + self._lblInitState['text'] = 'Intializing..' + + elif state == AudioState.CONNECTED: + self._initFrame.pack_forget() + self._callFrame.pack(fill=tk.BOTH) + else: + self._callFrame.pack_forget() + self._initFrame.pack(fill=tk.BOTH) + if state == AudioState.FAILED: + self._lblInitState['text'] = 'Failed' + else: + self._lblInitState['text'] = 'Normal cleared' + self._btnCancel.pack_forget() + + self._btnHold['text'] = 'Hold' + self._btnHold.config(state=tk.NORMAL) + self._rxMute = False + self._txMute = False + self.btnRxMute['text'] = 'Mute' + self.btnTxMute['text'] = 'Mute' + self.rxVol.set(5.0) + + # save last state + self._state = state + + def setStatsText(self, stats_str): + self.stat.config(state=tk.NORMAL) + self.stat.delete("0.0", tk.END) + self.stat.insert(tk.END, stats_str) + self.stat.config(state=tk.DISABLED) + + def _onHold(self): + self._btnHold.config(state=tk.DISABLED) + # notify app + if self._btnHold['text'] == 'Hold': + self._observer.onHold(self.peerUri) + self._btnHold['text'] = 'Unhold' + else: + self._observer.onUnhold(self.peerUri) + self._btnHold['text'] = 'Hold' + self._btnHold.config(state=tk.NORMAL) + + def _onHangup(self): + # notify app + self._observer.onHangup(self.peerUri) + + def _onRxMute(self): + # notify app + self._rxMute = not self._rxMute + self._observer.onRxMute(self.peerUri, self._rxMute) + self.btnRxMute['text'] = 'Unmute' if self._rxMute else 'Mute' + + def _onRxVol(self, event): + # notify app + vol = self.rxVol.get() + self._observer.onRxVol(self.peerUri, vol*10.0) + + def _onTxMute(self): + # notify app + self._txMute = not self._txMute + self._observer.onTxMute(self.peerUri, self._txMute) + self.btnTxMute['text'] = 'Unmute' if self._txMute else 'Mute' + + def _createInitWidgets(self): + self._initFrame = ttk.Frame(self) + #self._initFrame.pack(fill=tk.BOTH) + + + self._lblInitState = tk.Label(self._initFrame, font=("Arial", "12"), text='') + self._lblInitState.pack(side=tk.TOP, fill=tk.X, expand=1) + + # Operation: cancel/kick + self._btnCancel = ttk.Button(self._initFrame, text = 'Cancel', command=self._onHangup) + self._btnCancel.pack(side=tk.TOP) + + def _createWidgets(self): + self._callFrame = ttk.Frame(self) + #self._callFrame.pack(fill=tk.BOTH) + + # toolbar + toolbar = ttk.Frame(self._callFrame) + toolbar.pack(side=tk.TOP, fill=tk.X) + self._btnHold = ttk.Button(toolbar, text='Hold', command=self._onHold) + self._btnHold.pack(side=tk.LEFT, fill=tk.Y) + #self._btnXfer = ttk.Button(toolbar, text='Transfer..') + #self._btnXfer.pack(side=tk.LEFT, fill=tk.Y) + self._btnHangUp = ttk.Button(toolbar, text='Hangup', command=self._onHangup) + self._btnHangUp.pack(side=tk.LEFT, fill=tk.Y) + + # volume tool + vol_frm = ttk.Frame(self._callFrame) + vol_frm.pack(side=tk.TOP, fill=tk.X) + + self.rxVolFrm = ttk.Labelframe(vol_frm, text='RX volume') + self.rxVolFrm.pack(side=tk.LEFT, fill=tk.Y) + + self.btnRxMute = ttk.Button(self.rxVolFrm, width=8, text='Mute', command=self._onRxMute) + self.btnRxMute.pack(side=tk.LEFT) + self.rxVol = tk.Scale(self.rxVolFrm, orient=tk.HORIZONTAL, from_=0.0, to=10.0, showvalue=1) #, tickinterval=10.0, showvalue=1) + self.rxVol.set(5.0) + self.rxVol.bind("", self._onRxVol) + self.rxVol.pack(side=tk.LEFT) + + self.txVolFrm = ttk.Labelframe(vol_frm, text='TX volume') + self.txVolFrm.pack(side=tk.RIGHT, fill=tk.Y) + + self.btnTxMute = ttk.Button(self.txVolFrm, width=8, text='Mute', command=self._onTxMute) + self.btnTxMute.pack(side=tk.LEFT) + + # stat + self.stat = tk.Text(self._callFrame, width=10, height=2, bg='lightgray', relief=tk.FLAT, font=("Arial", "9")) + self.stat.insert(tk.END, 'stat here') + self.stat.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1) + + +class ChatObserver(TextObserver, AudioObserver): + def onAddParticipant(self): + pass + def onStartAudio(self): + pass + def onStopAudio(self): + pass + def onCloseWindow(self): + pass + +class ChatFrame(tk.Toplevel): + """ + Room + """ + def __init__(self, observer): + tk.Toplevel.__init__(self) + self.protocol("WM_DELETE_WINDOW", self._onClose) + self._observer = observer + + self._text = None + self._text_shown = True + + self._audioEnabled = False + self._audioFrames = [] + self._createWidgets() + + def _createWidgets(self): + # toolbar + self.toolbar = ttk.Frame(self) + self.toolbar.pack(side=tk.TOP, fill=tk.BOTH) + + btnText = ttk.Button(self.toolbar, text='Show/hide text', command=self._onShowHideText) + btnText.pack(side=tk.LEFT, fill=tk.Y) + btnAudio = ttk.Button(self.toolbar, text='Start/stop audio', command=self._onStartStopAudio) + btnAudio.pack(side=tk.LEFT, fill=tk.Y) + + ttk.Separator(self.toolbar, orient=tk.VERTICAL).pack(side=tk.LEFT, fill=tk.Y, padx = 4) + + btnAdd = ttk.Button(self.toolbar, text='Add participant..', command=self._onAddParticipant) + btnAdd.pack(side=tk.LEFT, fill=tk.Y) + + # media frame + self.media = ttk.Frame(self) + self.media.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=1) + + # create Text Chat frame + self.media_left = ttk.Frame(self.media) + self._text = TextFrame(self.media_left, self._observer) + self._text.pack(fill=tk.BOTH, expand=1) + self.media_left.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) + + # create other media frame + self.media_right = ttk.Frame(self.media) + + def _arrangeMediaFrames(self): + if len(self._audioFrames) == 0: + self.media_right.pack_forget() + return + + self.media_right.pack(side=tk.RIGHT, fill=tk.BOTH, expand=1) + MAX_ROWS = 3 + row_num = 0 + col_num = 1 + for frm in self._audioFrames: + frm.grid(row=row_num, column=col_num, sticky='nsew', padx=5, pady=5) + row_num += 1 + if row_num >= MAX_ROWS: + row_num = 0 + col_num += 1 + + def _onShowHideText(self): + self.textShowHide(not self._text_shown) + + def _onAddParticipant(self): + self._observer.onAddParticipant() + + def _onStartStopAudio(self): + self._audioEnabled = not self._audioEnabled + if self._audioEnabled: + self._observer.onStartAudio() + else: + self._observer.onStopAudio() + self.enableAudio(self._audioEnabled) + + def _onClose(self): + self._observer.onCloseWindow() + + # APIs + + def bringToFront(self): + self.deiconify() + self.lift() + self._text._typingBox.focus_set() + + def textAddMessage(self, msg, is_chat = True): + self._text.addMessage(msg, is_chat) + + def textSetTypingIndication(self, who, is_typing = True): + self._text.setTypingIndication(who, is_typing) + + def addParticipant(self, participant_uri): + aud_frm = AudioFrame(self.media_right, participant_uri, self._observer) + self._audioFrames.append(aud_frm) + + def delParticipant(self, participant_uri): + for aud_frm in self._audioFrames: + if participant_uri == aud_frm.peerUri: + self._audioFrames.remove(aud_frm) + # need to delete aud_frm manually? + aud_frm.destroy() + return + + def textShowHide(self, show = True): + if show: + self.media_left.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) + self._text._typingBox.focus_set() + else: + self.media_left.pack_forget() + self._text_shown = show + + def enableAudio(self, is_enabled = True): + if is_enabled: + self._arrangeMediaFrames() + else: + self.media_right.pack_forget() + self._audioEnabled = is_enabled + + def audioUpdateState(self, participant_uri, state): + for aud_frm in self._audioFrames: + if participant_uri == aud_frm.peerUri: + aud_frm.updateState(state) + break + if state >= AudioState.DISCONNECTED and len(self._audioFrames) == 1: + self.enableAudio(False) + else: + self.enableAudio(True) + + def audioSetStatsText(self, participant_uri, stats_str): + for aud_frm in self._audioFrames: + if participant_uri == aud_frm.peerUri: + aud_frm.setStatsText(stats_str) + break + +if __name__ == '__main__': + root = tk.Tk() + root.title("Chat") + root.columnconfigure(0, weight=1) + root.rowconfigure(0, weight=1) + + obs = ChatObserver() + dlg = ChatFrame(obs) + #dlg = TextFrame(root) + #dlg = AudioFrame(root) + + #dlg.pack(fill=tk.BOTH, expand=1) + root.mainloop() diff --git a/pjsip-apps/src/pygui/endpoint.py b/pjsip-apps/src/pygui/endpoint.py new file mode 100644 index 00000000..d76dbf3f --- /dev/null +++ b/pjsip-apps/src/pygui/endpoint.py @@ -0,0 +1,53 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import pjsua2 as pj +import application + + +class Endpoint(pj.Endpoint): + """ + This is high level Python object inherited from pj.Endpoint + """ + instance = None + def __init__(self): + pj.Endpoint.__init__(self) + Endpoint.instance = self + + +def validateUri(uri): + return Endpoint.instance.utilVerifyUri(uri) == pj.PJ_SUCCESS + +def validateSipUri(uri): + return Endpoint.instance.utilVerifySipUri(uri) == pj.PJ_SUCCESS + + +if __name__ == '__main__': + application.main() diff --git a/pjsip-apps/src/pygui/log.py b/pjsip-apps/src/pygui/log.py new file mode 100644 index 00000000..d3772419 --- /dev/null +++ b/pjsip-apps/src/pygui/log.py @@ -0,0 +1,127 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import pjsua2 as pj +import application + + +class LogWindow(tk.Toplevel): + """ + Log window + """ + instance = None + def __init__(self, app): + tk.Toplevel.__init__(self, name='logwnd', width=640, height=480) + LogWindow.instance = self + self.app = app + self.state('withdrawn') + self.title('Log') + self._createWidgets() + self.protocol("WM_DELETE_WINDOW", self._onHide) + + def addLog(self, entry): + """entry fields: + int level; + string msg; + long threadId; + string threadName; + """ + self.addLog2(entry.level, entry.msg) + + def addLog2(self, level, msg): + if level==5: + tags = ('trace',) + elif level==3: + tags = ('info',) + elif level==2: + tags = ('warning',) + elif level<=1: + tags = ('error',) + else: + tags = None + self.text.insert(tk.END, msg, tags) + self.text.see(tk.END) + + def _createWidgets(self): + self.rowconfigure(0, weight=1) + self.rowconfigure(1, weight=0) + self.columnconfigure(0, weight=1) + self.columnconfigure(1, weight=0) + + self.text = tk.Text(self, font=('Courier New', '8'), wrap=tk.NONE, undo=False, padx=4, pady=5) + self.text.grid(row=0, column=0, sticky='nswe', padx=5, pady=5) + + scrl = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.text.yview) + self.text.config(yscrollcommand=scrl.set) + scrl.grid(row=0, column=1, sticky='nsw', padx=5, pady=5) + + scrl = ttk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.text.xview) + self.text.config(xscrollcommand=scrl.set) + scrl.grid(row=1, column=0, sticky='we', padx=5, pady=5) + + self.text.bind("", self._onKey) + + self.text.tag_configure('normal', font=('Courier New', '8'), foreground='black') + self.text.tag_configure('trace', font=('Courier New', '8'), foreground='#777777') + self.text.tag_configure('info', font=('Courier New', '8', 'bold'), foreground='black') + self.text.tag_configure('warning', font=('Courier New', '8', 'bold'), foreground='cyan') + self.text.tag_configure('error', font=('Courier New', '8', 'bold'), foreground='red') + + def _onKey(self, event): + # Ignore key event to make text widget read-only + return "break" + + def _onHide(self): + # Hide when close ('x') button is clicked + self.withdraw() + self.app.showLogWindow.set(0) + + +def writeLog2(level, msg): + if LogWindow.instance: + LogWindow.instance.addLog2(level, msg) + +def writeLog(entry): + if LogWindow.instance: + LogWindow.instance.addLog(entry) + +class Logger(pj.LogWriter): + """ + Logger to receive log messages from pjsua2 + """ + def __init__(self): + pj.LogWriter.__init__(self) + + def write(self, entry): + print entry.msg, + writeLog(entry) + +if __name__ == '__main__': + application.main() diff --git a/pjsip-apps/src/pygui/settings.py b/pjsip-apps/src/pygui/settings.py new file mode 100644 index 00000000..25f053e2 --- /dev/null +++ b/pjsip-apps/src/pygui/settings.py @@ -0,0 +1,362 @@ +# $Id$ +# +# pjsua Python GUI Demo +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import sys +if sys.version_info[0] >= 3: # Python 3 + import tkinter as tk + from tkinter import ttk + from tkinter import messagebox as msgbox +else: + import Tkinter as tk + import tkMessageBox as msgbox + import ttk + +import pjsua2 as pj +#import application + +# Transport setting +class SipTransportConfig: + def __init__(self, type, enabled): + #pj.PersistentObject.__init__(self) + self.type = type + self.enabled = enabled + self.config = pj.TransportConfig() + def readObject(self, node): + child_node = node.readContainer("SipTransport") + self.type = child_node.readInt("type") + self.enabled = child_node.readBool("enabled") + self.config.readObject(child_node) + def writeObject(self, node): + child_node = node.writeNewContainer("SipTransport") + child_node.writeInt("type", self.type) + child_node.writeBool("enabled", self.enabled) + self.config.writeObject(child_node) + +# Account setting with buddy list +class AccConfig: + def __init__(self): + self.enabled = True + self.config = pj.AccountConfig() + self.buddyConfigs = [] + def readObject(self, node): + acc_node = node.readContainer("Account") + self.enabled = acc_node.readBool("enabled") + self.config.readObject(acc_node) + buddy_node = acc_node.readArray("buddies") + while buddy_node.hasUnread(): + buddy_cfg = pj.BuddyConfig() + buddy_cfg.readObject(buddy_node) + self.buddyConfigs.append(buddy_cfg) + def writeObject(self, node): + acc_node = node.writeNewContainer("Account") + acc_node.writeBool("enabled", self.enabled) + self.config.writeObject(acc_node) + buddy_node = acc_node.writeNewArray("buddies") + for buddy in self.buddyConfigs: + buddy_node.writeObject(buddy) + + +# Master settings +class AppConfig: + def __init__(self): + self.epConfig = pj.EpConfig() # pj.EpConfig() + self.udp = SipTransportConfig(pj.PJSIP_TRANSPORT_UDP, True) + self.tcp = SipTransportConfig(pj.PJSIP_TRANSPORT_TCP, True) + self.tls = SipTransportConfig(pj.PJSIP_TRANSPORT_TLS, False) + self.accounts = [] # Array of AccConfig + + def loadFile(self, file): + json = pj.JsonDocument() + json.loadFile(file) + root = json.getRootContainer() + self.epConfig = pj.EpConfig() + self.epConfig.readObject(root) + + tp_node = root.readArray("transports") + self.udp.readObject(tp_node) + self.tcp.readObject(tp_node) + if tp_node.hasUnread(): + self.tls.readObject(tp_node) + + acc_node = root.readArray("accounts") + while acc_node.hasUnread(): + acfg = AccConfig() + acfg.readObject(acc_node) + self.accounts.append(acfg) + + def saveFile(self,file): + json = pj.JsonDocument() + + # Write endpoint config + json.writeObject(self.epConfig) + + # Write transport config + tp_node = json.writeNewArray("transports") + self.udp.writeObject(tp_node) + self.tcp.writeObject(tp_node) + self.tls.writeObject(tp_node) + + # Write account configs + node = json.writeNewArray("accounts") + for acc in self.accounts: + acc.writeObject(node) + + json.saveFile(file) + + +# Settings dialog +class Dialog(tk.Toplevel): + """ + This implements account settings dialog to manipulate account settings. + """ + def __init__(self, parent, cfg): + tk.Toplevel.__init__(self, parent) + self.transient(parent) + self.parent = parent + self.title('Settings') + + self.frm = ttk.Frame(self) + self.frm.pack(expand='yes', fill='both') + + self.isOk = False + self.cfg = cfg + + self.createWidgets() + + def doModal(self): + if self.parent: + self.parent.wait_window(self) + else: + self.wait_window(self) + return self.isOk + + def createWidgets(self): + # The notebook + self.frm.rowconfigure(0, weight=1) + self.frm.rowconfigure(1, weight=0) + self.frm.columnconfigure(0, weight=1) + self.frm.columnconfigure(1, weight=1) + self.wTab = ttk.Notebook(self.frm) + self.wTab.grid(column=0, row=0, columnspan=2, padx=10, pady=10, ipadx=20, ipady=20, sticky=tk.N+tk.S+tk.W+tk.E) + + # Main buttons + btnOk = ttk.Button(self.frm, text='Ok', command=self.onOk) + btnOk.grid(column=0, row=1, sticky=tk.E, padx=20, pady=10) + btnCancel = ttk.Button(self.frm, text='Cancel', command=self.onCancel) + btnCancel.grid(column=1, row=1, sticky=tk.W, padx=20, pady=10) + + # Tabs + self.createBasicTab() + self.createNetworkTab() + self.createMediaTab() + + def createBasicTab(self): + # Prepare the variables to set/receive values from GUI + self.cfgLogFile = tk.StringVar(value=self.cfg.epConfig.logConfig.filename) + self.cfgLogAppend = tk.BooleanVar(value=True if (self.cfg.epConfig.logConfig.fileFlags & pj.PJ_O_APPEND) else False) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + ttk.Label(frm, text='User Agent:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Label(frm, text=self.cfg.epConfig.uaConfig.userAgent).grid(row=row, column=1, sticky=tk.W, pady=2, padx=6) + row += 1 + ttk.Label(frm, text='Max calls:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Label(frm, text=str(self.cfg.epConfig.uaConfig.maxCalls)).grid(row=row, column=1, sticky=tk.W, pady=2, padx=6) + row += 1 + ttk.Label(frm, text='Log file:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Entry(frm, textvariable=self.cfgLogFile, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Checkbutton(frm, text='Append log file', variable=self.cfgLogAppend).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + + self.wTab.add(frm, text='Basic') + + def createNetworkTab(self): + self.cfgNameserver = tk.StringVar() + if len(self.cfg.epConfig.uaConfig.nameserver): + self.cfgNameserver.set(self.cfg.epConfig.uaConfig.nameserver[0]) + self.cfgStunServer = tk.StringVar() + if len(self.cfg.epConfig.uaConfig.stunServer): + self.cfgStunServer.set(self.cfg.epConfig.uaConfig.stunServer[0]) + self.cfgStunIgnoreError = tk.BooleanVar(value=self.cfg.epConfig.uaConfig.stunIgnoreFailure) + + self.cfgUdpEnabled = tk.BooleanVar(value=self.cfg.udp.enabled) + self.cfgUdpPort = tk.IntVar(value=self.cfg.udp.config.port) + self.cfgTcpEnabled = tk.BooleanVar(value=self.cfg.tcp.enabled) + self.cfgTcpPort = tk.IntVar(value=self.cfg.tcp.config.port) + self.cfgTlsEnabled = tk.BooleanVar(value=self.cfg.tls.enabled) + self.cfgTlsPort = tk.IntVar(value=self.cfg.tls.config.port) + + self.cfgTlsCaFile = tk.StringVar(value=self.cfg.tls.config.tlsConfig.CaListFile) + self.cfgTlsCertFile = tk.StringVar(value=self.cfg.tls.config.tlsConfig.certFile) + self.cfgTlsVerifyClient = tk.BooleanVar(value=self.cfg.tls.config.tlsConfig.verifyClient) + self.cfgTlsVerifyServer = tk.BooleanVar(value=self.cfg.tls.config.tlsConfig.verifyServer) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + #ttk.Label(frm, text='UDP transport:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Checkbutton(frm, text='Enable UDP transport', variable=self.cfgUdpEnabled).grid(row=row, column=0, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='UDP port:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=0, to=65535, textvariable=self.cfgUdpPort, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(0 for any)').grid(row=row, column=1, sticky=tk.E, pady=6, padx=6) + row += 1 + #ttk.Label(frm, text='TCP transport:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Checkbutton(frm, text='Enable TCP transport', variable=self.cfgTcpEnabled).grid(row=row, column=0, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='TCP port:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=0, to=65535, textvariable=self.cfgTcpPort, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(0 for any)').grid(row=row, column=1, sticky=tk.E, pady=6, padx=6) + row += 1 + #ttk.Label(frm, text='TLS transport:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Checkbutton(frm, text='Enable TLS transport', variable=self.cfgTlsEnabled).grid(row=row, column=0, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='TLS port:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=0, to=65535, textvariable=self.cfgTlsPort, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(0 for any)').grid(row=row, column=1, sticky=tk.E, pady=6, padx=6) + row += 1 + ttk.Label(frm, text='TLS CA file:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Entry(frm, textvariable=self.cfgTlsCaFile, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='TLS cert file:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Entry(frm, textvariable=self.cfgTlsCertFile, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Checkbutton(frm, text='TLS verify server', variable=self.cfgTlsVerifyServer).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Checkbutton(frm, text='TLS verify client', variable=self.cfgTlsVerifyClient).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='DNS and STUN:').grid(row=row, column=0, sticky=tk.W, pady=2, padx=8) + row += 1 + ttk.Label(frm, text='Nameserver:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Entry(frm, textvariable=self.cfgNameserver, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='STUN Server:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Entry(frm, textvariable=self.cfgStunServer, width=32).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Checkbutton(frm, text='Ignore STUN failure at startup', variable=self.cfgStunIgnoreError).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + + self.wTab.add(frm, text='Network') + + def createMediaTab(self): + self.cfgClockrate = tk.IntVar(value=self.cfg.epConfig.medConfig.clockRate) + self.cfgSndClockrate = tk.IntVar(value=self.cfg.epConfig.medConfig.sndClockRate) + self.cfgAudioPtime = tk.IntVar(value=self.cfg.epConfig.medConfig.audioFramePtime) + self.cfgMediaQuality = tk.IntVar(value=self.cfg.epConfig.medConfig.quality) + self.cfgCodecPtime = tk.IntVar(value=self.cfg.epConfig.medConfig.ptime) + self.cfgVad = tk.BooleanVar(value=not self.cfg.epConfig.medConfig.noVad) + self.cfgEcTailLen = tk.IntVar(value=self.cfg.epConfig.medConfig.ecTailLen) + + # Build the tab page + frm = ttk.Frame(self.frm) + frm.columnconfigure(0, weight=1) + frm.columnconfigure(1, weight=2) + row = 0 + ttk.Label(frm, text='Max media ports:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Label(frm, text=str(self.cfg.epConfig.medConfig.maxMediaPorts)).grid(row=row, column=1, sticky=tk.W, pady=2, padx=6) + row += 1 + ttk.Label(frm, text='Core clock rate:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=8000, to=48000, increment=8000, textvariable=self.cfgClockrate, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Snd device clock rate:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=0, to=48000, increment=8000, textvariable=self.cfgSndClockrate, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(0: follow core)').grid(row=row, column=1, sticky=tk.E, pady=6, padx=6) + row += 1 + ttk.Label(frm, text='Core ptime:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=10, to=400, increment=10, textvariable=self.cfgAudioPtime, width=3).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='RTP ptime:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=20, to=400, increment=10, textvariable=self.cfgCodecPtime, width=3).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='Media quality (1-10):').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=1, to=10, textvariable=self.cfgMediaQuality, width=5).grid(row=row, column=1, sticky=tk.W, padx=6) + row += 1 + ttk.Label(frm, text='VAD:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + ttk.Checkbutton(frm, text='Enable', variable=self.cfgVad).grid(row=row, column=1, sticky=tk.W, padx=6, pady=2) + row += 1 + ttk.Label(frm, text='Echo canceller tail length:').grid(row=row, column=0, sticky=tk.E, pady=2, padx=8) + tk.Spinbox(frm, from_=0, to=400, increment=10, textvariable=self.cfgEcTailLen, width=3).grid(row=row, column=1, sticky=tk.W, padx=6) + ttk.Label(frm, text='(ms, 0 to disable)').grid(row=row, column=1, sticky=tk.E, pady=6, padx=6) + + self.wTab.add(frm, text='Media') + + def onOk(self): + # Check basic settings + errors = ""; + if errors: + msgbox.showerror("Error detected:", errors) + return + + # Basic settings + self.cfg.epConfig.logConfig.filename = self.cfgLogFile.get() + flags = pj.PJ_O_APPEND if self.cfgLogAppend.get() else 0 + self.cfg.epConfig.logConfig.fileFlags = self.cfg.epConfig.logConfig.fileFlags | flags + + # Network settings + self.cfg.epConfig.uaConfig.nameserver.clear() + if len(self.cfgNameserver.get()): + self.cfg.epConfig.uaConfig.nameserver.append(self.cfgNameserver.get()) + self.cfg.epConfig.uaConfig.stunServer.clear() + if len(self.cfgStunServer.get()): + self.cfg.epConfig.uaConfig.stunServer.append(self.cfgStunServer.get()) + + self.cfg.epConfig.uaConfig.stunIgnoreFailure = self.cfgStunIgnoreError.get() + + self.cfg.udp.enabled = self.cfgUdpEnabled.get() + self.cfg.udp.config.port = self.cfgUdpPort.get() + self.cfg.tcp.enabled = self.cfgTcpEnabled.get() + self.cfg.tcp.config.port = self.cfgTcpPort.get() + self.cfg.tls.enabled = self.cfgTlsEnabled.get() + self.cfg.tls.config.port = self.cfgTlsPort.get() + + self.cfg.tls.config.tlsConfig.CaListFile = self.cfgTlsCaFile.get() + self.cfg.tls.config.tlsConfig.certFile = self.cfgTlsCertFile.get() + self.cfg.tls.config.tlsConfig.verifyClient = self.cfgTlsVerifyClient.get() + self.cfg.tls.config.tlsConfig.verifyServer = self.cfgTlsVerifyServer.get() + + # Media + self.cfg.epConfig.medConfig.clockRate = self.cfgClockrate.get() + self.cfg.epConfig.medConfig.sndClockRate = self.cfgSndClockrate.get() + self.cfg.epConfig.medConfig.audioFramePtime = self.cfgAudioPtime.get() + self.cfg.epConfig.medConfig.quality = self.cfgMediaQuality.get() + self.cfg.epConfig.medConfig.ptime = self.cfgCodecPtime.get() + self.cfg.epConfig.medConfig.noVad = not self.cfgVad.get() + self.cfg.epConfig.medConfig.ecTailLen = self.cfgEcTailLen.get() + + self.isOk = True + self.destroy() + + def onCancel(self): + self.destroy() + + +if __name__ == '__main__': + #application.main() + acfg = AppConfig() + acfg.loadFile('pygui.js') + + dlg = Dialog(None, acfg) + if dlg.doModal(): + acfg.saveFile('pygui.js') + \ No newline at end of file diff --git a/pjsip-apps/src/samples/debug.c b/pjsip-apps/src/samples/debug.c deleted file mode 100644 index 6f79d9f8..00000000 --- a/pjsip-apps/src/samples/debug.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $Id$ */ -/* - * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) - * Copyright (C) 2003-2008 Benny Prijono - * - * 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 - */ - -/* - * PURPOSE: - * The purpose of this file is to allow debugging of a sample application - * using MSVC IDE. - */ - -/* To debug a sample application, include the source file here. - * E.g.: - * #include "playfile.c" - */ -#include "icedemo.c" - diff --git a/pjsip-apps/src/samples/debug.cpp b/pjsip-apps/src/samples/debug.cpp new file mode 100644 index 00000000..6f79d9f8 --- /dev/null +++ b/pjsip-apps/src/samples/debug.cpp @@ -0,0 +1,32 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono + * + * 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 + */ + +/* + * PURPOSE: + * The purpose of this file is to allow debugging of a sample application + * using MSVC IDE. + */ + +/* To debug a sample application, include the source file here. + * E.g.: + * #include "playfile.c" + */ +#include "icedemo.c" + diff --git a/pjsip-apps/src/samples/pjsua2_demo.cpp b/pjsip-apps/src/samples/pjsua2_demo.cpp new file mode 100644 index 00000000..65a6a45f --- /dev/null +++ b/pjsip-apps/src/samples/pjsua2_demo.cpp @@ -0,0 +1,290 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2013 Teluu Inc. (http://www.teluu.com) + * + * 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 +#include +#include +#include + +using namespace pj; + +class MyAccount; + +class MyCall : public Call +{ +private: + MyAccount *myAcc; + +public: + MyCall(Account &acc, int call_id = PJSUA_INVALID_ID) + : Call(acc, call_id) + { + myAcc = (MyAccount *)&acc; + } + + virtual void onCallState(OnCallStateParam &prm); +}; + +class MyAccount : public Account +{ +public: + std::vector calls; + +public: + MyAccount() + {} + + ~MyAccount() + { + std::cout << "*** Account is being deleted: No of calls=" + << calls.size() << std::endl; + } + + void removeCall(Call *call) + { + for (std::vector::iterator it = calls.begin(); + it != calls.end(); ++it) + { + if (*it == call) { + calls.erase(it); + break; + } + } + } + + virtual void onRegState(OnRegStateParam &prm) + { + AccountInfo ai = getInfo(); + std::cout << (ai.regIsActive? "*** Register: code=" : "*** Unregister: code=") + << prm.code << std::endl; + } + + virtual void onIncomingCall(OnIncomingCallParam &iprm) + { + Call *call = new MyCall(*this, iprm.callId); + CallInfo ci = call->getInfo(); + CallOpParam prm; + + std::cout << "*** Incoming Call: " << ci.remoteUri << " [" + << ci.stateText << "]" << std::endl; + + calls.push_back(call); + prm.statusCode = (pjsip_status_code)200; + call->answer(prm); + } +}; + +void MyCall::onCallState(OnCallStateParam &prm) +{ + CallInfo ci = getInfo(); + std::cout << "*** Call: " << ci.remoteUri << " [" << ci.stateText + << "]" << std::endl; + + if (ci.state == PJSIP_INV_STATE_DISCONNECTED) { + myAcc->removeCall(this); + /* Delete the call */ + delete this; + } +} + +static void mainProg1() throw(Error) +{ + Endpoint ep; + + // Create library + ep.libCreate(); + + // Init library + EpConfig ep_cfg; + ep_cfg.logConfig.level = 4; + ep.libInit( ep_cfg ); + + // Transport + TransportConfig tcfg; + tcfg.port = 5060; + ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg); + + // Start library + ep.libStart(); + std::cout << "*** PJSUA2 STARTED ***" << std::endl; + + // Add account + AccountConfig acc_cfg; + acc_cfg.idUri = "sip:test1@pjsip.org"; + acc_cfg.regConfig.registrarUri = "sip:pjsip.org"; + acc_cfg.sipConfig.authCreds.push_back( AuthCredInfo("digest", "*", + "test1", 0, "test1") ); + std::auto_ptr acc(new MyAccount); + acc->create(acc_cfg); + + pj_thread_sleep(2000); + + // Make outgoing call + Call *call = new MyCall(*acc); + acc->calls.push_back(call); + CallOpParam prm(true); + prm.opt.audioCount = 1; + prm.opt.videoCount = 0; + call->makeCall("sip:test1@pjsip.org", prm); + + // Hangup all calls + pj_thread_sleep(8000); + ep.hangupAllCalls(); + pj_thread_sleep(4000); + + // Destroy library + std::cout << "*** PJSUA2 SHUTTING DOWN ***" << std::endl; +} + +void mainProg2() throw(Error) +{ + Endpoint ep; + + // Create library + ep.libCreate(); + + string json_str; + + { + EpConfig epCfg; + JsonDocument jDoc; + + epCfg.uaConfig.maxCalls = 61; + epCfg.uaConfig.userAgent = "Just JSON Test"; + epCfg.uaConfig.stunServer.push_back("stun1.pjsip.org"); + epCfg.uaConfig.stunServer.push_back("stun2.pjsip.org"); + epCfg.logConfig.filename = "THE.LOG"; + + jDoc.writeObject(epCfg); + json_str = jDoc.saveString(); + std::cout << json_str << std::endl << std::endl; + } + + { + EpConfig epCfg; + JsonDocument rDoc; + string output; + + rDoc.loadString(json_str); + rDoc.readObject(epCfg); + + JsonDocument wDoc; + + wDoc.writeObject(epCfg); + json_str = wDoc.saveString(); + std::cout << json_str << std::endl << std::endl; + + wDoc.saveFile("jsontest.js"); + } + + { + EpConfig epCfg; + JsonDocument rDoc; + + rDoc.loadFile("jsontest.js"); + rDoc.readObject(epCfg); + pj_file_delete("jsontest.js"); + } + + ep.libDestroy(); +} + +void mainProg() throw(Error) +{ + Endpoint ep; + + // Create library + ep.libCreate(); + + string json_str; + + { + JsonDocument jdoc; + AccountConfig accCfg; + + accCfg.idUri = "\"Just Test\" "; + accCfg.regConfig.registrarUri = "sip:pjsip.org"; + SipHeader h; + h.hName = "X-Header"; + h.hValue = "User header"; + accCfg.regConfig.headers.push_back(h); + + accCfg.sipConfig.proxies.push_back(""); + accCfg.sipConfig.proxies.push_back(""); + + accCfg.mediaConfig.transportConfig.tlsConfig.ciphers.push_back(1); + accCfg.mediaConfig.transportConfig.tlsConfig.ciphers.push_back(2); + accCfg.mediaConfig.transportConfig.tlsConfig.ciphers.push_back(3); + + AuthCredInfo aci; + aci.scheme = "digest"; + aci.username = "test"; + aci.data = "passwd"; + aci.realm = "*"; + accCfg.sipConfig.authCreds.push_back(aci); + + jdoc.writeObject(accCfg); + json_str = jdoc.saveString(); + std::cout << "Original:" << std::endl; + std::cout << json_str << std::endl << std::endl; + } + + { + JsonDocument rdoc; + + rdoc.loadString(json_str); + AccountConfig accCfg; + rdoc.readObject(accCfg); + + JsonDocument wdoc; + wdoc.writeObject(accCfg); + json_str = wdoc.saveString(); + + std::cout << "Parsed:" << std::endl; + std::cout << json_str << std::endl << std::endl; + } + + ep.libDestroy(); +} + +int main() +{ + int ret = 0; + + /* Test endpoint instantiation and destruction without libCreate(), + * libInit() etc. + */ + { + Endpoint ep; + ep.natDetectType(); + { + } + } + + try { + mainProg1(); + std::cout << "Success" << std::endl; + } catch (Error & err) { + std::cout << "Exception: " << err.info() << std::endl; + ret = 1; + } + + return ret; +} + + diff --git a/pjsip-apps/src/swig/Makefile b/pjsip-apps/src/swig/Makefile new file mode 100644 index 00000000..815e0e18 --- /dev/null +++ b/pjsip-apps/src/swig/Makefile @@ -0,0 +1,32 @@ +include ../../../build.mak + +ifneq ($(findstring android,$(TARGET_NAME)),) + # no python for android + DIRS = java +else + DIRS = python java +endif + +export SWIG_FLAGS=-I../../../../pjlib/include \ + -I../../../../pjlib-util/include \ + -I../../../../pjmedia/include \ + -I../../../../pjsip/include \ + -I../../../../pjnath/include -c++ +export SRC_DIR=../../../../pjsip/include +export SRCS=$(SRC_DIR)/pjsua2/endpoint.hpp $(SRC_DIR)/pjsua2/types.hpp + +.PHONY: all clean dep depend distclean print realclean install uninstall + +all: symbols.i + +all clean dep depend distclean print realclean install uninstall: + for dir in $(DIRS); do \ + if $(MAKE) $(MAKE_FLAGS) -C $$dir $@; then \ + true; \ + else \ + exit 1; \ + fi; \ + done + +symbols.i: symbols.lst + python importsym.py diff --git a/pjsip-apps/src/swig/importsym.py b/pjsip-apps/src/swig/importsym.py new file mode 100644 index 00000000..32faf2cc --- /dev/null +++ b/pjsip-apps/src/swig/importsym.py @@ -0,0 +1,193 @@ +# $Id$ +# +# importsym.py: Import C symbol decls (structs, enums, etc) and write them +# to another file +# +# Copyright (C)2013 Teluu Inc. (http://www.teluu.com) +# +# 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 +# +import pycparser +from pycparser import c_generator +import sys +import os + +def which(program): + import os + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + if sys.platform == 'win32' and not program.endswith(".exe"): + program += ".exe" + + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + return None + +# +PJ_ROOT_PATH = "../../../" + +# CPP is needed by pycparser. +CPP_PATH = which("cpp") +if not CPP_PATH: + print 'Error: need to have cpp in PATH' + sys.exit(1) + +# Hardcoded! +if sys.platform == 'win32': + PYCPARSER_DIR="C:/devs/tools/pycparser" +elif sys.platform == "linux2": + PYCPARSER_DIR="/home/bennylp/Desktop/opt/src/pycparser-master" +else: + PYCPARSER_DIR="/Library/Python/2.7/site-packages/pycparser" + +if not os.path.exists(PYCPARSER_DIR + '/utils/fake_libc_include'): + print "Error: couldn't find pycparser utils in '%s'" % PYPARSER_DIR + sys.exit(1) + +# Heading, to be placed before the source files +C_HEADING_SECTION = """ +#define PJ_AUTOCONF 1 +#define jmp_buf int +#define __attribute__(x) +""" + +# CPP (C preprocessor) settings +CPP_CFLAGS = [ + '-I' + PYCPARSER_DIR + '/utils/fake_libc_include', + "-I" + PJ_ROOT_PATH + "pjlib/include", + "-I" + PJ_ROOT_PATH + "pjlib-util/include", + "-I" + PJ_ROOT_PATH + "pjnath/include", + "-I" + PJ_ROOT_PATH + "pjmedia/include", + "-I" + PJ_ROOT_PATH + "pjsip/include" + ] + + +class SymbolVisitor(pycparser.c_ast.NodeVisitor): + def __init__(self, names): + self.nodeDict = {} + for name in names: + self.nodeDict[name] = None + + def _add(self, node): + if self.nodeDict.has_key(node.name): + self.nodeDict[node.name] = node + + def visit_Struct(self, node): + self._add(node) + + def visit_Enum(self, node): + self._add(node) + + def visit_Typename(self, node): + self._add(node) + + def visit_Typedef(self, node): + self._add(node) + + +TEMP_FILE="tmpsrc.h" + +class SymbolImporter: + """ + Import C selected declarations from C source file and move it + to another file. + + Parameters: + - listfile Path of file containing list of C source file + and identifier names to be imported. The format + of the listfile is: + + filename name1 name2 name3 + + for example: + + pj/sock_qos.h pj_qos_type pj_qos_flag + pj/types.h pj_status_t PJ_SUCCESS + """ + def __init__(self): + pass + + def process(self, listfile, outfile): + + # Read listfile + f = open(listfile) + lines = f.readlines() + f.close() + + # Process each line in list file, while generating the + # temporary C file to be processed by pycparser + f = open(TEMP_FILE, "w") + f.write(C_HEADING_SECTION) + names = [] + fcnt = 0 + for line in lines: + spec = line.split() + if len(spec) < 2: + continue + fcnt += 1 + f.write("#include <%s>\n" % spec[0]) + names.extend(spec[1:]) + f.close() + print 'Parsing %d symbols from %d files..' % (len(names), fcnt) + + # Parse the temporary C file + ast = pycparser.parse_file(TEMP_FILE, use_cpp=True, cpp_path=CPP_PATH, cpp_args=CPP_CFLAGS) + os.remove(TEMP_FILE) + + # Filter the declarations that we wanted + print 'Filtering..' + visitor = SymbolVisitor(names) + visitor.visit(ast) + + # Print symbol declarations to outfile + print 'Writing declarations..' + f = open(outfile, 'w') + f.write("// This file is autogenerated by importsym script, do not modify!\n\n") + gen = pycparser.c_generator.CGenerator() + for name in names: + node = visitor.nodeDict[name] + if not node: + print " ** Warning: declaration for '%s' is not found **" % k + else: + print " writing '%s'.." % name + output = gen.visit(node) + ";\n\n" + f.write(output) + f.close() + print "Done." + + +if __name__ == "__main__": + print "Importing symbols: 'symbols.lst' --> 'symbols.i'" + si = SymbolImporter() + si.process("symbols.lst", "symbols.i") + try: + os.remove("lextab.py") + except OSError: + pass + try: + os.remove("yacctab.py") + except OSError: + pass + + \ No newline at end of file diff --git a/pjsip-apps/src/swig/java/Makefile b/pjsip-apps/src/swig/java/Makefile new file mode 100644 index 00000000..1946891f --- /dev/null +++ b/pjsip-apps/src/swig/java/Makefile @@ -0,0 +1,124 @@ +include ../../../../build.mak + +ifneq ($(findstring android,$(TARGET_NAME)),) + OS=android +else + ifneq ($(findstring darwin,$(TARGET_NAME)),) + OS=darwin + endif +endif + +OUT_DIR=output +ifeq ($(OS),Windows_NT) + LIBPJSUA2_SO=$(OUT_DIR)/pjsua2.dll +else + ifeq ($(OS),darwin) + LIBPJSUA2_SO=$(OUT_DIR)/libpjsua2.jnilib + else + ifeq ($(OS),android) + LIBPJSUA2_SO=android/libs/armeabi/libpjsua2.so + else + LIBPJSUA2_SO=$(OUT_DIR)/libpjsua2.so + endif + endif +endif + +# Get JDK location +ifeq ("$(JAVA_HOME)","") + # Get javac location to determine JDK location + JAVAC_PATH = $(shell which javac) + ifeq ("$(JAVAC_PATH)","") + $(error Cannot determine JDK location using 'which' command. Please define JAVA_HOME envvar) + endif + + JAVAC_PATH := $(realpath $(JAVAC_PATH)) + JAVA_BIN := $(dir $(JAVAC_PATH)) + JAVA_HOME := $(patsubst %/bin/,%,$(JAVA_BIN)) +else + ifeq (exists, $(shell test -d $(JAVA_HOME)/bin && echo exists )) + JAVA_BIN := $(JAVA_HOME)/bin + else + JAVA_BIN := $(JAVA_HOME) + endif +endif + +# OS specific +ifeq ($(OS),Windows_NT) + MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,--kill-at +else + MY_JNI_CFLAGS = -fPIC + MY_JNI_LDFLAGS = -L$(MY_JDK)/lib + ifeq ($(OS),darwin) + MY_JNI_LDFLAGS := $(MY_JNI_LDFLAGS) -Wl,-soname,pjsua2.so + endif + ifeq ($(OS),android) + MY_JNI_CFLAGS := $(MY_JNI_CFLAGS) -D__ANDROID__ + endif +endif + +# Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe) +MY_SWIG = swig +MY_JDK = $(JAVA_HOME) +ifneq ($(findstring bin,$(JAVA_BIN)),) + MY_JAVA = $(MY_JDK)/bin/java + MY_JAVAC = $(MY_JDK)/bin/javac +else + MY_JAVA = $(MY_JDK)/java + MY_JAVAC = $(MY_JDK)/javac +endif +MY_JNI_CFLAGS := $(MY_JNI_CFLAGS) -I$(MY_JDK)/include -I$(MY_JDK)/include/win32 \ + -I$(MY_JDK)/include/linux -I. + +# Build settings +MY_CFLAGS = $(PJ_CFLAGS) $(MY_JNI_CFLAGS) +MY_LDFLAGS = $(PJ_LDFLAGS) -lpjsua2-$(TARGET_NAME) $(PJ_LDLIBS) $(MY_JNI_LDFLAGS) +MY_PACKAGE_NAME = org.pjsip.pjsua2 +ifeq ($(OS),android) + MY_PACKAGE_PATH = android/src/$(subst .,/,$(MY_PACKAGE_NAME)) +else + MY_PACKAGE_PATH = $(OUT_DIR)/$(subst .,/,$(MY_PACKAGE_NAME)) +endif + +MY_APP_JAVA = android/src/$(subst .,/,$(MY_PACKAGE_NAME))/app/MyApp.java + +.PHONY: all java install uninstall + +all: $(LIBPJSUA2_SO) java + +$(LIBPJSUA2_SO): $(OUT_DIR)/pjsua2_wrap.o + $(PJ_CXX) -shared -o $(LIBPJSUA2_SO) $(OUT_DIR)/pjsua2_wrap.o $(MY_CFLAGS) $(MY_LDFLAGS) + +$(OUT_DIR)/pjsua2_wrap.o: $(OUT_DIR)/pjsua2_wrap.cpp Makefile + $(PJ_CXX) -c $(OUT_DIR)/pjsua2_wrap.cpp -o $(OUT_DIR)/pjsua2_wrap.o $(MY_CFLAGS) $(MY_LDFLAGS) + +$(OUT_DIR)/pjsua2_wrap.cpp: ../pjsua2.i ../symbols.i $(SRCS) + mkdir -p $(MY_PACKAGE_PATH) + swig $(SWIG_FLAGS) -java -package $(MY_PACKAGE_NAME) -outdir $(MY_PACKAGE_PATH) -o $(OUT_DIR)/pjsua2_wrap.cpp ../pjsua2.i + +clean distclean realclean: + rm -rf $(LIBPJSUA2_SO) $(OUT_DIR)/* $(MY_PACKAGE_PATH)/*.java $(MY_PACKAGE_PATH)/*.class + +java: $(MY_PACKAGE_PATH)/Error.class $(MY_PACKAGE_PATH)/test.class $(MY_PACKAGE_PATH)/sample.class + +$(MY_PACKAGE_PATH)/Error.class: $(MY_PACKAGE_PATH)/Error.java + $(MY_JAVAC) -d $(OUT_DIR) $(MY_PACKAGE_PATH)/*.java $(MY_APP_JAVA) + +$(MY_PACKAGE_PATH)/test.class: test.java + $(MY_JAVAC) -d $(OUT_DIR) -classpath "$(OUT_DIR)" test.java + +$(MY_PACKAGE_PATH)/sample.class: sample.java + $(MY_JAVAC) -d $(OUT_DIR) -classpath "$(OUT_DIR)" sample.java + +test: + @# Need to specify classpath and library path, alternatively, they can be set via + @# CLASSPATH and java.library.path env settings + $(MY_JAVA) -cp "$(OUT_DIR)" -Djava.library.path="$(OUT_DIR)" test + +sample: + @# Need to specify classpath and library path, alternatively, they can be set via + @# CLASSPATH and java.library.path env settings + $(MY_JAVA) -cp "$(OUT_DIR)" -Djava.library.path="$(OUT_DIR)" org.pjsip.pjsua2.app.sample + +install: +uninstall: + diff --git a/pjsip-apps/src/swig/java/android/.classpath b/pjsip-apps/src/swig/java/android/.classpath new file mode 100644 index 00000000..b76ec6cd --- /dev/null +++ b/pjsip-apps/src/swig/java/android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/pjsip-apps/src/swig/java/android/.project b/pjsip-apps/src/swig/java/android/.project new file mode 100644 index 00000000..434a3408 --- /dev/null +++ b/pjsip-apps/src/swig/java/android/.project @@ -0,0 +1,33 @@ + + + Pjsua2 + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/pjsip-apps/src/swig/java/android/.settings/org.eclipse.jdt.core.prefs b/pjsip-apps/src/swig/java/android/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..48ab4c6b --- /dev/null +++ b/pjsip-apps/src/swig/java/android/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/pjsip-apps/src/swig/java/android/AndroidManifest.xml b/pjsip-apps/src/swig/java/android/AndroidManifest.xml new file mode 100644 index 00000000..5a9b0aef --- /dev/null +++ b/pjsip-apps/src/swig/java/android/AndroidManifest.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pjsip-apps/src/swig/java/android/ic_launcher-web.png b/pjsip-apps/src/swig/java/android/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/pjsip-apps/src/swig/java/android/ic_launcher-web.png differ diff --git a/pjsip-apps/src/swig/java/android/jni/Android.mk b/pjsip-apps/src/swig/java/android/jni/Android.mk new file mode 100644 index 00000000..94912baf --- /dev/null +++ b/pjsip-apps/src/swig/java/android/jni/Android.mk @@ -0,0 +1,12 @@ +include ../../../../../build.mak + +LOCAL_PATH := $(PJDIR)/pjsip-apps/src/swig/java/android +include $(CLEAR_VARS) + +LOCAL_MODULE := libpjsua2 +LOCAL_CFLAGS := $(APP_CFLAGS) -frtti -fexceptions +LOCAL_LDFLAGS := $(APP_LDFLAGS) +LOCAL_LDLIBS := $(APP_LDLIBS) +LOCAL_SRC_FILES := ../output/pjsua2_wrap.cpp + +include $(BUILD_SHARED_LIBRARY) diff --git a/pjsip-apps/src/swig/java/android/jni/Application.mk b/pjsip-apps/src/swig/java/android/jni/Application.mk new file mode 100644 index 00000000..87124dd8 --- /dev/null +++ b/pjsip-apps/src/swig/java/android/jni/Application.mk @@ -0,0 +1 @@ +APP_STL := gnustl_static diff --git a/pjsip-apps/src/swig/java/android/proguard-project.txt b/pjsip-apps/src/swig/java/android/proguard-project.txt new file mode 100644 index 00000000..f2fe1559 --- /dev/null +++ b/pjsip-apps/src/swig/java/android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/pjsip-apps/src/swig/java/android/project.properties b/pjsip-apps/src/swig/java/android/project.properties new file mode 100644 index 00000000..0840b4a0 --- /dev/null +++ b/pjsip-apps/src/swig/java/android/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-15 diff --git a/pjsip-apps/src/swig/java/android/res/drawable-hdpi/ic_launcher.png b/pjsip-apps/src/swig/java/android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/pjsip-apps/src/swig/java/android/res/drawable-hdpi/ic_launcher.png differ diff --git a/pjsip-apps/src/swig/java/android/res/drawable-mdpi/ic_launcher.png b/pjsip-apps/src/swig/java/android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/pjsip-apps/src/swig/java/android/res/drawable-mdpi/ic_launcher.png differ diff --git a/pjsip-apps/src/swig/java/android/res/drawable-xhdpi/ic_launcher.png b/pjsip-apps/src/swig/java/android/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/pjsip-apps/src/swig/java/android/res/drawable-xhdpi/ic_launcher.png differ diff --git a/pjsip-apps/src/swig/java/android/res/drawable-xxhdpi/ic_launcher.png b/pjsip-apps/src/swig/java/android/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/pjsip-apps/src/swig/java/android/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/pjsip-apps/src/swig/java/android/res/drawable/bkg.xml b/pjsip-apps/src/swig/java/android/res/drawable/bkg.xml new file mode 100644 index 00000000..f5052332 --- /dev/null +++ b/pjsip-apps/src/swig/java/android/res/drawable/bkg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/pjsip-apps/src/swig/java/android/res/layout/activity_call.xml b/pjsip-apps/src/swig/java/android/res/layout/activity_call.xml new file mode 100644 index 00000000..3745eb39 --- /dev/null +++ b/pjsip-apps/src/swig/java/android/res/layout/activity_call.xml @@ -0,0 +1,41 @@ + + + + + + + +