fix filename self-references
[vlc.git] / modules / demux / mkv / matroska_segment.hpp
1 /*****************************************************************************
2  * matroska_segment.hpp : matroska demuxer
3  *****************************************************************************
4  * Copyright (C) 2003-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *          Steve Lhomme <steve.lhomme@free.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef _MATROSKA_SEGMENT_HPP_
26 #define _MATROSKA_SEGMENT_HPP_
27
28 #include "mkv.hpp"
29
30 class EbmlParser;
31
32 class chapter_edition_c;
33 class chapter_translation_c;
34 class chapter_item_c;
35
36 struct mkv_track_t;
37 struct mkv_index_t;
38
39 class matroska_segment_c
40 {
41 public:
42     matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estream );
43     virtual ~matroska_segment_c();
44
45     KaxSegment              *segment;
46     EbmlStream              & es;
47
48     /* time scale */
49     uint64_t                i_timescale;
50
51     /* duration of the segment */
52     mtime_t                 i_duration;
53     mtime_t                 i_start_time;
54
55     /* all tracks */
56     std::vector<mkv_track_t*> tracks;
57
58     /* from seekhead */
59     int                     i_seekhead_count;
60     int64_t                 i_seekhead_position;
61     int64_t                 i_cues_position;
62     int64_t                 i_tracks_position;
63     int64_t                 i_info_position;
64     int64_t                 i_chapters_position;
65     int64_t                 i_tags_position;
66     int64_t                 i_attachments_position;
67
68     KaxCluster              *cluster;
69     uint64                  i_block_pos;
70     uint64                  i_cluster_pos;
71     int64_t                 i_start_pos;
72     KaxSegmentUID           *p_segment_uid;
73     KaxPrevUID              *p_prev_segment_uid;
74     KaxNextUID              *p_next_segment_uid;
75
76     bool                    b_cues;
77     int                     i_index;
78     int                     i_index_max;
79     mkv_index_t             *p_indexes;
80
81     /* info */
82     char                    *psz_muxing_application;
83     char                    *psz_writing_application;
84     char                    *psz_segment_filename;
85     char                    *psz_title;
86     char                    *psz_date_utc;
87
88     /* !!!!! GCC 3.3 bug on Darwin !!!!! */
89     /* when you remove this variable the compiler issues an atomicity error */
90     /* this variable only works when using std::vector<chapter_edition_c> */
91     std::vector<chapter_edition_c*> stored_editions;
92     int                             i_default_edition;
93
94     std::vector<chapter_translation_c*> translations;
95     std::vector<KaxSegmentFamily*>  families;
96
97     demux_sys_t                    & sys;
98     EbmlParser                     *ep;
99     bool                           b_preloaded;
100
101     bool Preload();
102     bool PreloadFamily( const matroska_segment_c & segment );
103     void InformationCreate();
104     void Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_global_position );
105     int BlockGet( KaxBlock * &, KaxSimpleBlock * &, bool *, bool *, int64_t *);
106
107     int BlockFindTrackIndex( size_t *pi_track,
108                              const KaxBlock *, const KaxSimpleBlock * );
109
110     bool Select( mtime_t i_start_time );
111     void UnSelect();
112
113     static bool CompareSegmentUIDs( const matroska_segment_c * item_a, const matroska_segment_c * item_b );
114
115 private:
116     void LoadCues( KaxCues *cues );
117     void LoadTags( KaxTags *tags );
118     bool LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int64_t i_element_position );
119     void ParseInfo( KaxInfo *info );
120     void ParseAttachments( KaxAttachments *attachments );
121     void ParseChapters( KaxChapters *chapters );
122     void ParseSeekHead( KaxSeekHead *seekhead );
123     void ParseTracks( KaxTracks *tracks );
124     void ParseChapterAtom( int i_level, KaxChapterAtom *ca, chapter_item_c & chapters );
125     void ParseTrackEntry( KaxTrackEntry *m );
126     void ParseCluster( );
127     void ParseSimpleTags( KaxTagSimple *tag );
128     void IndexAppendCluster( KaxCluster *cluster );
129 };
130
131
132 #endif