Skip to content
Snippets Groups Projects
Commit 1319d055 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

codecs dynamic load

parent 916bc091
Branches
Tags
No related merge requests found
...@@ -35,7 +35,6 @@ AC_CONFIG_FILES([libs/Makefile \ ...@@ -35,7 +35,6 @@ AC_CONFIG_FILES([libs/Makefile \
AC_CONFIG_FILES([src/Makefile \ AC_CONFIG_FILES([src/Makefile \
src/sflphone \ src/sflphone \
src/audio/Makefile \ src/audio/Makefile \
src/audio/gsm/Makefile \
src/config/Makefile \ src/config/Makefile \
src/dbus/Makefile \ src/dbus/Makefile \
src/zeroconf/Makefile]) src/zeroconf/Makefile])
...@@ -65,7 +64,7 @@ VERSION=`echo $VERSION | cut -d- -f1` ...@@ -65,7 +64,7 @@ VERSION=`echo $VERSION | cut -d- -f1`
AC_SUBST(VERSION) AC_SUBST(VERSION)
dnl Settings need Standard C++ Library dnl Settings need Standard C++ Library
LIBS="$LIBS -lstdc++" LIBS="$LIBS -lstdc++ -lgsm"
dnl Solaris pkgadd support definitions dnl Solaris pkgadd support definitions
PKGADD_PKG="SFLPhone" PKGADD_PKG="SFLPhone"
......
SUBDIRS = gsm #SUBDIRS = gsm
noinst_LTLIBRARIES = libaudio.la noinst_LTLIBRARIES = libaudio.la
...@@ -12,17 +12,17 @@ SPEEX_FLAG= ...@@ -12,17 +12,17 @@ SPEEX_FLAG=
SPEEX_LIB= SPEEX_LIB=
endif endif
libaudio_la_SOURCES = alaw.cpp audiofile.cpp g711.cpp tonelist.cpp \ libaudio_la_SOURCES = audiofile.cpp g711.cpp tonelist.cpp \
audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfgenerator.cpp gsmcodec.cpp \ audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfgenerator.cpp gsmcodec.cpp \
tonegenerator.cpp ulaw.cpp codecDescriptor.cpp \ tonegenerator.cpp ulaw.cpp codecDescriptor.cpp \
audioloop.cpp ringbuffer.cpp $(SPEEX_SOURCES_CPP) audioloop.cpp ringbuffer.cpp $(SPEEX_SOURCES_CPP)
AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES) AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES)
libaudio_la_LIBADD = gsm/libgsm.la $(SPEEX_LIB) #libaudio_la_LIBADD = gsm/libgsm.la $(SPEEX_LIB)
libaudio_la_CPPFLAGS = $(SPEEX_FLAG) libaudio_la_CPPFLAGS = $(SPEEX_FLAG)
noinst_HEADERS = audioloop.h common.h ringbuffer.h alaw.h audiofile.h g711.h \ noinst_HEADERS = audioloop.h common.h ringbuffer.h audiofile.h g711.h \
tonelist.h audiortp.h audiocodec.h audiolayer.h audiodevice.h \ tonelist.h audiortp.h audiocodec.h audiolayer.h audiodevice.h \
dtmfgenerator.h gsmcodec.h tonegenerator.h ulaw.h \ dtmfgenerator.h gsmcodec.h tonegenerator.h ulaw.h \
codecDescriptor.h dtmf.h tone.h \ codecDescriptor.h dtmf.h tone.h \
......
...@@ -274,7 +274,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp) ...@@ -274,7 +274,7 @@ AudioRtpRTX::sendSessionFromMic(int timestamp)
int pl = 0; int pl = 0;
AudioCodec* audiocodec = create_codec(); AudioCodec* audiocodec = create_codec();
//audiocodec1->test(); audiocodec->test();
// STEP: // STEP:
// 1. get data from mic // 1. get data from mic
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "audiocodec.h" #include "audiocodec.h"
#include "gsmcodec.h" #include "gsmcodec.h"
#include "alaw.h" //#include "alaw.h"
#include "ulaw.h" #include "ulaw.h"
#include "codecDescriptor.h" #include "codecDescriptor.h"
#ifdef HAVE_SPEEX #ifdef HAVE_SPEEX
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
CodecDescriptorMap::CodecDescriptorMap() CodecDescriptorMap::CodecDescriptorMap()
{ {
_codecMap[PAYLOAD_CODEC_ALAW] = new Alaw(); //_codecMap[PAYLOAD_CODEC_ALAW] = new Alaw();
_codecMap[PAYLOAD_CODEC_ALAW] = new Ulaw();
_codecMap[PAYLOAD_CODEC_ULAW] = new Ulaw(); _codecMap[PAYLOAD_CODEC_ULAW] = new Ulaw();
_codecMap[PAYLOAD_CODEC_GSM] = new Gsm(); _codecMap[PAYLOAD_CODEC_GSM] = new Gsm();
#ifdef HAVE_SPEEX #ifdef HAVE_SPEEX
......
File added
...@@ -19,30 +19,35 @@ ...@@ -19,30 +19,35 @@
*/ */
#include <iostream> #include <iostream>
#include "gsmcodec.h" #include <gsm/gsm.h>
#include "audiocodec.h"
#include "../global.h" #include "../global.h"
class Gsm : public AudioCodec {
public:
// 3 GSM A 8000 1 [RFC3551] // 3 GSM A 8000 1 [RFC3551]
Gsm::Gsm(int payload) : AudioCodec(payload, "GSM") Gsm(int payload = 0)
: AudioCodec(payload, "GSM")
{ {
_description = "GSM"; _description = "GSM";
_clockRate = 8000; _clockRate = 8000;
_channel = 1; _channel = 1;
if (!(_decode_gsmhandle = gsm_create() )) if (!(_decode_gsmhandle = gsm_create() ))
_debug("ERROR: decode_gsm_create\n"); _debug("ERROR: decode_gsm_create\n");
if (!(_encode_gsmhandle = gsm_create() )) if (!(_encode_gsmhandle = gsm_create() ))
_debug("AudioCodec: ERROR: encode_gsm_create\n"); _debug("AudioCodec: ERROR: encode_gsm_create\n");
} }
Gsm::~Gsm (void) ~Gsm (void)
{ {
gsm_destroy(_decode_gsmhandle); gsm_destroy(_decode_gsmhandle);
gsm_destroy(_encode_gsmhandle); gsm_destroy(_encode_gsmhandle);
} }
int virtual int codecDecode (short *dst, unsigned char *src, unsigned int size)
Gsm::codecDecode (short *dst, unsigned char *src, unsigned int size)
{ {
(void)size; (void)size;
if (gsm_decode(_decode_gsmhandle, (gsm_byte*)src, (gsm_signal*)dst) < 0) { if (gsm_decode(_decode_gsmhandle, (gsm_byte*)src, (gsm_signal*)dst) < 0) {
...@@ -51,18 +56,29 @@ Gsm::codecDecode (short *dst, unsigned char *src, unsigned int size) ...@@ -51,18 +56,29 @@ Gsm::codecDecode (short *dst, unsigned char *src, unsigned int size)
return 320; return 320;
} }
int virtual int codecEncode (unsigned char *dst, short *src, unsigned int size)
Gsm::codecEncode (unsigned char *dst, short *src, unsigned int size)
{ {
(void)size; (void)size;
gsm_encode(_encode_gsmhandle, (gsm_signal*)src, (gsm_byte*)dst); gsm_encode(_encode_gsmhandle, (gsm_signal*)src, (gsm_byte*)dst);
return 33; return 33;
} }
void virtual void test()
Gsm::test()
{ {
printf("MOn OSTIE GSM!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); printf("MOn OSTIE GSM!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
} }
private:
gsm _decode_gsmhandle;
gsm _encode_gsmhandle;
};
// the class factories
extern "C" AudioCodec* create_gsm() {
return new Gsm();
}
extern "C" void destroy_gsm(AudioCodec* a) {
delete a;
}
...@@ -21,10 +21,12 @@ ...@@ -21,10 +21,12 @@
#ifndef __GSM_H__ #ifndef __GSM_H__
#define __GSM_H__ #define __GSM_H__
#include <gsm.h>
#include "audiocodec.h" #include "audiocodec.h"
extern "C" { /*extern "C" {
#include "gsm/gsm.h" #include "gsm/gsm.h"
} }*/
/** /**
* GSM audio codec C++ class (over gsm/gsm.h) * GSM audio codec C++ class (over gsm/gsm.h)
......
...@@ -13,7 +13,7 @@ public: ...@@ -13,7 +13,7 @@ public:
} }
virtual void test(){ virtual void test(){
printf("MON OSTIE !!!!!!!!!!!!!!!!!!!!!!!!!!\n"); printf("MON OSTIE !!!!!!!!!!!!!!!!!!!!!!!!!! ULAW\n");
} }
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) { virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
...@@ -24,7 +24,6 @@ public: ...@@ -24,7 +24,6 @@ public:
} }
virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) { virtual int codecEncode (unsigned char *dst, short *src, unsigned int size) {
//return G711::ULawEncode (dst, src, size);
size >>= 1; size >>= 1;
uint8* end = dst+size; uint8* end = dst+size;
while(dst<end) while(dst<end)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment