Re: [FFmpeg-devel] [PATCH] Add support for HLS PLAYLIST types EVENT and VOD

2016-03-12 Thread Michael Niedermayer
On Thu, Dec 17, 2015 at 03:16:45AM +, Adam Kent wrote:
> Thanks Carl, good point, hope this is better.
> 
> ---
>  doc/muxers.texi  |  8 
>  libavformat/hlsenc.c | 20 
>  2 files changed, 28 insertions(+)

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add support for HLS PLAYLIST types EVENT and VOD

2015-12-16 Thread Carl Eugen Hoyos
Adam Kent  semicircular.net> writes:

> +if (hls->flags & HLS_EVENT_PLAYLIST) {
> +avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
> +} else if (hls->flags & HLS_VOD_PLAYLIST) {
> +avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");

This seems to indicate that they are exclusive 
(it it not ok to set both).

If this is true, I believe you should use a 
"playlist" options that allows to set "none", 
"event" or "vod".

Carl Eugen

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add support for HLS PLAYLIST types EVENT and VOD

2015-12-16 Thread Adam Kent
Thanks Carl, good point, hope this is better.

---
 doc/muxers.texi  |  8 
 libavformat/hlsenc.c | 20 
 2 files changed, 28 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index b6d8823..c6e3b8f 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -368,6 +368,14 @@ Will produce the playlist, @file{out.m3u8}, and a single 
segment file,
 @item hls_flags delete_segments
 Segment files removed from the playlist are deleted after a period of time
 equal to the duration of the segment plus the duration of the playlist.
+
+@item hls_playlist_type event
+Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces
+@option{hls_list_size} to 0; the playlist can only be appended to.
+
+@item hls_playlist_type vod
+Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces
+@option{hls_list_size} to 0; the playlist must not change.
 @end table
 
 @anchor{ico}
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index adcf7df..11bb045 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -63,6 +63,13 @@ typedef enum HLSFlags {
 HLS_OMIT_ENDLIST = (1 << 4),
 } HLSFlags;
 
+typedef enum {
+PLAYLIST_TYPE_NONE,
+PLAYLIST_TYPE_EVENT,
+PLAYLIST_TYPE_VOD,
+PLAYLIST_TYPE_NB,
+} PlaylistType;
+
 typedef struct HLSContext {
 const AVClass *class;  // Class for private options.
 unsigned number;
@@ -78,6 +85,7 @@ typedef struct HLSContext {
 int max_nb_segments;   // Set by a private option.
 int  wrap; // Set by a private option.
 uint32_t flags;// enum HLSFlags
+uint32_t pl_type;  // enum PlaylistType
 char *segment_filename;
 
 int use_localtime;  ///< flag to expand filename with localtime
@@ -335,6 +343,10 @@ static int hls_append_segment(HLSContext *hls, double 
duration, int64_t pos,
 
 hls->last_segment = en;
 
+// EVENT or VOD playlists imply sliding window cannot be used
+if (hls->pl_type != PLAYLIST_TYPE_NONE)
+hls->max_nb_segments = 0;
+
 if (hls->max_nb_segments && hls->nb_entries >= hls->max_nb_segments) {
 en = hls->segments;
 hls->segments = en->next;
@@ -411,6 +423,11 @@ static int hls_window(AVFormatContext *s, int last)
 }
 avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
 avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
+if (hls->pl_type == PLAYLIST_TYPE_EVENT) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
+} else if (hls->pl_type == PLAYLIST_TYPE_VOD) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
+}
 
 av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
sequence);
@@ -875,6 +892,9 @@ static const AVOption options[] = {
 {"discont_start", "start the playlist with a discontinuity tag", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX,   E, "flags"},
 {"omit_endlist", "Do not append an endlist when ending stream", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_OMIT_ENDLIST }, 0, UINT_MAX,   E, "flags"},
 { "use_localtime", "set filename expansion with strftime at segment 
creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
+{"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), 
AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, 
"pl_type" },
+{"event", "EVENT playlist", 0, AV_OPT_TYPE_CONST, {.i64 = 
PLAYLIST_TYPE_EVENT }, INT_MIN, INT_MAX, E, "pl_type" },
+{"vod", "VOD playlist", 0, AV_OPT_TYPE_CONST, {.i64 = PLAYLIST_TYPE_VOD }, 
INT_MIN, INT_MAX, E, "pl_type" },
 {"method", "set the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING, 
{.str = NULL},  0, 0,E},
 
 { NULL },
-- 
2.1.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add support for HLS PLAYLIST types EVENT and VOD

2015-12-15 Thread Adam Kent
Adds HLS flags to emit the X-PLAYLIST-TYPE tag to the top of generated
M3U8 files.

See the spec:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-18#section-4.3.3.5

There was also an FFMPEG trac ticket #4571 that had this as a wishlist item:
https://trac.ffmpeg.org/ticket/4571

---
 doc/muxers.texi  | 6 ++
 libavformat/hlsenc.c | 9 +
 2 files changed, 15 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index b6d8823..cbbf23e 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -368,6 +368,12 @@ Will produce the playlist, @file{out.m3u8}, and a single 
segment file,
 @item hls_flags delete_segments
 Segment files removed from the playlist are deleted after a period of time
 equal to the duration of the segment plus the duration of the playlist.
+
+@item hls_flags event
+Emit #EXT-X-PLAYLIST-TYPE:EVENT at the top of the M3U8 file.
+
+@item hls_flags vod
+Emit #EXT-X-PLAYLIST-TYPE:VOD at the top of the M3U8 file.
 @end table
 
 @anchor{ico}
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index adcf7df..8db2088 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -61,6 +61,8 @@ typedef enum HLSFlags {
 HLS_ROUND_DURATIONS = (1 << 2),
 HLS_DISCONT_START = (1 << 3),
 HLS_OMIT_ENDLIST = (1 << 4),
+HLS_EVENT_PLAYLIST = (1 << 5),
+HLS_VOD_PLAYLIST = (1 << 6),
 } HLSFlags;
 
 typedef struct HLSContext {
@@ -411,6 +413,11 @@ static int hls_window(AVFormatContext *s, int last)
 }
 avio_printf(out, "#EXT-X-TARGETDURATION:%d\n", target_duration);
 avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
+if (hls->flags & HLS_EVENT_PLAYLIST) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:EVENT\n");
+} else if (hls->flags & HLS_VOD_PLAYLIST) {
+avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
+}
 
 av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
sequence);
@@ -874,6 +881,8 @@ static const AVOption options[] = {
 {"round_durations", "round durations in m3u8 to whole numbers", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_ROUND_DURATIONS }, 0, UINT_MAX,   E, "flags"},
 {"discont_start", "start the playlist with a discontinuity tag", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX,   E, "flags"},
 {"omit_endlist", "Do not append an endlist when ending stream", 0, 
AV_OPT_TYPE_CONST, {.i64 = HLS_OMIT_ENDLIST }, 0, UINT_MAX,   E, "flags"},
+{"event", "set playlist type as 'EVENT'", 0, AV_OPT_TYPE_CONST, {.i64 = 
HLS_EVENT_PLAYLIST }, 0, UINT_MAX,   E, "flags"},
+{"vod", "set playlist type as 'VOD'", 0, AV_OPT_TYPE_CONST, {.i64 = 
HLS_VOD_PLAYLIST }, 0, UINT_MAX,   E, "flags"},
 { "use_localtime", "set filename expansion with strftime at segment 
creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
 {"method", "set the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING, 
{.str = NULL},  0, 0,E},
 
-- 
2.1.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel