diff mbox series

[FFmpeg-devel] avformat/hlsenc: Allow setting master_pl_publish_rate to a negative value to have it write immediately

Message ID 20231103173332.94028-1-davejohansen@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat/hlsenc: Allow setting master_pl_publish_rate to a negative value to have it write immediately | expand

Commit Message

David Johansen Nov. 3, 2023, 5:33 p.m. UTC
---
 libavformat/hlsenc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 4ef84c05c1..76d8094de6 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -245,7 +245,7 @@  typedef struct HLSContext {
     char *var_stream_map; /* user specified variant stream map string */
     char *cc_stream_map; /* user specified closed caption streams map string */
     char *master_pl_name;
-    unsigned int master_publish_rate;
+    int master_publish_rate;
     int http_persistent;
     AVIOContext *m3u8_out;
     AVIOContext *sub_m3u8_out;
@@ -1388,7 +1388,9 @@  static int create_master_playlist(AVFormatContext *s,
     char temp_filename[MAX_URL_SIZE];
 
     input_vs->m3u8_created = 1;
-    if (!hls->master_m3u8_created) {
+    if (hls->master_publish_rate < 0) {
+        hls->master_publish_rate = 0;
+    } else if (!hls->master_m3u8_created) {
         /* For the first time, wait until all the media playlists are created */
         for (i = 0; i < hls->nb_varstreams; i++)
             if (!hls->var_streams[i].m3u8_created)
@@ -3162,7 +3164,7 @@  static const AVOption options[] = {
     {"var_stream_map", "Variant stream map string", OFFSET(var_stream_map), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,    E},
     {"cc_stream_map", "Closed captions stream map string", OFFSET(cc_stream_map), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,    E},
     {"master_pl_name", "Create HLS master playlist with this name", OFFSET(master_pl_name), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,    E},
-    {"master_pl_publish_rate", "Publish master play list every after this many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E},
+    {"master_pl_publish_rate", "Publish master play list every after this many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, E},
     {"http_persistent", "Use persistent HTTP connections", OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
     {"timeout", "set timeout for socket I/O operations", OFFSET(timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = E },
     {"ignore_io_errors", "Ignore IO errors for stable long-duration runs with network output", OFFSET(ignore_io_errors), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },