]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
add passthrough and file format support for G.722 16KHz audio (issue #5084, original...
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 25 Oct 2006 00:26:17 +0000 (00:26 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 25 Oct 2006 00:26:17 +0000 (00:26 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@46154 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_h323.c
channels/chan_iax2.c
formats/format_pcm.c
include/asterisk/frame.h
main/frame.c
main/rtp.c
main/translate.c

index 5a7bbc901b7b409fd9ad7da480fa986d2f53c3c6..ef08d20bec68a608f38455247cf6b34f043289d8 100644 (file)
@@ -2995,6 +2995,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:
index 4c9f239b700ddba17dfcad35d75382b6dc44dbde..5a4ed3cd40ffdf0abbdf9f7253fcadb07946d2d4 100644 (file)
@@ -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 &                     \
index 9ae1398e6e44dc6d703131819f31825753120937..a3a40b7d49e0c2fc3b33528a5b3abd4514f8deab 100644 (file)
@@ -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");
index bcc533a95aa0669f68640e58275177688d53b371..fa1c1289128b926d767419ae1233498576664403 100644 (file)
@@ -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 */
index 4bbbcbdae79cc86ec56cc9e85648ebe315ad5aa6..9bb40cd17c1207be4f95f6c37d902a7841f96f3d 100644 (file)
@@ -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" },
@@ -611,7 +612,7 @@ static int show_codecs_deprecated(int fd, int argc, char *argv[])
        ast_cli(fd, "--------------------------------------------------------------------------------\n");
        if ((argc == 2) || (!strcasecmp(argv[1],"audio"))) {
                found = 1;
-               for (i=0;i<12;i++) {
+               for (i=0;i<13;i++) {
                        snprintf(hex,25,"(0x%x)",1<<i);
                        ast_cli(fd, "%11u (1 << %2d) %10s  audio   %8s   (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
                }
@@ -1471,6 +1472,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:
index 6be71d3e60587891f24e83083b3484343e56b61f..4d2b1e247f35549e9206918a313968c0dfe70cc5 100644 (file)
@@ -1273,6 +1273,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"},
@@ -1299,6 +1300,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},
index f0685145ddc2c440589eb35d99297bd3529be6a3..1e9c1e77bc9fb63741f92e242775f673a4be819d 100644 (file)
@@ -486,7 +486,7 @@ static void rebuild_matrix(int samples)
 /*! \brief CLI "show translation" command handler */
 static int show_translation_deprecated(int fd, int argc, char *argv[])
 {
-#define SHOW_TRANS 12
+#define SHOW_TRANS 13
        int x, y, z;
        int curlen = 0, longest = 0;
 
@@ -555,7 +555,6 @@ static int show_translation_deprecated(int fd, int argc, char *argv[])
 
 static int show_translation(int fd, int argc, char *argv[])
 {
-#define SHOW_TRANS 12
        int x, y, z;
        int curlen = 0, longest = 0;