summaryrefslogtreecommitdiffstats
path: root/src/modules/dcc/gsmcodec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/dcc/gsmcodec.cpp')
-rw-r--r--src/modules/dcc/gsmcodec.cpp54
1 files changed, 6 insertions, 48 deletions
diff --git a/src/modules/dcc/gsmcodec.cpp b/src/modules/dcc/gsmcodec.cpp
index 58af1473..22320eb4 100644
--- a/src/modules/dcc/gsmcodec.cpp
+++ b/src/modules/dcc/gsmcodec.cpp
@@ -26,64 +26,22 @@
#ifdef COMPILE_USE_GSM
-#include <dlfcn.h>
-
#define GSM_PACKED_FRAME_SIZE_IN_BYTES 33
#define GSM_UNPACKED_FRAME_SIZE_IN_BYTES 320
#define GSM_UNPACKED_FRAME_SIZE_IN_SHORTS 160
-void * (*gsm_session_create)() = 0;
-void (*gsm_session_destroy)(void *) = 0;
-void (*gsm_session_encode)(void *,short *,unsigned char *) = 0;
-int (*gsm_session_decode)(void *,unsigned char *,short *) = 0;
-
-
-void * g_pGSMCodecLibraryHandle = 0;
-
-bool kvi_gsm_codec_init()
-{
- if(g_pGSMCodecLibraryHandle)return true; // Already initialized
-
- g_pGSMCodecLibraryHandle = dlopen("libgsm.so",RTLD_NOW | RTLD_GLOBAL);
- if(!g_pGSMCodecLibraryHandle)return false; // no way to open it
-
- gsm_session_create = (void * (*)()) dlsym(g_pGSMCodecLibraryHandle,"gsm_create");
- gsm_session_destroy = (void (*)(void *)) dlsym(g_pGSMCodecLibraryHandle,"gsm_destroy");
- gsm_session_encode = (void (*)(void *,short *,unsigned char *)) dlsym(g_pGSMCodecLibraryHandle,"gsm_encode");
- gsm_session_decode = (int (*)(void *,unsigned char *,short *)) dlsym(g_pGSMCodecLibraryHandle,"gsm_decode");
-
- if(! (gsm_session_create && gsm_session_destroy && gsm_session_encode && gsm_session_decode))
- {
- dlclose(g_pGSMCodecLibraryHandle);
- g_pGSMCodecLibraryHandle = 0;
- return false;
- }
- return true;
-}
-
-void kvi_gsm_codec_done()
-{
- if(g_pGSMCodecLibraryHandle)
- {
- dlclose(g_pGSMCodecLibraryHandle);
- g_pGSMCodecLibraryHandle = 0;
- }
-}
-
-
-
KviDccVoiceGsmCodec::KviDccVoiceGsmCodec()
: KviDccVoiceCodec()
{
- m_pEncodeState = gsm_session_create();
- m_pDecodeState = gsm_session_create();
+ m_pEncodeState = gsm_create();
+ m_pDecodeState = gsm_create();
m_szName = "gsm (compression 33:320)";
}
KviDccVoiceGsmCodec::~KviDccVoiceGsmCodec()
{
- gsm_session_destroy(m_pEncodeState);
- gsm_session_destroy(m_pDecodeState);
+ gsm_destroy(m_pEncodeState);
+ gsm_destroy(m_pDecodeState);
}
void KviDccVoiceGsmCodec::encode(KviDataBuffer * signal,KviDataBuffer * stream)
@@ -101,7 +59,7 @@ void KviDccVoiceGsmCodec::encode(KviDataBuffer * signal,KviDataBuffer * stream)
while(ptr != endPtr)
{
- gsm_session_encode(m_pEncodeState,(short *)ptr,stream->data() + uFrameOffset);
+ gsm_encode(m_pEncodeState,(short *)ptr,stream->data() + uFrameOffset);
ptr += GSM_UNPACKED_FRAME_SIZE_IN_BYTES;
uFrameOffset += GSM_PACKED_FRAME_SIZE_IN_BYTES;
}
@@ -129,7 +87,7 @@ void KviDccVoiceGsmCodec::decode(KviDataBuffer * stream,KviDataBuffer * signal)
// or a broken frame...
// but if we receive broken frames over DCC...well....better
// check the hardware...or the remote codec as well...
- gsm_session_decode(m_pDecodeState,ptr,(short *)(signal->data() + uSignalOffset));
+ gsm_decode(m_pDecodeState,ptr,(short *)(signal->data() + uSignalOffset));
ptr += GSM_PACKED_FRAME_SIZE_IN_BYTES;
uSignalOffset += GSM_UNPACKED_FRAME_SIZE_IN_BYTES;
}