]> git.sesse.net Git - vlc/blobdiff - modules/demux/mkv/mkv.cpp
Matroska demux: use var_Inherit
[vlc] / modules / demux / mkv / mkv.cpp
index ae7329afba0590c2624a01577be99f21d203c6b9..b17fbfb5e1c962c7ff9ed0bc2c91a618f404f0b3 100644 (file)
@@ -42,28 +42,28 @@ static void Close( vlc_object_t * );
 vlc_module_begin ()
     set_shortname( "Matroska" )
     set_description( N_("Matroska stream demuxer" ) )
-    set_capability( "demux", 0 )
+    set_capability( "demux", 50 )
     set_callbacks( Open, Close )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_DEMUX )
 
-    add_bool( "mkv-use-ordered-chapters", 1, NULL,
+    add_bool( "mkv-use-ordered-chapters", true, NULL,
             N_("Ordered chapters"),
             N_("Play ordered chapters as specified in the segment."), true );
 
-    add_bool( "mkv-use-chapter-codec", 1, NULL,
+    add_bool( "mkv-use-chapter-codec", true, NULL,
             N_("Chapter codecs"),
             N_("Use chapter codecs found in the segment."), true );
 
-    add_bool( "mkv-preload-local-dir", 1, NULL,
+    add_bool( "mkv-preload-local-dir", false, NULL,
             N_("Preload Directory"),
             N_("Preload matroska files from the same family in the same directory (not good for broken files)."), true );
 
-    add_bool( "mkv-seek-percent", 0, NULL,
+    add_bool( "mkv-seek-percent", false, NULL,
             N_("Seek based on percent not time"),
             N_("Seek based on percent not time."), true );
 
-    add_bool( "mkv-use-dummy", 0, NULL,
+    add_bool( "mkv-use-dummy", false, NULL,
             N_("Dummy Elements"),
             N_("Read and discard unknown EBML elements (not good for broken files)."), true );
 
@@ -137,7 +137,7 @@ static int Open( vlc_object_t * p_this )
         goto error;
     }
 
-    if (config_GetInt( p_demux, "mkv-preload-local-dir" ))
+    if (var_InheritInteger( p_demux, "mkv-preload-local-dir" ))
     {
         /* get the files from the same dir from the same family (based on p_demux->psz_path) */
         if (p_demux->psz_path[0] != '\0' && !strcmp(p_demux->psz_access, ""))
@@ -145,15 +145,15 @@ static int Open( vlc_object_t * p_this )
             // assume it's a regular file
             // get the directory path
             s_path = p_demux->psz_path;
-            if (s_path.at(s_path.length() - 1) == DIRECTORY_SEPARATOR)
+            if (s_path.at(s_path.length() - 1) == DIR_SEP_CHAR)
             {
                 s_path = s_path.substr(0,s_path.length()-1);
             }
             else
             {
-                if (s_path.find_last_of(DIRECTORY_SEPARATOR) > 0)
+                if (s_path.find_last_of(DIR_SEP_CHAR) > 0)
                 {
-                    s_path = s_path.substr(0,s_path.find_last_of(DIRECTORY_SEPARATOR));
+                    s_path = s_path.substr(0,s_path.find_last_of(DIR_SEP_CHAR));
                 }
             }
 
@@ -166,7 +166,7 @@ static int Open( vlc_object_t * p_this )
                 {
                     if (strlen(psz_file) > 4)
                     {
-                        s_filename = s_path + DIRECTORY_SEPARATOR + psz_file;
+                        s_filename = s_path + DIR_SEP_CHAR + psz_file;
 
 #ifdef WIN32
                         if (!strcasecmp(s_filename.c_str(), p_demux->psz_path))
@@ -278,7 +278,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     vlc_meta_t *p_meta;
     input_attachment_t ***ppp_attach;
     int *pi_int;
-    int i;
 
     switch( i_query )
     {
@@ -294,7 +293,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                                                         p_sys->stored_attachments.size() );
             if( !(*ppp_attach) )
                 return VLC_ENOMEM;
-            for( i = 0; i < p_sys->stored_attachments.size(); i++ )
+            for( size_t i = 0; i < p_sys->stored_attachments.size(); i++ )
             {
                 attachment_c *a = p_sys->stored_attachments[i];
                 (*ppp_attach)[i] = vlc_input_attachment_New( a->psz_file_name.c_str(), a->psz_mime_type.c_str(), NULL,
@@ -420,7 +419,7 @@ static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, chapter_it
     }
 
     /* seek without index or without date */
-    if( f_percent >= 0 && (config_GetInt( p_demux, "mkv-seek-percent" ) || !p_segment->b_cues || i_date < 0 ))
+    if( f_percent >= 0 && (var_InheritInteger( p_demux, "mkv-seek-percent" ) || !p_segment->b_cues || i_date < 0 ))
     {
         if( p_sys->f_duration >= 0 && p_segment->b_cues )
         {
@@ -579,10 +578,9 @@ static void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simp
         }
         else
         {
-            if( !strcmp( tk->psz_codec, "V_MS/VFW/FOURCC" ) )
+            if( tk->b_dts_only )
             {
-                // in VFW we have no idea about B frames
-                p_block->i_pts = 0;
+                p_block->i_pts = VLC_TS_INVALID;
                 p_block->i_dts = i_pts;
             }
             else
@@ -605,10 +603,16 @@ msg_Dbg( p_demux, "block i_dts: %"PRId64" / i_pts: %"PRId64, p_block->i_dts, p_b
             p_block->i_length = i_duration * 1000;
         }
 
+        /* FIXME remove when VLC_TS_INVALID work is done */
+        if( i == 0 || p_block->i_dts > VLC_TS_INVALID )
+            p_block->i_dts += VLC_TS_0;
+        if( !tk->b_dts_only && ( i == 0 || p_block->i_pts > VLC_TS_INVALID ) )
+            p_block->i_pts += VLC_TS_0;
+
         es_out_Send( p_demux->out, tk->p_es, p_block );
 
         /* use time stamp only for first block */
-        i_pts = 0;
+        i_pts = VLC_TS_INVALID;
     }
 }
 
@@ -861,7 +865,8 @@ static int Demux( demux_t *p_demux)
         else
             p_sys->i_pts = (p_sys->i_chapter_time + block->GlobalTimecode()) / (mtime_t) 1000;
 
-        es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_pts );
+        /* */
+        es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_pts );
 
         if( p_sys->i_pts >= p_sys->i_start_pts  )
         {