summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-30 16:43:31 +0200
committerwm4 <wm4@nowhere>2012-09-18 21:04:45 +0200
commitd21b109bf7d3f36c13298d794c856eff834946c3 (patch)
tree86e8bfcdcc61aa75af10402e6b921bc5ad21224a /stream
parentfbc424ef35d4c76235feb3aa8295bcb8a3ce9443 (diff)
downloadmpv-d21b109bf7d3f36c13298d794c856eff834946c3.tar.bz2
mpv-d21b109bf7d3f36c13298d794c856eff834946c3.tar.xz
core: fix DVD subtitle selection
Add all subtitle tracks as reported by libdvdread at playback start. Display language for subtitle and audio tracks. This commit restores these features to the state when demux_mpg was default for DVD playback, and makes them work with demux_lavf and the recent changes to subtitle selection in the frontend. demux_mpg, which was the default demuxer for DVD playback, reordered the subtitle streams according to the "logical" subtitle track number, which conforms to the track layout reported by libdvdread, and is what stream_dvd expects for the STREAM_CTRL_GET_LANG call. demux_lavf, on the other hand, adds the streams in the order it encounters them in the MPEG stream. It seems this order is essentially random, and can't be mapped easily to what stream_dvd expects. Solve this by making demux_lavf hand out the MPEG stream IDs (using the demuxer_id field). The MPEG IDs are mapped by mplayer.c by special casing DVD playback (map_id_from/to_demuxer() functions). This mapping is essentially the same what demux_mpg did. Making demux_lavf reorder the streams is out of the question, because its stream handling is already messy enough. (Note that demux_lavf doesn't export stream IDs for other formats, because most time libavformat demuxers do not set AVStream.id, and we don't know which demuxers do. But we know that MPEG is safe.) Another major complication is that subtitle tracks are added lazily, as soon as the demuxer encounters the first subtitle packet for a given subtitle stream. Add the streams in advance. If a yet non-existent stream is selected, demux_lavf must be made to auto-select that subtitle stream as soon as it is added. Otherwise, the first subtitle packet would be lost. This is done by DEMUXER_CTRL_PRESELECT_SUBTITLE. demux_mpg didn't need this: the frontend code could just set ds->id to the desired stream number. But demux_lavf's stream IDs don't map directly to the stream number as used by libdvdread, which is why this hack is needed.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.h7
-rw-r--r--stream/stream_bluray.c4
-rw-r--r--stream/stream_dvd.c4
3 files changed, 5 insertions, 10 deletions
diff --git a/stream/stream.h b/stream/stream.h
index 6ce5b7bcac..eeb2f769bd 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -96,13 +96,8 @@
#define STREAM_CTRL_GET_NUM_TITLES 12
#define STREAM_CTRL_GET_LANG 13
-enum stream_ctrl_type {
- stream_ctrl_audio,
- stream_ctrl_sub,
-};
-
struct stream_lang_req {
- enum stream_ctrl_type type;
+ int type; // STREAM_AUDIO, STREAM_SUB
int id;
char *name;
};
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index 7c4f970159..68dea3db4c 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -199,11 +199,11 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)
BLURAY_STREAM_INFO *si = NULL;
int count = 0;
switch (req->type) {
- case stream_ctrl_audio:
+ case STREAM_AUDIO:
count = ti->clips[0].audio_stream_count;
si = ti->clips[0].audio_streams;
break;
- case stream_ctrl_sub:
+ case STREAM_SUB:
count = ti->clips[0].pg_stream_count;
si = ti->clips[0].pg_streams;
break;
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index e3e1595619..5332311856 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -693,10 +693,10 @@ static int control(stream_t *stream,int cmd,void* arg)
struct stream_lang_req *req = arg;
int lang = 0;
switch(req->type) {
- case stream_ctrl_audio:
+ case STREAM_AUDIO:
lang = dvd_lang_from_aid(stream, req->id);
break;
- case stream_ctrl_sub:
+ case STREAM_SUB:
lang = dvd_lang_from_sid(stream, req->id);
break;
}