PR #20598 opened by Kaarle Ritvanen (kunkku)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20598
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20598.patch

Correctly set the AVFMTCTX_UNSEEKABLE flag for live RTP streams. Some external 
applications, such as Qt Multimedia, depend on this flag being set correctly.


>From 4b5050ea12b9979fb0e7849adb72bd0e07013494 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <[email protected]>
Date: Tue, 29 Apr 2025 14:35:00 +0300
Subject: [PATCH] avformat/rtsp: set AVFMTCTX_UNSEEKABLE flag

for live RTP streams. Some external applications, such as Qt Multimedia,
depend on this flag being set correctly.

Signed-off-by: Kaarle Ritvanen <[email protected]>
---
 libavformat/rtsp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d601d63a89..e8f44e571a 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -663,8 +663,8 @@ static void sdp_parse_line(AVFormatContext *s, 
SDPParseState *s1,
             rtsp_parse_range_npt(p, &start, &end);
             s->start_time = start;
             /* AV_NOPTS_VALUE means live broadcast (and can't seek) */
-            s->duration   = (end == AV_NOPTS_VALUE) ?
-                            AV_NOPTS_VALUE : end - start;
+            if (end != AV_NOPTS_VALUE)
+                s->duration = end - start;
         } else if (av_strstart(p, "lang:", &p)) {
             if (s->nb_streams > 0) {
                 get_word(buf1, sizeof(buf1), &p);
@@ -754,6 +754,8 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
     char buf[SDP_MAX_SIZE], *q;
     SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
 
+    s->duration = AV_NOPTS_VALUE;
+
     p = content;
     for (;;) {
         p += strspn(p, SPACE_CHARS);
@@ -787,6 +789,9 @@ int ff_sdp_parse(AVFormatContext *s, const char *content)
         av_freep(&s1->default_exclude_source_addrs[i]);
     av_freep(&s1->default_exclude_source_addrs);
 
+    if (s->duration == AV_NOPTS_VALUE)
+        s->ctx_flags |= AVFMTCTX_UNSEEKABLE;
+
     return 0;
 }
 #endif /* CONFIG_RTPDEC */
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to