Text taken from: http://www.piemontewireless.net/PJSip155_and_iPhoneSDK312

Thanks to huge work of PJSip team and to Samuel Vinson for iphonesound.c code.

Checkout the latest svn trunk version of PJSip from here:

http://svn.pjsip.org/repos/pjproject/trunk

or download the latest PJSIP from here:

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

First step, you need to patches some files in pjproject:

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

#define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 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)

and

export CFLAGS += -DPJMEDIA_AUDIO_DEV_HAS_WMME=0
endif

+#
+# iPod/iPhone
+#
+ifeq ($(AC_PJMEDIA_SND),iphone)
+export CFLAGS += -DPJMEDIA_AUDIO_LEG_HAS_AUDIOQUEUE=1 -DPJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE=1
+endif
+
#
# Null sound device

Step 6: Makefile

In Makefile (located at the root), add the line with ‘+’

-DIRS = pjlib pjlib-util pjnath third_party pjmedia pjsip pjsip-apps
+DIRS = pjlib pjlib-util pjnath third_party pjmedia pjsip

Step 7: pjmedia/build/Makefile

export PJMEDIA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
alaw_ulaw.o alaw_ulaw_table.o bidirectional.o clock_thread.o codec.o \
conference.o conf_switch.o delaybuf.o echo_common.o \
echo_port.o echo_suppress.o endpoint.o errno.o \
g711.o jbuf.o master_port.o mem_capture.o mem_player.o \
null_port.o plc_common.o port.o splitcomb.o \
resample_resample.o resample_libsamplerate.o \
resample_port.o rtcp.o rtcp_xr.o rtp.o \
sdp.o sdp_cmp.o sdp_neg.o session.o silencedet.o \
- sound_legacy.o sound_port.o stereo_port.o \
+ iphonesound.o sound_port.o stereo_port.o \
stream.o tonegen.o transport_adapter_sample.o \
transport_ice.o transport_loop.o \
transport_srtp.o transport_udp.o \
wav_player.o wav_playlist.o wav_writer.o wave.o \
wsola.o

# $(TARGET) is defined in os-$(OS_NAME).mak file in current directory.
#
-TARGETS := pjmedia pjmedia-audiodev pjmedia-codec pjsdp pjmedia-test
+TARGETS := pjmedia pjmedia-audiodev pjmedia-codec pjsdp

all: $(TARGETS)

Step 8: pjmedia/src/pjmedia-audiodev/legacy_dev.c

In legacy_dev.c, add the line with ‘+’

return status;
}

*p_aud_strm = &strm->base;
+ (*p_aud_strm)->op = &stream_op;
return PJ_SUCCESS;
}

Step 9: pjmedia/src/pjmedia-audiodev/audiodev.c

pjmedia_aud_dev_factory* pjmedia_symb_mda_factory(pj_pool_factory *pf);
#endif

+#if PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE
+pjmedia_aud_dev_factory* pjmedia_legacy_factory(pj_pool_factory *pf);
+#endif
+
#define MAX_DRIVERS 16
#define MAX_DEVS 64

#if PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA
aud_subsys.drv[aud_subsys.drv_cnt++].create = &pjmedia_symb_mda_factory;
#endif
+#if PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE
+ aud_subsys.drv[aud_subsys.drv_cnt++].create = &pjmedia_legacy_factory;
+#endif

/* Initialize each factory and build the device ID list */
for (i=0; i

Download iphonesound.c

Download from http://siphon.googlecode.com/files/iphonesound-20091226.c and rename in pjmedia/src/pjmedia/iphonesound.c

Step 10: Configuration

Generate configuration script

autoconf aconfigure.ac > aconfigure

Step 11: 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

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.

Thanks to Simone, for this wonderful guide.

Text taken from: http://www.piemontewireless.net/PJSip155_and_iPhoneSDK312

Regards
Syed Arsalan Pervez aka SAP