[MPlayer-cvslog] r36433 - in trunk: mencoder.c mplayer.c stream/stream.h stream/stream_bluray.c

reimar subversion at mplayerhq.hu
Sun Aug 25 19:57:25 CEST 2013


Author: reimar
Date: Sun Aug 25 19:57:25 2013
New Revision: 36433

Log:
Support -alang and -slang for bluray://

Modified:
   trunk/mencoder.c
   trunk/mplayer.c
   trunk/stream/stream.h
   trunk/stream/stream_bluray.c

Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c	Sun Aug 25 19:23:22 2013	(r36432)
+++ trunk/mencoder.c	Sun Aug 25 19:57:25 2013	(r36433)
@@ -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);

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sun Aug 25 19:23:22 2013	(r36432)
+++ trunk/mplayer.c	Sun Aug 25 19:57:25 2013	(r36433)
@@ -3312,6 +3312,15 @@ play_next_file:
             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";

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	Sun Aug 25 19:23:22 2013	(r36432)
+++ trunk/stream/stream.h	Sun Aug 25 19:57:25 2013	(r36433)
@@ -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 */

Modified: trunk/stream/stream_bluray.c
==============================================================================
--- trunk/stream/stream_bluray.c	Sun Aug 25 19:23:22 2013	(r36432)
+++ trunk/stream/stream_bluray.c	Sun Aug 25 19:57:25 2013	(r36433)
@@ -105,6 +105,48 @@ static int bluray_stream_fill_buffer(str
     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 @@ static int bluray_stream_control(stream_
 
     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;
     }
 


More information about the MPlayer-cvslog mailing list