From: Rashad Tatum <tatum.rashad@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Rashad Tatum <tatum.rashad@gmail.com> Subject: [FFmpeg-devel] [PATCH v5 3/3] libavformat/rtsp: Fix playback of sdp files from http urls. Date: Tue, 25 Feb 2025 23:01:07 -0500 Message-ID: <20250226040116.1056751-3-tatum.rashad@gmail.com> (raw) In-Reply-To: <20250226040116.1056751-1-tatum.rashad@gmail.com> Support wildcard source-filter destinations. Revamp source-filter processing to only happen after the first media description was processed and either when the next one starts or when we have reached the end of the sdp. This handles a wider variety of cases and doesn't rely on any optional media descriptions. --- libavformat/rtsp.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index ac17717195..1fbcb20167 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <stdbool.h> + #include "config_components.h" #include "libavutil/avassert.h" @@ -393,9 +395,10 @@ static void copy_default_source_addrs(struct RTSPSource **addrs, int count, { RTSPSource *rtsp_src, *rtsp_src2; int i; + const char* wildcard_dest = "*"; for (i = 0; i < count; i++) { rtsp_src = addrs[i]; - if (strcmp(rtsp_src->dest_addr, sdp_ip_str) == 0) { + if ((strcmp(rtsp_src->dest_addr, sdp_ip_str) == 0) || (strcmp(rtsp_src->dest_addr, wildcard_dest) == 0)) { rtsp_src2 = av_memdup(rtsp_src, sizeof(*rtsp_src)); if (!rtsp_src2) continue; @@ -425,7 +428,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, { RTSPState *rt = s->priv_data; char buf1[64], st_type[64]; - const char *p, *sdp_ip_str, *dest_addr; + const char *p, *dest_addr; enum AVMediaType codec_type; int payload_type; AVStream *st; @@ -451,7 +454,6 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, if (get_sockaddr(s, buf1, &sdp_ip)) return; - sdp_ip_str = av_strdup(buf1); ttl = 16; if (*p == '/') { p++; @@ -466,19 +468,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, rtsp_st->sdp_ip = sdp_ip; rtsp_st->sdp_ttl = ttl; - copy_default_source_addrs(s1->default_include_source_addrs, - s1->nb_default_include_source_addrs, - &rtsp_st->include_source_addrs, - &rtsp_st->nb_include_source_addrs, - sdp_ip_str); - copy_default_source_addrs(s1->default_exclude_source_addrs, - s1->nb_default_exclude_source_addrs, - &rtsp_st->exclude_source_addrs, - &rtsp_st->nb_exclude_source_addrs, - sdp_ip_str); - } - av_freep(&sdp_ip_str); break; case 's': av_dict_set(&s->metadata, "title", p, 0); @@ -521,6 +511,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, rtsp_st->sdp_ip = s1->default_ip; rtsp_st->sdp_ttl = s1->default_ttl; + + get_word(buf1, sizeof(buf1), &p); /* port */ rtsp_st->sdp_port = atoi(buf1); @@ -728,13 +720,31 @@ int ff_sdp_parse(AVFormatContext *s, const char *content) { const char *p; int letter, i; - char buf[SDP_MAX_SIZE], *q; + char buf[SDP_MAX_SIZE], sdp_ip_str[50], *q; + bool parsed_first_media_desc = false; SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state; p = content; for (;;) { p += strspn(p, SPACE_CHARS); letter = *p; + if(parsed_first_media_desc && (letter == 'm' || letter == '\0')) { + RTSPState *rt = s->priv_data; + RTSPStream *rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; + getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, + sizeof(rtsp_st->sdp_ip), + sdp_ip_str, sizeof(sdp_ip_str), NULL, 0, NI_NUMERICHOST); + copy_default_source_addrs(s1->default_include_source_addrs, + s1->nb_default_include_source_addrs, + &rtsp_st->include_source_addrs, + &rtsp_st->nb_include_source_addrs, + sdp_ip_str); + copy_default_source_addrs(s1->default_exclude_source_addrs, + s1->nb_default_exclude_source_addrs, + &rtsp_st->exclude_source_addrs, + &rtsp_st->nb_exclude_source_addrs, + sdp_ip_str); + } if (letter == '\0') break; p++; @@ -749,7 +759,11 @@ int ff_sdp_parse(AVFormatContext *s, const char *content) p++; } *q = '\0'; + sdp_parse_line(s, s1, letter, buf); + if(letter == 'm') + parsed_first_media_desc = true; + next_line: while (*p != '\n' && *p != '\0') p++; -- 2.48.1 _______________________________________________ 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".
prev parent reply other threads:[~2025-02-26 4:02 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-02-26 4:01 [FFmpeg-devel] [PATCH v5 1/3] libavformat/rtsp: Make source specific multicast work for rtsp streams Rashad Tatum 2025-02-26 4:01 ` [FFmpeg-devel] [PATCH v5 2/3] libavformat/rtsp: Free memory allocated for temporary variables while processing sdp info Rashad Tatum 2025-02-26 8:52 ` Andreas Rheinhardt 2025-02-26 12:14 ` Rashad Tatum 2025-02-26 12:52 ` Rashad Tatum 2025-02-26 13:16 ` Rashad Tatum 2025-02-26 13:18 ` Rashad Tatum 2025-02-26 13:19 ` Rashad Tatum 2025-02-26 4:01 ` Rashad Tatum [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250226040116.1056751-3-tatum.rashad@gmail.com \ --to=tatum.rashad@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git