Skip to content

Commit

Permalink
Support -alang and -slang for bluray://
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36433 b3059339-0415-0410-9bf9-f77b7e298cf2
  • Loading branch information
reimar committed Aug 25, 2013
1 parent 0a6b4dd commit df67c12
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 23 deletions.
7 changes: 7 additions & 0 deletions mencoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,13 @@ if(stream->type==STREAMTYPE_BD){
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);
Expand Down
9 changes: 9 additions & 0 deletions mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3312,6 +3312,15 @@ int main(int argc, char *argv[])
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";
Expand Down
2 changes: 2 additions & 0 deletions stream/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ typedef struct {
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 */
77 changes: 54 additions & 23 deletions stream/stream_bluray.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,48 @@ static int bluray_stream_fill_buffer(stream_t *s, char *buf, int len)
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;
Expand Down Expand Up @@ -196,31 +238,20 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)

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;
}
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++;
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;
}
si++;
}
bd_free_title_info(ti);
if (ti)
bd_free_title_info(ti);
return STREAM_ERROR;
}

Expand Down

0 comments on commit df67c12

Please sign in to comment.