Compile available codecs in PJSip with iPhoneSDK312

Da PiemonteWireless.

Indice

How compile available codecs in PJSip svn trunk (or 1.5.5) with iPhone SDK3.1.2

After you compiled successful PJSip with iPhone SDK3.1.2 (look this howto), with other little changes you can compile all the available codecs too.


You need to patches some files in pjproject:

In build.mak.in

 APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/lib/libg7221codec-$(LIB_SUFFIX)
 endif
 
+ifeq (@ac_has_g729_codec@,1)
+APP_THIRD_PARTY_LIBS += -lg729codec-$(TARGET_NAME)
+APP_THIRD_PARTY_LIB_FILES += $(PJ_DIR)/third_party/g729/lib
+endif
+


In pjmedia/build/os-auto.mak.in

 AC_NO_G722_CODEC=@ac_no_g722_codec@
 AC_NO_G7221_CODEC=@ac_no_g7221_codec@
+AC_HAS_G729_CODEC=@ac_has_g729_codec@
 
 export CODEC_OBJS=


and


 export G7221_CFLAGS += -I$(THIRD_PARTY)
 endif
 
+ifeq ($(AC_HAS_G729_CODEC),1)
+export CFLAGS += -I$(THIRD_PARTY)/g729/include -DPJMEDIA_HAS_G729_CODEC=1
+export CODEC_OBJS += g729.o
+endif
 
 #
 # PortAudio


In pjmedia/include/pjmedia-codec/config.h

 #   define PJMEDIA_HAS_G722_CODEC    1
 #endif
 
+/**
+ * Unless specified otherwise, G.729 codec is not included by default.
+ */
+#ifndef PJMEDIA_HAS_G729_CODEC
+#   define PJMEDIA_HAS_G729_CODEC    0
+#endif
 
 /**
  * Enable the features provided by Intel IPP libraries, for example


In pjmedia/include/pjmedia-codec/config_auto.h.in

 #undef PJMEDIA_HAS_G7221_CODEC
 #endif
 
+/* G729 codec */
+#ifndef PJMEDIA_HAS_G729_CODEC
+#undef PJMEDIA_HAS_G729_CODEC
+#endif
 
 #endif /* __PJMEDIA_CODEC_CONFIG_AUTO_H_ */


In pjmedia/include/pjmedia-codec.h

 #include <pjmedia-codec/ilbc.h>
 #include <pjmedia-codec/g722.h>
 #include <pjmedia-codec/g7221.h>
+#include <pjmedia-codec/g729.h>
 #include <pjmedia-codec/ipp_codecs.h>
 #include <pjmedia-codec/passthrough.h>


In aconfigure.ac

              AC_MSG_RESULT([Skipping libsamplerate detection])
             )
 
+dnl ########################################################
+dnl # G.729 support
+dnl #
+AC_SUBST(ac_has_g729_codec)
+AC_ARG_ENABLE(g729_codec,
+    AC_HELP_STRING([--enable-g729-codec],
+       [Enable g729 support (derived from ITU implementation).]),
+        [ac_has_g729_codec=1]
+        AC_DEFINE(PJMEDIA_HAS_G729_CODEC,1)
+        AC_MSG_RESULT([Checking if g729 codec is disabled...no]),
+    [ac_has_g729_codec=]
+    AC_MSG_RESULT([Checking if g729 codec is disabled...yes])
+    )
 
 dnl ########################################################
 dnl # Intel IPP support


In pjsip/src/pjsua-lib/pjsua_media.c

        return status;
    }
#endif /* PJMEDIA_HAS_G7221_CODEC */

+#if PJMEDIA_HAS_G729_CODEC
+    status = pjmedia_codec_g729_init(pjsua_var.med_endpt);
+    if (status != PJ_SUCCESS) {
+        pjsua_perror(THIS_FILE, "Error initializing G729 codec", status);
+        return status;
+    }
+#endif /* PJMEDIA_HAS_G729_CODEC */

#if PJMEDIA_HAS_L16_CODEC


In third_party/build/os-auto.mak.in

ifneq (@ac_no_g7221_codec@,1)
DIRS += g7221
endif

+ifeq (@ac_has_g729_codec@,1)
+DIRS += g729
+endif
+
ifneq ($(findstring pa,@ac_pjmedia_snd@),)


Download files

Download this file: File:G729.c

and move it in pjmedia/src/pjmedia-codec/g729.c

Download this file: File:G729.h

and move it in pjmedia/include/pjmedia-codec/g729.h

Download this file: File:G729-iphoneSdk312.zip

uncompress it, then copy its g729/ directory in third_party/ directory.

Now create a directory named third_party/build/g729/ and move the file third_party/g729/Makefile in third_party/build/g729/ directory.


In pjlib/include/pj/config_site.h

Enable the codecs you want to use and add the G729 one. For now don't use SPEEX codec; I've tested also iLBC and it doesn't works well, instead the G729 works very well.

#define PJMEDIA_HAS_GSM_CODEC 1
#define PJMEDIA_HAS_L16_CODEC 1
#define PJMEDIA_HAS_ILBC_CODEC 1
#define PJMEDIA_HAS_SPEEX_CODEC 0
#define PJMEDIA_HAS_G722_CODEC 1
#define PJMEDIA_HAS_G729_CODEC 1


Now setup a develop environment:

Env variables

export DEV=/Developer/Platforms/iPhoneOS.platform/Developer
export SDK=${DEV}/SDKs/iPhoneOS3.1.2.sdk
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"


Symb links to arm compiler

cd ${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


It's time to start compilation, finally!!!!

Generate conf

autoconf aconfigure.ac > aconfigure


Compilation

./aconfigure --host=arm-apple-darwin9 --disable-speex-aec \
--disable-speex-codec --enable-g729-codec --disable-ssl


make dep
make


If you have no errors, you'll find in libs directories the libraries you need.



Riferimenti:


Name (required):

Website:

Comment:

If you want you can write here comments and questions.
NIKHIL said ...
14:10, 3 mar 2010 (CET)
HI,

I have compiled according to your instructions & I got libraries also. When I register it is throwing exception

EXC-BAD-ACCESS after sip_connect. callback function is not being called. Please suggest me where is the problem.


Andy said ...
16:58, 9 mar 2010 (CET)
Hi, thanks for the above info.

I have this working with G729 but would like to try iLBC, how did you get it to work with iLBC? what did you add to siphon to make it work?

Thanks


Paul V said ...
12:03, 22 mar 2010 (CET)
Hi! I am interested in compiling g729 not only for iPhoneOS, but also for iPhoneSimulator.

I changed Env values and other listed down script that way (http://groups.google.com/group/siphon/browse_thread/thread/c3b55ea15ae1ee29):

  1. !/bin/sh

export DEV=/Developer/Platforms/iPhoneSimulator.platform/Developer export SDK=${DEV}/SDKs/iPhoneSimulator3.1.2.sdk export PATH=${DEV}/usr/bin:${PATH} export CFLAGS="-O2 -arch i686 -isysroot ${SDK}" export LDFLAGS="-O2 -arch i686 -isysroot ${SDK}" export CPP="${DEV}/usr/bin/cpp"

cd ${DEV}/usr/bin ln -s i686-apple-darwin9-gcc-4.0.1 i686-apple-darwin9-gcc ln -s i686-apple-darwin9-g++-4.0.1 i686-apple-darwin9-g++ ln -s ranlib i686-apple-darwin9-ranlib

cd ~/Desktop/siPhon/pjproject-svn/

autoconf aconfigure.ac > aconfigure

./aconfigure --host=i686-apple-darwin9 --disable-speex-aec \ --disable-speex-codec --enable-g729-codec --disable-ssl

make dep make

BUT, I get error while make:

make -f /Users/useruser1/Desktop/siPhon/pjproject-svn/build/rules.mak APP=G729_CODEC app=libg729codec ../../lib/libg729codec-i686-apple-darwin9.a i686-apple-darwin9-gcc -c -Wall -DPJ_AUTOCONF=1 -O2 -arch i686 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.2.sdk -I../.. -I../../g729/Headers -I../../../pjlib/include \ -o output/libg729codec-i686-apple-darwin9/Sources/acelp_ca.o \ ../../g729/Sources/acelp_ca.c make[3]: i686-apple-darwin9-gcc: Command not found make[3]: *** [output/libg729codec-i686-apple-darwin9/Sources/acelp_ca.o] Error 127 make[2]: *** [libg729codec] Error 2 make[1]: *** [all] Error 1 make: *** [all] Error 1 Jock-2:pjproject-svn useruser1$ make -f /Users/useruser1/Desktop/siPhon/pjproject-svn/build/rules.mak APP=G729_CODEC app=libg729codec ../../lib/libg729codec-i686-apple-darwin9.a make: *** No rule to make target `../../lib/libg729codec-i686-apple-darwin9.a'. Stop.

What should I do to compile g729 for Simulator ???


Andy said ...
17:52, 25 mar 2010 (CET)
As far as I am aware you cant compile the g729 codec or any codec to run on the simulator, it has to be built and installed on an iPhone using the SDK.


Oleg said ...
00:19, 11 apr 2010 (CEST)
First of all — thanks for great manual!

I have done all steps and have compiled libs. But while building Xcode project with linked libs, I have error:

...../compat/setjmp.h:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pj_jmp_buf'

Screen shot: http://grab.by/3FCO

Alejandro Orellana said ...
14:58, 12 apr 2010 (CEST)
Great guide. i have followed all the steps successfully and compile a simple pjsua example.

however when i make a call, i have no audio. the logs are fine. signaling looks good even seems like the rtp streams are good and connected to the proper ports in pjsip, but no audio., nothing.

I see some people here also have the same problem.

any help it would be much appreciated.
fvisticot said ...
20:36, 16 apr 2010 (CEST)
Thank you for this very useful tutorial !!!!

Unfortunately, all is working exception to the sound... It seems that i'm not alone to have this pb....

Is it possible to have your view regarding possible issue with sound feature...
Ghazanfar Ali said ...
15:45, 5 ago 2010 (CEST)
Hi All,

Is it possible to compile this G729 library for PJSIP on Microsoft Windows Desktop. I have searched lot of forums and sites but couldn't find a better resource how to integrate G729 Codec in PJSIP on Microsoft Windows Platform.

Thanking in advance, Regards, Ghazanfar Ali

email: ghazanfar.ali@hotmail.com

1608 Rating: 3.8/5 (9 votes cast)

Strumenti personali