On Mon, Feb 3, 2020 at 4:34 PM Jun Li <junli1...@gmail.com> wrote: > Fix #8479 > Apply rtcpport from sdp file if it contains rtcp attribute. > > Signed-off-by: Jun Li <junli1...@gmail.com> > --- > libavformat/rtsp.c | 12 ++++++++++-- > libavformat/rtsp.h | 1 + > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c > index cd6fc32a29..c892f21142 100644 > --- a/libavformat/rtsp.c > +++ b/libavformat/rtsp.c > @@ -577,6 +577,10 @@ static void sdp_parse_line(AVFormatContext *s, > SDPParseState *s1, > if (s1->seen_fmtp) { > parse_fmtp(s, rt, payload_type, s1->delayed_fmtp); > } > + } else if (av_strstart(p, "rtcp:", &p) && s->nb_streams > 0) { > + rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; > + get_word(buf1, sizeof(buf1), &p); > + rtsp_st->rtcp_port = strtol(buf1, NULL, 10); > } else if (av_strstart(p, "fmtp:", &p) || > av_strstart(p, "framesize:", &p)) { > // let dynamic protocol handlers have a stab at the line. > @@ -2367,6 +2371,7 @@ static int sdp_read_header(AVFormatContext *s) > > if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) { > AVDictionary *opts = map_to_opts(rt); > + int rtcp_port = rtsp_st->rtcp_port; > > err = getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, > sizeof(rtsp_st->sdp_ip), > @@ -2377,10 +2382,13 @@ static int sdp_read_header(AVFormatContext *s) > av_dict_free(&opts); > goto fail; > } > + > + if (rtcp_port <= 0) > + rtcp_port = rtsp_st->sdp_port + 1; > ff_url_join(url, sizeof(url), "rtp", NULL, > namebuf, rtsp_st->sdp_port, > - > "?localport=%d&ttl=%d&connect=%d&write_to_source=%d", > - rtsp_st->sdp_port, rtsp_st->sdp_ttl, > + > "?localport=%d&localrtcpport=%d&ttl=%d&connect=%d&write_to_source=%d", > + rtsp_st->sdp_port, rtcp_port, rtsp_st->sdp_ttl, > rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0, > rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : > 0); > > diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h > index 54a9a30c16..15747fe6d1 100644 > --- a/libavformat/rtsp.h > +++ b/libavformat/rtsp.h > @@ -448,6 +448,7 @@ typedef struct RTSPStream { > /** The following are used only in SDP, not RTSP */ > //@{ > int sdp_port; /**< port (from SDP content) */ > + int rtcp_port; /**< rtcp port (from SDP content) */ > struct sockaddr_storage sdp_ip; /**< IP address (from SDP content) */ > int nb_include_source_addrs; /**< Number of source-specific multicast > include source IP addresses (from SDP content) */ > struct RTSPSource **include_source_addrs; /**< Source-specific > multicast include source IP addresses (from SDP content) */ > -- > 2.17.1 > > Ping _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".