Thanks to Samuel who made this possible for iphone, the text below is taken from the following site with few modification to compile it successfully for iphone.

link: http://code.google.com/p/siphon/wiki/CompilationForiPhoneOS2_X

Lets begin, download the 1.0.x release of pjproject from the pjsip website, i have given link below for ease.

link: http://www.pjsip.org/download.htm

(note: GNU Linux/MacOS X/Unix users should use the .tar.bz2 version, so download the .tar.bz2 file else it won’t work)

Follow the following steps to modify few file, please carefully follow it as its a bit different from the one available at the above mentioned website.

note: before you begin, if you are copying directly from the site then be careful as some characters are not copied properly and can cause error when you try to compile pjsip.

Step 1: aconfigure.ac

In aconfigure.ac file add the lines below displayed with ‘+’. Of course copy without ‘+’

if test “$enable_sound” = “no”; then
true;
else
case $target in
+ arm-apple-darwin*)
+ LIBS=”$LIBS -framework CoreAudio -framework CoreFoundation -framework AudioToolbox”
+ ac_pjmedia_snd=iphone
+ AC_MSG_RESULT([Checking sound device backend... AudioQueue])
+ ;;
*darwin*)
LIBS=”$LIBS -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox”
if test “`uname -r`” = “6.8″; then

Step 2: build/rules.mak

In rules.mak modify, remove lines with ‘-’ and add lines with ‘+’:

$(LIB): $(OBJDIRS) $(OBJS) $($(APP)_EXTRA_DEP)
if test ! -d $(LIBDIR); then $(subst @@,$(subst /,$(HOST_PSEP),$(LIBDIR)),$(HOST_MKDIR)); fi
- $(AR) $(LIB) $(OBJS)
- $(RANLIB) $(LIB)
+ $(RANLIB) -static -o $(LIB) $(OBJS)

Step 3: pjlib/include/pj/config_site.h

It can be necessary to define some macro. For example :

#undef PJ_HAS_FLOATING_POINT
#define PJ_HAS_FLOATING_POINT 1

/* SRTP has not been ported to iPhone yet */
# undef PJMEDIA_HAS_SRTP
# define PJMEDIA_HAS_SRTP 0

/* Disable some codecs for now */
# define PJMEDIA_HAS_GSM_CODEC 1
# define PJMEDIA_HAS_L16_CODEC 0
# define PJMEDIA_HAS_ILBC_CODEC 0
# define PJMEDIA_HAS_SPEEX_CODEC 0
# define PJMEDIA_HAS_G722_CODEC 0

Step 4: pjmedia/build/os-auto.mak.in

In os-auto.mak.in, add the line with ‘+’

# – ds: Win32 DirectSound (dsound.c)
+# – iphone: iPhone AudioQueue (iphonesound.c)
# – null: Null sound device (nullsound.c)

Add the line below, for example between “Win 32 Direct Sound” and ” Null Sound Device”

#
# iPod/iPhone
#
ifeq ($(AC_PJMEDIA_SND),iphone)
export SOUND_OBJS = iphonesound.o
export CFLAGS += -DPJMEDIA_SOUND_IMPLEMENTATION=PJMEDIA_SOUND_IPHONE_SOUND
endif

We have defined a new target for sound device.

Step 5: pjmedia/include/pjmedia/config.h

in config.h add the lines below with ‘+’:

/** Constant for Win32 MME sound backend. */
#define PJMEDIA_SOUND_WIN32_MME_SOUND 3

+/** Constant for AudioQueue sound backend. */
+#define PJMEDIA_SOUND_IPHONE_SOUND 4

Almost there few steps more…

Step 6: pjmedia/src/pjmedia

Download iphonesound from the link below, rename it to iphonesound.c and paste it in the above mentioned directory.

link: http://siphon.googlecode.com/files/iphonesound-20091226.c

note: currently sound is disabled, but will get back to this, first follow the next 2 steps to get the lib compiled.

Step 7: Configuration

Generate configuration script

autoconf aconfigure.ac > aconfigure

Step 8: Compilation

iPhone SDK doesn't provide some programs without version number, so we create symbolic link. We should test before create link, but we are very lazy. Copy the lines below in file with name like compile.sh in the root of pjsip.

#!/bin/sh

export DEV=/Developer/Platforms/iPhoneOS.platform/Developer
export SDK=${DEV}/SDKs/iPhoneOS2.1.sdk

pushd ${DEV}/usr/bin
ln -s arm-apple-darwin9-gcc-4.0.1 arm-apple-darwin9-gcc
ln -s arm-apple-darwin9-g++-4.0.1 arm-apple-darwin9-g++
ln -s ranlib arm-apple-darwin9-ranlib
popd

export PATH=${DEV}/usr/bin:${PATH}

export CFLAGS="-O2 -arch armv6 -isysroot ${SDK}"

export LDFLAGS="-O2 -arch armv6 -isysroot ${SDK}"

export CPP="${DEV}/usr/bin/cpp"

./aconfigure --host=arm-apple-darwin9 --disable-speex-aec \
--disable-speex-codec --disable-l16-codec --disable-g722-codec \
--disable-ilbc-codec --disable-ssl --disable-sound

make dep
make

We must not forget to change access right to allow execution. We can run compile.sh after some minutes pjsip is compiled.

Step 9: Now for Sound

Assume that you have been able to successfully compile the pjsip lib by now.

Now open iphonesound.c that you have pasted a little while back and uncomment and comment the following line(s).

//#if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_IPHONE_SOUND
#if PJMEDIA_AUDIO_LEG_HAS_AUDIOQUEUE

change the above to

#if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_IPHONE_SOUND
//#if PJMEDIA_AUDIO_LEG_HAS_AUDIOQUEUE

secondly search for the following in iphonesound.c

PJMEDIA_AUD_DEFAULT_CAPTURE_DEV
PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV

and replace with -1 and -2 respectively and now remove the ‘–disable-sound’ from the compile.sh you created and recompile.

That’s it … now you should have working pjsip lib and you can add this in the siphon project and you are good to go.

Comments and suggestion are welcome but please be constructive.

P.S. i have tested this on iphone 3Gs, 3G and 2G, sound in 2G is not that good but rest is working fine and in 3Gs and 3G sound is perfect.

Regards
Syed Arsalan Pervez aka SAP