]> git.sesse.net Git - ffmpeg/commitdiff
avformat, hls: add a flag to signal unavailability of seeking
authorwm4 <nfxjfg@googlemail.com>
Wed, 24 Jan 2018 07:02:25 +0000 (08:02 +0100)
committerwm4 <nfxjfg@googlemail.com>
Sat, 27 Jan 2018 03:10:52 +0000 (04:10 +0100)
The seek function can just return an error if seeking is unavailable,
but often this is too late. Add a flag that signals that the stream is
unseekable, and use it in HLS.

doc/APIchanges
libavformat/avformat.h
libavformat/hls.c
libavformat/version.h

index c27f104c951c08bd299d885a0f363f44f971712e..59e3b20c08b88beeb8a6ca36b1a541d8bc31b74b 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-01-xx - xxxxxxx - lavf 58.6.100 - avformat.h
+  Add AVFMTCTX_UNSEEKABLE (for HLS demuxer).
+
 2018-xx-xx - xxxxxxx - lavu 56.9.100 - aes_ctr.h
   Add method to set the 16-byte IV.
 
index e5740be2b4dfb6a85e32267ca4b245c72dfcda39..60ab9fbc804e1f83dae261b9d75b61c12fa09bcc 100644 (file)
@@ -1275,6 +1275,11 @@ typedef struct AVProgram {
 
 #define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
                                          (streams are added dynamically) */
+#define AVFMTCTX_UNSEEKABLE    0x0002 /**< signal that the stream is definitely
+                                         not seekable, and attempts to call the
+                                         seek function will fail. For some
+                                         network protocols (e.g. HLS), this can
+                                         change dynamically at runtime. */
 
 typedef struct AVChapter {
     int id;                 ///< unique ID to identify the chapter
index ff7bdecc9338e2de7b5f5d34b6351869c5767f40..6e1a2e3f1eda8d8a1d74074986045e671875314e 100644 (file)
@@ -930,6 +930,11 @@ fail:
     av_free(new_url);
     if (close_in)
         ff_format_io_close(c->ctx, &in);
+    c->ctx->ctx_flags = c->ctx->ctx_flags & ~(unsigned)AVFMTCTX_UNSEEKABLE;
+    if (!c->n_variants || !c->variants[0]->n_playlists ||
+        !(c->variants[0]->playlists[0]->finished ||
+          c->variants[0]->playlists[0]->type == PLS_TYPE_EVENT))
+        c->ctx->ctx_flags |= AVFMTCTX_UNSEEKABLE;
     return ret;
 }
 
@@ -2213,8 +2218,7 @@ static int hls_read_seek(AVFormatContext *s, int stream_index,
     int stream_subdemuxer_index;
     int64_t first_timestamp, seek_timestamp, duration;
 
-    if ((flags & AVSEEK_FLAG_BYTE) ||
-        !(c->variants[0]->playlists[0]->finished || c->variants[0]->playlists[0]->type == PLS_TYPE_EVENT))
+    if ((flags & AVSEEK_FLAG_BYTE) || (c->ctx->ctx_flags & AVFMTCTX_UNSEEKABLE))
         return AVERROR(ENOSYS);
 
     first_timestamp = c->first_timestamp == AV_NOPTS_VALUE ?
index 148fc75faa091fa86448a80f3c587ab9b6152a5b..5ff8a89ae0864c8614ecb1aa262050719557a42d 100644 (file)
@@ -32,8 +32,8 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR   5
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR   6
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \