Getting Started: Building for Apple iPhone, iPad and iPod Touch ¶
Apple iOS target is supported by PJSIP version 1.7 and later.
Features ¶
Some of the features of the iPhone port:
Requirements ¶
Build Preparation ¶
Building PJSIP ¶
Just run:
$ cd /path/to/your/pjsip/dir
$ ./configure-iphone
$ make dep && make clean && make
For iPhone 5, use armv7s architecture:
$ cd /path/to/your/pjsip/dir
$ ARCH='-arch armv7s' ./configure-iphone
$ make dep && make clean && make
Open ipjsua.xcodeproj using Xcode in pjproject/pjsip-apps/src/pjsua/ios and build the project. You will see telnet instructions on the device's screen. Telnet to this address to operate the application. See PJSUA CLI Manual for commands available. (For release 2.1 and below, ipjsua is located in pjproject/pjsip-apps/src/ipjsua and does not have CLI telnet feature).
Notes:
Simulator ¶
To configure the build system for the iPhone simulator:
export DEVPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
ARCH="-arch i386" CFLAGS="-O2 -m32 -miphoneos-version-min=4.0" LDFLAGS="-O2 -m32 -miphoneos-version-min=4.0" ./configure-iphone
make dep && make clean && make
Note that the exact paths may vary according to your SDK version.
OpenSSL Suport ¶
Follow the instructions below to enable TLS transport by using OpenSSL:
Common problems ¶
Unable to accept incoming call in background mode (iOS4) ¶
If while in the background, ipjsua (or your application) is unable to detect if there is an incoming call and display the local notification:
Note: these steps do not troubleshoot audio problems.
Audio session management issue (iOS7) ¶
Since the deprecation of C-interface Audio Session API in iOS 7 SDK, PJSIP now uses AVAudioSession to set audio session category (to PlayAndRecord?) and activate/deactivate audio session. Application will need to do its own audio session management to handle input/output route and notifications (interruption, media server reset, etc). Please refer to Apple's official doc on Audio Session Programming Guide and our ticket #1697.
Audio issue (no audio) (iOS7) ¶
There are a few reports that the audio is not working on iOS 7 (so far it's only reported to happen in iPhone 5) after getting the following error:
iPhone mediaserverd[45] <Error>: 10:53:59.986 ERROR: [0x240b000] 740: _vp: initialize hw input: fs mismatched! REF=0.000000Hz, MIC=44100.000000Hz
iPhone mediaserverd[45] <Error>: Resampler2 bad sample rate(s) : 0.00 16000.00
One solution is to set the sound device's clock rate to 44100 Hz as to avoid resampling.
Supporting multiple architectures (armv6, armv7, armv7s, and so on) ¶
You need to compile separately for each architecture. If your iPhone SDK has llvm-gcc compiler (which is the supported compiler starting iOS SDK 5) or clang, then you need to set ARCH environment variable to the desired architecture before running configure-iphone, for example:
export ARCH = "-arch armv6"
Then you need to combine the resulting libraries using the lipo command. For example:
lipo -arch armv6 lib/armv6/libpjlib.a -arch armv7 lib/armv7/libpjlib.a -create -output lib/libpjlib.a
Unable to support Bluetooth input ¶
Since Bluetooth input support is only available for iOS 3.1 or later, you need to specifically specify that your deployment target is iOS 3.1 or above. You can do this either in user.mak:
export CFLAGS += -D__IPHONE_OS_VERSION_MIN_REQUIRED=30100
or in config_site.h:
#define __IPHONE_OS_VERSION_MIN_REQUIRED 30100
You need to recompile PJSIP after this.
Problem with interruption (by a phone call or an alarm), headset plug/unplug, or Bluetooth input ¶
For devices running iOS 4.0 or later, you need to enable your application to respond to remote-control events. This allows PJSIP to properly receive and process the above events. You can do this by adding the following code in your application:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
For more details, please refer to Apple's doc on Remote Control of Multimedia.
Sound not working in the simulator ¶
Go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects". If it still doesn't work, you can try some other suggestions here.
List of Issues ¶
iPhone: Echo cancellation may not work on iOS using SDK 4.x
iPhone: Long delay when calling AudioConverterNew() causing timeout in acquiring pjsua lock (thanks Bogdan Krakowski the report)
Incoming TCP connection on iPhone iOS4 BG mode would fail over and over with EAGAIN error (thanks Bogdan Krakowski for the report)
Crash in coreaudio_dev (iPhone OS) when there is no call during a GSM interruption
Fix crash in coreaudio_dev's interruptionListener (iPhone OS) and support for multiple interrupted streams (thanks to Seth Hinze for the patch)
iPhone: Fix problems with echo cancellation and Bluetooth input (SDK 4.x)
iPhone: UDP socket send error after waking up from background mode (thanks Joe Meade for the report)
iPhone (info only): No audio in calls if app is woken up from background mode without network connectivity (thanks Joe Meade for the report)
Long delay in iPhone initialization (thanks Guy Zelkha for the report)
Crash in iPhone iOS when trying to make a call after the application is left running for days (thanks Alejandro Orellana for the report)
Assertion may be raised if iPhone app woken up to perform registration and the server is down (thanks Alejandro Orellana for the report)
Use CFHost API for pj_getaddrinfo() on iPhone OS
Build correctness on non-video platforms (Symbian, iPhone, Windows Mobile)
Fixes assertion when interruptionListener is called from an unregistered thread on iPhone OS (thanks to Ilya Kalinin for the patch)
Disable local host resolution on iPhone OS
Handle socket failure in STUN resolution when coming back from iPhone/iOS background mode
Other iPhone Projects ¶
Also have a look at these PJSIP iPhone ports by pjsip users:
Attachments