📄 speexcodec.cxx
字号:
{ \
NULL, \
EQUIVALENCE_COUNTRY_CODE, EQUIVALENCE_EXTENSION_CODE, EQUIVALENCE_MANUFACTURER_CODE, \
(const unsigned char *)speex##suffix##Str, sizeof(speex##suffix##Str)-1, \
NULL \
}; \
CREATE_IETFSPEEX_CAP_DATA(desc, suffix, ordinal, 8000) \
#define DECLARE_NARROW_SPEEX_CODEC(prefix, suffix, ordinal, bitsPerFrame) \
/* Original OpenH323 capability */ \
{ \
/* encoder */ \
PLUGIN_CODEC_VERSION, /* codec API version */ \
&licenseInfo, /* license information */ \
PluginCodec_MediaTypeAudio | /* audio codec */ \
PluginCodec_InputTypeRaw | /* raw input data */ \
PluginCodec_OutputTypeRaw | /* raw output data */ \
PluginCodec_RTPTypeShared | /* share RTP code */ \
PluginCodec_RTPTypeDynamic | /* dynamic RTP type */ \
PluginCodec_DecodeSilence, /* can encode silence frames */ \
prefix##suffix, /* text decription */ \
L16Desc, /* source format */ \
prefix##suffix, /* destination format */ \
(void *)ordinal, /* user data */ \
8000, /* samples per second */ \
bitsPerFrame*50, /* raw bits per second */ \
NARROW_NS_PER_FRAME, /* nanoseconds per frame */ \
NARROW_SAMPLES_PER_FRAME, /* samples per frame */ \
(bitsPerFrame + 7) / 8, /* bytes per frame */ \
1, /* recommended number of frames per packet */ \
1, /* maximum number of frames per packet */ \
0, /* IANA RTP payload code */ \
sdpSpeex, /* RTP payload name */ \
create_encoder, /* create codec function */ \
destroy_encoder, /* destroy codec */ \
codec_encoder, /* encode/decode */ \
NULL, /* codec controls */ \
PluginCodec_H323Codec_nonStandard, /* h323CapabilityType */ \
&prefix##suffix##Cap /* h323CapabilityData */ \
}, \
{ \
/* decoder */ \
PLUGIN_CODEC_VERSION, /* codec API version */ \
&licenseInfo, /* license information */ \
PluginCodec_MediaTypeAudio | /* audio codec */ \
PluginCodec_InputTypeRaw | /* raw input data */ \
PluginCodec_OutputTypeRaw | /* raw output data */ \
PluginCodec_RTPTypeShared | /* share RTP code */ \
PluginCodec_RTPTypeDynamic | /* dynamic RTP type */ \
PluginCodec_DecodeSilence, /* can encode silence frames */ \
prefix##suffix, /* text decription */ \
prefix##suffix, /* source format */ \
L16Desc, /* destination format */ \
(void *)ordinal, /* user data */ \
8000, /* samples per second */ \
bitsPerFrame*50, /* raw bits per second */ \
NARROW_NS_PER_FRAME, /* nanoseconds per frame */ \
NARROW_SAMPLES_PER_FRAME, /* samples per frame */ \
(bitsPerFrame+7)/8, /* bytes per frame */ \
1, /* recommended number of frames per packet */ \
1, /* maximum number of frames per packet */ \
0, /* IANA RTP payload code */ \
sdpSpeex, /* RTP payload name */ \
create_decoder, /* create codec function */ \
destroy_decoder, /* destroy codec */ \
codec_decoder, /* encode/decode */ \
NULL, /* codec controls */ \
PluginCodec_H323Codec_nonStandard, /* h323CapabilityType */ \
&prefix##suffix##Cap /* h323CapabilityData */ \
} \
CREATE_NARROW_SPEEX_CAP_DATA(Narrow-5.95k, Narrow5k95, 2)
CREATE_NARROW_SPEEX_CAP_DATA(Narrow-8k, Narrow8k, 3)
CREATE_NARROW_SPEEX_CAP_DATA(Narrow-11k, Narrow11k, 4)
CREATE_NARROW_SPEEX_CAP_DATA(Narrow-15k, Narrow15k, 5)
CREATE_NARROW_SPEEX_CAP_DATA(Narrow-18.2k, Narrow18k2, 6)
CREATE_NARROW_SPEEX_CAP_DATA(Narrow-24.6k, Narrow24k6, 7)
////////////////////////////////////////////////////////////////////////////////////////////////
#define CREATE_WIDE_SPEEX_CAP_DATA(desc, suffix, ordinal) \
static const char speex##suffix[] = "Speex" #desc; \
static const char speex##suffix##Str[] = "Speex bs4 Wide" #ordinal; \
static struct PluginCodec_H323NonStandardCodecData speex##suffix##Cap = \
{ \
NULL, \
EQUIVALENCE_COUNTRY_CODE, EQUIVALENCE_EXTENSION_CODE, EQUIVALENCE_MANUFACTURER_CODE, \
(const unsigned char *)speex##suffix##Str, sizeof(speex##suffix##Str)-1, \
NULL \
}; \
CREATE_IETFSPEEX_CAP_DATA(desc, suffix, ordinal, 16000)
#define DECLARE_WIDE_SPEEX_CODEC(prefix, suffix, ordinal, bitsPerFrame) \
/* Original OpenH323 capability */ \
{ \
/* encoder */ \
PLUGIN_CODEC_VERSION, /* codec API version */ \
&licenseInfo, /* license information */ \
PluginCodec_MediaTypeAudio | /* audio codec */ \
PluginCodec_InputTypeRaw | /* raw input data */ \
PluginCodec_OutputTypeRaw | /* raw output data */ \
PluginCodec_RTPTypeShared | /* share RTP code */ \
PluginCodec_RTPTypeDynamic | /* dynamic RTP type */ \
PluginCodec_DecodeSilence, /* can encode silence frames */ \
prefix##suffix, /* text decription */ \
L16Desc, /* source format */ \
prefix##suffix, /* destination format */ \
(void *)ordinal, /* user data */ \
16000, /* samples per second */ \
bitsPerFrame*50, /* raw bits per second */ \
WIDE_NS_PER_FRAME, /* nanoseconds per frame */ \
WIDE_SAMPLES_PER_FRAME, /* samples per frame */ \
(bitsPerFrame+7)/8, /* bytes per frame */ \
1, /* recommended number of frames per packet */ \
1, /* maximum number of frames per packet */ \
0, /* IANA RTP payload code */ \
sdpSpeex, /* RTP payload name */ \
create_encoder, /* create codec function */ \
destroy_encoder, /* destroy codec */ \
codec_encoder, /* encode/decode */ \
NULL, /* codec controls */ \
PluginCodec_H323Codec_nonStandard, /* h323CapabilityType */ \
&prefix##suffix##Cap /* h323CapabilityData */ \
}, \
{ \
/* decoder */ \
PLUGIN_CODEC_VERSION, /* codec API version */ \
&licenseInfo, /* license information */ \
PluginCodec_MediaTypeAudio | /* audio codec */ \
PluginCodec_InputTypeRaw | /* raw input data */ \
PluginCodec_OutputTypeRaw | /* raw output data */ \
PluginCodec_RTPTypeShared | /* share RTP code */ \
PluginCodec_RTPTypeDynamic | /* dynamic RTP type */ \
PluginCodec_DecodeSilence, /* can encode silence frames */ \
prefix##suffix, /* text decription */ \
prefix##suffix, /* source format */ \
L16Desc, /* destination format */ \
(void *)ordinal, /* user data */ \
16000, /* samples per second */ \
bitsPerFrame*50, /* raw bits per second */ \
WIDE_NS_PER_FRAME, /* nanoseconds per frame */ \
WIDE_SAMPLES_PER_FRAME, /* samples per frame */ \
(bitsPerFrame+7)/8, /* bytes per frame */ \
1, /* recommended number of frames per packet */ \
1, /* maximum number of frames per packet */ \
0, /* IANA RTP payload code */ \
sdpSpeex, /* RTP payload name */ \
create_decoder, /* create codec function */ \
destroy_decoder, /* destroy codec */ \
codec_decoder, /* encode/decode */ \
NULL, /* codec controls */ \
PluginCodec_H323Codec_nonStandard, /* h323CapabilityType */ \
&prefix##suffix##Cap /* h323CapabilityData */ \
} \
CREATE_WIDE_SPEEX_CAP_DATA(Wide-11.55k, Wide11k5, 2)
CREATE_WIDE_SPEEX_CAP_DATA(Wide-17.6k, Wide17k6, 3)
CREATE_WIDE_SPEEX_CAP_DATA(Wide-28.6k, Wide28k6, 4)
////////////////////////////////////////////////////////////////////////////////////////////////
#define CREATE_NARROW_SPEEXW_CAP_DATA(desc, suffix, ordinal) \
static const char speexW##suffix[] = "SpeexW" #desc; \
static struct PluginCodec_H323NonStandardCodecData speexW##suffix##Cap = \
{ \
NULL, \
MICROSOFT_COUNTRY_CODE, MICROSOFT_T35EXTENSION, MICROSOFT_MANUFACTURER, \
speexW##suffix##Hdr, sizeof(speexW##suffix##Hdr), \
NULL \
}; \
#define DECLARE_NARROW_SPEEXW_CODEC(suffix, ordinal, bitsPerFrame) \
/* SpeexW OpenH323 capability */ \
{ \
/* encoder */ \
PLUGIN_CODEC_VERSION, /* codec API version */ \
&licenseInfo, /* license information */ \
PluginCodec_MediaTypeAudio | /* audio codec */ \
PluginCodec_InputTypeRaw | /* raw input data */ \
PluginCodec_OutputTypeRaw | /* raw output data */ \
PluginCodec_RTPTypeShared | /* share RTP code */ \
PluginCodec_RTPTypeDynamic | /* dynamic RTP type */ \
PluginCodec_DecodeSilence, /* can encode silence frames */ \
speexW##suffix, /* text decription */ \
L16Desc, /* source format */ \
speexW##suffix, /* destination format */ \
(void *)ordinal, /* user data */ \
8000, /* samples per second */ \
bitsPerFrame*50, /* raw bits per second */ \
NARROW_NS_PER_FRAME, /* nanoseconds per frame */ \
NARROW_SAMPLES_PER_FRAME, /* samples per frame */ \
(bitsPerFrame+7)/8, /* bytes per frame */ \
1, /* recommended number of frames per packet */ \
1, /* maximum number of frames per packet */ \
0, /* IANA RTP payload code */ \
NULL, /* RTP payload name */ \
create_encoder, /* create codec function */ \
destroy_encoder, /* destroy codec */ \
codec_encoder, /* encode/decode */ \
NULL, /* codec controls */ \
PluginCodec_H323Codec_nonStandard, /* h323CapabilityType */ \
&speexW##suffix##Cap /* h323CapabilityData */ \
}, \
{ \
/* decoder */ \
PLUGIN_CODEC_VERSION, /* codec API version */ \
&licenseInfo, /* license information */ \
PluginCodec_MediaTypeAudio | /* audio codec */ \
PluginCodec_InputTypeRaw | /* raw input data */ \
PluginCodec_OutputTypeRaw | /* raw output data */ \
PluginCodec_RTPTypeShared | /* share RTP code */ \
PluginCodec_RTPTypeDynamic, /* dynamic RTP type */ \
speexW##suffix, /* text decription */ \
speexW##suffix, /* source format */ \
L16Desc, /* destination format */ \
(void *)ordinal, /* user data */ \
8000, /* samples per second */ \
bitsPerFrame*50, /* raw bits per second */ \
NARROW_NS_PER_FRAME, /* nanoseconds per frame */ \
NARROW_SAMPLES_PER_FRAME, /* samples per frame */ \
(bitsPerFrame+7)/8, /* bytes per frame */ \
1, /* recommended number of frames per packet */ \
1, /* maximum number of frames per packet */ \
0, /* IANA RTP payload code */ \
NULL, /* RTP payload name */ \
create_decoder, /* create codec function */ \
destroy_decoder, /* destroy codec */ \
codec_decoder, /* encode/decode */ \
NULL, /* codec controls */ \
PluginCodec_H323Codec_nonStandard, /* h323CapabilityType */ \
&speexW##suffix##Cap /* h323CapabilityData */ \
} \
CREATE_NARROW_SPEEXW_CAP_DATA(Narrow-8k, Narrow8k, 3)
////////////////////////////////////////////////////////////////////////////////////////////////
#define NARROW_BITSPERFRAME_MODE2 119 // 5950
#define NARROW_BITSPERFRAME_MODE3 160 // 8000
#define NARROW_BITSPERFRAME_MODE4 220 // 11000
#define NARROW_BITSPERFRAME_MODE5 300 // 15000
#define NARROW_BITSPERFRAME_MODE6 364 // 18200
#define NARROW_BITSPERFRAME_MODE7 492 // 26400
#define WIDE_BITSPERFRAME_MODE2 (NARROW_BITSPERFRAME_MODE2 + 112) // 11550
#define WIDE_BITSPERFRAME_MODE3 (NARROW_BITSPERFRAME_MODE3 + 192) // 17600
#define WIDE_BITSPERFRAME_MODE4 (NARROW_BITSPERFRAME_MODE4 + 352) // 28600
static struct PluginCodec_Definition ver1SpeexCodecDefn[] = {
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow5k95, 2, NARROW_BITSPERFRAME_MODE2),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow8k, 3, NARROW_BITSPERFRAME_MODE3),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow11k, 4, NARROW_BITSPERFRAME_MODE4),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow15k, 5, NARROW_BITSPERFRAME_MODE5),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow18k2, 6, NARROW_BITSPERFRAME_MODE6),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow24k6, 7, NARROW_BITSPERFRAME_MODE7),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow5k95, 2, NARROW_BITSPERFRAME_MODE2),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow8k, 3, NARROW_BITSPERFRAME_MODE3),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow11k, 4, NARROW_BITSPERFRAME_MODE4),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow15k, 5, NARROW_BITSPERFRAME_MODE5),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow18k2, 6, NARROW_BITSPERFRAME_MODE6),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow24k6, 7, NARROW_BITSPERFRAME_MODE7),
//DECLARE_SPEEXW_CODEC(Narrow5k95, 2), // does not work
DECLARE_NARROW_SPEEXW_CODEC(Narrow8k, 3, NARROW_BITSPERFRAME_MODE3),
//DECLARE_SPEEX_CODEC(Narrow11k, 4), // does not work
//DECLARE_SPEEX_CODEC(Narrow15k, 5), // does not work
//DECLARE_SPEEX_CODEC(Narrow18k2, 6), // does not work
//DECLARE_SPEEX_CODEC(Narrow24k6, 7) // does not work
};
#define NUM_VER1_DEFNS (sizeof(ver1SpeexCodecDefn) / sizeof(struct PluginCodec_Definition))
static struct PluginCodec_Definition ver2SpeexCodecDefn[] = {
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow5k95, 2, NARROW_BITSPERFRAME_MODE2),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow8k, 3, NARROW_BITSPERFRAME_MODE3),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow11k, 4, NARROW_BITSPERFRAME_MODE4),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow15k, 5, NARROW_BITSPERFRAME_MODE5),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow18k2, 6, NARROW_BITSPERFRAME_MODE6),
DECLARE_NARROW_SPEEX_CODEC(speex, Narrow24k6, 7, NARROW_BITSPERFRAME_MODE7),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow5k95, 2, NARROW_BITSPERFRAME_MODE2),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow8k, 3, NARROW_BITSPERFRAME_MODE3),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow11k, 4, NARROW_BITSPERFRAME_MODE4),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow15k, 5, NARROW_BITSPERFRAME_MODE5),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow18k2, 6, NARROW_BITSPERFRAME_MODE6),
DECLARE_NARROW_SPEEX_CODEC(ietfSpeex, Narrow24k6, 7, NARROW_BITSPERFRAME_MODE7),
//DECLARE_SPEEXW_CODEC(Narrow5k95, 2), // does not work
DECLARE_NARROW_SPEEXW_CODEC(Narrow8k, 3, NARROW_BITSPERFRAME_MODE3),
//DECLARE_SPEEX_CODEC(Narrow11k, 4), // does not work
//DECLARE_SPEEX_CODEC(Narrow15k, 5), // does not work
//DECLARE_SPEEX_CODEC(Narrow18k2, 6), // does not work
//DECLARE_SPEEX_CODEC(Narrow24k6, 7) // does not work
DECLARE_WIDE_SPEEX_CODEC(speex, Wide11k5, 2, WIDE_BITSPERFRAME_MODE2),
DECLARE_WIDE_SPEEX_CODEC(speex, Wide17k6, 3, WIDE_BITSPERFRAME_MODE3),
DECLARE_WIDE_SPEEX_CODEC(speex, Wide28k6, 4, WIDE_BITSPERFRAME_MODE4),
DECLARE_WIDE_SPEEX_CODEC(ietfSpeex, Wide11k5, 2, WIDE_BITSPERFRAME_MODE2),
DECLARE_WIDE_SPEEX_CODEC(ietfSpeex, Wide17k6, 3, WIDE_BITSPERFRAME_MODE3),
DECLARE_WIDE_SPEEX_CODEC(ietfSpeex, Wide28k6, 4, WIDE_BITSPERFRAME_MODE4),
};
#define NUM_VER2_DEFNS (sizeof(ver2SpeexCodecDefn) / sizeof(struct PluginCodec_Definition))
/////////////////////////////////////////////////////////////////////////////
extern "C" {
PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version)
{
if (version == 1) {
*count = NUM_VER1_DEFNS;
return ver1SpeexCodecDefn;
}
else
{
*count = NUM_VER2_DEFNS;
return ver2SpeexCodecDefn;
}
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -