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

Martin Storsjö martin
Fri Feb 11 20:57:08 CET 2011


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

> On Fri, Feb 11, 2011 at 2:19 PM, Martin Storsj? <martin at martin.st> wrote:
> > 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).
> 
> Check rdt.c.

Oh, I see, sorry for that.

Do you have any sample urls that I could try out, that uses this feature?

In any case, the current code doesn't work since AVStream->priv_data isn't 
used any longer (and previously, when it was used, copying the priv_data 
pointer in this way would lead to double frees when freeing all AVStreams 
priv_data).

Could AVStream->id be used for this? Currently, id is set to 0 for all 
streams. Could we set AVStream->id to the corresponding RTSPStream index?

// Martin



More information about the ffmpeg-devel mailing list