diff options
author | wm4 <wm4@nowhere> | 2013-07-02 12:18:04 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-02 12:19:16 +0200 |
commit | 3f3ffd0de4943a1ce8e5dd1fbf457bcba989fc2b (patch) | |
tree | f46693b5285f97bc3a24cfed58194caf669b8766 /stream | |
parent | e00621ac4605e96c9452f4d65216d0019f7e55cb (diff) | |
download | mpv-3f3ffd0de4943a1ce8e5dd1fbf457bcba989fc2b.tar.bz2 mpv-3f3ffd0de4943a1ce8e5dd1fbf457bcba989fc2b.tar.xz |
core: update metadata during playback, allow streams to export metadata
STREAM_CTRL_GET_METADATA will be used to poll for streamcast metadata.
Also add DEMUXER_CTRL_UPDATE_INFO, which could in theory be used by
demux_lavf.c. (Unfortunately, libavformat is too crappy to read metadata
mid-stream for mp3 or ogg, so we don't implement it.)
Diffstat (limited to 'stream')
-rw-r--r-- | stream/cache.c | 23 | ||||
-rw-r--r-- | stream/stream.h | 1 |
2 files changed, 23 insertions, 1 deletions
diff --git a/stream/cache.c b/stream/cache.c index f30130ae35..4015aae82c 100644 --- a/stream/cache.c +++ b/stream/cache.c @@ -31,7 +31,7 @@ // Time in seconds the cache updates "cached" controls. Note that idle mode // will block the cache from doing this, and this timeout is honored only if // the cache is active. -#define CACHE_UPDATE_CONTROLS_TIME 0.1 +#define CACHE_UPDATE_CONTROLS_TIME 2.0 #include <stdio.h> @@ -102,6 +102,7 @@ struct priv { unsigned int stream_num_chapters; int stream_cache_idle; int stream_cache_fill; + char **stream_metadata; }; // Store additional per-byte metadata. Since per-byte would be way too @@ -306,6 +307,7 @@ static void update_cached_controls(struct priv *s) { unsigned int ui; double d; + char **m; s->stream_time_length = 0; if (stream_control(s->stream, STREAM_CTRL_GET_TIME_LENGTH, &d) == STREAM_OK) s->stream_time_length = d; @@ -318,6 +320,10 @@ static void update_cached_controls(struct priv *s) s->stream_num_chapters = 0; if (stream_control(s->stream, STREAM_CTRL_GET_NUM_CHAPTERS, &ui) == STREAM_OK) s->stream_num_chapters = ui; + if (stream_control(s->stream, STREAM_CTRL_GET_METADATA, &m) == STREAM_OK) { + talloc_free(s->stream_metadata); + s->stream_metadata = talloc_steal(s, m); + } stream_update_size(s->stream); s->stream_size = s->stream->end_pos; } @@ -368,6 +374,21 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg) } return STREAM_UNSUPPORTED; } + case STREAM_CTRL_GET_METADATA: { + if (s->stream_metadata && s->stream_metadata[0]) { + char **m = talloc_new(NULL); + int num_m = 0; + for (int n = 0; s->stream_metadata[n]; n++) { + char *t = talloc_strdup(m, s->stream_metadata[n]); + MP_TARRAY_APPEND(NULL, m, num_m, t); + } + MP_TARRAY_APPEND(NULL, m, num_m, NULL); + MP_TARRAY_APPEND(NULL, m, num_m, NULL); + *(char ***)arg = m; + return STREAM_OK; + } + return STREAM_UNSUPPORTED; + } } return STREAM_ERROR; } diff --git a/stream/stream.h b/stream/stream.h index 1bcd97bed1..d5400470d3 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -103,6 +103,7 @@ #define STREAM_CTRL_GET_CHAPTER_TIME 21 #define STREAM_CTRL_GET_DVD_INFO 22 #define STREAM_CTRL_SET_CONTENTS 23 +#define STREAM_CTRL_GET_METADATA 24 struct stream_lang_req { int type; // STREAM_AUDIO, STREAM_SUB |