summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-01 19:43:11 +0200
committerwm4 <wm4@nowhere>2013-06-01 19:43:11 +0200
commit27d383918a3d63559c85ca96b2162a13234f2abc (patch)
treedaac6d3fbbfece956e72189a032866f093b42764 /demux/demux.c
parentf7b9b92179333e5bf399cbb6289b66ed3439445c (diff)
downloadmpv-27d383918a3d63559c85ca96b2162a13234f2abc.tar.bz2
mpv-27d383918a3d63559c85ca96b2162a13234f2abc.tar.xz
core: add demux_sub pseudo demuxer
Subtitle files are opened in mplayer.c, not using the demuxer infrastructure in general. Pretend that this is not the case (outside of the loading code) by opening a pseudo demuxer that does nothing. One advantage is that the initialization code is now the same, and there's no confusion about what the difference between track->stream, track->sh_sub and mpctx->sh_sub is supposed to be. This is a bit stupid, and it would be much better if there were proper subtitle demuxers (there are many in recent FFmpeg, but not Libav). So for now this is just a transition to a more proper architecture. Look at demux_sub like an artifical limb: it's ugly, but don't hate it - it helps you to get on with your life.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 3e27b43f93..12e0d9083a 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -66,6 +66,7 @@ extern const demuxer_desc_t demuxer_desc_mpeg_es;
extern const demuxer_desc_t demuxer_desc_mpeg4_es;
extern const demuxer_desc_t demuxer_desc_h264_es;
extern const demuxer_desc_t demuxer_desc_mpeg_ts;
+extern const demuxer_desc_t demuxer_desc_sub;
/* Please do not add any new demuxers here. If you want to implement a new
* demuxer, add it to libavformat, except for wrappers around external
@@ -95,6 +96,8 @@ const demuxer_desc_t *const demuxer_list[] = {
&demuxer_desc_mpeg_ts,
// auto-probe last, because it checks file-extensions only
&demuxer_desc_mf,
+ // no auto-probe
+ &demuxer_desc_sub,
/* Please do not add any new demuxers here. If you want to implement a new
* demuxer, add it to libavformat, except for wrappers around external
* libraries and demuxers requiring binary support. */
@@ -217,8 +220,8 @@ static const demuxer_desc_t *get_demuxer_desc_from_type(int file_format)
}
-demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
- int a_id, int v_id, int s_id, char *filename)
+static demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
+ int a_id, int v_id, int s_id, char *filename)
{
struct demuxer *d = talloc_zero(NULL, struct demuxer);
d->stream = stream;
@@ -248,6 +251,18 @@ demuxer_t *new_demuxer(struct MPOpts *opts, stream_t *stream, int type,
return d;
}
+// for demux_sub.c
+demuxer_t *new_sub_pseudo_demuxer(struct MPOpts *opts)
+{
+ struct stream *s = open_stream("null://", NULL, NULL);
+ assert(s);
+ struct demuxer *d = new_demuxer(opts, s, DEMUXER_TYPE_SUB,
+ -1, -1, -1, NULL);
+ new_sh_stream(d, STREAM_SUB);
+ talloc_steal(d, s);
+ return d;
+}
+
static struct sh_stream *new_sh_stream_id(demuxer_t *demuxer,
enum stream_type type,
int stream_index,