Browse code

hls: Add an option to prepend a baseurl to the playlist entries

Useful to generate playlists with absolute paths.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>

Luca Barbato authored on 2014/03/19 05:19:00
Showing 2 changed files
... ...
@@ -114,6 +114,9 @@ Set the maximum number of playlist entries.
114 114
 Set the number after which index wraps.
115 115
 @item -start_number @var{number}
116 116
 Start the sequence from @var{number}.
117
+@item -hls_base_url @var{baseurl}
118
+Append @var{baseurl} to every entry in the playlist.
119
+Useful to generate playlists with absolute paths.
117 120
 @end table
118 121
 
119 122
 @anchor{image2}
... ...
@@ -55,6 +55,7 @@ typedef struct HLSContext {
55 55
     ListEntry *list;
56 56
     ListEntry *end_list;
57 57
     char *basename;
58
+    char *baseurl;
58 59
     AVIOContext *pb;
59 60
 } HLSContext;
60 61
 
... ...
@@ -148,6 +149,8 @@ static int hls_window(AVFormatContext *s, int last)
148 148
 
149 149
     for (en = hls->list; en; en = en->next) {
150 150
         avio_printf(hls->pb, "#EXTINF:%d,\n", en->duration);
151
+        if (hls->baseurl)
152
+            avio_printf(hls->pb, "%s", hls->baseurl);
151 153
         avio_printf(hls->pb, "%s\n", en->name);
152 154
     }
153 155
 
... ...
@@ -319,6 +322,7 @@ static const AVOption options[] = {
319 319
     {"hls_time",      "segment length in seconds",               OFFSET(time),    AV_OPT_TYPE_FLOAT,  {.dbl = 2},     0, FLT_MAX, E},
320 320
     {"hls_list_size", "maximum number of playlist entries",      OFFSET(size),    AV_OPT_TYPE_INT,    {.i64 = 5},     0, INT_MAX, E},
321 321
     {"hls_wrap",      "number after which the index wraps",      OFFSET(wrap),    AV_OPT_TYPE_INT,    {.i64 = 0},     0, INT_MAX, E},
322
+    {"hls_base_url",  "url to prepend to each playlist entry",   OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,       E},
322 323
     { NULL },
323 324
 };
324 325