diff options
Diffstat (limited to 'pjmedia')
-rw-r--r-- | pjmedia/build/pjmedia_codec.dsp | 12 | ||||
-rw-r--r-- | pjmedia/build/pjmedia_codec.vcproj | 382 | ||||
-rw-r--r-- | pjmedia/include/pjmedia-codec.h | 1 | ||||
-rw-r--r-- | pjmedia/include/pjmedia-codec/config.h | 8 | ||||
-rw-r--r-- | pjmedia/include/pjmedia-codec/g7221.h | 113 | ||||
-rw-r--r-- | pjmedia/include/pjmedia-codec/types.h | 14 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-codec/g7221.c | 854 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-codec/l16.c | 6 |
8 files changed, 1196 insertions, 194 deletions
diff --git a/pjmedia/build/pjmedia_codec.dsp b/pjmedia/build/pjmedia_codec.dsp index ee56f483..3f9eb75f 100644 --- a/pjmedia/build/pjmedia_codec.dsp +++ b/pjmedia/build/pjmedia_codec.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MD /W4 /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /I "../../third_party/speex/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /c
+# ADD CPP /nologo /MD /W4 /Zi /O2 /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /I "../../third_party" /I "../../third_party/speex/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
@@ -67,7 +67,7 @@ LIB32=link.exe -lib # PROP Target_Dir ""
F90=df.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W4 /Gm /ZI /Od /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /I "../../third_party/speex/include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /GZ /c
+# ADD CPP /nologo /MTd /W4 /Gm /ZI /Od /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /I "../../third_party" /I "../../third_party/speex/include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
@@ -113,6 +113,10 @@ SOURCE="..\src\pjmedia-codec\g722.c" # End Source File
# Begin Source File
+SOURCE="..\src\pjmedia-codec\g7221.c"
+# End Source File
+# Begin Source File
+
SOURCE="..\src\pjmedia-codec\gsm.c"
!IF "$(CFG)" == "pjmedia_codec - Win32 Release"
@@ -180,6 +184,10 @@ SOURCE="..\include\pjmedia-codec\g722.h" # End Source File
# Begin Source File
+SOURCE="..\include\pjmedia-codec\g7221.h"
+# End Source File
+# Begin Source File
+
SOURCE="..\include\pjmedia-codec\gsm.h"
# End Source File
# Begin Source File
diff --git a/pjmedia/build/pjmedia_codec.vcproj b/pjmedia/build/pjmedia_codec.vcproj index 0f5217b1..d4ccd3ec 100644 --- a/pjmedia/build/pjmedia_codec.vcproj +++ b/pjmedia/build/pjmedia_codec.vcproj @@ -45,7 +45,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party;../../third_party/speex/include;../../third_party"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -94,11 +94,14 @@ />
</Configuration>
<Configuration
- Name="Debug|Windows Mobile 6 Standard SDK (ARMV4I)"
- OutputDirectory="output\$(ProjectName)-$(PlatformName)-$(ConfigurationName)"
- IntermediateDirectory="$(OutDir)"
+ Name="Release|Win32"
+ OutputDirectory=".\output\pjmedia-codec-i386-win32-vc8-release"
+ IntermediateDirectory=".\output\pjmedia-codec-i386-win32-vc8-release"
ConfigurationType="4"
- CharacterSet="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@@ -117,30 +120,37 @@ />
<Tool
Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- FavorSizeOrSpeed="0"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
- ExceptionHandling="0"
- RuntimeLibrary="1"
- WarningLevel="3"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;../../third_party"
+ PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.pch"
+ AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ BrowseInformation="1"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
DebugInformationFormat="3"
- CompileAs="0"
- CompileForArchitecture="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
- AdditionalOptions=""
+ OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-release.lib"
+ SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
@@ -150,26 +160,20 @@ />
<Tool
Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.bsc"
/>
<Tool
- Name="VCCodeSignTool"
+ Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory=".\output\pjmedia-codec-i386-win32-vc8-release"
- IntermediateDirectory=".\output\pjmedia-codec-i386-win32-vc8-release"
+ Name="Debug-Static|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@@ -193,28 +197,27 @@ />
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;"../../../ipp-samples/speech-codecs/core/usc/include""
- PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
- StringPooling="true"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.pch"
- AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-release/"
- ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-release/"
- ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ Optimization="0"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;../../third_party"
+ PreprocessorDefinitions="_DEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-debug/pjmedia_codec.pch"
+ AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-debug/"
+ ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-debug/"
+ ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-debug/"
BrowseInformation="1"
WarningLevel="4"
SuppressStartupBanner="true"
- DebugInformationFormat="3"
+ DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
+ PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
@@ -222,7 +225,7 @@ />
<Tool
Name="VCLibrarianTool"
- OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-release.lib"
+ OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-debug.lib"
SuppressStartupBanner="true"
/>
<Tool
@@ -234,7 +237,7 @@ <Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
- OutputFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.bsc"
+ OutputFile=".\output\pjmedia-codec-i386-win32-vc8-debug/pjmedia_codec.bsc"
/>
<Tool
Name="VCFxCopTool"
@@ -244,11 +247,14 @@ />
</Configuration>
<Configuration
- Name="Release|Windows Mobile 6 Standard SDK (ARMV4I)"
- OutputDirectory="output\$(ProjectName)-$(PlatformName)-$(ConfigurationName)"
- IntermediateDirectory="$(OutDir)"
+ Name="Release-Dynamic|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
- CharacterSet="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@@ -267,29 +273,37 @@ />
<Tool
Name="VCCLCompilerTool"
- ExecutionBucket="7"
Optimization="2"
- FavorSizeOrSpeed="2"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
- PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
- ExceptionHandling="0"
- RuntimeLibrary="0"
- WarningLevel="3"
- DebugInformationFormat="0"
- CompileAs="0"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;../../third_party"
+ PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.pch"
+ AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ BrowseInformation="1"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
- AdditionalOptions=""
+ OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-release.lib"
+ SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
@@ -299,24 +313,18 @@ />
<Tool
Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.bsc"
/>
<Tool
- Name="VCCodeSignTool"
+ Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
</Configuration>
<Configuration
- Name="Debug-Static|Win32"
+ Name="Debug-Dynamic|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
@@ -343,11 +351,11 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;../../third_party"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
- RuntimeLibrary="1"
+ RuntimeLibrary="3"
PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-debug/pjmedia_codec.pch"
AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-debug/"
ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-debug/"
@@ -392,11 +400,14 @@ />
</Configuration>
<Configuration
- Name="Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I)"
- OutputDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
- IntermediateDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
+ Name="Release-Static|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
- CharacterSet="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@@ -412,34 +423,40 @@ />
<Tool
Name="VCMIDLTool"
- TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
- ExecutionBucket="7"
- Optimization="0"
- FavorSizeOrSpeed="0"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
- ExceptionHandling="0"
- RuntimeLibrary="1"
- WarningLevel="3"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;../../third_party"
+ PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.pch"
+ AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-release/"
+ BrowseInformation="1"
+ WarningLevel="4"
+ SuppressStartupBanner="true"
DebugInformationFormat="3"
- CompileAs="0"
- CompileForArchitecture="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
- AdditionalOptions=""
+ OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-release.lib"
+ SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
@@ -449,31 +466,22 @@ />
<Tool
Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.bsc"
/>
<Tool
- Name="VCCodeSignTool"
+ Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
- <DeploymentTool
- ForceDirty="-1"
- RemoteDirectory=""
- RegisterOutput="0"
- AdditionalFiles=""
- />
- <DebuggerTool
- />
</Configuration>
<Configuration
- Name="Release-Dynamic|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Debug|Windows Mobile 6 Standard SDK (ARMV4I)"
+ OutputDirectory="output\$(ProjectName)-$(PlatformName)-$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)"
ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -492,37 +500,30 @@ />
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;"../../../ipp-samples/speech-codecs/core/usc/include""
- PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
- StringPooling="true"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.pch"
- AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-release/"
- ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-release/"
- ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-release/"
- BrowseInformation="1"
- WarningLevel="4"
- SuppressStartupBanner="true"
+ ExecutionBucket="7"
+ Optimization="0"
+ FavorSizeOrSpeed="0"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
+ PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
+ ExceptionHandling="0"
+ RuntimeLibrary="1"
+ WarningLevel="3"
DebugInformationFormat="3"
+ CompileAs="0"
+ CompileForArchitecture="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
- OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-release.lib"
- SuppressStartupBanner="true"
+ AdditionalOptions=""
/>
<Tool
Name="VCALinkTool"
@@ -532,20 +533,26 @@ />
<Tool
Name="VCBscMakeTool"
- SuppressStartupBanner="true"
- OutputFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.bsc"
/>
<Tool
- Name="VCFxCopTool"
+ Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
</Configuration>
<Configuration
- Name="Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I)"
- OutputDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
- IntermediateDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
+ Name="Release|Windows Mobile 6 Standard SDK (ARMV4I)"
+ OutputDirectory="output\$(ProjectName)-$(PlatformName)-$(ConfigurationName)"
+ IntermediateDirectory="$(OutDir)"
ConfigurationType="4"
CharacterSet="1"
>
@@ -563,7 +570,6 @@ />
<Tool
Name="VCMIDLTool"
- TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
@@ -616,14 +622,11 @@ />
</Configuration>
<Configuration
- Name="Debug-Dynamic|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Debug-Static|Windows Mobile 6 Standard SDK (ARMV4I)"
+ OutputDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
+ IntermediateDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -639,39 +642,34 @@ />
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
+ ExecutionBucket="7"
Optimization="0"
+ FavorSizeOrSpeed="0"
AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
- PreprocessorDefinitions="_DEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-debug/pjmedia_codec.pch"
- AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-debug/"
- ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-debug/"
- ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-debug/"
- BrowseInformation="1"
- WarningLevel="4"
- SuppressStartupBanner="true"
- DebugInformationFormat="4"
+ PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
+ ExceptionHandling="0"
+ RuntimeLibrary="1"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ CompileAs="0"
+ CompileForArchitecture="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="_DEBUG"
- Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
- OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-debug.lib"
- SuppressStartupBanner="true"
+ AdditionalOptions=""
/>
<Tool
Name="VCALinkTool"
@@ -681,18 +679,24 @@ />
<Tool
Name="VCBscMakeTool"
- SuppressStartupBanner="true"
- OutputFile=".\output\pjmedia-codec-i386-win32-vc8-debug/pjmedia_codec.bsc"
/>
<Tool
- Name="VCFxCopTool"
+ Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
</Configuration>
<Configuration
- Name="Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I)"
+ Name="Release-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I)"
OutputDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
IntermediateDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
ConfigurationType="4"
@@ -717,16 +721,15 @@ <Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
- Optimization="0"
- FavorSizeOrSpeed="0"
+ Optimization="2"
+ FavorSizeOrSpeed="2"
AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
- PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
+ PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
ExceptionHandling="0"
- RuntimeLibrary="1"
+ RuntimeLibrary="0"
WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
CompileAs="0"
- CompileForArchitecture="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -766,14 +769,11 @@ />
</Configuration>
<Configuration
- Name="Release-Static|Win32"
- OutputDirectory="$(ConfigurationName)"
- IntermediateDirectory="$(ConfigurationName)"
+ Name="Debug-Dynamic|Windows Mobile 6 Standard SDK (ARMV4I)"
+ OutputDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
+ IntermediateDirectory="Windows Mobile 6 Standard SDK (ARMV4I)\$(ConfigurationName)"
ConfigurationType="4"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
- UseOfMFC="0"
- ATLMinimizesCRunTimeLibraryUsage="false"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
@@ -789,40 +789,34 @@ />
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="2"
- InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include;"../../../ipp-samples/speech-codecs/core/usc/include""
- PreprocessorDefinitions="NDEBUG;WIN32;_LIB;PJ_WIN32=1;PJ_M_I386=1;HAVE_CONFIG_H"
- StringPooling="true"
- RuntimeLibrary="0"
- EnableFunctionLevelLinking="true"
- PrecompiledHeaderFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.pch"
- AssemblerListingLocation=".\output\pjmedia-codec-i386-win32-vc8-release/"
- ObjectFile=".\output\pjmedia-codec-i386-win32-vc8-release/"
- ProgramDataBaseFileName=".\output\pjmedia-codec-i386-win32-vc8-release/"
- BrowseInformation="1"
- WarningLevel="4"
- SuppressStartupBanner="true"
+ ExecutionBucket="7"
+ Optimization="0"
+ FavorSizeOrSpeed="0"
+ AdditionalIncludeDirectories="../include;../../pjlib/include;../../third_party/speex/include"
+ PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);SMARTPHONE2003_UI_MODEL;SMARTPHONE2003_UI_MODEL"
+ ExceptionHandling="0"
+ RuntimeLibrary="1"
+ WarningLevel="3"
DebugInformationFormat="3"
+ CompileAs="0"
+ CompileForArchitecture="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
- PreprocessorDefinitions="NDEBUG"
- Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
- OutputFile="..\lib\pjmedia-codec-i386-win32-vc8-release.lib"
- SuppressStartupBanner="true"
+ AdditionalOptions=""
/>
<Tool
Name="VCALinkTool"
@@ -832,15 +826,21 @@ />
<Tool
Name="VCBscMakeTool"
- SuppressStartupBanner="true"
- OutputFile=".\output\pjmedia-codec-i386-win32-vc8-release/pjmedia_codec.bsc"
/>
<Tool
- Name="VCFxCopTool"
+ Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
</Configuration>
<Configuration
Name="Release-Static|Windows Mobile 6 Standard SDK (ARMV4I)"
@@ -928,6 +928,10 @@ >
</File>
<File
+ RelativePath="..\src\pjmedia-codec\g7221.c"
+ >
+ </File>
+ <File
RelativePath="..\src\pjmedia-codec\gsm.c"
>
<FileConfiguration
@@ -1205,6 +1209,10 @@ >
</File>
<File
+ RelativePath="..\include\pjmedia-codec\g7221.h"
+ >
+ </File>
+ <File
RelativePath="..\include\pjmedia-codec\gsm.h"
>
</File>
diff --git a/pjmedia/include/pjmedia-codec.h b/pjmedia/include/pjmedia-codec.h index 8b7c3f64..e6d211da 100644 --- a/pjmedia/include/pjmedia-codec.h +++ b/pjmedia/include/pjmedia-codec.h @@ -30,6 +30,7 @@ #include <pjmedia-codec/speex.h> #include <pjmedia-codec/ilbc.h> #include <pjmedia-codec/g722.h> +#include <pjmedia-codec/g7221.h> #include <pjmedia-codec/ipp_codecs.h> #include <pjmedia-codec/passthrough.h> diff --git a/pjmedia/include/pjmedia-codec/config.h b/pjmedia/include/pjmedia-codec/config.h index 805ac63c..046c8618 100644 --- a/pjmedia/include/pjmedia-codec/config.h +++ b/pjmedia/include/pjmedia-codec/config.h @@ -233,4 +233,12 @@ #endif +/** + * G.722.1 codec is disabled by default, it's currently under development. + */ +#ifndef PJMEDIA_HAS_G7221_CODEC +# define PJMEDIA_HAS_G7221_CODEC 0 +#endif + + #endif /* __PJMEDIA_CODEC_CONFIG_H__ */ diff --git a/pjmedia/include/pjmedia-codec/g7221.h b/pjmedia/include/pjmedia-codec/g7221.h new file mode 100644 index 00000000..11ec11f4 --- /dev/null +++ b/pjmedia/include/pjmedia-codec/g7221.h @@ -0,0 +1,113 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJMEDIA_CODECS_G7221_H__ +#define __PJMEDIA_CODECS_G7221_H__ + +/** + * @file pjmedia-codec/g7221.h + * @brief G722.1 codec. + */ + +#include <pjmedia-codec/types.h> + +/** + * @defgroup PJMED_G7221_CODEC G722.1 Codec + * @ingroup PJMEDIA_CODEC + * @brief Implementation of G722.1 codec + * @{ + * + * <b>G722.1 licensed from PolycomŽ</b> + * <b>G722.1 Annex C licensed from PolycomŽ</b> + * + * This section describes functions to register and register G722.1 codec + * factory to the codec manager. After the codec factory has been registered, + * application can use @ref PJMEDIA_CODEC API to manipulate the codec. + * + * PJMEDIA G722.1 codec implementation is based on ITU-T Recommendation + * G.722.1 (05/2005) C fixed point implementation including its Annex C. + * + * G722.1 is a low complexity codec that supports for 7kHz and 14kHz bandwidth + * audio signals working at bitrates ranging from 16kbps to 48kbps. It may be + * used with speech or music inputs. + * + * The codec implementation supports for standard and non-standard bitrates. + * By default, the standard bitrates are enabled upon initialization, i.e.: + * - 24kbps and 32kbps for audio bandwidth 7 kHz (16kHz sampling rate), + * - 24kbps, 32kbps, and 48kbps for audio bandwidth 14 kHz (32kHz sampling + * rate). + * The usage of non-standard bitrates must follow this requirements: + * - for sampling rate 16kHz: 16000 to 32000 bps, it must be a multiple of 400 + * - for sampling rate 32kHz: 24000 to 48000 bps, it must be a multiple of 400 + * Note that currently it is only up to two non-standard modes can be enabled + * at one time. + */ + +PJ_BEGIN_DECL + +/** + * Initialize and register G722.1 codec factory to pjmedia endpoint. + * + * @param endpt The pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt ); + + +/** + * Enable and disable G722.1 mode. By default, the standard modes are + * enabled upon initialization, i.e.: + * - sampling rate 16kHz, bitrate 24kbps and 32kbps. + * - sampling rate 32kHz, bitrate 24kbps, 32kbps, and 48kbps. + * This function can also be used for enabling non-standard modes. + * Note that currently it is only up to two non-standard modes can be + * enabled at one time. + * + * @param sample_rate PCM sampling rate, in Hz, valid values are only + * 16000 and 32000. + * @param bitrate G722.1 bitrate, in bps, the valid values are + * standard and non-standard bitrates as described + * above. + * @param enabled PJ_TRUE for enabling specified mode. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate, + unsigned bitrate, + pj_bool_t enabled); + + +/** + * Unregister G722.1 codecs factory from pjmedia endpoint. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjmedia_codec_g7221_deinit(void); + + +PJ_END_DECL + + +/** + * @} + */ + +#endif /* __PJMEDIA_CODECS_G7221_H__ */ + diff --git a/pjmedia/include/pjmedia-codec/types.h b/pjmedia/include/pjmedia-codec/types.h index c1bae165..dde1371d 100644 --- a/pjmedia/include/pjmedia-codec/types.h +++ b/pjmedia/include/pjmedia-codec/types.h @@ -22,7 +22,6 @@ #include <pjmedia-codec/config.h> - /** * These are the dynamic payload types that are used by codecs in * this library. Also see the header file <pjmedia/codec.h> for list @@ -44,12 +43,12 @@ enum PJMEDIA_RTP_PT_SPEEX_UWB, /**< Speex 32KHz */ PJMEDIA_RTP_PT_L16_8KHZ_MONO, /**< L16 @ 8KHz, mono */ PJMEDIA_RTP_PT_L16_8KHZ_STEREO, /**< L16 @ 8KHz, stereo */ - PJMEDIA_RTP_PT_L16_11KHZ_MONO, /**< L16 @ 11KHz, mono */ - PJMEDIA_RTP_PT_L16_11KHZ_STEREO, /**< L16 @ 11KHz, stereo */ + //PJMEDIA_RTP_PT_L16_11KHZ_MONO, /**< L16 @ 11KHz, mono */ + //PJMEDIA_RTP_PT_L16_11KHZ_STEREO, /**< L16 @ 11KHz, stereo */ PJMEDIA_RTP_PT_L16_16KHZ_MONO, /**< L16 @ 16KHz, mono */ PJMEDIA_RTP_PT_L16_16KHZ_STEREO, /**< L16 @ 16KHz, stereo */ - PJMEDIA_RTP_PT_L16_22KHZ_MONO, /**< L16 @ 22KHz, mono */ - PJMEDIA_RTP_PT_L16_22KHZ_STEREO, /**< L16 @ 22KHz, stereo */ + //PJMEDIA_RTP_PT_L16_22KHZ_MONO, /**< L16 @ 22KHz, mono */ + //PJMEDIA_RTP_PT_L16_22KHZ_STEREO, /**< L16 @ 22KHz, stereo */ PJMEDIA_RTP_PT_L16_32KHZ_MONO, /**< L16 @ 32KHz, mono */ PJMEDIA_RTP_PT_L16_32KHZ_STEREO, /**< L16 @ 32KHz, stereo */ PJMEDIA_RTP_PT_L16_48KHZ_MONO, /**< L16 @ 48KHz, mono */ @@ -65,6 +64,11 @@ enum PJMEDIA_RTP_PT_G722_1_16, /**< G722.1 (16Kbps) */ PJMEDIA_RTP_PT_G722_1_24, /**< G722.1 (24Kbps) */ PJMEDIA_RTP_PT_G722_1_32, /**< G722.1 (32Kbps) */ + PJMEDIA_RTP_PT_G7221C_24, /**< G722.1 Annex C (24Kbps)*/ + PJMEDIA_RTP_PT_G7221C_32, /**< G722.1 Annex C (32Kbps)*/ + PJMEDIA_RTP_PT_G7221C_48, /**< G722.1 Annex C (48Kbps)*/ + PJMEDIA_RTP_PT_G7221_RSV1, /**< G722.1 reserve */ + PJMEDIA_RTP_PT_G7221_RSV2, /**< G722.1 reserve */ }; diff --git a/pjmedia/src/pjmedia-codec/g7221.c b/pjmedia/src/pjmedia-codec/g7221.c new file mode 100644 index 00000000..785e832a --- /dev/null +++ b/pjmedia/src/pjmedia-codec/g7221.c @@ -0,0 +1,854 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <pjmedia-codec/g7221.h> +#include <pjmedia/codec.h> +#include <pjmedia/errno.h> +#include <pjmedia/endpoint.h> +#include <pjmedia/port.h> +#include <pjmedia/silencedet.h> +#include <pj/assert.h> +#include <pj/log.h> +#include <pj/math.h> +#include <pj/pool.h> +#include <pj/string.h> +#include <pj/os.h> + +/* + * Only build this file if PJMEDIA_HAS_G7221_CODEC != 0 + */ +#if defined(PJMEDIA_HAS_G7221_CODEC) && PJMEDIA_HAS_G7221_CODEC!=0 + +#include "../../third_party/g7221/common/defs.h" + +#define THIS_FILE "g7221.c" + +/* Codec tag, it is the SDP encoding name and also MIME subtype name */ +#define CODEC_TAG "G7221" + +/* Sampling rates definition */ +#define WB_SAMPLE_RATE 16000 +#define UWB_SAMPLE_RATE 32000 + +/* Maximum number of samples per frame. */ +#define MAX_SAMPLES_PER_FRAME (UWB_SAMPLE_RATE * 20 / 1000) + +/* Maximum number of codec params. */ +#define MAX_CODEC_MODES 8 +#define START_RSV_MODES_IDX 6 + + +/* Prototypes for G722.1 codec factory */ +static pj_status_t test_alloc( pjmedia_codec_factory *factory, + const pjmedia_codec_info *id ); +static pj_status_t default_attr( pjmedia_codec_factory *factory, + const pjmedia_codec_info *id, + pjmedia_codec_param *attr ); +static pj_status_t enum_codecs( pjmedia_codec_factory *factory, + unsigned *count, + pjmedia_codec_info codecs[]); +static pj_status_t alloc_codec( pjmedia_codec_factory *factory, + const pjmedia_codec_info *id, + pjmedia_codec **p_codec); +static pj_status_t dealloc_codec( pjmedia_codec_factory *factory, + pjmedia_codec *codec ); + +/* Prototypes for G722.1 codec implementation. */ +static pj_status_t codec_init( pjmedia_codec *codec, + pj_pool_t *pool ); +static pj_status_t codec_open( pjmedia_codec *codec, + pjmedia_codec_param *attr ); +static pj_status_t codec_close( pjmedia_codec *codec ); +static pj_status_t codec_modify(pjmedia_codec *codec, + const pjmedia_codec_param *attr ); +static pj_status_t codec_parse( pjmedia_codec *codec, + void *pkt, + pj_size_t pkt_size, + const pj_timestamp *ts, + unsigned *frame_cnt, + pjmedia_frame frames[]); +static pj_status_t codec_encode( pjmedia_codec *codec, + const struct pjmedia_frame *input, + unsigned output_buf_len, + struct pjmedia_frame *output); +static pj_status_t codec_decode( pjmedia_codec *codec, + const struct pjmedia_frame *input, + unsigned output_buf_len, + struct pjmedia_frame *output); +static pj_status_t codec_recover( pjmedia_codec *codec, + unsigned output_buf_len, + struct pjmedia_frame *output); + +/* Definition for G722.1 codec operations. */ +static pjmedia_codec_op codec_op = +{ + &codec_init, + &codec_open, + &codec_close, + &codec_modify, + &codec_parse, + &codec_encode, + &codec_decode, + &codec_recover +}; + +/* Definition for G722.1 codec factory operations. */ +static pjmedia_codec_factory_op codec_factory_op = +{ + &test_alloc, + &default_attr, + &enum_codecs, + &alloc_codec, + &dealloc_codec +}; + + +/* Structure of G722.1 mode */ +typedef struct codec_mode +{ + pj_bool_t enabled; /* Is this mode enabled? */ + pj_uint8_t pt; /* Payload type. */ + unsigned sample_rate; /* Default sampling rate to be used.*/ + unsigned bitrate; /* Bitrate. */ + char bitrate_str[8]; /* Bitrate in string. */ +} codec_mode; + + +/* G722.1 codec factory */ +static struct codec_factory { + pjmedia_codec_factory base; /**< Base class. */ + pjmedia_endpt *endpt; /**< PJMEDIA endpoint instance. */ + pj_pool_t *pool; /**< Codec factory pool. */ + pj_mutex_t *mutex; /**< Codec factory mutex. */ + + unsigned mode_count; /**< Number of G722.1 modes. */ + codec_mode modes[MAX_CODEC_MODES]; /**< The G722.1 modes. */ + unsigned mode_rsv_start;/**< Start index of G722.1 non- + standard modes, currently + there can only be up to two + non-standard modes enabled + at the same time. */ +} codec_factory; + +/* G722.1 codec private data. */ +typedef struct codec_private { + pj_pool_t *pool; /**< Pool for each instance. */ + pj_bool_t plc_enabled; /**< PLC enabled? */ + pj_bool_t vad_enabled; /**< VAD enabled? */ + pjmedia_silence_det *vad; /**< PJMEDIA VAD instance. */ + pj_timestamp last_tx; /**< Timestamp of last transmit.*/ + + /* ITU ref implementation seems to leave the codec engine states to be + * managed by the application, so here we go. + */ + + /* Common engine state */ + pj_uint16_t samples_per_frame; /**< Samples per frame. */ + pj_uint16_t bitrate; /**< Coded stream bitrate. */ + pj_uint16_t frame_size; /**< Coded frame size. */ + pj_uint16_t frame_size_bits; /**< Coded frame size in bits. */ + pj_uint16_t number_of_regions; /**< Number of regions. */ + + /* Encoder specific state */ + Word16 *enc_old_frame; + + /* Decoder specific state */ + Word16 *dec_old_frame; + Rand_Obj dec_randobj; + Word16 dec_old_mag_shift; + Word16 *dec_old_mlt_coefs; +} codec_private_t; + +/* + * Helper function for looking up mode based on payload type. + */ +static codec_mode* lookup_mode(unsigned pt) +{ + codec_mode* mode = NULL; + unsigned i; + + for (i = 0; i < codec_factory.mode_count; ++i) { + mode = &codec_factory.modes[i]; + if (mode->pt == pt) + break; + } + + return mode; +} + +/* + * Helper function to validate G722.1 mode. Valid modes are defined as: + * 1. sample rate must be 16kHz or 32kHz, + * 2. bitrate: + * - for sampling rate 16kHz: 16000 to 32000 bps, it must be a multiple + * of 400 (to keep RTP payload octed-aligned) + * - for sampling rate 32kHz: 24000 to 48000 bps, it must be a multiple + * of 400 (to keep RTP payload octed-aligned) + */ +static pj_bool_t validate_mode(unsigned sample_rate, unsigned bitrate) +{ + if (sample_rate == WB_SAMPLE_RATE) { + if (bitrate < 16000 || bitrate > 32000 || + ((bitrate-16000) % 400 != 0)) + { + return PJ_FALSE; + } + } else if (sample_rate == UWB_SAMPLE_RATE) { + if (bitrate < 24000 || bitrate > 48000 || + ((bitrate-24000) % 400 != 0)) + { + return PJ_FALSE; + } + } else { + return PJ_FALSE; + } + + return PJ_TRUE; +} + +/* + * Initialize and register G722.1 codec factory to pjmedia endpoint. + */ +PJ_DEF(pj_status_t) pjmedia_codec_g7221_init( pjmedia_endpt *endpt ) +{ + pjmedia_codec_mgr *codec_mgr; + codec_mode *mode; + pj_status_t status; + + if (codec_factory.pool != NULL) { + /* Already initialized. */ + return PJ_SUCCESS; + } + + /* Initialize codec modes, by default all standard bitrates are enabled */ + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_TRUE; + mode->pt = PJMEDIA_RTP_PT_G722_1_24; + mode->sample_rate = WB_SAMPLE_RATE; + mode->bitrate = 24000; + pj_utoa(mode->bitrate, mode->bitrate_str); + + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_TRUE; + mode->pt = PJMEDIA_RTP_PT_G722_1_32; + mode->sample_rate = WB_SAMPLE_RATE; + mode->bitrate = 32000; + pj_utoa(mode->bitrate, mode->bitrate_str); + + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_TRUE; + mode->pt = PJMEDIA_RTP_PT_G7221C_24; + mode->sample_rate = UWB_SAMPLE_RATE; + mode->bitrate = 24000; + pj_utoa(mode->bitrate, mode->bitrate_str); + + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_TRUE; + mode->pt = PJMEDIA_RTP_PT_G7221C_32; + mode->sample_rate = UWB_SAMPLE_RATE; + mode->bitrate = 32000; + pj_utoa(mode->bitrate, mode->bitrate_str); + + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_TRUE; + mode->pt = PJMEDIA_RTP_PT_G7221C_48; + mode->sample_rate = UWB_SAMPLE_RATE; + mode->bitrate = 48000; + pj_utoa(mode->bitrate, mode->bitrate_str); + + /* Non-standard bitrates */ + + /* Bitrate 16kbps is non-standard but rather commonly used. */ + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_FALSE; + mode->pt = PJMEDIA_RTP_PT_G722_1_16; + mode->sample_rate = WB_SAMPLE_RATE; + mode->bitrate = 16000; + pj_utoa(mode->bitrate, mode->bitrate_str); + + /* Reserved two modes for non-standard bitrates */ + codec_factory.mode_rsv_start = codec_factory.mode_count; + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_FALSE; + mode->pt = PJMEDIA_RTP_PT_G7221_RSV1; + + mode = &codec_factory.modes[codec_factory.mode_count++]; + mode->enabled = PJ_FALSE; + mode->pt = PJMEDIA_RTP_PT_G7221_RSV2; + + pj_assert(codec_factory.mode_count <= MAX_CODEC_MODES); + + /* Create G722.1 codec factory. */ + codec_factory.base.op = &codec_factory_op; + codec_factory.base.factory_data = NULL; + codec_factory.endpt = endpt; + + codec_factory.pool = pjmedia_endpt_create_pool(endpt, "G722.1 codec", + 4000, 4000); + if (!codec_factory.pool) + return PJ_ENOMEM; + + /* Create mutex. */ + status = pj_mutex_create_simple(codec_factory.pool, "G722.1 codec", + &codec_factory.mutex); + if (status != PJ_SUCCESS) + goto on_error; + + /* Get the codec manager. */ + codec_mgr = pjmedia_endpt_get_codec_mgr(endpt); + if (!codec_mgr) { + status = PJ_EINVALIDOP; + goto on_error; + } + + /* Register codec factory to endpoint. */ + status = pjmedia_codec_mgr_register_factory(codec_mgr, + &codec_factory.base); + if (status != PJ_SUCCESS) + goto on_error; + + /* Done. */ + return PJ_SUCCESS; + +on_error: + if (codec_factory.mutex) { + pj_mutex_destroy(codec_factory.mutex); + codec_factory.mutex = NULL; + } + + pj_pool_release(codec_factory.pool); + codec_factory.pool = NULL; + return status; +} + + +/** + * Enable and disable G722.1 modes, including non-standard modes. + */ +PJ_DEF(pj_status_t) pjmedia_codec_g7221_set_mode(unsigned sample_rate, + unsigned bitrate, + pj_bool_t enabled) +{ + unsigned i; + + /* Validate mode */ + if (!validate_mode(sample_rate, bitrate)) + return PJMEDIA_CODEC_EINMODE; + + /* Look up in factory modes table */ + for (i = 0; i < codec_factory.mode_count; ++i) { + if (codec_factory.modes[i].sample_rate == sample_rate && + codec_factory.modes[i].bitrate == bitrate) + { + codec_factory.modes[i].enabled = enabled; + return PJ_SUCCESS; + } + } + + /* Mode not found in modes table, this may be a request to enable + * a non-standard G722.1 mode. + */ + + /* Non-standard mode need to be initialized first before user + * can disable it. + */ + if (!enabled) + return PJ_ENOTFOUND; + + /* Initialize a non-standard mode, look for available space. */ + for (i = codec_factory.mode_rsv_start; + i < codec_factory.mode_count; ++i) + { + if (!codec_factory.modes[i].enabled) + { + codec_mode *mode = &codec_factory.modes[i]; + mode->enabled = PJ_TRUE; + mode->sample_rate = sample_rate; + mode->bitrate = bitrate; + pj_utoa(mode->bitrate, mode->bitrate_str); + + return PJ_SUCCESS; + } + } + + /* No space for non-standard mode. */ + return PJ_ETOOMANY; +} + + +/* + * Unregister G722.1 codec factory from pjmedia endpoint. + */ +PJ_DEF(pj_status_t) pjmedia_codec_g7221_deinit(void) +{ + pjmedia_codec_mgr *codec_mgr; + pj_status_t status; + + if (codec_factory.pool == NULL) { + /* Already deinitialized */ + return PJ_SUCCESS; + } + + pj_mutex_lock(codec_factory.mutex); + + /* Get the codec manager. */ + codec_mgr = pjmedia_endpt_get_codec_mgr(codec_factory.endpt); + if (!codec_mgr) { + pj_pool_release(codec_factory.pool); + codec_factory.pool = NULL; + return PJ_EINVALIDOP; + } + + /* Unregister G722.1 codec factory. */ + status = pjmedia_codec_mgr_unregister_factory(codec_mgr, + &codec_factory.base); + + /* Destroy mutex. */ + pj_mutex_destroy(codec_factory.mutex); + + /* Destroy pool. */ + pj_pool_release(codec_factory.pool); + codec_factory.pool = NULL; + + return status; +} + +/* + * Check if factory can allocate the specified codec. + */ +static pj_status_t test_alloc( pjmedia_codec_factory *factory, + const pjmedia_codec_info *info ) +{ + PJ_UNUSED_ARG(factory); + + /* Type MUST be audio. */ + if (info->type != PJMEDIA_TYPE_AUDIO) + return PJMEDIA_CODEC_EUNSUP; + + /* Check encoding name. */ + if (pj_stricmp2(&info->encoding_name, CODEC_TAG) != 0) + return PJMEDIA_CODEC_EUNSUP; + + /* Check clock-rate */ + if (info->clock_rate != WB_SAMPLE_RATE && + info->clock_rate != UWB_SAMPLE_RATE) + { + return PJMEDIA_CODEC_EUNSUP; + } + + return PJ_SUCCESS; +} + +/* + * Generate default attribute. + */ +static pj_status_t default_attr ( pjmedia_codec_factory *factory, + const pjmedia_codec_info *id, + pjmedia_codec_param *attr ) +{ + codec_mode *mode; + + PJ_ASSERT_RETURN(factory==&codec_factory.base, PJ_EINVAL); + + pj_bzero(attr, sizeof(pjmedia_codec_param)); + + mode = lookup_mode(id->pt); + if (mode == NULL || !mode->enabled) + return PJMEDIA_CODEC_EUNSUP; + + attr->info.pt = (pj_uint8_t)id->pt; + attr->info.channel_cnt = 1; + attr->info.clock_rate = mode->sample_rate; + attr->info.max_bps = mode->bitrate; + attr->info.avg_bps = mode->bitrate; + attr->info.pcm_bits_per_sample = 16; + attr->info.frm_ptime = 20; + + /* Default flags. */ + attr->setting.plc = 1; + attr->setting.vad = 0; + attr->setting.frm_per_pkt = 1; + + /* Default FMTP setting */ + attr->setting.dec_fmtp.cnt = 1; + attr->setting.dec_fmtp.param[0].name = pj_str("bitrate"); + attr->setting.dec_fmtp.param[0].val = pj_str(mode->bitrate_str); + + return PJ_SUCCESS; +} + +/* + * Enum codecs supported by this factory. + */ +static pj_status_t enum_codecs( pjmedia_codec_factory *factory, + unsigned *count, + pjmedia_codec_info codecs[]) +{ + unsigned i; + + PJ_ASSERT_RETURN(factory==&codec_factory.base, PJ_EINVAL); + PJ_ASSERT_RETURN(codecs && *count > 0, PJ_EINVAL); + + *count = PJ_MIN(*count, codec_factory.mode_count); + + for (i=0; i<*count; ++i) { + if (!codec_factory.modes[i].enabled) + continue; + + pj_bzero(&codecs[i], sizeof(pjmedia_codec_info)); + codecs[i].encoding_name = pj_str((char*)CODEC_TAG); + codecs[i].pt = codec_factory.modes[i].pt; + codecs[i].type = PJMEDIA_TYPE_AUDIO; + codecs[i].clock_rate = codec_factory.modes[i].sample_rate; + codecs[i].channel_cnt = 1; + } + + return PJ_SUCCESS; +} + +/* + * Allocate a new codec instance. + */ +static pj_status_t alloc_codec( pjmedia_codec_factory *factory, + const pjmedia_codec_info *id, + pjmedia_codec **p_codec) +{ + codec_private_t *codec_data; + pjmedia_codec *codec; + pj_pool_t *pool; + pj_status_t status; + + PJ_ASSERT_RETURN(factory && id && p_codec, PJ_EINVAL); + PJ_ASSERT_RETURN(factory == &codec_factory.base, PJ_EINVAL); + + pj_mutex_lock(codec_factory.mutex); + + /* Create pool for codec instance */ + pool = pjmedia_endpt_create_pool(codec_factory.endpt, "G7221", 512, 512); + codec = PJ_POOL_ZALLOC_T(pool, pjmedia_codec); + codec->op = &codec_op; + codec->factory = factory; + codec->codec_data = PJ_POOL_ZALLOC_T(pool, codec_private_t); + codec_data = (codec_private_t*) codec->codec_data; + codec_data->pool = pool; + + /* Create silence detector */ + status = pjmedia_silence_det_create(pool, id->clock_rate, + id->clock_rate * 20 / 1000, + &codec_data->vad); + if (status != PJ_SUCCESS) { + pj_mutex_unlock(codec_factory.mutex); + return status; + } + + pj_mutex_unlock(codec_factory.mutex); + + *p_codec = codec; + return PJ_SUCCESS; +} + +/* + * Free codec. + */ +static pj_status_t dealloc_codec( pjmedia_codec_factory *factory, + pjmedia_codec *codec ) +{ + codec_private_t *codec_data; + pj_pool_t *pool; + + PJ_ASSERT_RETURN(factory && codec, PJ_EINVAL); + PJ_ASSERT_RETURN(factory == &codec_factory.base, PJ_EINVAL); + + /* Close codec, if it's not closed. */ + codec_data = (codec_private_t*) codec->codec_data; + pool = codec_data->pool; + codec_close(codec); + + /* Release codec pool */ + pj_pool_release(pool); + + return PJ_SUCCESS; +} + +/* + * Init codec. + */ +static pj_status_t codec_init( pjmedia_codec *codec, + pj_pool_t *pool ) +{ + PJ_UNUSED_ARG(codec); + PJ_UNUSED_ARG(pool); + return PJ_SUCCESS; +} + +/* + * Open codec. + */ +static pj_status_t codec_open( pjmedia_codec *codec, + pjmedia_codec_param *attr ) +{ + codec_private_t *codec_data = (codec_private_t*) codec->codec_data; + pj_pool_t *pool; + unsigned tmp; + + /* Validation mode first! */ + if (!validate_mode(attr->info.clock_rate, attr->info.avg_bps)) + return PJMEDIA_CODEC_EINMODE; + + pool = codec_data->pool; + + /* Initialize common state */ + codec_data->vad_enabled = (attr->setting.vad != 0); + codec_data->plc_enabled = (attr->setting.plc != 0); + + codec_data->bitrate = (pj_uint16_t)attr->info.avg_bps; + codec_data->frame_size_bits = (pj_uint16_t)(attr->info.avg_bps*20/1000); + codec_data->frame_size = (pj_uint16_t)(codec_data->frame_size_bits>>3); + codec_data->samples_per_frame = (pj_uint16_t) + (attr->info.clock_rate*20/1000); + codec_data->number_of_regions = (pj_uint16_t) + (attr->info.clock_rate <= WB_SAMPLE_RATE? + NUMBER_OF_REGIONS:MAX_NUMBER_OF_REGIONS); + + /* Initialize encoder state */ + tmp = codec_data->samples_per_frame << 1; + codec_data->enc_old_frame = (Word16*)pj_pool_zalloc(pool, tmp); + + /* Initialize decoder state */ + tmp = codec_data->samples_per_frame; + codec_data->dec_old_frame = (Word16*)pj_pool_zalloc(pool, tmp); + + tmp = codec_data->samples_per_frame << 1; + codec_data->dec_old_mlt_coefs = (Word16*)pj_pool_zalloc(pool, tmp); + + codec_data->dec_randobj.seed0 = 1; + codec_data->dec_randobj.seed1 = 1; + codec_data->dec_randobj.seed2 = 1; + codec_data->dec_randobj.seed3 = 1; + + return PJ_SUCCESS; +} + +/* + * Close codec. + */ +static pj_status_t codec_close( pjmedia_codec *codec ) +{ + PJ_UNUSED_ARG(codec); + + return PJ_SUCCESS; +} + + +/* + * Modify codec settings. + */ +static pj_status_t codec_modify( pjmedia_codec *codec, + const pjmedia_codec_param *attr ) +{ + codec_private_t *codec_data = (codec_private_t*) codec->codec_data; + + codec_data->vad_enabled = (attr->setting.vad != 0); + codec_data->plc_enabled = (attr->setting.plc != 0); + + return PJ_SUCCESS; +} + +/* + * Get frames in the packet. + */ +static pj_status_t codec_parse( pjmedia_codec *codec, + void *pkt, + pj_size_t pkt_size, + const pj_timestamp *ts, + unsigned *frame_cnt, + pjmedia_frame frames[]) +{ + codec_private_t *codec_data = (codec_private_t*) codec->codec_data; + unsigned count = 0; + + PJ_ASSERT_RETURN(frame_cnt, PJ_EINVAL); + + /* Parse based on fixed frame size. */ + while (pkt_size >= codec_data->frame_size && count < *frame_cnt) { + frames[count].type = PJMEDIA_FRAME_TYPE_AUDIO; + frames[count].buf = pkt; + frames[count].size = codec_data->frame_size; + frames[count].timestamp.u64 = ts->u64 + + count * codec_data->samples_per_frame; + + pkt = (pj_uint8_t*)pkt + codec_data->frame_size; + pkt_size -= codec_data->frame_size; + + ++count; + } + + pj_assert(pkt_size == 0); + *frame_cnt = count; + + return PJ_SUCCESS; +} + +/* + * Encode frames. + */ +static pj_status_t codec_encode( pjmedia_codec *codec, + const struct pjmedia_frame *input, + unsigned output_buf_len, + struct pjmedia_frame *output) +{ + codec_private_t *codec_data = (codec_private_t*) codec->codec_data; + Word16 mlt_coefs[MAX_SAMPLES_PER_FRAME]; + Word16 mag_shift; + + /* Check frame in & out size */ + PJ_ASSERT_RETURN((pj_uint16_t)input->size == + (codec_data->samples_per_frame<<1), + PJMEDIA_CODEC_EPCMTOOSHORT); + PJ_ASSERT_RETURN(output_buf_len >= codec_data->frame_size, + PJMEDIA_CODEC_EFRMTOOSHORT); + + /* Apply silence detection if VAD is enabled */ + if (codec_data->vad_enabled) { + pj_bool_t is_silence; + pj_int32_t silence_duration; + + pj_assert(codec_data->vad); + + silence_duration = pj_timestamp_diff32(&codec_data->last_tx, + &input->timestamp); + + is_silence = pjmedia_silence_det_detect(codec_data->vad, + (const pj_int16_t*) input->buf, + (input->size >> 1), + NULL); + if (is_silence && + PJMEDIA_CODEC_MAX_SILENCE_PERIOD != -1 && + silence_duration < (PJMEDIA_CODEC_MAX_SILENCE_PERIOD * + (int)codec_data->samples_per_frame / 20)) + { + output->type = PJMEDIA_FRAME_TYPE_NONE; + output->buf = NULL; + output->size = 0; + output->timestamp = input->timestamp; + return PJ_SUCCESS; + } else { + codec_data->last_tx = input->timestamp; + } + } + + /* Convert input samples to rmlt coefs */ + mag_shift = samples_to_rmlt_coefs((Word16*)input->buf, + codec_data->enc_old_frame, + mlt_coefs, + codec_data->samples_per_frame); + + /* Encode the mlt coefs */ + encoder(codec_data->frame_size_bits, + codec_data->number_of_regions, + mlt_coefs, + mag_shift, + output->buf); + + output->type = PJMEDIA_FRAME_TYPE_AUDIO; + output->size = codec_data->frame_size; + + return PJ_SUCCESS; +} + +/* + * Decode frame. + */ +static pj_status_t codec_decode( pjmedia_codec *codec, + const struct pjmedia_frame *input, + unsigned output_buf_len, + struct pjmedia_frame *output) +{ + codec_private_t *codec_data = (codec_private_t*) codec->codec_data; + Word16 mlt_coefs[MAX_SAMPLES_PER_FRAME]; + Word16 mag_shift; + Bit_Obj bitobj; + Word16 frame_error_flag = 0; + + /* Check frame out length size */ + PJ_ASSERT_RETURN(output_buf_len >= + (unsigned)(codec_data->samples_per_frame<<1), + PJMEDIA_CODEC_EPCMTOOSHORT); + + /* If input is NULL, perform PLC by settting frame_error_flag to 1 */ + if (input) { + /* Check frame in length size */ + PJ_ASSERT_RETURN((pj_uint16_t)input->size == codec_data->frame_size, + PJMEDIA_CODEC_EFRMINLEN); + bitobj.code_word_ptr = (Word16*)input->buf; + bitobj.current_word = *bitobj.code_word_ptr; + bitobj.code_bit_count = 0; + bitobj.number_of_bits_left = codec_data->frame_size_bits; + } else { + pj_bzero(&bitobj, sizeof(bitobj)); + frame_error_flag = 1; + } + + /* Process the input frame to get mlt coefs */ + decoder(&bitobj, + &codec_data->dec_randobj, + codec_data->number_of_regions, + mlt_coefs, + &mag_shift, + &codec_data->dec_old_mag_shift, + codec_data->dec_old_mlt_coefs, + frame_error_flag); + + /* Convert the mlt_coefs to PCM samples */ + rmlt_coefs_to_samples(mlt_coefs, + codec_data->dec_old_frame, + (Word16*)output->buf, + codec_data->samples_per_frame, + mag_shift); + + output->type = PJMEDIA_FRAME_TYPE_AUDIO; + output->size = codec_data->samples_per_frame << 1; + + return PJ_SUCCESS; +} + +/* + * Recover lost frame. + */ +static pj_status_t codec_recover( pjmedia_codec *codec, + unsigned output_buf_len, + struct pjmedia_frame *output) +{ + codec_private_t *codec_data = (codec_private_t*) codec->codec_data; + + /* Use native PLC when PLC is enabled. */ + if (codec_data->plc_enabled) + return codec_decode(codec, NULL, output_buf_len, output); + + /* Otherwise just return zero-fill frame. */ + output->type = PJMEDIA_FRAME_TYPE_AUDIO; + output->size = codec_data->samples_per_frame << 1; + + pjmedia_zero_samples((pj_int16_t*)output->buf, + codec_data->samples_per_frame); + + return PJ_SUCCESS; +} + +#endif /* PJMEDIA_HAS_G7221_CODEC */ diff --git a/pjmedia/src/pjmedia-codec/l16.c b/pjmedia/src/pjmedia-codec/l16.c index 2b1ad7b3..2789498e 100644 --- a/pjmedia/src/pjmedia-codec/l16.c +++ b/pjmedia/src/pjmedia-codec/l16.c @@ -330,6 +330,8 @@ static pj_status_t l16_enum_codecs( pjmedia_codec_factory *factory, ++count; } +// disable some L16 modes +#if 0 if (count < *max_count) { /* 11025 Hz mono */ codecs[count].type = PJMEDIA_TYPE_AUDIO; @@ -349,6 +351,7 @@ static pj_status_t l16_enum_codecs( pjmedia_codec_factory *factory, codecs[count].channel_cnt = 2; ++count; } +#endif if (count < *max_count) { /* 16000 Hz mono */ @@ -371,6 +374,8 @@ static pj_status_t l16_enum_codecs( pjmedia_codec_factory *factory, ++count; } +// disable some L16 modes +#if 0 if (count < *max_count) { /* 22050 Hz mono */ codecs[count].type = PJMEDIA_TYPE_AUDIO; @@ -391,6 +396,7 @@ static pj_status_t l16_enum_codecs( pjmedia_codec_factory *factory, codecs[count].channel_cnt = 2; ++count; } +#endif if (count < *max_count) { /* 32000 Hz mono */ |