summaryrefslogtreecommitdiffstats
path: root/stream/stream_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-07 15:54:34 +0100
committerwm4 <wm4@nowhere>2019-11-07 22:53:13 +0100
commite5a9b792ecf08ddbcf3b674de3a00f7a919d1858 (patch)
treeead751b12d006d13f138867324b62dda62b8e77b /stream/stream_lavf.c
parentca75fedaf4dea19986159f1caa5ab9ebc202f9d4 (diff)
downloadmpv-e5a9b792ecf08ddbcf3b674de3a00f7a919d1858.tar.bz2
mpv-e5a9b792ecf08ddbcf3b674de3a00f7a919d1858.tar.xz
stream: replace STREAM_CTRL_GET_SIZE with a proper entrypoint
This is overlay convoluted as a stream control, and important enough to warrant "first class" functionality.
Diffstat (limited to 'stream/stream_lavf.c')
-rw-r--r--stream/stream_lavf.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index 98c66e4f71..5359d8d7d4 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -107,6 +107,12 @@ static int seek(stream_t *s, int64_t newpos)
return 1;
}
+static int64_t get_size(stream_t *s)
+{
+ AVIOContext *avio = s->priv;
+ return avio_size(avio);
+}
+
static void close_f(stream_t *stream)
{
AVIOContext *avio = stream->priv;
@@ -122,15 +128,7 @@ static void close_f(stream_t *stream)
static int control(stream_t *s, int cmd, void *arg)
{
AVIOContext *avio = s->priv;
- int64_t size;
switch(cmd) {
- case STREAM_CTRL_GET_SIZE:
- size = avio_size(avio);
- if (size >= 0) {
- *(int64_t *)arg = size;
- return 1;
- }
- break;
case STREAM_CTRL_AVSEEK: {
struct stream_avseek *c = arg;
int64_t r = avio_seek_time(avio, c->stream_index, c->timestamp, c->flags);
@@ -333,6 +331,7 @@ static int open_f(stream_t *stream)
stream->seek = stream->seekable ? seek : NULL;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
+ stream->get_size = get_size;
stream->control = control;
stream->close = close_f;
// enable cache (should be avoided for files, but no way to detect this)