]> git.sesse.net Git - vlc/commitdiff
Select subtitle stream from the mkv container automatically
authorBernie Purcell <bitmap@videolan.org>
Mon, 10 Sep 2007 01:53:28 +0000 (01:53 +0000)
committerBernie Purcell <bitmap@videolan.org>
Mon, 10 Sep 2007 01:53:28 +0000 (01:53 +0000)
if it has a DEFAULT flag on it. User overrides for
preferred language should continue to take precedence.
The current versions of MKVToolnix correctly support DEFAULT
track tag but some older versions don't. If you want to have
subtitle streams in your mkv file, but not have them activate
by default, try remuxing any files causing you trouble, with
the current version of MKVToolnix, and turning the DEFAULT
track flag option to NO for all subtitles streams.
MKVToolnix is available from http://www.bunkus.org/videotools/mkvtoolnix/

include/vlc_es_out.h
modules/demux/mkv.cpp
src/input/es_out.c

index 048a9542c92d08d0f19d7fcfb9fc90dc3367deb0..f5b2351ea14bd6dbd15e7809e5aad33c6b34a85d 100644 (file)
@@ -55,6 +55,9 @@ enum es_out_query_e
     /* set es selected for the es category(audio/video/spu) */
     ES_OUT_SET_ES,      /* arg1= es_out_id_t*                   */
 
+    /* set 'default' tag on es (copied across from container) */
+    ES_OUT_SET_DEFAULT, /* arg1= es_out_id_t*                   */
+
     /* force selection/unselection of the ES (bypass current mode)*/
     ES_OUT_SET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t   */
     ES_OUT_GET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t*  */
index 891701707a291d2ad21cb44d06beba8f5104cbdc..520240fc81fccba87ccfbbab4adfed041568eecb 100644 (file)
@@ -2619,6 +2619,18 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
 
         tracks[i_track]->p_es = es_out_Add( sys.demuxer.out, &tracks[i_track]->fmt );
 
+        /* Turn on a subtitles track if it has been flagged as default -
+         * but only do this if no subtitles track has already been engaged,
+         * either by an earlier 'default track' (??) or by default
+         * language choice behaviour.
+         */
+        if( tracks[i_track]->b_default )
+        {
+            es_out_Control( sys.demuxer.out,
+                            ES_OUT_SET_DEFAULT,
+                            tracks[i_track]->p_es );
+        }
+
         es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, tracks[i_track]->p_es, i_start_time );
     }
     
index 1f3271df6e1705a35eca966a56348dbd5d8c8681..de0c550c5703344f65eb5564e2ee1c0da23145af 100644 (file)
@@ -108,6 +108,7 @@ struct es_out_sys_t
     /* es to select */
     int         i_audio_last, i_audio_id;
     int         i_sub_last, i_sub_id;
+    int         i_default_sub_id;   /* As specified in container; if applicable */
     char        **ppsz_audio_language;
     char        **ppsz_sub_language;
 
@@ -179,6 +180,8 @@ es_out_t *input_EsOutNew( input_thread_t *p_input )
     var_Get( p_input, "sub-track", &val );
     p_sys->i_sub_last = val.i_int;
 
+    p_sys->i_default_sub_id   = -1;
+
     if( !p_input->b_preparsing )
     {
         var_Get( p_input, "audio-language", &val );
@@ -1128,6 +1131,12 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force )
 
                 i_wanted  = es->i_channel;
             }
+            else if( p_sys->i_default_sub_id >= 0 )
+            {
+                if( es->i_id == p_sys->i_default_sub_id )
+                    i_wanted = es->i_channel;
+            }
+
             if( p_sys->i_sub_last >= 0 )
                 i_wanted  = p_sys->i_sub_last;
 
@@ -1491,6 +1500,42 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
                 pl_Release( p_playlist );
             }
             return VLC_SUCCESS;
+            
+        case ES_OUT_SET_DEFAULT:
+        {
+            es = (es_out_id_t*) va_arg( args, es_out_id_t * );
+
+            if( es == NULL )
+            {
+                /*p_sys->i_default_video_id = -1;*/
+                /*p_sys->i_default_audio_id = -1;*/
+                p_sys->i_default_sub_id = -1;
+            }
+            else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )
+            {
+                /*p_sys->i_default_video_id = -1;*/
+            }
+            else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
+            {
+                /*p_sys->i_default_audio_id = -1;*/
+            }
+            else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
+            {
+                p_sys->i_default_sub_id = -1;
+            }
+            else
+            {
+                /*if( es->fmt.i_cat == VIDEO_ES )
+                    p_sys->i_default_video_id = es->i_id;
+                else
+                if( es->fmt.i_cat == AUDIO_ES )
+                    p_sys->i_default_audio_id = es->i_id;
+                else*/
+                if( es->fmt.i_cat == SPU_ES )
+                    p_sys->i_default_sub_id = es->i_id;
+            }
+            return VLC_SUCCESS;
+        }
 
         case ES_OUT_SET_PCR:
         case ES_OUT_SET_GROUP_PCR: