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

MKV: Handle multi-editions as different titles

Close #7401
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 720f0f1b
...@@ -653,18 +653,19 @@ bool demux_sys_t::PreloadLinked() ...@@ -653,18 +653,19 @@ bool demux_sys_t::PreloadLinked()
p_seg = used_segments[i]; p_seg = used_segments[i];
if ( p_seg->Editions() != NULL ) if ( p_seg->Editions() != NULL )
{ {
input_title_t *p_title = vlc_input_title_New();
p_seg->i_sys_title = i;
int i_chapters;
// TODO use a name for each edition, let the TITLE deal with a codec name
for ( j=0; j<p_seg->Editions()->size(); j++ ) for ( j=0; j<p_seg->Editions()->size(); j++ )
{ {
input_title_t *p_title = vlc_input_title_New();
int i_chapters;
// TODO use a name for each edition, let the TITLE deal with a codec name
if ( p_title->psz_name == NULL ) if ( p_title->psz_name == NULL )
{ {
const char* psz_tmp = (*p_seg->Editions())[j]->GetMainName().c_str(); const char* psz_tmp = (*p_seg->Editions())[j]->GetMainName().c_str();
if( *psz_tmp != '\0' ) if( *psz_tmp != '\0' )
p_title->psz_name = strdup( psz_tmp ); p_title->psz_name = strdup( psz_tmp );
else if( asprintf(&(p_title->psz_name), "%s %d", N_("Segment"), (int)i) == -1 )
p_title->psz_name = NULL;
} }
i_chapters = 0; i_chapters = 0;
...@@ -672,17 +673,11 @@ bool demux_sys_t::PreloadLinked() ...@@ -672,17 +673,11 @@ bool demux_sys_t::PreloadLinked()
// Input duration into i_length // Input duration into i_length
p_title->i_length = ( *p_seg->Editions() )[j]->i_duration; p_title->i_length = ( *p_seg->Editions() )[j]->i_duration;
}
// create a name if there is none titles.push_back( p_title );
if ( p_title->psz_name == NULL )
{
if( asprintf(&(p_title->psz_name), "%s %d", N_("Segment"), (int)i) == -1 )
p_title->psz_name = NULL;
} }
titles.push_back( p_title );
} }
p_seg->i_sys_title = p_seg->i_current_edition;
} }
// TODO decide which segment should be first used (VMG for DVD) // TODO decide which segment should be first used (VMG for DVD)
...@@ -719,6 +714,10 @@ bool demux_sys_t::PreparePlayback( virtual_segment_c *p_new_segment ) ...@@ -719,6 +714,10 @@ bool demux_sys_t::PreparePlayback( virtual_segment_c *p_new_segment )
p_current_segment->CurrentSegment()->InformationCreate( ); p_current_segment->CurrentSegment()->InformationCreate( );
p_current_segment->CurrentSegment()->Select( 0 ); p_current_segment->CurrentSegment()->Select( 0 );
/* Seek to the beginning */
p_current_segment->Seek(p_current_segment->CurrentSegment()->sys.demuxer,
0, 0, NULL, -1);
return true; return true;
} }
......
...@@ -355,19 +355,23 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -355,19 +355,23 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
*ppp_title = (input_title_t**)malloc( sizeof( input_title_t**) * p_sys->titles.size() ); *ppp_title = (input_title_t**)malloc( sizeof( input_title_t**) * p_sys->titles.size() );
for( size_t i = 0; i < p_sys->titles.size(); i++ ) for( size_t i = 0; i < p_sys->titles.size(); i++ )
{
(*ppp_title)[i] = vlc_input_title_Duplicate( p_sys->titles[i] ); (*ppp_title)[i] = vlc_input_title_Duplicate( p_sys->titles[i] );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
return VLC_EGENERIC; return VLC_EGENERIC;
case DEMUX_SET_TITLE: case DEMUX_SET_TITLE:
/* TODO handle editions as titles */ /* handle editions as titles */
i_idx = (int)va_arg( args, int ); i_idx = (int)va_arg( args, int );
if( i_idx < p_sys->used_segments.size() ) if(i_idx < p_sys->titles.size() && p_sys->titles[i_idx]->i_seekpoint)
{ {
p_sys->JumpTo( *p_sys->used_segments[i_idx], NULL ); p_sys->p_current_segment->i_current_edition = i_idx;
p_sys->i_current_title = i_idx;
p_sys->p_current_segment->p_current_chapter = p_sys->p_current_segment->editions[p_sys->p_current_segment->i_current_edition]->getChapterbyTimecode(0);
Seek( p_demux, (int64_t)p_sys->titles[i_idx]->seekpoint[0]->i_time_offset, -1, NULL);
p_demux->info.i_seekpoint |= INPUT_UPDATE_SEEKPOINT;
p_demux->info.i_seekpoint = 0;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
return VLC_EGENERIC; return VLC_EGENERIC;
......
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