1 /*****************************************************************************
2 * mkv.hpp : matroska demuxer
3 *****************************************************************************
4 * Copyright (C) 2003-2005, 2008 the VideoLAN team
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 *****************************************************************************/
28 /*****************************************************************************
30 *****************************************************************************/
33 /* config.h may include inttypes.h, so make sure we define that option
35 #define __STDC_FORMAT_MACROS 1
36 #define __STDC_CONSTANT_MACROS 1
37 #define __STDC_LIMIT_MACROS 1
45 #include <vlc_common.h>
46 #include <vlc_plugin.h>
49 # include <time.h> /* time() */
53 #include <vlc_charset.h>
54 #include <vlc_input.h>
55 #include <vlc_demux.h>
64 /* libebml and matroska */
65 #include "ebml/EbmlHead.h"
66 #include "ebml/EbmlSubHead.h"
67 #include "ebml/EbmlStream.h"
68 #include "ebml/EbmlContexts.h"
69 #include "ebml/EbmlVoid.h"
70 #include "ebml/EbmlVersion.h"
71 #include "ebml/StdIOCallback.h"
73 #include "matroska/KaxAttachments.h"
74 #include "matroska/KaxAttached.h"
75 #include "matroska/KaxBlock.h"
76 #include "matroska/KaxBlockData.h"
77 #include "matroska/KaxChapters.h"
78 #include "matroska/KaxCluster.h"
79 #include "matroska/KaxClusterData.h"
80 #include "matroska/KaxContexts.h"
81 #include "matroska/KaxCues.h"
82 #include "matroska/KaxCuesData.h"
83 #include "matroska/KaxInfo.h"
84 #include "matroska/KaxInfoData.h"
85 #include "matroska/KaxSeekHead.h"
86 #include "matroska/KaxSegment.h"
87 #include "matroska/KaxTag.h"
88 #include "matroska/KaxTags.h"
89 //#include "matroska/KaxTagMulti.h"
90 #include "matroska/KaxTracks.h"
91 #include "matroska/KaxTrackAudio.h"
92 #include "matroska/KaxTrackVideo.h"
93 #include "matroska/KaxTrackEntryData.h"
94 #include "matroska/KaxContentEncoding.h"
95 #include "matroska/KaxVersion.h"
97 #include "ebml/StdIOCallback.h"
102 #include "../mp4/libmp4.h"
110 #define MATROSKA_COMPRESSION_NONE -1
111 #define MATROSKA_COMPRESSION_ZLIB 0
112 #define MATROSKA_COMPRESSION_BLIB 1
113 #define MATROSKA_COMPRESSION_LZOX 2
114 #define MATROSKA_COMPRESSION_HEADER 3
116 #define MKVD_TIMECODESCALE 1000000
118 #define MKV_IS_ID( el, C ) ( el != NULL && typeid( *el ) == typeid( C ) )
121 using namespace LIBMATROSKA_NAMESPACE;
124 void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock,
125 mtime_t i_pts, mtime_t i_duration, bool f_mandatory );
130 attachment_c( const std::string& _psz_file_name, const std::string& _psz_mime_type, int _i_size )
132 ,psz_file_name( _psz_file_name)
133 ,psz_mime_type( _psz_mime_type)
137 ~attachment_c() { free( p_data ); }
139 /* Allocs the data space. Returns true if allocation went ok */
142 p_data = malloc( i_size );
143 return (p_data != NULL);
146 const char* fileName() const { return psz_file_name.c_str(); }
147 const char* mimeType() const { return psz_mime_type.c_str(); }
148 int size() const { return i_size; }
153 std::string psz_file_name;
154 std::string psz_mime_type;
157 class matroska_segment_c;
158 struct matroska_stream_c
160 matroska_stream_c() :p_io_callback(NULL) ,p_estream(NULL) {}
163 delete p_io_callback;
167 IOCallback *p_io_callback;
168 EbmlStream *p_estream;
170 std::vector<matroska_segment_c*> segments;
174 /*****************************************************************************
175 * definitions of structures and functions used by this plugins
176 *****************************************************************************/
184 unsigned int i_number;
186 unsigned int i_extra_data;
187 uint8_t *p_extra_data;
193 uint64_t i_default_duration;
194 float f_timecodescale;
203 unsigned int i_original_rate;
206 /* data to be send first */
208 uint8_t *p_data_init;
210 /* hack : it's for seek */
211 bool b_search_keyframe;
215 const char *psz_codec_name;
216 const char *psz_codec_settings;
217 const char *psz_codec_info_url;
218 const char *psz_codec_download_url;
220 /* encryption/compression */
221 int i_compression_type;
222 KaxContentCompSettings *p_compression_data;
238 #endif /* _MKV_HPP_ */