Wednesday, February 10, 2016

Sigcomp in asterisk - Part -1


Libraries for Sigcomp
  1. Libsigcomp – C++ library .due to C++ codes its hard to integrate in Asterisk
  2. tinySIGCOMP – C library and part of doubango Stack .

In asterisk 1.8.3.2 We are using tinySIGCOMP ( needs tinySAK  )

Issues
Asterisk uses PTHREAD_MUTEX_RECURSIVE_NP while Sigcomp uses PTHREAD_MUTEX_RECURSIVE ,Centos & Xtensa Kernel Also has Non –portable version (NP) version so Sigcomp won’t Compile .


Getting Sources
Doubango 2.0 has to be used ,in TINYXCAP we are using Doubango 1.0

Cd
asterisk_src/add-ons/sigcomp



Compile tinySAK
Cd tinysak

Sh autogen.sh
./configure

replace THREAD_MUTEX_RECURSIVE in src/tsk_mutex.c to PTHREAD_MUTEX_RECURSIVE_NP

Edit tinySAK/src/Makefile & tinySAK/test/Makefile  and replace
LIBTOOL = $(SHELL) $(top_builddir)/libtool with LIBTOOL= libtool

Edit tinySAK/test/Makefile and following
LDFLAGS =-lpthread


Make install will install libraries and headers in
/usr/local/include/tinySAK/*.h

And in

/usr/local/lib/libtinySAK.la
/usr/local/lib/libtinySAK.a
/usr/local/lib/libtinySAK.so.0.0.0


Compiling SIGCOMP

Cd tinySIGCOMP

Add Makefile and following path

#APP := lib$(PROJECT)_$(MARCH).$(EXT)
EXT := a
APP := libtinySIGCOMP.$(EXT)
CC := ${CROSS_COMPILE}gcc
#CFLAGS := $(CFLAGS_LIB) -I../tinySAK/src -I./src -I$(BUILDROOT_TOOL_PATH)/usr/include/libxml2
#LDFLAGS := $(LDFLAGS_LIB) -ltinySAK_$(MARCH) -L$(BUILDROOT_TOOL_PATH)/usr/lib
CFLAGS := $(CFLAGS_LIB) -I../tinySAK/src -I./src
LDFLAGS := $(LDFLAGS_LIB) -ltinySAK_$(MARCH) -L$(BUILDROOT_TOOL_PATH)/usr/lib


all: $(APP)

OBJS = \
            src/adler32.o\
            src/compress.o\
            src/deflate.o\
            src/tcomp.o\
            src/tcomp_buffer.o\
            src/tcomp_compartment.o\
            src/tcomp_compressordata.o\
            src/tcomp_compressordisp.o\
            src/tcomp_compressor_deflate.o\
            src/tcomp_compressor_dummy.o\
            src/tcomp_decompressordisp.o\
            src/tcomp_deflatedata.o\
            src/tcomp_deflatedata.ghost.o\
            src/tcomp_deflatedata.zlib.o\
            src/tcomp_dicts.o\
            src/tcomp_manager.o\
            src/tcomp_message.o\
            src/tcomp_nackinfo.o\
            src/tcomp_params.o\
            src/tcomp_reqfeed.o\
            src/tcomp_result.o\
            src/tcomp_state.o\
            src/tcomp_statehandler.o\
            src/tcomp_udvm.bytecopy.o\
            src/tcomp_udvm.o\
            src/tcomp_udvm.instructions.o\
            src/tcomp_udvm.nack.o\
            src/tcomp_udvm.operands.o\
            src/tcomp_udvm.statemanagment.o\
            src/trees.o\
            src/zutil.o\

           

$(APP): $(OBJS)
ifeq ($(EXT), a)
            $(AR) rcs $@ $^
else
            $(CC) $(LDFLAGS) -o $@ $^
endif

%.o: %.c
            $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
           
install: $(APP)
            $(ANDROID_SDK_ROOT)/tools/adb remount
            $(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(LIB_DIR)/$(APP)
            $(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(LIB_DIR)/$(APP)
           
clean:
            @rm -f $(OBJS) $(APP)

Make to compile ,which generates sigcomp library libtinySIGCOMP.a


Integrating with Asterisk

Compiling with Asterisk
Change channels/Makefile as below :

--- channels/Makefile2  2012-01-22 12:47:55.000000000 +0530
+++ channels/Makefile   2012-01-23 11:50:49.000000000 +0530
@@ -71,7 +71,12 @@ dist-clean::

 $(if $(filter chan_iax2,$(EMBEDDED_MODS)),modules.link,chan_iax2.so): iax2-parser.o iax2-provision.o
 iax2-parser.o iax2-provision.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_iax2)
-$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): $(subst .c,.o,$(wildcard sip/*.c))
+AST_ADDONS_IMS=$(ASTTOPDIR)/addons/sigcomp
+chan_sip.o: _ASTCFLAGS+=-I$(AST_ADDONS_IMS) -I/home/alok/latest_cvs/asterisk_src/add-ons/sigcomp/tinySIGCOMP/src
+
+#chan_sip.o: _ASTCFLAGS+=-I$(AST_ADDONS_IMS)
+#$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): $(subst .c,.o,$(wildcard sip/*.c)) $(subst .c,.o,$(wildcard $(AST_ADDONS_IMS)/*.c))
+$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): $(subst .c,.o,$(wildcard sip/*.c)) /home/alok/latest_cvs/asterisk_src/add-ons/sigcomp/tinySIGCOMP/libtinySIGCOMP.a /usr/lib/libtinySAK.so.0
 $(subst .c,.o,$(wildcard sip/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_sip)
 $(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): sig_analog.o sig_pri.o sig_ss7.o
 sig_analog.o sig_pri.o sig_ss7.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)


Asterisk-1.8.3.2/addons/sigcomp ->All sigcomp related files
Also link src folders of tinySIGCOMP and tinySAK

Files needed for SIGCOMP by asterisk
  1. libtinySIGCOMP.a
  2. libtinySAK.so.0.0.0



Asterisk Sigcomp Flow
__sip_xmit(Sends out packet)  ---------àCompression-àCompressed Packetàsipsock_read(Receives packets) àDecompression

1 comment:

  1. https://alokprasad7.blogspot.com/2016/02/sigcomp-in-asterisk-part-2-chansip.html ( Asterisk patch to add sigcomp support)

    ReplyDelete

Featured Post

XDP - Getting Started with XDP (Linux)