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 )
41 ,i_current_edition(-1)
42 ,p_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 );
52 void AddSegments( const std::vector<matroska_segment_c*> &segments );
54 void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, chapter_item_c *p_chapter, int64_t i_global_position );
56 mtime_t Duration() const;
58 inline chapter_edition_c *CurrentEdition()
60 if ( i_current_edition >= 0 && size_t(i_current_edition) < p_editions->size() )
61 return (*p_editions)[i_current_edition];
64 std::vector<chapter_edition_c*>* Editions() const { return p_editions; };
66 matroska_segment_c * CurrentSegment() const
68 if ( linked_segments.size() == 0 || i_current_segment >= linked_segments.size() )
70 return linked_segments[i_current_segment];
73 chapter_item_c *CurrentChapter() { return p_current_chapter; }
77 if ( i_current_segment < linked_segments.size()-1 )
85 bool FindUID( KaxSegmentUID & uid ) const
87 for ( size_t i=0; i<linked_uids.size(); i++ )
89 if ( linked_uids[i] == uid )
95 chapter_item_c *FindChapter( int64_t i_find_uid );
97 bool UpdateCurrentToChapter( demux_t & demux );
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 );
107 std::vector<matroska_segment_c*> linked_segments;
108 std::vector<KaxSegmentUID> linked_uids;
109 size_t i_current_segment;
111 int i_current_edition;
112 chapter_item_c *p_current_chapter;
114 std::vector<chapter_edition_c*> *p_editions;
116 void AppendUID( const EbmlBinary * UID );
120 size_t AddSegment( matroska_segment_c *p_segment );
121 void PreloadLinked( );
122 void PrepareChapters( );