diff options
author | wm4 <wm4@nowhere> | 2017-02-02 18:24:27 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-02-02 18:26:58 +0100 |
commit | fb9a32977d6abf4c83a92d993af58e393819c062 (patch) | |
tree | daa8fac391c393560588ce8653943a8259f59815 /demux/demux_disc.c | |
parent | e13a62fc346867450cd41d02cffbdaf477a3fec4 (diff) | |
download | mpv-fb9a32977d6abf4c83a92d993af58e393819c062.tar.bz2 mpv-fb9a32977d6abf4c83a92d993af58e393819c062.tar.xz |
stream: get rid of streamtype enum
Because it's kind of dumb. (But not sure if it was worth the trouble.)
For stream_file.c, we add new explicit fields. The rest are rather
special uses and can be killed by comparing the stream impl. name.
The changes to DVD/BD/CD/TV are entirely untested.
Diffstat (limited to 'demux/demux_disc.c')
-rw-r--r-- | demux/demux_disc.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/demux/demux_disc.c b/demux/demux_disc.c index 805ba4ccff..ad54db8c19 100644 --- a/demux/demux_disc.c +++ b/demux/demux_disc.c @@ -43,6 +43,8 @@ struct priv { double base_dts; // packet DTS that maps to base_time double last_dts; // DTS of previously demuxed packet bool seek_reinit; // needs reinit after seek + + bool is_dvd, is_cdda; }; // If the timestamp difference between subsequent packets is this big, assume @@ -65,7 +67,7 @@ static void reselect_streams(demuxer_t *demuxer) static void get_disc_lang(struct stream *stream, struct sh_stream *sh) { struct stream_lang_req req = {.type = sh->type, .id = sh->demuxer_id}; - if (stream->uncached_type == STREAMTYPE_DVD && sh->type == STREAM_SUB) + if (sh->type == STREAM_SUB) req.id = req.id & 0x1F; // mpeg ID to index stream_control(stream, STREAM_CTRL_GET_LANG, &req); if (req.name[0]) @@ -76,7 +78,7 @@ static void add_dvd_streams(demuxer_t *demuxer) { struct priv *p = demuxer->priv; struct stream *stream = demuxer->stream; - if (stream->uncached_type != STREAMTYPE_DVD) + if (!p->is_dvd) return; struct stream_dvd_info_req info; if (stream_control(stream, STREAM_CTRL_GET_DVD_INFO, &info) > 0) { @@ -162,7 +164,7 @@ static void d_seek(demuxer_t *demuxer, double seek_pts, int flags) { struct priv *p = demuxer->priv; - if (demuxer->stream->uncached_type == STREAMTYPE_CDDA) { + if (p->is_cdda) { demux_seek(p->slave, seek_pts, flags); return; } @@ -222,7 +224,7 @@ static int d_fill_buffer(demuxer_t *demuxer) return 1; } - if (demuxer->stream->uncached_type == STREAMTYPE_CDDA) { + if (p->is_cdda) { demux_add_packet(sh, pkt); return 1; } @@ -285,7 +287,21 @@ static int d_open(demuxer_t *demuxer, enum demux_check check) struct demuxer_params params = {.force_format = "+lavf"}; - if (demuxer->stream->uncached_type == STREAMTYPE_CDDA) + struct stream *cur = demuxer->stream; + const char *sname = ""; + while (cur) { + if (cur->info) + sname = cur->info->name; + cur = cur->underlying; // down the caching chain + } + + p->is_cdda = strcmp(sname, "cdda") == 0; + p->is_dvd = strcmp(sname, "dvd") == 0 || + strcmp(sname, "ifo") == 0 || + strcmp(sname, "dvdnav") == 0 || + strcmp(sname, "ifo_dvdnav") == 0; + + if (p->is_cdda) params.force_format = "+rawaudio"; char *t = NULL; @@ -311,7 +327,7 @@ static int d_open(demuxer_t *demuxer, enum demux_check check) // (actually libavformat/mpegts.c) to seek sometimes when reading a packet. // It does this to seek back a bit in case the current file position points // into the middle of a packet. - if (demuxer->stream->uncached_type != STREAMTYPE_CDDA) { + if (!p->is_cdda) { demuxer->stream->seekable = false; // Can be seekable even if the stream isn't. |