[FFmpeg-devel] rtsp: fix wrong codec setup for some sdp

Submitted by Hyun Yoo on Sept. 7, 2019, 10:23 a.m.

Details

Message ID CAJzQz-EvfCZq7SwOis=QAt_sfywtXBGBqhpwnD02c3g_V5bF4w@mail.gmail.com
State New
Headers show

Commit Message

Hyun Yoo Sept. 7, 2019, 10:23 a.m.
From: Hyun Yoo <easetheworld@gmail.com>

rtsp_st->sdp_payload_type is the first codec in 'm=' tag
st->codecpar->id is the first supported codec in 'a=' tag
the two is not guaranteed to be same for example when
1) the order between attributes is random(rfc4566 doesn't force it)
2) the first codec is same for 'm=' and 'a=' but it is unsupported codec
   then st->codecpar->id will be the next one in 'a='(if it's supported)

Signed-off-by: EaseTheWorld <easetheworld@gmail.com>
---
 libavformat/rtsp.c | 7 +++++++
 1 file changed, 7 insertions(+)

                 sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
@@ -582,6 +585,10 @@ static void sdp_parse_line(AVFormatContext *s,
SDPParseState *s1,
             // let dynamic protocol handlers have a stab at the line.
             get_word(buf1, sizeof(buf1), &p);
             payload_type = atoi(buf1);
+            rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
+            // parse only sdp_payload_type specified in 'm=' tag
+            if (rtsp_st->sdp_payload_type != payload_type)
+                return;
             if (s1->seen_rtpmap) {
                 parse_fmtp(s, rt, payload_type, buf);
             } else {

Comments

Michael Niedermayer Sept. 7, 2019, 7:28 p.m.
On Sat, Sep 07, 2019 at 07:23:13PM +0900, Hyun Yoo wrote:
> From: Hyun Yoo <easetheworld@gmail.com>
> 
> rtsp_st->sdp_payload_type is the first codec in 'm=' tag
> st->codecpar->id is the first supported codec in 'a=' tag
> the two is not guaranteed to be same for example when
> 1) the order between attributes is random(rfc4566 doesn't force it)
> 2) the first codec is same for 'm=' and 'a=' but it is unsupported codec
>    then st->codecpar->id will be the next one in 'a='(if it's supported)
> 
> Signed-off-by: EaseTheWorld <easetheworld@gmail.com>
> ---
>  libavformat/rtsp.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> index c153cac88b..be3002690e 100644
> --- a/libavformat/rtsp.c
> +++ b/libavformat/rtsp.c
> @@ -569,6 +569,9 @@ static void sdp_parse_line(AVFormatContext *s,
> SDPParseState *s1,
>              get_word(buf1, sizeof(buf1), &p);
>              payload_type = atoi(buf1);
>              rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
> +            // parse only sdp_payload_type specified in 'm=' tag
> +            if (rtsp_st->sdp_payload_type != payload_type)
> +                return;
>              if (rtsp_st->stream_index >= 0) {
>                  st = s->streams[rtsp_st->stream_index];
>                  sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
> @@ -582,6 +585,10 @@ static void sdp_parse_line(AVFormatContext *s,
> SDPParseState *s1,

Applying: rtsp: fix wrong codec setup for some sdp
error: corrupt patch at line 10

there are extra newlines in the patch ...

[...]
Hyun Yoo Sept. 8, 2019, 1:28 a.m.
Sorry about this.
At first I commit with git format-patch & send-email on my desktop
but it was discarded because I didn't subcribe to devel mailing list.
After join the ml I forwarded the mail on mobile gmail which might cause
the extra newline mess.
What should I do now?
git send-email commit the same patch again?

2019년 9월 8일 (일) 오전 4:28, Michael Niedermayer <michael@niedermayer.cc>님이 작성:

> On Sat, Sep 07, 2019 at 07:23:13PM +0900, Hyun Yoo wrote:
> > From: Hyun Yoo <easetheworld@gmail.com>
> >
> > rtsp_st->sdp_payload_type is the first codec in 'm=' tag
> > st->codecpar->id is the first supported codec in 'a=' tag
> > the two is not guaranteed to be same for example when
> > 1) the order between attributes is random(rfc4566 doesn't force it)
> > 2) the first codec is same for 'm=' and 'a=' but it is unsupported codec
> >    then st->codecpar->id will be the next one in 'a='(if it's supported)
> >
> > Signed-off-by: EaseTheWorld <easetheworld@gmail.com>
> > ---
> >  libavformat/rtsp.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> > index c153cac88b..be3002690e 100644
> > --- a/libavformat/rtsp.c
> > +++ b/libavformat/rtsp.c
> > @@ -569,6 +569,9 @@ static void sdp_parse_line(AVFormatContext *s,
> > SDPParseState *s1,
> >              get_word(buf1, sizeof(buf1), &p);
> >              payload_type = atoi(buf1);
> >              rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
> > +            // parse only sdp_payload_type specified in 'm=' tag
> > +            if (rtsp_st->sdp_payload_type != payload_type)
> > +                return;
> >              if (rtsp_st->stream_index >= 0) {
> >                  st = s->streams[rtsp_st->stream_index];
> >                  sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
> > @@ -582,6 +585,10 @@ static void sdp_parse_line(AVFormatContext *s,
> > SDPParseState *s1,
>
> Applying: rtsp: fix wrong codec setup for some sdp
> error: corrupt patch at line 10
>
> there are extra newlines in the patch ...
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> If you fake or manipulate statistics in a paper in physics you will never
> get a job again.
> If you fake or manipulate statistics in a paper in medicin you will get
> a job for life at the pharma industry.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Sept. 8, 2019, 10:14 p.m.
On Sun, Sep 08, 2019 at 10:28:49AM +0900, Hyun Yoo wrote:
> Sorry about this.
> At first I commit with git format-patch & send-email on my desktop
> but it was discarded because I didn't subcribe to devel mailing list.
> After join the ml I forwarded the mail on mobile gmail which might cause
> the extra newline mess.
> What should I do now?
> git send-email commit the same patch again?

yes but try to send it to yourself first, if it is ok then
resubmit to ML

thanks

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index c153cac88b..be3002690e 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -569,6 +569,9 @@  static void sdp_parse_line(AVFormatContext *s,
SDPParseState *s1,
             get_word(buf1, sizeof(buf1), &p);
             payload_type = atoi(buf1);
             rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1];
+            // parse only sdp_payload_type specified in 'm=' tag
+            if (rtsp_st->sdp_payload_type != payload_type)
+                return;
             if (rtsp_st->stream_index >= 0) {
                 st = s->streams[rtsp_st->stream_index];