diff --git a/channels/chan_h323.c b/channels/chan_h323.c index 5cc7cddb0294776dcf261a43394ad677a6e4c998..ffb86b0d752897916391fee1e4315214182bbe73 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -3122,6 +3122,8 @@ static char *convertcap(int cap) return "ULAW"; case AST_FORMAT_ALAW: return "ALAW"; + case AST_FORMAT_G722: + return "G.722"; case AST_FORMAT_ADPCM: return "G.728"; case AST_FORMAT_G729A: diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index dfefcea9c993194c6ff364042b868daffdf6d190..108846d6b7cd2d3745bf23bee837e31d7af5b74b 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -183,7 +183,8 @@ int (*iax2_regfunk)(const char *username, int onoff) = NULL; #define IAX_CAPABILITY_MEDBANDWIDTH (IAX_CAPABILITY_FULLBANDWIDTH & \ ~AST_FORMAT_SLINEAR & \ ~AST_FORMAT_ULAW & \ - ~AST_FORMAT_ALAW) + ~AST_FORMAT_ALAW & \ + ~AST_FORMAT_G722) /* A modem */ #define IAX_CAPABILITY_LOWBANDWIDTH (IAX_CAPABILITY_MEDBANDWIDTH & \ ~AST_FORMAT_G726 & \ diff --git a/formats/format_pcm.c b/formats/format_pcm.c index 9ae1398e6e44dc6d703131819f31825753120937..a3a40b7d49e0c2fc3b33528a5b3abd4514f8deab 100644 --- a/formats/format_pcm.c +++ b/formats/format_pcm.c @@ -443,6 +443,18 @@ static const struct ast_format pcm_f = { .buf_size = BUF_SIZE + AST_FRIENDLY_OFFSET, }; +static const struct ast_format g722_f = { + .name = "g722", + .exts = "g722", + .format = AST_FORMAT_G722, + .write = pcm_write, + .seek = pcm_seek, + .trunc = pcm_trunc, + .tell = pcm_tell, + .read = pcm_read, + .buf_size = (BUF_SIZE * 2) + AST_FRIENDLY_OFFSET, +}; + static const struct ast_format au_f = { .name = "au", .exts = "au", @@ -467,14 +479,18 @@ static int load_module(void) for (index = 0; index < (sizeof(alaw_silence) / sizeof(alaw_silence[0])); index++) alaw_silence[index] = AST_LIN2A(0); - return ast_format_register(&pcm_f) || ast_format_register(&alaw_f) - || ast_format_register(&au_f); + return ast_format_register(&pcm_f) + || ast_format_register(&alaw_f) + || ast_format_register(&au_f) + || ast_format_register(&g722_f); } static int unload_module(void) { - return ast_format_unregister(pcm_f.name) || ast_format_unregister(alaw_f.name) - || ast_format_unregister(au_f.name); + return ast_format_unregister(pcm_f.name) + || ast_format_unregister(alaw_f.name) + || ast_format_unregister(au_f.name) + || ast_format_unregister(g722_f.name); } -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw/Sun uLaw/ALaw 8khz Audio support (PCM,PCMA,AU)"); +AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw/Sun uLaw/ALaw 8KHz Audio support (PCM,PCMA,AU) and G.722 16Khz Audio Support"); diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h index bcc533a95aa0669f68640e58275177688d53b371..fa1c1289128b926d767419ae1233498576664403 100644 --- a/include/asterisk/frame.h +++ b/include/asterisk/frame.h @@ -240,6 +240,8 @@ extern struct ast_frame ast_null_frame; #define AST_FORMAT_ILBC (1 << 10) /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */ #define AST_FORMAT_G726 (1 << 11) +/*! G.722 */ +#define AST_FORMAT_G722 (1 << 12) /*! Maximum audio format */ #define AST_FORMAT_MAX_AUDIO (1 << 15) /*! Maximum audio mask */ diff --git a/main/frame.c b/main/frame.c index f797f55fad48b55b2a22f112e8ae8cf9f2049540..1b18a611da5d0ee8fc817a0f88f8a545042fb8d6 100644 --- a/main/frame.c +++ b/main/frame.c @@ -106,14 +106,15 @@ static struct ast_format_list AST_FORMAT_LIST[] = { /*!< Bit number: comment { 1, AST_FORMAT_GSM, "gsm" , "GSM", 33, 20, 300, 20, 20 }, /*!< 2: codec_gsm.c */ { 1, AST_FORMAT_ULAW, "ulaw", "G.711 u-law", 80, 10, 150, 10, 20 }, /*!< 3: codec_ulaw.c */ { 1, AST_FORMAT_ALAW, "alaw", "G.711 A-law", 80, 10, 150, 10, 20 }, /*!< 4: codec_alaw.c */ - { 1, AST_FORMAT_G726, "g726", "G.726 RFC3551", 40, 10, 300, 10, 20 },/*!< 5: codec_g726.c */ + { 1, AST_FORMAT_G726, "g726", "G.726 RFC3551", 40, 10, 300, 10, 20 }, /*!< 5: codec_g726.c */ { 1, AST_FORMAT_ADPCM, "adpcm" , "ADPCM", 40, 10, 300, 10, 20 }, /*!< 6: codec_adpcm.c */ { 1, AST_FORMAT_SLINEAR, "slin", "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE }, /*!< 7 */ - { 1, AST_FORMAT_LPC10, "lpc10", "LPC10", 7, 20, 20, 20, 20 }, /*!< 8: codec_lpc10.c */ + { 1, AST_FORMAT_LPC10, "lpc10", "LPC10", 7, 20, 20, 20, 20 }, /*!< 8: codec_lpc10.c */ { 1, AST_FORMAT_G729A, "g729", "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729 }, /*!< 9: Binary commercial distribution */ - { 1, AST_FORMAT_SPEEX, "speex", "SpeeX", 10, 10, 60, 10, 20 }, /*!< 10: codec_speex.c */ + { 1, AST_FORMAT_SPEEX, "speex", "SpeeX", 10, 10, 60, 10, 20 }, /*!< 10: codec_speex.c */ { 1, AST_FORMAT_ILBC, "ilbc", "iLBC", 50, 30, 30, 30, 30 }, /*!< 11: codec_ilbc.c */ /* inc=30ms - workaround */ { 1, AST_FORMAT_G726_AAL2, "g726aal2", "G.726 AAL2", 40, 10, 300, 10, 20 }, /*!< 12: codec_g726.c */ + { 1, AST_FORMAT_G722, "g722", "G722"}, /*!< 13 */ { 0, 0, "nothing", "undefined" }, { 0, 0, "nothing", "undefined" }, { 0, 0, "nothing", "undefined" }, @@ -1356,6 +1357,7 @@ int ast_codec_get_samples(struct ast_frame *f) break; case AST_FORMAT_ULAW: case AST_FORMAT_ALAW: + case AST_FORMAT_G722: samples = f->datalen; break; case AST_FORMAT_ADPCM: diff --git a/main/rtp.c b/main/rtp.c index 589584deeb846834d443f50a44ff1d926eaac979..c34f56b117493e5e16e0c46a44dffc26b401053e 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -1330,6 +1330,7 @@ static struct { {{1, AST_FORMAT_G729A}, "audio", "G729"}, {{1, AST_FORMAT_SPEEX}, "audio", "speex"}, {{1, AST_FORMAT_ILBC}, "audio", "iLBC"}, + {{1, AST_FORMAT_G722}, "audio", "G722"}, {{1, AST_FORMAT_G726_AAL2}, "audio", "AAL2-G726-32"}, {{0, AST_RTP_DTMF}, "audio", "telephone-event"}, {{0, AST_RTP_CISCO_DTMF}, "audio", "cisco-telephone-event"}, @@ -1356,6 +1357,7 @@ static struct rtpPayloadType static_RTP_PT[MAX_RTP_PT] = { [6] = {1, AST_FORMAT_ADPCM}, /* 16 kHz */ [7] = {1, AST_FORMAT_LPC10}, [8] = {1, AST_FORMAT_ALAW}, + [9] = {1, AST_FORMAT_G722}, [10] = {1, AST_FORMAT_SLINEAR}, /* 2 channels */ [11] = {1, AST_FORMAT_SLINEAR}, /* 1 channel */ [13] = {0, AST_RTP_CN}, diff --git a/main/translate.c b/main/translate.c index 7845a24f16cc45561bbf2828391f986ce47219e1..d130a38dea659c319ffcd5626595964765b37507 100644 --- a/main/translate.c +++ b/main/translate.c @@ -476,7 +476,7 @@ static void rebuild_matrix(int samples) static int show_translation(int fd, int argc, char *argv[]) { -#define SHOW_TRANS 12 +#define SHOW_TRANS 13 int x, y, z; int curlen = 0, longest = 0;