Mkv: kill warnings.
[vlc.git] / modules / demux / mkv / matroska_segment.hpp
1 /*****************************************************************************
2  * mkv.cpp : 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
31 #include "Ebml_parser.hpp"
32
33 class chapter_edition_c;
34 class chapter_translation_c;
35 class chapter_item_c;
36
37 class matroska_segment_c
38 {
39 public:
40     matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estream )
41         :segment(NULL)
42         ,es(estream)
43         ,i_timescale(MKVD_TIMECODESCALE)
44         ,i_duration(-1)
45         ,i_start_time(0)
46         ,i_seekhead_count(0)
47         ,i_seekhead_position(-1)
48         ,i_cues_position(-1)
49         ,i_tracks_position(-1)
50         ,i_info_position(-1)
51         ,i_chapters_position(-1)
52         ,i_tags_position(-1)
53         ,i_attachments_position(-1)
54         ,cluster(NULL)
55         ,i_block_pos(0)
56         ,i_cluster_pos(0)
57         ,i_start_pos(0)
58         ,p_segment_uid(NULL)
59         ,p_prev_segment_uid(NULL)
60         ,p_next_segment_uid(NULL)
61         ,b_cues(false)
62         ,i_index(0)
63         ,i_index_max(1024)
64         ,psz_muxing_application(NULL)
65         ,psz_writing_application(NULL)
66         ,psz_segment_filename(NULL)
67         ,psz_title(NULL)
68         ,psz_date_utc(NULL)
69         ,i_default_edition(0)
70         ,sys(demuxer)
71         ,ep(NULL)
72         ,b_preloaded(false)
73     {
74         p_indexes = (mkv_index_t*)malloc( sizeof( mkv_index_t ) * i_index_max );
75     }
76
77     virtual ~matroska_segment_c();
78
79     KaxSegment              *segment;
80     EbmlStream              & es;
81
82     /* time scale */
83     uint64_t                i_timescale;
84
85     /* duration of the segment */
86     mtime_t                 i_duration;
87     mtime_t                 i_start_time;
88
89     /* all tracks */
90     std::vector<mkv_track_t*> tracks;
91
92     /* from seekhead */
93     int                     i_seekhead_count;
94     int64_t                 i_seekhead_position;
95     int64_t                 i_cues_position;
96     int64_t                 i_tracks_position;
97     int64_t                 i_info_position;
98     int64_t                 i_chapters_position;
99     int64_t                 i_tags_position;
100     int64_t                 i_attachments_position;
101
102     KaxCluster              *cluster;
103     uint64                  i_block_pos;
104     uint64                  i_cluster_pos;
105     int64_t                 i_start_pos;
106     KaxSegmentUID           *p_segment_uid;
107     KaxPrevUID              *p_prev_segment_uid;
108     KaxNextUID              *p_next_segment_uid;
109
110     bool                    b_cues;
111     int                     i_index;
112     int                     i_index_max;
113     mkv_index_t             *p_indexes;
114
115     /* info */
116     char                    *psz_muxing_application;
117     char                    *psz_writing_application;
118     char                    *psz_segment_filename;
119     char                    *psz_title;
120     char                    *psz_date_utc;
121
122     /* !!!!! GCC 3.3 bug on Darwin !!!!! */
123     /* when you remove this variable the compiler issues an atomicity error */
124     /* this variable only works when using std::vector<chapter_edition_c> */
125     std::vector<chapter_edition_c*> stored_editions;
126     int                             i_default_edition;
127
128     std::vector<chapter_translation_c*> translations;
129     std::vector<KaxSegmentFamily*>  families;
130  
131     demux_sys_t                    & sys;
132     EbmlParser                     *ep;
133     bool                           b_preloaded;
134
135     bool Preload( );
136     bool LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int64_t i_element_position );
137     bool PreloadFamily( const matroska_segment_c & segment );
138     void ParseInfo( KaxInfo *info );
139     void ParseAttachments( KaxAttachments *attachments );
140     void ParseChapters( KaxChapters *chapters );
141     void ParseSeekHead( KaxSeekHead *seekhead );
142     void ParseTracks( KaxTracks *tracks );
143     void ParseChapterAtom( int i_level, KaxChapterAtom *ca, chapter_item_c & chapters );
144     void ParseTrackEntry( KaxTrackEntry *m );
145     void ParseCluster( );
146     void IndexAppendCluster( KaxCluster *cluster );
147     void LoadCues( KaxCues *cues );
148     void LoadTags( KaxTags *tags );
149     void InformationCreate( );
150     void Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_global_position );
151     int BlockGet( KaxBlock * &, KaxSimpleBlock * &, int64_t *, int64_t *, int64_t *);
152
153     int BlockFindTrackIndex( size_t *pi_track,
154                              const KaxBlock *, const KaxSimpleBlock * );
155
156
157     bool Select( mtime_t i_start_time );
158     void UnSelect( );
159
160     static bool CompareSegmentUIDs( const matroska_segment_c * item_a, const matroska_segment_c * item_b );
161 };
162
163
164 #endif