[FFmpeg-devel] [PATCH 1/2] rtsp: Don't use AVStream->priv_data for mapping RTSPStreams to AVStreams

Martin Storsjö martin
Fri Feb 11 20:19:59 CET 2011


On Fri, 11 Feb 2011, Ronald S. Bultje wrote:

> On Fri, Feb 11, 2011 at 2:20 AM, Martin Storsj? <martin at martin.st> wrote:
> > Since a few weeks ago, AVStream->priv_data isn't set. The much
> > more straightforward solution is to use RTSPStream->stream_index
> > instead.
> > ---
> > Btw, are there any better-working RealRTSP samples than the ones
> > on multimediawiki? The audio-only ones work fine, but most of
> > the ones with video crash ffplay sooner or later (unrelated
> > to these patches).
> >
> > ?libavformat/rtspdec.c | ? ?5 ++---
> > ?1 files changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
> > index 45ed7bb..31a51f8 100644
> > --- a/libavformat/rtspdec.c
> > +++ b/libavformat/rtspdec.c
> > @@ -281,9 +281,9 @@ retry:
> > ? ? ? ? ? ? snprintf(cmd, sizeof(cmd),
> > ? ? ? ? ? ? ? ? ? ? ?"Subscribe: ");
> > ? ? ? ? ? ? for (i = 0; i < rt->nb_rtsp_streams; i++) {
> > + ? ? ? ? ? ? ? ?int r = rt->rtsp_streams[i]->stream_index;
> > ? ? ? ? ? ? ? ? rule_nr = 0;
> > - ? ? ? ? ? ? ? ?for (r = 0; r < s->nb_streams; r++) {
> > - ? ? ? ? ? ? ? ? ? ?if (s->streams[r]->priv_data == rt->rtsp_streams[i]) {
> > + ? ? ? ? ? ? ? ?if (r >= 0) {
> > ? ? ? ? ? ? ? ? ? ? ? ? if (s->streams[r]->discard != AVDISCARD_ALL) {
> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (!first)
> > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? av_strlcat(rt->last_subscription, ",",
> 
> Not a good idea! This breaks playback of streams with multiple audio
> tracks, e.g. absolute radio high bitrate. These have multiple
> AVStreams per RTSPStream (switch using 'a' in ffplay, set starting
> stream using -ast <num>), and this patch breaks that.

Uhm, no? As far as I can see, each RTSPStream corresponds to one AVStream. 
av_new_stream isn't called anywhere else except sdp_parse_line, where 
av_new_stream() is called once for each RTSPStream created (except for 
mpeg2ts streams).

Also, this code segment current probably doesn't work at all (but playback 
of the streams from the wiki rtsp sample list I've tried do work fine), 
since the priv_data field is null for all AVStreams, since I fixed the 
leak/double free mess a few weeks ago.

// Martin



More information about the ffmpeg-devel mailing list