wiki:G729CodecForPJSIP2x_iOS6
Last modified 3 years ago Last modified on 04/11/13 16:16:30

G.729 codec for PJSIP 2.1 and iOS 6

This manual describe how to configure and compile the official PJSIP 2.1 with G.729 codec support for iOS 6

NOTE: This manual is based on the following tutorial Compile available codecs in PJSip with iPhoneSDK312 - by PiemonteWireless

The following pjproject files need to be patched:

- 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
+

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

# Codecs
#
AC_NO_G711_CODEC=@ac_no_g711_codec@
AC_NO_L16_CODEC=@ac_no_l16_codec@
AC_NO_GSM_CODEC=@ac_no_gsm_codec@
AC_NO_SPEEX_CODEC=@ac_no_speex_codec@
AC_NO_ILBC_CODEC=@ac_no_ilbc_codec@
AC_NO_G722_CODEC=@ac_no_g722_codec@
AC_NO_G7221_CODEC=@ac_no_g7221_codec@
+AC_HAS_G729_CODEC=@ac_has_g729_codec@
AC_NO_OPENCORE_AMRNB=@ac_no_opencore_amrnb@
AC_NO_OPENCORE_AMRWB=@ac_no_opencore_amrwb@

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
+else
+export CFLAGS += -DPJMEDIA_HAS_G729_CODEC=0
+endif

ifeq ($(AC_NO_OPENCORE_AMRNB),1)
export CFLAGS += -DPJMEDIA_HAS_OPENCORE_AMRNB_CODEC=0
 

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

#ifndef PJMEDIA_HAS_G722_CODEC
#   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

/**
 * Default G.722 codec encoder and decoder level adjustment. The G.722

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

/* G7221 codec */
#ifndef PJMEDIA_HAS_G7221_CODEC
#undef PJMEDIA_HAS_G7221_CODEC
#endif

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

/* OpenCORE AMR-NB codec */

- pjmedia/include/pjmedia-codec.h

#include <pjmedia-codec/audio_codecs.h>
#include <pjmedia-codec/l16.h>
#include <pjmedia-codec/ffmpeg_vid_codecs.h>
#include <pjmedia-codec/gsm.h>
#include <pjmedia-codec/speex.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/opencore_amr.h>
#include <pjmedia-codec/passthrough.h>
#include <pjmedia-codec/silk.h>

- aconfigure.ac

			     [ac_v4l2_cflags="-DPJMEDIA_VIDEO_DEV_HAS_V4L2=1"
			      ac_v4l2_ldflags="-lv4l2"
			      LIBS="$LIBS -lv4l2"
			     ]
			     )
	      ])


+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_DEFINE(PJMEDIA_HAS_G729_CODEC,0)
+    AC_MSG_RESULT([Checking if g729 codec is disabled...yes])
+    )
+
dnl ########################################################
dnl # Intel IPP support

- pjmedia/src/pjmedia-codec/audio-codecs.c

 #endif /* PJMEDIA_HAS_G7221_CODEC */

    
+#if PJMEDIA_HAS_G729_CODEC
+    status = pjmedia_codec_g729_init(endpt);
+    if (status != PJ_SUCCESS) {
+        return status;
+    }
+#endif /* PJMEDIA_HAS_G729_CODEC */
+    
#if PJMEDIA_HAS_L16_CODEC

- 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@),)
ifeq (@ac_external_pa@,1)

Download files

Download this file: g729.c
and move it in pjmedia/src/pjmedia-codec/g729.c

Download this file: g729.h
and move it in pjmedia/include/pjmedia-codec/g729.h

Download this file: G729-iOS.zip
uncompress it, then copy its g729/ directory under the third_party/ directory.

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


- pjlib/include/pj/config_site.h

Your pjlib/include/pj/config_site.h should look like this :

#define PJ_CONFIG_IPHONE 1
+#define PJMEDIA_HAS_G729_CODEC 1
#include <pj/config_site_sample.h>

To add support for the G.7221 codec you just need to add the following line (as PJSIP has already support this codec):

#define PJMEDIA_HAS_G7221_CODEC 1

or finally your pjlib/include/pj/config_site.h should look like this :

#define PJ_CONFIG_IPHONE 1
+#define PJMEDIA_HAS_G729_CODEC 1
+#define PJMEDIA_HAS_G7221_CODEC 1
#include <pj/config_site_sample.h>

Generate autoconfigure

Open terminal and type the following commands:

cd path/to/pjproject

rm -f aconfigure

autoconf aconfigure.ac > aconfigure

sudo chmod 777 aconfigure

Compilation

The final step is to edit the configure-iphone script by adding the --enable-g729-codec option to the ./aconfigure command

./aconfigure --host=arm-apple-darwin9 --enable-g729-codec --disable-sdl $*

Done! Now you are ready to compile PJSIP 2.1 for iOS 6 with G.729 codec support:

make clean & make distclean

./configure-iphone

make dep && make clean && make

All in one download

All modified pjproject (PJSIP 2.1) files including the G.729 codec are available for download[[BR]]

All you need is to download this file: pjproject-G729-iOS
replace all pjproject files and add the new ones, then you should repeat the last 2 steps from above to generate autoconfigure and compile PJSIP


Attention: Before performing any changes is recommended to backup your code''