summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-09-07 21:58:46 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:04 +0200
commitb298140b07842bd3573866564ad30ddfef65638c (patch)
tree0239561d157e4c8e5fd62c73bfde6eb46bdf2047 /demux
parentf77515ebafb9fdfd177671b848211824e654206f (diff)
downloadmpv-b298140b07842bd3573866564ad30ddfef65638c.tar.bz2
mpv-b298140b07842bd3573866564ad30ddfef65638c.tar.xz
demux: return stream file size differently, rip out stream ctrls
The stream size return was the only thing that still required doing STREAM_CTRLs from frontend through the demuxer layer. This can be done much easier, so rip it out. Also rip out the now unused infrastructure for STREAM_CTRLs via demuxer layer.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux.c37
-rw-r--r--demux/demux.h6
2 files changed, 2 insertions, 41 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 6c4f9542f8..3aade0f200 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1878,6 +1878,7 @@ static struct demux_packet *dequeue_packet(struct demux_stream *ds)
// This implies this function is actually called from "the" user thread.
if (pkt->pos >= ds->in->d_user->filepos)
ds->in->d_user->filepos = pkt->pos;
+ ds->in->d_user->filesize = ds->in->stream_size;
pkt->pts = MP_ADD_PTS(pkt->pts, ds->in->ts_offset);
pkt->dts = MP_ADD_PTS(pkt->dts, ds->in->ts_offset);
@@ -3115,30 +3116,9 @@ static void update_cache(struct demux_internal *in)
}
// must be called locked
-static int cached_stream_control(struct demux_internal *in, int cmd, void *arg)
-{
- switch (cmd) {
- case STREAM_CTRL_GET_SIZE:
- if (in->stream_size < 0)
- return STREAM_UNSUPPORTED;
- *(int64_t *)arg = in->stream_size;
- return STREAM_OK;
- }
- return STREAM_ERROR;
-}
-
-// must be called locked
static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
{
switch (cmd) {
- case DEMUXER_CTRL_STREAM_CTRL: {
- struct demux_ctrl_stream_ctrl *c = arg;
- int r = cached_stream_control(in, c->ctrl, c->arg);
- if (r == STREAM_ERROR)
- break;
- c->res = r;
- return CONTROL_OK;
- }
case DEMUXER_CTRL_GET_BITRATE_STATS: {
double *rates = arg;
for (int n = 0; n < STREAM_TYPE_COUNT; n++)
@@ -3217,14 +3197,6 @@ static void thread_demux_control(void *p)
pthread_mutex_unlock(&in->lock);
- if (cmd == DEMUXER_CTRL_STREAM_CTRL) {
- struct demux_ctrl_stream_ctrl *c = arg;
- if (in->threading)
- MP_VERBOSE(demuxer, "blocking for STREAM_CTRL %d\n", c->ctrl);
- c->res = stream_control(demuxer->stream, c->ctrl, c->arg);
- if (c->res != STREAM_UNSUPPORTED)
- r = CONTROL_OK;
- }
if (r != CONTROL_OK) {
if (in->threading)
MP_VERBOSE(demuxer, "blocking for DEMUXER_CTRL %d\n", cmd);
@@ -3272,13 +3244,6 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg)
return r;
}
-int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg)
-{
- struct demux_ctrl_stream_ctrl c = {ctrl, arg, STREAM_UNSUPPORTED};
- demux_control(demuxer, DEMUXER_CTRL_STREAM_CTRL, &c);
- return c.res;
-}
-
bool demux_cancel_test(struct demuxer *demuxer)
{
return mp_cancel_test(demuxer->cancel);
diff --git a/demux/demux.h b/demux/demux.h
index b8d5cb5ee0..1bb8e2f7c8 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -32,8 +32,6 @@
enum demux_ctrl {
DEMUXER_CTRL_SWITCHED_TRACKS = 1,
- DEMUXER_CTRL_IDENTIFY_PROGRAM,
- DEMUXER_CTRL_STREAM_CTRL,
DEMUXER_CTRL_GET_READER_STATE,
DEMUXER_CTRL_GET_BITRATE_STATS, // double[STREAM_TYPE_COUNT]
DEMUXER_CTRL_REPLACE_STREAM,
@@ -192,6 +190,7 @@ typedef struct demuxer {
const demuxer_desc_t *desc; ///< Demuxer description structure
const char *filetype; // format name when not identified by demuxer (libavformat)
int64_t filepos; // input stream current pos.
+ int64_t filesize;
char *filename; // same as stream->url
bool seekable;
bool partially_seekable; // true if _maybe_ seekable; implies seekable=true
@@ -243,7 +242,6 @@ typedef struct demuxer {
// Since the demuxer can run in its own thread, and the stream is not
// thread-safe, only the demuxer is allowed to access the stream directly.
- // You can freely use demux_stream_control() to send STREAM_CTRLs.
// Also note that the stream can get replaced if fully_read is set.
struct stream *stream;
} demuxer_t;
@@ -308,8 +306,6 @@ int demuxer_add_chapter(demuxer_t *demuxer, char *name,
void demux_set_stream_tags(struct demuxer *demuxer, struct sh_stream *sh,
struct mp_tags *tags);
-int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg);
-
void demux_metadata_changed(demuxer_t *demuxer);
void demux_update(demuxer_t *demuxer);