--- /dev/null
+/* \r
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application\r
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>\r
+ *\r
+ * Version: MPL 1.1\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version\r
+ * 1.1 (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ * http://www.mozilla.org/MPL/\r
+ *\r
+ * Software distributed under the License is distributed on an "AS IS" basis,\r
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
+ * for the specific language governing rights and limitations under the\r
+ * License.\r
+ *\r
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application\r
+ *\r
+ * The Initial Developer of the Original Code is\r
+ * Anthony Minessale II <anthmct@yahoo.com>\r
+ * Portions created by the Initial Developer are Copyright (C)\r
+ * the Initial Developer. All Rights Reserved.\r
+ *\r
+ * Contributor(s):\r
+ * \r
+ * Anthony Minessale II <anthmct@yahoo.com>\r
+ * Michael Jerris <mike@jerris.com>\r
+ *\r
+ * mod_codec_gsm.c -- gsm Codec Module\r
+ *\r
+ */ \r
+#include "switch.h"\r
+#include "gsm.h"\r
+\rstatic const char modname[] = "mod_codec_gsm";
+\r\rstruct gsm_context {
+ \rgsm encoder;
+ \rgsm decoder;
+\r};
+\r\rstatic switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flags,
+ const struct switch_codec_settings *codec_settings) \r
+{
+ \rstruct gsm_context *context;
+ \rint encoding, decoding;
+ \r\rencoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
+ \rdecoding = (flags & SWITCH_CODEC_FLAG_DECODE);
+ \r\rif (!(encoding || decoding)) {
+ \rreturn SWITCH_STATUS_FALSE;
+ \r} else {
+ \rcontext = switch_core_alloc(codec->memory_pool, sizeof(*context));
+ \rif (encoding)
+ context->encoder = gsm_create();
+ \rif (decoding)
+ context->decoder = gsm_create();
+ \r}
+ \r\rcodec->private = context;
+ \r\rreturn SWITCH_STATUS_SUCCESS;
+\r\r}
+\r\rstatic switch_status switch_gsm_destroy(switch_codec *codec) \r
+{
+ \rstruct gsm_context *context = codec->private;
+ \rint encoding = (codec->flags & SWITCH_CODEC_FLAG_ENCODE);
+ \rint decoding = (codec->flags & SWITCH_CODEC_FLAG_DECODE);
+ \r\rif (encoding)
+ gsm_destroy(context->encoder);
+ \rif (decoding)
+ gsm_destroy(context->decoder);
+ \r\rcodec->private = NULL;
+ \rreturn SWITCH_STATUS_SUCCESS;
+\r}
+\r\r\rstatic switch_status switch_gsm_encode(switch_codec *codec, \rswitch_codec *other_codec, \rvoid *decoded_data,
+ \rsize_t decoded_data_len, \rint decoded_rate, \rvoid *encoded_data,
+ \rsize_t *encoded_data_len, \rint *encoded_rate, \runsigned int *flag) \r
+{
+ \rstruct gsm_context *context = codec->private;
+ \rint cbret = 0;
+ \r\rif (!context) {
+ \rreturn SWITCH_STATUS_FALSE;
+ \r}
+ \rif (decoded_data_len % 320 == 0) {
+ \runsigned int new_len = 0;
+ \rgsm_signal * ddp = decoded_data;
+ \rgsm_byte * edp = encoded_data;
+ \rint x;
+ \rint loops = (int) decoded_data_len / 320;
+ \rfor (x = 0; x < loops && new_len < *encoded_data_len; x++) {
+ \rgsm_encode(context->encoder, ddp, edp);
+ \redp += 33;
+ \rddp += 160;
+ \rnew_len += 33;
+ \r}
+ \rif (new_len <= *encoded_data_len) {
+ \r*encoded_data_len = new_len;
+ \r} else {
+ \rswitch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!! %u >= %u\n", new_len, *encoded_data_len);
+ \rreturn SWITCH_STATUS_FALSE;
+ \r}
+ \r}
+ \r\rreturn SWITCH_STATUS_SUCCESS;
+\r}
+\r\r\rstatic switch_status switch_gsm_decode(switch_codec *codec, \rswitch_codec *other_codec, \rvoid *encoded_data,
+ \rsize_t encoded_data_len, \rint encoded_rate, \rvoid *decoded_data,
+ \rsize_t *decoded_data_len, \rint *decoded_rate, \runsigned int *flag) \r
+{
+ \rstruct gsm_context *context = codec->private;
+ \r\rif (!context) {
+ \rreturn SWITCH_STATUS_FALSE;
+ \r}
+ \r\r\rif (encoded_data_len % 33 == 0) {
+ \rint loops = (int) encoded_data_len / 33;
+ \rgsm_byte * edp = encoded_data;
+ \rgsm_signal * ddp = decoded_data;
+ \rint x;
+ \runsigned int new_len = 0;
+ \rfor (x = 0; x < loops && new_len < *decoded_data_len; x++) {
+ \rgsm_decode(context->decoder, edp, ddp);
+ \rddp += 160;
+ \redp += 33;
+ \rnew_len += 320;
+ \r}
+ \rif (new_len <= *decoded_data_len) {
+ \r*decoded_data_len = new_len;
+ \r} else {
+ \rswitch_console_printf(SWITCH_CHANNEL_CONSOLE, "buffer overflow!!!\n");
+ \rreturn SWITCH_STATUS_FALSE;
+ \r}
+ \r} else {
+ \rswitch_console_printf(SWITCH_CHANNEL_CONSOLE, "yo this frame is an odd size [%d]\n", encoded_data_len);
+ \r}
+ \r\rreturn SWITCH_STATUS_SUCCESS;
+\r}
+
+\r\r
+/* Registration */ \r
+\rstatic const switch_codec_implementation gsm_8k_implementation = { \r
+ /*.samples_per_second */ 8000, \r
+ /*.bits_per_second */ 13200, \r
+ /*.microseconds_per_frame */ 20000, \r
+ /*.samples_per_frame */ 160, \r
+ /*.bytes_per_frame */ 320, \r
+ /*.encoded_bytes_per_frame */ 33, \r
+ /*.number_of_channels */ 1, \r
+ /*.pref_frames_per_packet */ 1, \r
+ /*.max_frames_per_packet */ 1, \r
+ /*.init */ switch_gsm_init, \r
+ /*.encode */ switch_gsm_encode, \r
+ /*.decode */ switch_gsm_decode, \r
+ /*.destroy */ switch_gsm_destroy, \r
+};
+\r\rstatic const switch_codec_interface gsm_codec_interface = { \r
+ /*.interface_name */ "gsm", \r
+ /*.codec_type */ SWITCH_CODEC_TYPE_AUDIO, \r
+ /*.ianacode */ 3, \r
+ /*.iananame */ "gsm", \r
+ /*.implementations */ &gsm_8k_implementation, \r
+};
+\r\rstatic switch_loadable_module_interface gsm_module_interface = { \r
+ /*.module_name */ modname, \r
+ /*.endpoint_interface */ NULL, \r
+ /*.timer_interface */ NULL, \r
+ /*.dialplan_interface */ NULL, \r
+ /*.codec_interface */ &gsm_codec_interface, \r
+ /*.application_interface */ NULL \r
+};
+\r\r\rSWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface,
+ char *filename)
+{
+ \r
+ /* connect my internal structure to the blank pointer passed to me */ \r
+ *interface = &gsm_module_interface;
+ \r\r
+ /* indicate that the module should continue to be loaded */ \r
+ return SWITCH_STATUS_SUCCESS;
+\r}
+
+\r\r\r\r\r\r
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+ ProjectType="Visual C++"\r
+ Version="8.00"\r
+ Name="mod_ilbc"\r
+ ProjectGUID="{4926323F-4EA8-4B7D-A3D3-65488725988F}"\r
+ RootNamespace="mod_ilbc"\r
+ Keyword="Win32Proj"\r
+ >\r
+ <Platforms>\r
+ <Platform\r
+ Name="Win32"\r
+ />\r
+ </Platforms>\r
+ <ToolFiles>\r
+ </ToolFiles>\r
+ <Configurations>\r
+ <Configuration\r
+ Name="Debug|Win32"\r
+ OutputDirectory="Debug"\r
+ IntermediateDirectory="Debug"\r
+ ConfigurationType="2"\r
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"\r
+ CharacterSet="2"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Codecilbc Debug"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ Optimization="0"\r
+ AdditionalIncludeDirectories=""$(InputDir)..\..\..\include";"$(InputDir)..\..\..\..\libs\include";"$(InputDir)..\..\..\..\libs\codec\ilbc\inc""\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"\r
+ MinimalRebuild="true"\r
+ BasicRuntimeChecks="3"\r
+ RuntimeLibrary="3"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="4"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="libilbc.lib FreeSwitchCore.lib"\r
+ OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ilbc.dll"\r
+ LinkIncremental="2"\r
+ AdditionalLibraryDirectories="..\..\..\..\libs\codec\ilbc\Debug;..\..\..\..\w32\vsnet\Debug"\r
+ GenerateDebugInformation="true"\r
+ ProgramDatabaseFile="$(OutDir)/mod_ilbc.pdb"\r
+ SubSystem="2"\r
+ ImportLibrary="$(OutDir)/mod_ilbc.lib"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebDeploymentTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ <Configuration\r
+ Name="Release|Win32"\r
+ OutputDirectory="Release"\r
+ IntermediateDirectory="Release"\r
+ ConfigurationType="2"\r
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"\r
+ CharacterSet="2"\r
+ >\r
+ <Tool\r
+ Name="VCPreBuildEventTool"\r
+ CommandLine="cscript /nologo $(InputDir)..\..\..\..\w32\vsnet\getlibs.vbs Mod_Codecilbc Release"\r
+ />\r
+ <Tool\r
+ Name="VCCustomBuildTool"\r
+ />\r
+ <Tool\r
+ Name="VCXMLDataGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebServiceProxyGeneratorTool"\r
+ />\r
+ <Tool\r
+ Name="VCMIDLTool"\r
+ />\r
+ <Tool\r
+ Name="VCCLCompilerTool"\r
+ AdditionalIncludeDirectories=""$(InputDir)..\..\..\include";"$(InputDir)..\..\..\..\libs\include";"$(InputDir)..\..\..\..\libs\codec\ilbc\inc""\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"\r
+ RuntimeLibrary="2"\r
+ UsePrecompiledHeader="0"\r
+ WarningLevel="3"\r
+ Detect64BitPortabilityProblems="true"\r
+ DebugInformationFormat="3"\r
+ />\r
+ <Tool\r
+ Name="VCManagedResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCResourceCompilerTool"\r
+ />\r
+ <Tool\r
+ Name="VCPreLinkEventTool"\r
+ />\r
+ <Tool\r
+ Name="VCLinkerTool"\r
+ AdditionalDependencies="libilbc.lib FreeSwitchCore.lib"\r
+ OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_ilbc.dll"\r
+ LinkIncremental="1"\r
+ AdditionalLibraryDirectories="..\..\..\..\libs\codec\ilbc\Release;..\..\..\..\w32\vsnet\Release"\r
+ GenerateDebugInformation="true"\r
+ SubSystem="2"\r
+ OptimizeReferences="2"\r
+ EnableCOMDATFolding="2"\r
+ LinkTimeCodeGeneration="1"\r
+ ImportLibrary="$(OutDir)/mod_ilbc.lib"\r
+ TargetMachine="1"\r
+ />\r
+ <Tool\r
+ Name="VCALinkTool"\r
+ />\r
+ <Tool\r
+ Name="VCManifestTool"\r
+ />\r
+ <Tool\r
+ Name="VCXDCMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCBscMakeTool"\r
+ />\r
+ <Tool\r
+ Name="VCFxCopTool"\r
+ />\r
+ <Tool\r
+ Name="VCAppVerifierTool"\r
+ />\r
+ <Tool\r
+ Name="VCWebDeploymentTool"\r
+ />\r
+ <Tool\r
+ Name="VCPostBuildEventTool"\r
+ />\r
+ </Configuration>\r
+ </Configurations>\r
+ <References>\r
+ </References>\r
+ <Files>\r
+ <Filter\r
+ Name="Source Files"\r
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+ >\r
+ <File\r
+ RelativePath="mod_ilbc.c"\r
+ >\r
+ </File>\r
+ </Filter>\r
+ <Filter\r
+ Name="Header Files"\r
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+ >\r
+ </Filter>\r
+ <Filter\r
+ Name="Resource Files"\r
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"\r
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+ >\r
+ </Filter>\r
+ </Files>\r
+ <Globals>\r
+ </Globals>\r
+</VisualStudioProject>\r