[4/4] rtpenc: Add support for G726 audio

Message ID 1322735168-85431-2-git-send-email-martin@martin.st
State Committed
Commit 04403ec2e405a3cfcfbdd45f1274be30c652e462
Headers show

Commit Message

Martin Storsjö Dec. 1, 2011, 10:26 a.m.
---
 libavformat/rtpenc.c |    5 +++++
 libavformat/sdp.c    |    8 ++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

Comments

Justin Ruggles Dec. 1, 2011, 2:43 p.m. | #1
On 12/01/2011 05:26 AM, Martin Storsjö wrote:

> ---
>  libavformat/rtpenc.c |    5 +++++
>  libavformat/sdp.c    |    8 ++++++++
>  2 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
> index 7434837..1f036a6 100644
> --- a/libavformat/rtpenc.c
> +++ b/libavformat/rtpenc.c
> @@ -72,6 +72,7 @@ static int is_supported(enum CodecID id)
>      case CODEC_ID_THEORA:
>      case CODEC_ID_VP8:
>      case CODEC_ID_ADPCM_G722:
> +    case CODEC_ID_ADPCM_G726:
>          return 1;
>      default:
>          return 0;
> @@ -411,6 +412,10 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
>           * clock. */
>          rtp_send_samples(s1, pkt->data, size, 8 * st->codec->channels);
>          break;
> +    case CODEC_ID_ADPCM_G726:
> +        rtp_send_samples(s1, pkt->data, size,
> +                         st->codec->bits_per_coded_sample * st->codec->channels);
> +        break;
>      case CODEC_ID_MP2:
>      case CODEC_ID_MP3:
>          rtp_send_mpegaudio(s1, pkt->data, size);
> diff --git a/libavformat/sdp.c b/libavformat/sdp.c
> index ba3d4dd..f0d4253 100644
> --- a/libavformat/sdp.c
> +++ b/libavformat/sdp.c
> @@ -517,6 +517,14 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
>                                           payload_type,
>                                           8000, c->channels);
>              break;
> +        case CODEC_ID_ADPCM_G726: {
> +            if (payload_type >= RTP_PT_PRIVATE)
> +                av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n",
> +                                         payload_type,
> +                                         c->bits_per_coded_sample*8,
> +                                         c->sample_rate);
> +            break;
> +        }
>          default:
>              /* Nothing special to do here... */
>              break;


looks ok.

-Justin

Patch

diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 7434837..1f036a6 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -72,6 +72,7 @@  static int is_supported(enum CodecID id)
     case CODEC_ID_THEORA:
     case CODEC_ID_VP8:
     case CODEC_ID_ADPCM_G722:
+    case CODEC_ID_ADPCM_G726:
         return 1;
     default:
         return 0;
@@ -411,6 +412,10 @@  static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
          * clock. */
         rtp_send_samples(s1, pkt->data, size, 8 * st->codec->channels);
         break;
+    case CODEC_ID_ADPCM_G726:
+        rtp_send_samples(s1, pkt->data, size,
+                         st->codec->bits_per_coded_sample * st->codec->channels);
+        break;
     case CODEC_ID_MP2:
     case CODEC_ID_MP3:
         rtp_send_mpegaudio(s1, pkt->data, size);
diff --git a/libavformat/sdp.c b/libavformat/sdp.c
index ba3d4dd..f0d4253 100644
--- a/libavformat/sdp.c
+++ b/libavformat/sdp.c
@@ -517,6 +517,14 @@  static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
                                          payload_type,
                                          8000, c->channels);
             break;
+        case CODEC_ID_ADPCM_G726: {
+            if (payload_type >= RTP_PT_PRIVATE)
+                av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n",
+                                         payload_type,
+                                         c->bits_per_coded_sample*8,
+                                         c->sample_rate);
+            break;
+        }
         default:
             /* Nothing special to do here... */
             break;