[FFmpeg-devel] [PATCH] Handle G.722 in RTP (both muxer and demuxer)

Luca Abeni lucabe72
Fri Sep 17 12:17:02 CEST 2010


Hi Martin,

On 09/15/2010 12:13 PM, Martin Storsj? wrote:
> From 70bbfd3e186dcf1508816ec2b580c5d520976394 Mon Sep 17 00:00:00 2001
> From: Martin Storsjo<martin at martin.st>
> Date: Mon, 9 Aug 2010 21:24:07 +0300
> Subject: [PATCH] Handle G722 in RTP and all the exceptions due to RFC 3551
>
> ---
>   libavformat/rtp.c    |    2 +-
>   libavformat/rtpdec.c |    7 +++++++
>   libavformat/rtpenc.c |   12 ++++++++++++
>   libavformat/sdp.c    |    6 ++++++
>   4 files changed, 26 insertions(+), 1 deletions(-)
I think you are missing a Changelog entry? (not that I care too much,
but I suspect it's required :)

> --- a/libavformat/rtp.c
> +++ b/libavformat/rtp.c
> @@ -48,7 +48,7 @@ static const struct
>     {6, "DVI4",        AVMEDIA_TYPE_AUDIO,   CODEC_ID_NONE, 16000, 1},
>     {7, "LPC",         AVMEDIA_TYPE_AUDIO,   CODEC_ID_NONE, 8000, 1},
>     {8, "PCMA",        AVMEDIA_TYPE_AUDIO,   CODEC_ID_PCM_ALAW, 8000, 1},
> -  {9, "G722",        AVMEDIA_TYPE_AUDIO,   CODEC_ID_NONE, 8000, 1},
> +  {9, "G722",        AVMEDIA_TYPE_AUDIO,   CODEC_ID_ADPCM_G722, 8000, 1},
This is ok

[...]
> --- a/libavformat/rtpenc.c
> +++ b/libavformat/rtpenc.c
> @@ -56,6 +56,7 @@ static int is_supported(enum CodecID id)
>       case CODEC_ID_VORBIS:
>       case CODEC_ID_THEORA:
>       case CODEC_ID_VP8:
> +    case CODEC_ID_ADPCM_G722:
>           return 1;
ok

[...]
> +    case CODEC_ID_ADPCM_G722:
> +        /* Due to a historical error, the clock rate for G722 in RTP is
> +         * 8000, even if the sample rate is 16000. See RFC 3551. */
> +        av_set_pts_info(st, 32, 1, 8000);
> +        break;
ok

[...]
> +    case CODEC_ID_ADPCM_G722:
> +        /* The actual sample size is half a byte per sample, but since the
> +         * stream clock rate is 8000 Hz while the sample rate is 16000 Hz,
> +         * the correct parameter for send_samples is 1 byte per stream clock. */
> +        rtp_send_samples(s1, pkt->data, size, 1 * st->codec->channels);
This looks hackish, but I have no better ideas... Is noone else can see a
better solution, I am ok with committing it.

> --- a/libavformat/sdp.c
> +++ b/libavformat/sdp.c
> @@ -419,6 +419,12 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
>               av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n",
>                                        payload_type);
>               break;
> +        case CODEC_ID_ADPCM_G722:
> +            if (payload_type>= RTP_PT_PRIVATE)
> +                av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n",
> +                                         payload_type,
> +                                         8000, c->channels);
> +            break;
ok


			Thanks,
				Luca



More information about the ffmpeg-devel mailing list