[FFmpeg-devel] [PATCH] allow to call rm_read_audio_stream_info() with NULL AVFormatcontext

Ronald S. Bultje rsbultje
Mon Nov 5 17:13:30 CET 2007


Hi Michael,

On 11/5/07, Michael Niedermayer <michaelni at gmx.at> wrote:
>
> On Sun, Nov 04, 2007 at 09:31:56PM -0800, Ronald S. Bultje wrote:
> > On 11/4/07, Michael Niedermayer <michaelni at gmx.at> wrote:
> the very first question about this is, why is this patch necessary?
> looking at it again it doesnt look like it would make any difference at
> all besides skiping metadata, i hardly would call that essential


For RTSP, the AVFormatContext::priv_data is the rtsp context, not the rm
context. The RMContext only comes into play in a stream-specific manner
(AVStream, that is). Also, the ByteIOContext is not the same, since we don't
want to read directly off the UDP socket, but rather do the RTP-regular
parsing first, into a temporary buffer, and then use that buffer as a source
for the rm-specific functions. Also, for the MDPR header, the data actually
comes from a SDP entry, so we would never be able to read it directly.

The effect of all of this is that I need to pass separate
RMContext/ByteIOContext from the AVFormatContext. Secondly, since the
AVFormatContext isn't what the rm demuxer would normally expect, I leave it
NULL. Because it is NULL, I need to make sure it's not written into. Indeed,
the metadata also comes in the SDP, so I don't want to overwrite that, so I
use the same condition for that also, which is why I don't provide the rtsp
AVFormatContext. I could pass an argument, but if we already have an
existing condition (s==NULL), why bother?

In code, here's what the rtsp code does (rough pseudo-code, don't take this
seriously):

ByteIOContext pb;
RMContext rm;
url_open_buf(&pb, data, size, URL_RDONLY);
memset(&rm, 0, sizeof(rm));
parse_mdpr(&pb, NULL /* s */, &rm, st);
url_close_buf(&pb);
while (have_rtsp_data(&rtsp_flags, &rtsp_time)) {
    url_open_buf(&pb, data, size, URL_RDONLY);
    parse_frame(&pb, NULL /* s */, &rm, st, &rtsp_flags, &rtsp_time);
    url_close_buf(&pb);
}

Here's what rmdec.c does:

parse_mdpr(&s->pb, s, s->priv_data, st);
while (sync(&flags, &time)) {
    parse_frame(&s->pb, s, s->priv_data, st, &flags, &time);
}

I hope that makes things a bit clearer.

Ronald




More information about the ffmpeg-devel mailing list