2 /*****************************************************************************
3 * mkv.cpp : matroska demuxer
4 *****************************************************************************
5 * Copyright (C) 2003-2004 the VideoLAN team
8 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * Steve Lhomme <steve.lhomme@free.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #ifndef _VIRTUAL_SEGMENT_HPP_
27 #define _VIRTUAL_SEGMENT_HPP_
31 #include "matroska_segment.hpp"
32 #include "chapters.hpp"
34 // class holding hard-linked segment together in the playback order
35 class virtual_segment_c
38 virtual_segment_c( matroska_segment_c *p_segment )
42 ,i_current_edition(-1)
43 ,psz_current_chapter(NULL)
45 linked_segments.push_back( p_segment );
47 AppendUID( p_segment->p_segment_uid );
48 AppendUID( p_segment->p_prev_segment_uid );
49 AppendUID( p_segment->p_next_segment_uid );
53 size_t AddSegment( matroska_segment_c *p_segment );
54 void PreloadLinked( );
55 mtime_t Duration( ) const;
56 void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *psz_chapter, int64_t i_global_position );
58 inline chapter_edition_c *Edition()
60 if ( i_current_edition >= 0 && size_t(i_current_edition) < p_editions->size() )
61 return (*p_editions)[i_current_edition];
65 matroska_segment_c * Segment() const
67 if ( linked_segments.size() == 0 || i_current_segment >= linked_segments.size() )
69 return linked_segments[i_current_segment];
72 inline chapter_item_c *CurrentChapter() {
73 return psz_current_chapter;
78 if ( i_current_segment < linked_segments.size()-1 )
86 bool FindUID( KaxSegmentUID & uid ) const
88 for ( size_t i=0; i<linked_uids.size(); i++ )
90 if ( linked_uids[i] == uid )
96 bool UpdateCurrentToChapter( demux_t & demux );
97 void PrepareChapters( );
99 chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
100 bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
101 const void *p_cookie,
102 size_t i_cookie_size );
103 chapter_item_c *FindChapter( int64_t i_find_uid );
105 std::vector<chapter_edition_c*> *p_editions;
109 std::vector<matroska_segment_c*> linked_segments;
110 std::vector<KaxSegmentUID> linked_uids;
111 size_t i_current_segment;
113 int i_current_edition;
114 chapter_item_c *psz_current_chapter;
116 void AppendUID( const EbmlBinary * UID );