1 /*****************************************************************************
2 * mkv.cpp : matroska demuxer
3 *****************************************************************************
4 * Copyright (C) 2003-2004 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Steve Lhomme <steve.lhomme@free.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #include "chapter_command.hpp"
28 void chapter_codec_cmds_c::AddCommand( const KaxChapterProcessCommand & command )
32 uint32 codec_time = uint32(-1);
33 for( i = 0; i < command.ListSize(); i++ )
35 const EbmlElement *k = command[i];
37 if( MKV_IS_ID( k, KaxChapterProcessTime ) )
39 codec_time = uint32( *static_cast<const KaxChapterProcessTime*>( k ) );
44 for( i = 0; i < command.ListSize(); i++ )
46 const EbmlElement *k = command[i];
48 if( MKV_IS_ID( k, KaxChapterProcessData ) )
50 KaxChapterProcessData *p_data = new KaxChapterProcessData( *static_cast<const KaxChapterProcessData*>( k ) );
54 during_cmds.push_back( p_data );
57 enter_cmds.push_back( p_data );
60 leave_cmds.push_back( p_data );
69 int16 dvd_chapter_codec_c::GetTitleNumber()
71 if ( p_private_data->GetSize() >= 3)
73 const binary* p_data = p_private_data->GetBuffer();
74 if ( p_data[0] == MATROSKA_DVD_LEVEL_SS )
76 return int16( (p_data[2] << 8) + p_data[3] );
82 bool dvd_chapter_codec_c::Enter()
84 bool f_result = false;
85 std::vector<KaxChapterProcessData*>::iterator index = enter_cmds.begin();
86 while ( index != enter_cmds.end() )
88 if ( (*index)->GetSize() )
90 binary *p_data = (*index)->GetBuffer();
91 size_t i_size = *p_data++;
92 // avoid reading too much from the buffer
93 i_size = __MIN( i_size, ((*index)->GetSize() - 1) >> 3 );
94 for ( ; i_size > 0; i_size--, p_data += 8 )
96 msg_Dbg( &sys.demuxer, "Matroska DVD enter command" );
97 f_result |= sys.dvd_interpretor.Interpret( p_data );
105 bool dvd_chapter_codec_c::Leave()
107 bool f_result = false;
108 std::vector<KaxChapterProcessData*>::iterator index = leave_cmds.begin();
109 while ( index != leave_cmds.end() )
111 if ( (*index)->GetSize() )
113 binary *p_data = (*index)->GetBuffer();
114 size_t i_size = *p_data++;
115 // avoid reading too much from the buffer
116 i_size = __MIN( i_size, ((*index)->GetSize() - 1) >> 3 );
117 for ( ; i_size > 0; i_size--, p_data += 8 )
119 msg_Dbg( &sys.demuxer, "Matroska DVD leave command" );
120 f_result |= sys.dvd_interpretor.Interpret( p_data );
128 std::string dvd_chapter_codec_c::GetCodecName( bool f_for_title ) const
131 if ( p_private_data->GetSize() >= 3)
133 const binary* p_data = p_private_data->GetBuffer();
134 /* if ( p_data[0] == MATROSKA_DVD_LEVEL_TT )
136 uint16_t i_title = (p_data[1] << 8) + p_data[2];
138 sprintf( psz_str, " %d ---", i_title );
139 result = N_("--- DVD Title");
142 else */ if ( p_data[0] == MATROSKA_DVD_LEVEL_LU )
145 sprintf( psz_str, " (%c%c) ---", p_data[1], p_data[2] );
146 result = N_("--- DVD Menu");
149 else if ( p_data[0] == MATROSKA_DVD_LEVEL_SS && f_for_title )
151 if ( p_data[1] == 0x00 )
152 result = N_("First Played");
153 else if ( p_data[1] == 0xC0 )
154 result = N_("Video Manager");
155 else if ( p_data[1] == 0x80 )
157 uint16_t i_title = (p_data[2] << 8) + p_data[3];
159 sprintf( psz_str, " %d -----", i_title );
160 result = N_("----- Title");
168 class virtual_segment_c;
169 class chapter_item_c;
171 // see http://www.dvd-replica.com/DVD/vmcmdset.php for a description of DVD commands
172 bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_size )
177 virtual_segment_c *p_segment = NULL;
178 chapter_item_c *p_chapter = NULL;
179 bool f_result = false;
180 uint16 i_command = ( p_command[0] << 8 ) + p_command[1];
182 // handle register tests if there are some
183 if ( (i_command & 0xF0) != 0 )
185 bool b_test_positive = true;//(i_command & CMD_DVD_IF_NOT) == 0;
186 bool b_test_value = (i_command & CMD_DVD_TEST_VALUE) != 0;
187 uint8 i_test = i_command & 0x70;
190 // see http://dvd.sourceforge.net/dvdinfo/vmi.html
193 switch ( i_command >> 12 )
196 i_cr1 = p_command[3];
197 i_cr2 = (p_command[4] << 8) + p_command[5];
202 i_cr1 = p_command[6];
203 i_cr2 = p_command[7];
204 b_test_value = false;
208 if ( ((p_command[1] >> 4) & 0x7) == 0)
210 i_cr1 = p_command[2];
211 i_cr2 = (p_command[6] << 8) + p_command[7];
215 i_cr1 = p_command[2];
216 i_cr2 = (p_command[6] << 8) + p_command[7];
224 i_value = GetPRM( i_cr2 );
228 case CMD_DVD_IF_GPREG_EQUAL:
230 msg_Dbg( &sys.demuxer, "IF %s EQUALS %s", GetRegTypeName( false, i_cr1 ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
231 if (!( GetPRM( i_cr1 ) == i_value ))
233 b_test_positive = false;
236 case CMD_DVD_IF_GPREG_NOT_EQUAL:
238 msg_Dbg( &sys.demuxer, "IF %s NOT EQUALS %s", GetRegTypeName( false, i_cr1 ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
239 if (!( GetPRM( i_cr1 ) != i_value ))
241 b_test_positive = false;
244 case CMD_DVD_IF_GPREG_INF:
246 msg_Dbg( &sys.demuxer, "IF %s < %s", GetRegTypeName( false, p_command[3] ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
247 if (!( GetPRM( i_cr1 ) < i_value ))
249 b_test_positive = false;
252 case CMD_DVD_IF_GPREG_INF_EQUAL:
253 // if inferior or equal
254 msg_Dbg( &sys.demuxer, "IF %s < %s", GetRegTypeName( false, p_command[3] ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
255 if (!( GetPRM( i_cr1 ) <= i_value ))
257 b_test_positive = false;
260 case CMD_DVD_IF_GPREG_AND:
262 msg_Dbg( &sys.demuxer, "IF %s & %s", GetRegTypeName( false, p_command[3] ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
263 if (!( GetPRM( i_cr1 ) & i_value ))
265 b_test_positive = false;
268 case CMD_DVD_IF_GPREG_SUP:
270 msg_Dbg( &sys.demuxer, "IF %s >= %s", GetRegTypeName( false, p_command[3] ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
271 if (!( GetPRM( i_cr1 ) > i_value ))
273 b_test_positive = false;
276 case CMD_DVD_IF_GPREG_SUP_EQUAL:
277 // if superior or equal
278 msg_Dbg( &sys.demuxer, "IF %s >= %s", GetRegTypeName( false, p_command[3] ).c_str(), GetRegTypeName( b_test_value, i_value ).c_str() );
279 if (!( GetPRM( i_cr1 ) >= i_value ))
281 b_test_positive = false;
286 if ( !b_test_positive )
290 // strip the test command
298 msg_Dbg( &sys.demuxer, "NOP" );
303 msg_Dbg( &sys.demuxer, "Break" );
307 case CMD_DVD_JUMP_TT:
309 uint8 i_title = p_command[5];
310 msg_Dbg( &sys.demuxer, "JumpTT %d", i_title );
312 // find in the ChapProcessPrivate matching this Title level
313 p_chapter = sys.BrowseCodecPrivate( 1, MatchTitleNumber, &i_title, sizeof(i_title), p_segment );
314 if ( p_segment != NULL )
316 sys.JumpTo( *p_segment, p_chapter );
322 case CMD_DVD_CALLSS_VTSM1:
324 msg_Dbg( &sys.demuxer, "CallSS" );
326 switch( (p_command[6] & 0xC0) >> 6 ) {
328 p_type = p_command[5] & 0x0F;
332 msg_Dbg( &sys.demuxer, "CallSS PGC (rsm_cell %x)", p_command[4]);
335 msg_Dbg( &sys.demuxer, "CallSS Title Entry (rsm_cell %x)", p_command[4]);
338 msg_Dbg( &sys.demuxer, "CallSS Root Menu (rsm_cell %x)", p_command[4]);
341 msg_Dbg( &sys.demuxer, "CallSS Subpicture Menu (rsm_cell %x)", p_command[4]);
344 msg_Dbg( &sys.demuxer, "CallSS Audio Menu (rsm_cell %x)", p_command[4]);
347 msg_Dbg( &sys.demuxer, "CallSS Angle Menu (rsm_cell %x)", p_command[4]);
350 msg_Dbg( &sys.demuxer, "CallSS Chapter Menu (rsm_cell %x)", p_command[4]);
353 msg_Dbg( &sys.demuxer, "CallSS <unknown> (rsm_cell %x)", p_command[4]);
356 p_chapter = sys.BrowseCodecPrivate( 1, MatchPgcType, &p_type, 1, p_segment );
357 if ( p_segment != NULL )
359 sys.JumpTo( *p_segment, p_chapter );
364 msg_Dbg( &sys.demuxer, "CallSS VMGM (menu %d, rsm_cell %x)", p_command[5] & 0x0F, p_command[4]);
367 msg_Dbg( &sys.demuxer, "CallSS VTSM (menu %d, rsm_cell %x)", p_command[5] & 0x0F, p_command[4]);
370 msg_Dbg( &sys.demuxer, "CallSS VMGM (pgc %d, rsm_cell %x)", (p_command[2] << 8) + p_command[3], p_command[4]);
375 case CMD_DVD_JUMP_SS:
377 msg_Dbg( &sys.demuxer, "JumpSS");
379 switch( (p_command[5] & 0xC0) >> 6 ) {
381 msg_Dbg( &sys.demuxer, "JumpSS FP");
384 p_type = p_command[5] & 0x0F;
388 msg_Dbg( &sys.demuxer, "JumpSS VMGM Title Entry");
391 msg_Dbg( &sys.demuxer, "JumpSS VMGM Root Menu");
394 msg_Dbg( &sys.demuxer, "JumpSS VMGM Subpicture Menu");
397 msg_Dbg( &sys.demuxer, "JumpSS VMGM Audio Menu");
400 msg_Dbg( &sys.demuxer, "JumpSS VMGM Angle Menu");
403 msg_Dbg( &sys.demuxer, "JumpSS VMGM Chapter Menu");
406 msg_Dbg( &sys.demuxer, "JumpSS <unknown>");
410 p_chapter = sys.BrowseCodecPrivate( 1, MatchIsVMG, NULL, 0, p_segment );
411 if ( p_segment != NULL )
413 p_chapter = p_segment->BrowseCodecPrivate( 1, MatchPgcType, &p_type, 1 );
414 if ( p_chapter != NULL )
416 sys.JumpTo( *p_segment, p_chapter );
422 p_type = p_command[5] & 0x0F;
426 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) Title Entry", p_command[4], p_command[3]);
429 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) Root Menu", p_command[4], p_command[3]);
432 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) Subpicture Menu", p_command[4], p_command[3]);
435 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) Audio Menu", p_command[4], p_command[3]);
438 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) Angle Menu", p_command[4], p_command[3]);
441 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) Chapter Menu", p_command[4], p_command[3]);
444 msg_Dbg( &sys.demuxer, "JumpSS VTSM (vts %d, ttn %d) <unknown>", p_command[4], p_command[3]);
448 p_chapter = sys.BrowseCodecPrivate( 1, MatchVTSMNumber, &p_command[4], 1, p_segment );
450 if ( p_segment != NULL && p_chapter != NULL )
452 // find the title in the VTS
453 p_chapter = p_chapter->BrowseCodecPrivate( 1, MatchTitleNumber, &p_command[3], 1 );
454 if ( p_chapter != NULL )
456 // find the specified menu in the VTSM
457 p_chapter = p_segment->BrowseCodecPrivate( 1, MatchPgcType, &p_type, 1 );
458 if ( p_chapter != NULL )
460 sys.JumpTo( *p_segment, p_chapter );
465 msg_Dbg( &sys.demuxer, "Title (%d) does not exist in this VTS", p_command[3] );
468 msg_Dbg( &sys.demuxer, "DVD Domain VTS (%d) not found", p_command[4] );
471 msg_Dbg( &sys.demuxer, "JumpSS VMGM (pgc %d)", (p_command[2] << 8) + p_command[3]);
476 case CMD_DVD_JUMPVTS_PTT:
478 uint8 i_title = p_command[5];
479 uint8 i_ptt = p_command[3];
481 msg_Dbg( &sys.demuxer, "JumpVTS Title (%d) PTT (%d)", i_title, i_ptt);
483 // find the current VTS content segment
484 p_chapter = sys.p_current_segment->BrowseCodecPrivate( 1, MatchIsDomain, NULL, 0 );
485 if ( p_chapter != NULL )
487 int16 i_curr_title = p_chapter->GetTitleNumber( );
488 if ( i_curr_title > 0 )
490 p_chapter = sys.BrowseCodecPrivate( 1, MatchVTSNumber, &i_curr_title, sizeof(i_curr_title), p_segment );
492 if ( p_segment != NULL && p_chapter != NULL )
494 // find the title in the VTS
495 p_chapter = p_chapter->BrowseCodecPrivate( 1, MatchTitleNumber, &i_title, sizeof(i_title) );
496 if ( p_chapter != NULL )
498 // find the chapter in the title
499 p_chapter = p_chapter->BrowseCodecPrivate( 1, MatchChapterNumber, &i_ptt, sizeof(i_ptt) );
500 if ( p_chapter != NULL )
502 sys.JumpTo( *p_segment, p_chapter );
507 msg_Dbg( &sys.demuxer, "Title (%d) does not exist in this VTS", i_title );
510 msg_Dbg( &sys.demuxer, "DVD Domain VTS (%d) not found", i_curr_title );
513 msg_Dbg( &sys.demuxer, "JumpVTS_PTT command found but not in a VTS(M)");
516 msg_Dbg( &sys.demuxer, "JumpVTS_PTT command but the DVD domain wasn't found");
519 case CMD_DVD_SET_GPRMMD:
521 msg_Dbg( &sys.demuxer, "Set GPRMMD [%d]=%d", (p_command[4] << 8) + p_command[5], (p_command[2] << 8) + p_command[3]);
523 if ( !SetGPRM( (p_command[4] << 8) + p_command[5], (p_command[2] << 8) + p_command[3] ) )
524 msg_Dbg( &sys.demuxer, "Set GPRMMD failed" );
527 case CMD_DVD_LINKPGCN:
529 uint16 i_pgcn = (p_command[6] << 8) + p_command[7];
531 msg_Dbg( &sys.demuxer, "Link PGCN(%d)", i_pgcn );
532 p_chapter = sys.p_current_segment->BrowseCodecPrivate( 1, MatchPgcNumber, &i_pgcn, 2 );
533 if ( p_chapter != NULL )
535 if ( !p_chapter->Enter( true ) )
536 // jump to the location in the found segment
537 sys.p_current_segment->Seek( sys.demuxer, p_chapter->i_user_start_time, -1, p_chapter, -1 );
545 uint8 i_cn = p_command[7];
547 p_chapter = sys.p_current_segment->CurrentChapter();
549 msg_Dbg( &sys.demuxer, "LinkCN (cell %d)", i_cn );
550 p_chapter = p_chapter->BrowseCodecPrivate( 1, MatchCellNumber, &i_cn, 1 );
551 if ( p_chapter != NULL )
553 if ( !p_chapter->Enter( true ) )
554 // jump to the location in the found segment
555 sys.p_current_segment->Seek( sys.demuxer, p_chapter->i_user_start_time, -1, p_chapter, -1 );
561 case CMD_DVD_GOTO_LINE:
563 msg_Dbg( &sys.demuxer, "GotoLine (%d)", (p_command[6] << 8) + p_command[7] );
567 case CMD_DVD_SET_HL_BTNN1:
569 msg_Dbg( &sys.demuxer, "SetHL_BTN (%d)", p_command[4] );
570 SetSPRM( 0x88, p_command[4] );
575 msg_Dbg( &sys.demuxer, "unsupported command : %02X %02X %02X %02X %02X %02X %02X %02X"
593 bool dvd_command_interpretor_c::MatchIsDomain( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
595 return ( data.p_private_data != NULL && data.p_private_data->GetBuffer()[0] == MATROSKA_DVD_LEVEL_SS );
598 bool dvd_command_interpretor_c::MatchIsVMG( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
600 if ( data.p_private_data == NULL || data.p_private_data->GetSize() < 2 )
603 return ( data.p_private_data->GetBuffer()[0] == MATROSKA_DVD_LEVEL_SS && data.p_private_data->GetBuffer()[1] == 0xC0);
606 bool dvd_command_interpretor_c::MatchVTSNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
608 if ( i_cookie_size != 2 || data.p_private_data == NULL || data.p_private_data->GetSize() < 4 )
611 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_SS || data.p_private_data->GetBuffer()[1] != 0x80 )
614 uint16 i_gtitle = (data.p_private_data->GetBuffer()[2] << 8 ) + data.p_private_data->GetBuffer()[3];
615 uint16 i_title = *(uint16*)p_cookie;
617 return (i_gtitle == i_title);
620 bool dvd_command_interpretor_c::MatchVTSMNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
622 if ( i_cookie_size != 1 || data.p_private_data == NULL || data.p_private_data->GetSize() < 4 )
625 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_SS || data.p_private_data->GetBuffer()[1] != 0x40 )
628 uint8 i_gtitle = data.p_private_data->GetBuffer()[3];
629 uint8 i_title = *(uint8*)p_cookie;
631 return (i_gtitle == i_title);
634 bool dvd_command_interpretor_c::MatchTitleNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
636 if ( i_cookie_size != 1 || data.p_private_data == NULL || data.p_private_data->GetSize() < 4 )
639 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_TT )
642 uint16 i_gtitle = (data.p_private_data->GetBuffer()[1] << 8 ) + data.p_private_data->GetBuffer()[2];
643 uint8 i_title = *(uint8*)p_cookie;
645 return (i_gtitle == i_title);
648 bool dvd_command_interpretor_c::MatchPgcType( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
650 if ( i_cookie_size != 1 || data.p_private_data == NULL || data.p_private_data->GetSize() < 8 )
653 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_PGC )
656 uint8 i_pgc_type = data.p_private_data->GetBuffer()[3] & 0x0F;
657 uint8 i_pgc = *(uint8*)p_cookie;
659 return (i_pgc_type == i_pgc);
662 bool dvd_command_interpretor_c::MatchPgcNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
664 if ( i_cookie_size != 2 || data.p_private_data == NULL || data.p_private_data->GetSize() < 8 )
667 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_PGC )
670 uint16 *i_pgc_n = (uint16 *)p_cookie;
671 uint16 i_pgc_num = (data.p_private_data->GetBuffer()[1] << 8) + data.p_private_data->GetBuffer()[2];
673 return (i_pgc_num == *i_pgc_n);
676 bool dvd_command_interpretor_c::MatchChapterNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
678 if ( i_cookie_size != 1 || data.p_private_data == NULL || data.p_private_data->GetSize() < 2 )
681 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_PTT )
684 uint8 i_chapter = data.p_private_data->GetBuffer()[1];
685 uint8 i_ptt = *(uint8*)p_cookie;
687 return (i_chapter == i_ptt);
690 bool dvd_command_interpretor_c::MatchCellNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size )
692 if ( i_cookie_size != 1 || data.p_private_data == NULL || data.p_private_data->GetSize() < 5 )
695 if ( data.p_private_data->GetBuffer()[0] != MATROSKA_DVD_LEVEL_CN )
698 uint8 *i_cell_n = (uint8 *)p_cookie;
699 uint8 i_cell_num = data.p_private_data->GetBuffer()[3];
701 return (i_cell_num == *i_cell_n);
704 const std::string matroska_script_interpretor_c::CMD_MS_GOTO_AND_PLAY = "GotoAndPlay";
706 // see http://www.matroska.org/technical/specs/chapters/index.html#mscript
707 // for a description of existing commands
708 bool matroska_script_interpretor_c::Interpret( const binary * p_command, size_t i_size )
710 bool b_result = false;
712 char *psz_str = (char*) malloc( i_size + 1 );
713 memcpy( psz_str, p_command, i_size );
714 psz_str[ i_size ] = '\0';
716 std::string sz_command = psz_str;
719 msg_Dbg( &sys.demuxer, "command : %s", sz_command.c_str() );
721 #if defined(__GNUC__) && (__GNUC__ < 3)
722 if ( sz_command.compare( CMD_MS_GOTO_AND_PLAY, 0, CMD_MS_GOTO_AND_PLAY.size() ) == 0 )
724 if ( sz_command.compare( 0, CMD_MS_GOTO_AND_PLAY.size(), CMD_MS_GOTO_AND_PLAY ) == 0 )
730 for ( i=CMD_MS_GOTO_AND_PLAY.size(); i<sz_command.size(); i++)
732 if ( sz_command[i] == '(' )
739 for ( j=i; j<sz_command.size(); j++)
741 if ( sz_command[j] == ')' )
748 std::string st = sz_command.substr( i+1, j-i-1 );
749 int64_t i_chapter_uid = atoi( st.c_str() );
751 virtual_segment_c *p_segment;
752 chapter_item_c *p_chapter = sys.FindChapter( i_chapter_uid, p_segment );
754 if ( p_chapter == NULL )
755 msg_Dbg( &sys.demuxer, "Chapter %"PRId64" not found", i_chapter_uid);
758 if ( !p_chapter->EnterAndLeave( sys.p_current_segment->CurrentChapter() ) )
759 p_segment->Seek( sys.demuxer, p_chapter->i_user_start_time, -1, p_chapter, -1 );
767 bool matroska_script_codec_c::Enter()
769 bool f_result = false;
770 std::vector<KaxChapterProcessData*>::iterator index = enter_cmds.begin();
771 while ( index != enter_cmds.end() )
773 if ( (*index)->GetSize() )
775 msg_Dbg( &sys.demuxer, "Matroska Script enter command" );
776 f_result |= interpretor.Interpret( (*index)->GetBuffer(), (*index)->GetSize() );
783 bool matroska_script_codec_c::Leave()
785 bool f_result = false;
786 std::vector<KaxChapterProcessData*>::iterator index = leave_cmds.begin();
787 while ( index != leave_cmds.end() )
789 if ( (*index)->GetSize() )
791 msg_Dbg( &sys.demuxer, "Matroska Script leave command" );
792 f_result |= interpretor.Interpret( (*index)->GetBuffer(), (*index)->GetSize() );