As suggested by autoreconf, keep libool macros in m4 directory.
[libmkv.git] / include / libmkv.h
blob20608b1bae96d43542accefa1701828be6251f2d
1 /*****************************************************************************
2 * libmkv.h:
3 *****************************************************************************
4 * Copyright (C) 2005 x264 project
6 * Authors: Mike Matsnev
7 * Nathan Caldwell
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
23 #ifndef _LIBMKV_H
24 #define _LIBMKV_H 1
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
34 #ifdef HAVE_STDINT_H
35 #include <stdint.h>
36 #else
37 #include <inttypes.h>
38 #endif
40 /* Video codecs */
41 #define MK_VCODEC_RAW "V_UNCOMPRESSED"
42 #define MK_VCODEC_MPEG1 "V_MPEG1"
43 #define MK_VCODEC_MPEG2 "V_MPEG2"
44 #define MK_VCODEC_THEORA "V_THEORA"
45 #define MK_VCODEC_SNOW "V_SNOW"
46 #define MK_VCODEC_MP4SP "V_MPEG4/ISO/SP"
47 #define MK_VCODEC_MP4ASP "V_MPEG4/ISO/ASP"
48 #define MK_VCODEC_MP4AP "V_MPEG4/ISO/AP"
49 #define MK_VCODEC_MP4AVC "V_MPEG4/ISO/AVC"
50 #define MK_VCODEC_MSVCM "V_MS/VFW/FOURCC"
51 #define MK_VCODEC_MSMP4V3 "V_MPEG4/MS/V3"
52 #define MK_VCODEC_REAL "V_REAL"
53 #define MK_VCODEC_REAL10 MK_VCODEC_REAL "/RV10"
54 #define MK_VCODEC_REAL20 MK_VCODEC_REAL "/RV20"
55 #define MK_VCODEC_REAL30 MK_VCODEC_REAL "/RV30"
56 #define MK_VCODEC_REAL40 MK_VCODEC_REAL "/RV40"
57 #define MK_VCODEC_QUICKTIME "V_QUICKTIME"
59 /* Audio codecs */
60 #define MK_ACODEC_AC3 "A_AC3"
61 #define MK_ACODEC_AC3BSID9 "A_AC3/BSID9"
62 #define MK_ACODEC_AC3BSID10 "A_AC3/BSID10"
63 #define MK_ACODEC_MP3 "A_MPEG/L3"
64 #define MK_ACODEC_MP2 "A_MPEG/L2"
65 #define MK_ACODEC_MP1 "A_MPEG/L1"
66 #define MK_ACODEC_DTS "A_DTS"
67 #define MK_ACODEC_PCMINTLE "A_PCM/INT/LIT"
68 #define MK_ACODEC_PCMINTBE "A_PCM/INT/BIG"
69 #define MK_ACODEC_PCMFLTLE "A_PCM/FLOAT/IEEE"
70 #define MK_ACODEC_TTA1 "A_TTA1"
71 #define MK_ACODEC_WAVPACK "A_WAVPACK4"
72 #define MK_ACODEC_VORBIS "A_VORBIS"
73 #define MK_ACODEC_FLAC "A_FLAC"
74 #define MK_ACODEC_AAC "A_AAC"
75 #define MK_ACODEC_MPC "A_MPC"
76 #define MK_ACODEC_REAL1 "A_REAL/14_4"
77 #define MK_ACODEC_REAL2 "A_REAL/28_8"
78 #define MK_ACODEC_REALCOOK "A_REAL/COOK"
79 #define MK_ACODEC_REALSIPR "A_REAL/SIPR"
80 #define MK_ACODEC_REALRALF "A_REAL/RALF"
81 #define MK_ACODEC_REALATRC "A_REAL/ATRC"
82 #define MK_ACODEC_MSACM "A_MS/ACM"
83 #define MK_ACODEC_QUICKTIME "A_QUICKTIME"
84 #define MK_ACODEC_QDMC MK_ACODEC_QUICKTIME "/QDMC"
85 #define MK_ACODEC_QDM2 MK_ACODEC_QUICKTIME "/QDM2"
86 #define MK_ACODEC_TTA1 "A_TTA1"
87 #define MK_ACODEC_WAVPACK4 "A_WAVEPACK4"
89 /* Subtitles */
90 #define MK_SUBTITLE_ASCII "S_TEXT/ASCII"
91 #define MK_SUBTITLE_UTF8 "S_TEXT/UTF8"
92 #define MK_SUBTITLE_SSA "S_TEXT/SSA"
93 #define MK_SUBTITLE_ASS "S_TEXT/ASS"
94 #define MK_SUBTITLE_USF "S_TEXT/USF"
95 #define MK_SUBTITLE_VOBSUB "S_VOBSUB"
96 #define MK_SUBTITLE_BMP "S_IMAGE/BMP"
98 /* Official Tags */
99 #define MK_TAG_TITLE "TITLE"
100 #define MK_TAG_SUBTITLE "SUBTITLE"
101 #define MK_TAG_DIRECTOR "DIRECTOR"
102 #define MK_TAG_ACTOR "ACTOR"
103 #define MK_TAG_WRITER "WRITTEN_BY"
104 #define MK_TAG_SCREENPLAY "SCREENPLAY_BY"
105 #define MK_TAG_PRODUCER "PRODUCER"
106 #define MK_TAG_EXECUTIVEPRODUCER "EXECUTIVE_PRODUCER"
107 #define MK_TAG_GENRE "GENRE"
108 #define MK_TAG_SUMMARY "SUMMARY"
109 #define MK_TAG_SYNOPSIS "SYNOPSIS"
110 #define MK_TAG_LAWRATING "LAW_RATING"
111 #define MK_TAG_COMMENT "COMMENT"
112 #define MK_TAG_PLAYCOUNT "PLAY_COUNTER"
113 #define MK_TAG_RATING "RATING"
115 typedef enum {
116 MK_TRACK_VIDEO = 0x01,
117 MK_TRACK_AUDIO = 0x02,
118 MK_TRACK_COMPLEX = 0x03,
119 MK_TRACK_LOGO = 0x10,
120 MK_TRACK_SUBTITLE = 0x11,
121 MK_TRACK_BUTTONS = 0x12,
122 MK_TRACK_CONTROL = 0x20
123 } mk_TrackType;
125 typedef enum {
126 MK_LACING_NONE = 0x00,
127 MK_LACING_XIPH,
128 MK_LACING_FIXED,
129 MK_LACING_EBML
130 } mk_LacingType;
132 typedef enum {
133 MK_ASPECTRATIO_FREE = 0x00,
134 MK_ASPECTRATIO_KEEP,
135 MK_ASPECTRATIO_FIXED
136 } mk_AspectType;
138 /* The enum uses the video naming where there isn't a common name for the targettype.
139 * Later we define the other names to their equivelent enum value.
141 enum {
142 MK_TARGETTYPE_SHOT = 10,
143 MK_TARGETTYPE_SCENE = 20,
144 MK_TARGETTYPE_CHAPTER = 30,
145 MK_TARGETTYPE_PART = 40,
146 MK_TARGETTYPE_MOVIE = 50,
147 MK_TARGETTYPE_SEQUEL = 60,
148 MK_TARGETTYPE_COLLECTION = 70
150 #define MK_TARGETTYPE_SUBTRACK MK_TARGETTYPE_SCENE
151 #define MK_TARGETTYPE_MOVEMENT MK_TARGETTYPE_SCENE
152 #define MK_TARGETTYPE_TRACK MK_TARGETTYPE_CHAPTER
153 #define MK_TARGETTYPE_SONG MK_TARGETTYPE_CHAPTER
154 #define MK_TARGETTYPE_SESSION MK_TARGETTYPE_PART
155 #define MK_TARGETTYPE_EPISODE MK_TARGETTYPE_MOVIE
156 #define MK_TARGETTYPE_CONCERT MK_TARGETTYPE_MOVIE
157 #define MK_TARGETTYPE_ALBUM MK_TARGETTYPE_MOVIE
158 #define MK_TARGETTYPE_OPERA MK_TARGETTYPE_MOVIE
159 #define MK_TARGETTYPE_SEASON MK_TARGETTYPE_SEQUEL
160 #define MK_TARGETTYPE_VOLUME MK_TARGETTYPE_SEQUEL
161 #define MK_TARGETTYPE_EDITION MK_TARGETTYPE_SEQUEL
162 #define MK_TARGETTYPE_ISSUE MK_TARGETTYPE_SEQUEL
163 #define MK_TARGETTYPE_OPUS MK_TARGETTYPE_SEQUEL
165 typedef struct mk_Writer_s mk_Writer;
166 typedef struct mk_Track_s mk_Track;
167 typedef struct mk_TrackConfig_s mk_TrackConfig;
169 struct mk_TrackConfig_s {
170 uint64_t trackUID; /* Optional: Unique identifier for the track. */
171 mk_TrackType trackType; /* Required: 1 = Video, 2 = Audio. */
172 int8_t flagEnabled; /* Required: Set 1 if the track is used,
173 * 0 if unused. (Default: enabled)
175 int8_t flagDefault; /* Required: Set 1 if this track is default,
176 * 0 if not default, -1 is undefined.
178 int8_t flagForced; /* Optional: Set 1 if the track MUST be shown during playback
179 * (Default: disabled)
181 int8_t flagLacing; /* Required: Set 1 if the track may contain blocks using lacing. */
182 uint8_t minCache; /* Optional: See Matroska spec. (Default: cache disabled) */
183 uint8_t maxCache;
184 int64_t defaultDuration; /* Optional: Number of nanoseconds per frame. */
185 char *name;
186 char *language;
187 char *codecID; /* Required: See codecs above. */
188 void *codecPrivate;
189 unsigned codecPrivateSize;
190 char *codecName;
191 union {
192 struct {
193 char flagInterlaced;
194 unsigned pixelWidth; /* Pixel width */
195 unsigned pixelHeight; /* Pixel height */
196 unsigned pixelCrop[4]; /* Pixel crop - 0 = bottom, 1 = top, 2 = left, 3 = right */
197 unsigned displayWidth; /* Display width */
198 unsigned displayHeight; /* Display height */
199 char displayUnit; /* Display Units - 0 = pixels, 1 = cm, 2 = in */
200 mk_AspectType aspectRatioType; /* Specifies the allowed
201 * modifications to the aspect ratio
203 } video;
204 struct {
205 float samplingFreq; /* Sampling Frequency in Hz */
206 unsigned channels; /* Number of channels for this track */
207 unsigned bitDepth; /* Bits per sample (PCM) */
208 } audio;
209 } extra;
212 /* vlc_compat writes the Seek entries at the top of the file because VLC
213 * stops parsing once it finds the first cluster. However, this creates
214 * extra overhead in the file.
216 mk_Writer *mk_createWriter(const char *filename, int64_t timescale,
217 uint8_t vlc_compat);
218 mk_Track *mk_createTrack(mk_Writer *w, mk_TrackConfig *tc);
219 int mk_writeHeader(mk_Writer *w, const char *writingApp);
220 int mk_startFrame(mk_Writer *w, mk_Track *track);
221 int mk_addFrameData(mk_Writer * w, mk_Track *track, const void *data,
222 unsigned size);
223 int mk_setFrameFlags(mk_Writer * w, mk_Track *track, int64_t timestamp,
224 unsigned keyframe);
225 int mk_setFrameLacing(mk_Writer *w, mk_Track * track,
226 mk_LacingType lacing, uint8_t num_frames,
227 uint64_t sizes[]);
228 int mk_createChapterSimple(mk_Writer *w, uint64_t start, uint64_t end,
229 char *name);
230 int mk_close(mk_Writer *w);
232 char *mk_laceXiph(uint64_t *sizes, uint8_t num_frames,
233 uint64_t *output_size);
235 int mk_createTagSimple(mk_Writer *w, char *tag_id, char *value);
236 int mk_createTagSimpleBin(mk_Writer *w, char *tag_id, const void *data,
237 unsigned size);
238 int mk_createAttachment( mk_Writer * w, char *name, char *description,
239 char *mime, const void *data, unsigned size);
241 #ifdef __cplusplus
243 #endif /* __cplusplus */
245 #endif /* _LIBMKV_H */