Matroska: cleanup so that relevant methods are in their correct files
[vlc/solaris.git] / modules / demux / mkv / mkv.hpp
blobe09bcb461c72f1436dbc32d649c65f38c6ed443e
1 /*****************************************************************************
2 * mkv.cpp : matroska demuxer
3 *****************************************************************************
4 * Copyright (C) 2003-2004 the VideoLAN team
5 * $Id$
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 #ifndef _MKV_H_
26 #define _MKV_H_
28 /*****************************************************************************
29 * Preamble
30 *****************************************************************************/
33 /* config.h may include inttypes.h, so make sure we define that option
34 * early enough. */
35 #define __STDC_FORMAT_MACROS 1
36 #define __STDC_CONSTANT_MACROS 1
37 #define __STDC_LIMIT_MACROS 1
39 #ifdef HAVE_CONFIG_H
40 # include "config.h"
41 #endif
43 #include <inttypes.h>
45 #include <vlc_common.h>
46 #include <vlc_plugin.h>
48 #ifdef HAVE_TIME_H
49 # include <time.h> /* time() */
50 #endif
52 #include <vlc_codecs.h> /* BITMAPINFOHEADER, WAVEFORMATEX */
53 #include <vlc_iso_lang.h>
54 #include <vlc_meta.h>
55 #include <vlc_charset.h>
56 #include <vlc_input.h>
57 #include <vlc_demux.h>
59 #include <iostream>
60 #include <cassert>
61 #include <typeinfo>
62 #include <string>
63 #include <vector>
64 #include <algorithm>
66 #ifdef HAVE_DIRENT_H
67 # include <dirent.h>
68 #endif
70 /* libebml and matroska */
71 #include "ebml/EbmlHead.h"
72 #include "ebml/EbmlSubHead.h"
73 #include "ebml/EbmlStream.h"
74 #include "ebml/EbmlContexts.h"
75 #include "ebml/EbmlVoid.h"
76 #include "ebml/EbmlVersion.h"
77 #include "ebml/StdIOCallback.h"
79 #include "matroska/KaxAttachments.h"
80 #include "matroska/KaxAttached.h"
81 #include "matroska/KaxBlock.h"
82 #include "matroska/KaxBlockData.h"
83 #include "matroska/KaxChapters.h"
84 #include "matroska/KaxCluster.h"
85 #include "matroska/KaxClusterData.h"
86 #include "matroska/KaxContexts.h"
87 #include "matroska/KaxCues.h"
88 #include "matroska/KaxCuesData.h"
89 #include "matroska/KaxInfo.h"
90 #include "matroska/KaxInfoData.h"
91 #include "matroska/KaxSeekHead.h"
92 #include "matroska/KaxSegment.h"
93 #include "matroska/KaxTag.h"
94 #include "matroska/KaxTags.h"
95 #include "matroska/KaxTagMulti.h"
96 #include "matroska/KaxTracks.h"
97 #include "matroska/KaxTrackAudio.h"
98 #include "matroska/KaxTrackVideo.h"
99 #include "matroska/KaxTrackEntryData.h"
100 #include "matroska/KaxContentEncoding.h"
101 #include "matroska/KaxVersion.h"
103 #include "ebml/StdIOCallback.h"
105 #include <vlc_keys.h>
107 extern "C" {
108 #include "../mp4/libmp4.h"
110 #ifdef HAVE_ZLIB_H
111 # include <zlib.h>
112 #endif
114 #define MATROSKA_COMPRESSION_NONE -1
115 #define MATROSKA_COMPRESSION_ZLIB 0
116 #define MATROSKA_COMPRESSION_BLIB 1
117 #define MATROSKA_COMPRESSION_LZOX 2
118 #define MATROSKA_COMPRESSION_HEADER 3
120 #define MKVD_TIMECODESCALE 1000000
122 #define MKV_IS_ID( el, C ) ( EbmlId( (*el) ) == C::ClassInfos.GlobalId )
125 using namespace LIBMATROSKA_NAMESPACE;
126 using namespace std;
128 void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock,
129 mtime_t i_pts, mtime_t i_duration, bool f_mandatory );
131 class attachment_c
133 public:
134 attachment_c()
135 :p_data(NULL)
136 ,i_size(0)
138 virtual ~attachment_c()
140 free( p_data );
143 std::string psz_file_name;
144 std::string psz_mime_type;
145 void *p_data;
146 int i_size;
149 class matroska_segment_c;
151 class matroska_stream_c
153 public:
154 matroska_stream_c( demux_sys_t & demuxer )
155 :p_in(NULL)
156 ,p_es(NULL)
157 ,sys(demuxer)
160 virtual ~matroska_stream_c()
162 delete p_in;
163 delete p_es;
166 IOCallback *p_in;
167 EbmlStream *p_es;
169 std::vector<matroska_segment_c*> segments;
171 demux_sys_t & sys;
175 /*****************************************************************************
176 * definitions of structures and functions used by this plugins
177 *****************************************************************************/
178 typedef struct
180 // ~mkv_track_t();
182 bool b_default;
183 bool b_enabled;
184 unsigned int i_number;
186 int i_extra_data;
187 uint8_t *p_extra_data;
189 char *psz_codec;
190 bool b_dts_only;
192 uint64_t i_default_duration;
193 float f_timecodescale;
194 mtime_t i_last_dts;
196 /* video */
197 es_format_t fmt;
198 float f_fps;
199 es_out_id_t *p_es;
201 /* audio */
202 unsigned int i_original_rate;
204 bool b_inited;
205 /* data to be send first */
206 int i_data_init;
207 uint8_t *p_data_init;
209 /* hack : it's for seek */
210 bool b_search_keyframe;
211 bool b_silent;
213 /* informative */
214 const char *psz_codec_name;
215 const char *psz_codec_settings;
216 const char *psz_codec_info_url;
217 const char *psz_codec_download_url;
219 /* encryption/compression */
220 int i_compression_type;
221 KaxContentCompSettings *p_compression_data;
223 } mkv_track_t;
225 typedef struct
227 int i_track;
228 int i_block_number;
230 int64_t i_position;
231 int64_t i_time;
233 bool b_key;
234 } mkv_index_t;
237 #endif /* _MKV_HPP_ */