[Ffmpeg-devel] [PATCH] RTP payload format for AMR
Michael Niedermayer
michaelni
Wed Mar 7 19:53:39 CET 2007
Hi
On Wed, Mar 07, 2007 at 09:00:11PM +0530, Kite Flyer wrote:
> Hi,
>
> My work required to stream AMR audio. The attached patch implements
> octet-aligned payload for AMR NB mono audio as per RFC 3267. It works well
> with several media players e.g. real player, QuickTime player etc.
>
> I could very well change the bit rate with "-ab" option using older SVN
> code. But current SVN code (ffmpeg.c) seems to break the option. Any idea
> how to set the audio bit rate now?
-ab 123 is now -ab 123k or kb
[...]
> + //TODO: find a way to pack maximum number of frames based on max_payload_size
yes
[...]
> }
> }
>
> +/* Send AMR audio. Note: AMR_NB, single channel is supported now. */
> +static void rtp_send_amr(AVFormatContext *s1,
> + const uint8_t *buf1, int size)
> +{
> + RTPDemuxContext *s = s1->priv_data;
> + AVStream *st = s1->streams[0];
> + const static uint8_t packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
> + uint8_t toc, ft;
> + int dlen;
> +
> + if (st->codec->codec_id != CODEC_ID_AMR_NB)
> + return; //FIXME: clean if reqd
> +
> + if (size < 1)
> + return;
> +
> + /* correct table of contents and add frames */
> + while (size > 0) {
this function cannot receive more then 1 frame at a time, if it does then
there is a bug somewhere, (if the amr encoder outputs several frames
concatenated then it is buggy, if a demuxer outputs such mess a AVParser
is needed to split it up, reimplementing such split up code everywhere
will not be accepted)
[...]
> +#ifdef DEBUG
> + printf("AMR: incomplete frame: frame type = %d, data len=%d, size = %d\n", ft, dlen, size);
> + //FIXME check if the data would come in next chunk
> +#endif
please use dprintf() insetad of printf under #ifdef DEBUG
> + }
> +
> + /* flush if max number of frames added */
> + //TODO: find a way to pack maximum number of frames
> + if (s->frame_count == AMR_NB_MAX_FRAMES)
> + {
> + s->buf[s->frame_count] &= 0x7f; // set f = 0
> + rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
> + s->timestamp += 160 * s->frame_count;
> + s->buf[0] = 0xf0;
> + memset(s->buf + 1, 0x7c, AMR_NB_MAX_FRAMES);
what does this memset do? isnt the area always overwritten again?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070307/a40f89db/attachment.pgp>
More information about the ffmpeg-devel
mailing list