Commit a1ded9a8 authored by Denis Charmet's avatar Denis Charmet Committed by Jean-Baptiste Kempf

Preload local directory for mkv only when needed

The option is now default enabled to be as simple as possible for the end users.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 25fc1243
......@@ -76,6 +76,7 @@ matroska_segment_c::matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estr
,sys(demuxer)
,ep(NULL)
,b_preloaded(false)
,b_ref_external_segments(false)
{
p_indexes = (mkv_index_t*)malloc( sizeof( mkv_index_t ) * i_index_max );
}
......
......@@ -97,6 +97,7 @@ public:
demux_sys_t & sys;
EbmlParser *ep;
bool b_preloaded;
bool b_ref_external_segments;
bool Preload();
bool PreloadFamily( const matroska_segment_c & segment );
......
......@@ -710,14 +710,20 @@ void matroska_segment_c::ParseInfo( KaxInfo *info )
else if( MKV_IS_ID( l, KaxPrevUID ) )
{
if ( p_prev_segment_uid == NULL )
{
p_prev_segment_uid = new KaxPrevUID(*static_cast<KaxPrevUID*>(l));
b_ref_external_segments = true;
}
msg_Dbg( &sys.demuxer, "| | + PrevUID=%d", *(uint32*)p_prev_segment_uid->GetBuffer() );
}
else if( MKV_IS_ID( l, KaxNextUID ) )
{
if ( p_next_segment_uid == NULL )
{
p_next_segment_uid = new KaxNextUID(*static_cast<KaxNextUID*>(l));
b_ref_external_segments = true;
}
msg_Dbg( &sys.demuxer, "| | + NextUID=%d", *(uint32*)p_next_segment_uid->GetBuffer() );
}
......@@ -860,6 +866,7 @@ void matroska_segment_c::ParseChapterAtom( int i_level, KaxChapterAtom *ca, chap
else if( MKV_IS_ID( l, KaxChapterSegmentUID ) )
{
chapters.p_segment_uid = new KaxChapterSegmentUID( *static_cast<KaxChapterSegmentUID*>(l) );
b_ref_external_segments = true;
msg_Dbg( &sys.demuxer, "| | | | + ChapterSegmentUID= %u", *(uint32*)chapters.p_segment_uid->GetBuffer() );
}
else if( MKV_IS_ID( l, KaxChapterSegmentEditionUID ) )
......
......@@ -58,7 +58,7 @@ vlc_module_begin ()
N_("Chapter codecs"),
N_("Use chapter codecs found in the segment."), true );
add_bool( "mkv-preload-local-dir", false,
add_bool( "mkv-preload-local-dir", true,
N_("Preload MKV files in the same directory"),
N_("Preload matroska files in the same directory to find linked segments (not good for broken files)."), false );
......@@ -92,6 +92,7 @@ static int Open( vlc_object_t * p_this )
std::string s_path, s_filename;
vlc_stream_io_callback *p_io_callback;
EbmlStream *p_io_stream;
bool b_need_preload = false;
/* peek the begining */
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
......@@ -130,6 +131,7 @@ static int Open( vlc_object_t * p_this )
for (size_t i=0; i<p_stream->segments.size(); i++)
{
p_stream->segments[i]->Preload();
b_need_preload |= p_stream->segments[i]->b_ref_external_segments;
}
p_segment = p_stream->segments[0];
......@@ -139,8 +141,9 @@ static int Open( vlc_object_t * p_this )
goto error;
}
if (var_InheritBool( p_demux, "mkv-preload-local-dir" ))
if (b_need_preload && var_InheritBool( p_demux, "mkv-preload-local-dir" ))
{
msg_Dbg( p_demux, "Preloading local dir" );
/* get the files from the same dir from the same family (based on p_demux->psz_path) */
if ( p_demux->psz_file && !strcmp( p_demux->psz_access, "file" ) )
{
......@@ -233,6 +236,8 @@ static int Open( vlc_object_t * p_this )
p_sys->PreloadFamily( *p_segment );
}
else if (b_need_preload)
msg_Warn( p_demux, "This file references other files, you may want to enable the preload of local directory");
if ( !p_sys->PreloadLinked() ||
!p_sys->PreparePlayback( NULL ) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment