Mercurial > mplayer.hg
changeset 36337:805ff0c5b699
Support -alang and -slang for bluray://
author | reimar |
---|---|
date | Sun, 25 Aug 2013 17:57:25 +0000 |
parents | e24ada1fc15f |
children | d9d308031e9e |
files | mencoder.c mplayer.c stream/stream.h stream/stream_bluray.c |
diffstat | 4 files changed, 72 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/mencoder.c Sun Aug 25 17:23:22 2013 +0000 +++ b/mencoder.c Sun Aug 25 17:57:25 2013 +0000 @@ -671,6 +671,13 @@ if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=bd_sid_from_lang(stream,dvdsub_lang); } +#ifdef CONFIG_LIBBLURAY +if(stream->type==STREAMTYPE_BLURAY){ + if(audio_lang && audio_id==-1) audio_id=bluray_id_from_lang(stream,stream_ctrl_audio,audio_lang); + if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=bluray_id_from_lang(stream,stream_ctrl_sub,dvdsub_lang); +} +#endif + #ifdef CONFIG_DVDREAD if(stream->type==STREAMTYPE_DVD){ if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang);
--- a/mplayer.c Sun Aug 25 17:23:22 2013 +0000 +++ b/mplayer.c Sun Aug 25 17:57:25 2013 +0000 @@ -3312,6 +3312,15 @@ dvdsub_id = bd_sid_from_lang(mpctx->stream, dvdsub_lang); } +#ifdef CONFIG_LIBBLURAY + if (mpctx->stream->type == STREAMTYPE_BLURAY) { + if (audio_lang && audio_id == -1) + audio_id = bluray_id_from_lang(mpctx->stream, stream_ctrl_audio, audio_lang); + if (dvdsub_lang && dvdsub_id == -1) + dvdsub_id = bluray_id_from_lang(mpctx->stream, stream_ctrl_sub, dvdsub_lang); + } +#endif + #ifdef CONFIG_DVDREAD if (mpctx->stream->type == STREAMTYPE_DVD) { current_module = "dvd lang->id";
--- a/stream/stream.h Sun Aug 25 17:23:22 2013 +0000 +++ b/stream/stream.h Sun Aug 25 17:57:25 2013 +0000 @@ -396,6 +396,8 @@ int channels; } stream_language_t; +int bluray_id_from_lang(stream_t *s, enum stream_ctrl_type type, const char *lang); + int parse_chapter_range(const m_option_t *conf, const char *range); #endif /* MPLAYER_STREAM_H */
--- a/stream/stream_bluray.c Sun Aug 25 17:23:22 2013 +0000 +++ b/stream/stream_bluray.c Sun Aug 25 17:57:25 2013 +0000 @@ -105,6 +105,48 @@ return bd_read(b->bd, buf, len); } +static BLURAY_TITLE_INFO *get_langs(const struct bluray_priv_s *b, enum stream_ctrl_type type, + const BLURAY_STREAM_INFO **si, int *count) +{ + BLURAY_TITLE_INFO *ti = bd_get_title_info(b->bd, b->current_title, b->current_angle); + *count = 0; + if (ti->clip_count) { + switch (type) { + case stream_ctrl_audio: + *count = ti->clips[0].audio_stream_count; + *si = ti->clips[0].audio_streams; + break; + case stream_ctrl_sub: + *count = ti->clips[0].pg_stream_count; + *si = ti->clips[0].pg_streams; + break; + } + if (*count > 0) + return ti; + } + *si = NULL; + bd_free_title_info(ti); + return NULL; +} + +int bluray_id_from_lang(stream_t *s, enum stream_ctrl_type type, const char *lang) +{ + struct bluray_priv_s *b = s->priv; + const BLURAY_STREAM_INFO *si; + int count; + BLURAY_TITLE_INFO *ti = get_langs(b, type, &si, &count); + while (count-- > 0) { + if (strstr(si->lang, lang)) { + bd_free_title_info(ti); + return si->pid; + } + si++; + } + if (ti) + bd_free_title_info(ti); + return -1; +} + static int bluray_stream_control(stream_t *s, int cmd, void *arg) { struct bluray_priv_s *b = s->priv; @@ -196,31 +238,20 @@ case STREAM_CTRL_GET_LANG: { struct stream_lang_req *req = arg; - BLURAY_TITLE_INFO *ti = bd_get_title_info(b->bd, b->current_title, b->current_angle); - if (ti->clip_count) { - BLURAY_STREAM_INFO *si = NULL; - int count = 0; - switch (req->type) { - case stream_ctrl_audio: - count = ti->clips[0].audio_stream_count; - si = ti->clips[0].audio_streams; - break; - case stream_ctrl_sub: - count = ti->clips[0].pg_stream_count; - si = ti->clips[0].pg_streams; - break; + const BLURAY_STREAM_INFO *si; + int count; + BLURAY_TITLE_INFO *ti = get_langs(b, req->type, &si, &count); + while (count-- > 0) { + if (si->pid == req->id) { + memcpy(req->buf, si->lang, 4); + req->buf[4] = 0; + bd_free_title_info(ti); + return STREAM_OK; } - while (count-- > 0) { - if (si->pid == req->id) { - memcpy(req->buf, si->lang, 4); - req->buf[4] = 0; - bd_free_title_info(ti); - return STREAM_OK; - } - si++; - } + si++; } - bd_free_title_info(ti); + if (ti) + bd_free_title_info(ti); return STREAM_ERROR; }