[vlc-commits] access: bluray: store stream selection in esout

Francois Cartegnie git at videolan.org
Wed Oct 17 20:39:22 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Oct 16 18:48:14 2018 +0200| [a07b8ba78525a20feecf006f8434516722a11d26] | committer: Francois Cartegnie

access: bluray: store stream selection in esout

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a07b8ba78525a20feecf006f8434516722a11d26
---

 modules/access/bluray.c | 63 ++++++++++++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 53d90aa9e3..6493d9f32a 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -191,10 +191,7 @@ typedef struct
 
     /* TS stream */
     es_out_t            *p_out;
-    int                 i_audio_stream_idx; /* Selected audio stream. -1 if default */
-    int                 i_spu_stream_idx;   /* Selected subtitle stream. -1 if default */
     bool                b_spu_enable;       /* enabled / disabled */
-    int                 i_video_stream;
     vlc_demux_chained_t *p_parser;
     bool                b_flushed;
     bool                b_pl_playing;       /* true when playing playlist */
@@ -749,9 +746,6 @@ static int blurayOpen(vlc_object_t *object)
     if (unlikely(!p_sys))
         return VLC_ENOMEM;
 
-    p_sys->i_audio_stream_idx = -1;
-    p_sys->i_spu_stream_idx = -1;
-    p_sys->i_video_stream = -1;
     p_sys->i_still_end_time = STILL_IMAGE_NOT_SET;
 
     /* init demux info fields */
@@ -1083,6 +1077,12 @@ typedef struct
     vlc_object_t *p_obj;
     vlc_array_t es; /* es_pair_t */
     void *priv;
+    struct
+    {
+        int i_audio_pid; /* Selected audio stream. -1 if default */
+        int i_video_pid;
+        int i_spu_pid;   /* Selected spu stream. -1 if default */
+    } selected;
     es_out_t es_out;
 } bluray_esout_priv_t;
 
@@ -1104,20 +1104,20 @@ static es_out_id_t *bluray_esOutAdd(es_out_t *p_out, const es_format_t *p_fmt)
 
     switch (fmt.i_cat) {
     case VIDEO_ES:
-        if (p_sys->i_video_stream != -1 && p_sys->i_video_stream != p_fmt->i_id)
+        if (esout_priv->selected.i_video_pid != -1 && esout_priv->selected.i_video_pid != p_fmt->i_id)
             fmt.i_priority = ES_PRIORITY_NOT_SELECTABLE;
         break ;
     case AUDIO_ES:
-        if (p_sys->i_audio_stream_idx != -1) {
-            if (blurayGetStreamPID(p_sys, BD_EVENT_AUDIO_STREAM, p_sys->i_audio_stream_idx) == p_fmt->i_id)
+        if (esout_priv->selected.i_audio_pid != -1) {
+            if (esout_priv->selected.i_audio_pid == p_fmt->i_id)
                 b_select = true;
             fmt.i_priority = ES_PRIORITY_NOT_SELECTABLE;
         }
         setStreamLang(p_sys, &fmt);
         break ;
     case SPU_ES:
-        if (p_sys->i_spu_stream_idx != -1) {
-            if (blurayGetStreamPID(p_sys, BD_EVENT_PG_TEXTST_STREAM, p_sys->i_spu_stream_idx) == p_fmt->i_id)
+        if (esout_priv->selected.i_spu_pid != -1) {
+            if (esout_priv->selected.i_spu_pid == p_fmt->i_id)
                 b_select = p_sys->b_spu_enable;
             fmt.i_priority = ES_PRIORITY_NOT_SELECTABLE;
         }
@@ -1184,9 +1184,24 @@ static int bluray_esOutControl(es_out_t *p_out, int i_query, va_list args)
         case BLURAY_ES_OUT_CONTROL_UNSET_ES_BY_PID:
         {
             bool b_select = (i_query == BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID);
-            es_pair_t *p_pair = getEsPairByPID(&esout_priv->es, va_arg(args, int));
+            const int i_bluray_stream_type = va_arg(args, int);
+            const int i_pid = va_arg(args, int);
+            switch(i_bluray_stream_type)
+            {
+                case BD_EVENT_AUDIO_STREAM:
+                    esout_priv->selected.i_audio_pid = i_pid;
+                    break;
+                case BD_EVENT_PG_TEXTST_STREAM:
+                    esout_priv->selected.i_spu_pid = i_pid;
+                    break;
+                default:
+                    break;
+            }
+
+            es_pair_t *p_pair = getEsPairByPID(&esout_priv->es, i_pid);
             if(unlikely(!p_pair))
                 return VLC_EGENERIC;
+
             return es_out_Control(esout_priv->p_dst_out,
                                   b_select ? ES_OUT_SET_ES : ES_OUT_UNSET_ES,
                                   p_pair->p_es);
@@ -1226,6 +1241,9 @@ static es_out_t *esOutNew(vlc_object_t *p_obj, es_out_t *p_dst_out, void *priv)
     esout_priv->p_obj = p_obj;
     esout_priv->priv = priv;
     esout_priv->es_out.cbs = &bluray_esOutCallbacks;
+    esout_priv->selected.i_audio_pid = -1;
+    esout_priv->selected.i_video_pid = -1;
+    esout_priv->selected.i_spu_pid = -1;
     return &esout_priv->es_out;
 }
 
@@ -1893,7 +1911,7 @@ static int bluraySetTitle(demux_t *p_demux, int i_title)
 #  define BLURAY_AUDIO_STREAM 0
 #endif
 
-static void blurayStreamSelected(demux_sys_t *p_sys, int i_pid)
+static void blurayOnUserStreamSelection(demux_sys_t *p_sys, int i_pid)
 {
     vlc_mutex_lock(&p_sys->pl_info_lock);
 
@@ -1902,7 +1920,6 @@ static void blurayStreamSelected(demux_sys_t *p_sys, int i_pid)
             // audio
             for (int i_id = 0; i_id < p_sys->p_clip_info->audio_stream_count; i_id++) {
                 if (i_pid == p_sys->p_clip_info->audio_streams[i_id].pid) {
-                    p_sys->i_audio_stream_idx = i_id;
                     bd_select_stream(p_sys->bluray, BLURAY_AUDIO_STREAM, i_id + 1, 1);
                     break;
                 }
@@ -1911,7 +1928,6 @@ static void blurayStreamSelected(demux_sys_t *p_sys, int i_pid)
             // subtitle
             for (int i_id = 0; i_id < p_sys->p_clip_info->pg_stream_count; i_id++) {
                 if (i_pid == p_sys->p_clip_info->pg_streams[i_id].pid) {
-                    p_sys->i_spu_stream_idx = i_id;
                     bd_select_stream(p_sys->bluray, BLURAY_PG_TEXTST_STREAM, i_id + 1, 1);
                     break;
                 }
@@ -1956,7 +1972,7 @@ static int blurayControl(demux_t *p_demux, int query, va_list args)
     case DEMUX_SET_ES:
     {
         int i_id = va_arg(args, int);
-        blurayStreamSelected(p_sys, i_id);
+        blurayOnUserStreamSelection(p_sys, i_id);
         break;
     }
     case DEMUX_SET_TITLE:
@@ -2327,7 +2343,7 @@ static void blurayStillImage( demux_t *p_demux, unsigned i_timeout )
     vlc_tick_sleep( VLC_TICK_FROM_MS(40) );
 }
 
-static void blurayStreamSelect(demux_t *p_demux, uint32_t i_type, uint32_t i_id)
+static void blurayOnStreamSelectedEvent(demux_t *p_demux, uint32_t i_type, uint32_t i_id)
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     int i_pid = -1;
@@ -2336,22 +2352,17 @@ static void blurayStreamSelect(demux_t *p_demux, uint32_t i_type, uint32_t i_id)
     i_id--;
 
     if (i_type == BD_EVENT_AUDIO_STREAM) {
-        p_sys->i_audio_stream_idx = i_id;
         i_pid = blurayGetStreamPID(p_sys, i_type, i_id);
     } else if (i_type == BD_EVENT_PG_TEXTST_STREAM) {
-        p_sys->i_spu_stream_idx = i_id;
         i_pid = blurayGetStreamPID(p_sys, i_type, i_id);
     }
 
     if (i_pid > 0)
     {
         if (i_type == BD_EVENT_PG_TEXTST_STREAM && !p_sys->b_spu_enable)
-            es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_UNSET_ES_BY_PID, i_pid);
+            es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_UNSET_ES_BY_PID, (int)i_type, i_pid);
         else
-        {
-            es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID, i_pid);
-            blurayStreamSelected(p_sys, i_pid);
-        }
+            es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID, (int)i_type, i_pid);
     }
 }
 
@@ -2385,7 +2396,6 @@ static void blurayUpdateCurrentClip(demux_t *p_demux, uint32_t clip)
     vlc_mutex_lock(&p_sys->pl_info_lock);
 
     p_sys->p_clip_info = NULL;
-    p_sys->i_video_stream = -1;
 
     if (p_sys->p_pl_info && clip < p_sys->p_pl_info->clip_count) {
 
@@ -2395,7 +2405,6 @@ static void blurayUpdateCurrentClip(demux_t *p_demux, uint32_t clip)
      * This may brake later, but it's enough for now.
      */
         assert(p_sys->p_clip_info->video_stream_count >= 1);
-        p_sys->i_video_stream = p_sys->p_clip_info->video_streams[0].pid;
     }
 
     vlc_mutex_unlock(&p_sys->pl_info_lock);
@@ -2482,7 +2491,7 @@ static void blurayHandleEvent(demux_t *p_demux, const BD_EVENT *e)
         break;
     case BD_EVENT_AUDIO_STREAM:
     case BD_EVENT_PG_TEXTST_STREAM:
-        blurayStreamSelect(p_demux, e->event, e->param);
+        blurayOnStreamSelectedEvent(p_demux, e->event, e->param);
         break;
     case BD_EVENT_IG_STREAM:
     case BD_EVENT_SECONDARY_AUDIO:



More information about the vlc-commits mailing list