Remove _XOPEN_SOURCE from libmkv.h.
[libmkv.git] / include / libmkv.h
blob35fbc4a3616977a7f1d65668ac32e26d99a5c145
1 /*****************************************************************************
2 * libmkv.h:
3 *****************************************************************************
4 * Copyright (C) 2005 x264 project
5 * $Id: $
7 * Authors: Mike Matsnev
8 * Nathan Caldwell
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
24 #ifndef _LIBMKV_H
25 #define _LIBMKV_H 1
27 #ifndef _LARGEFILE_SOURCE
28 #define _LARGEFILE_SOURCE
29 #endif
30 #ifndef _FILE_OFFSET_BITS
31 #define _FILE_OFFSET_BITS 64
32 #endif
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
38 #ifdef HAVE_STDINT_H
39 #include <stdint.h>
40 #else
41 #include <inttypes.h>
42 #endif
44 /* Video codecs */
45 #define MK_VCODEC_MPEG1 "V_MPEG1"
46 #define MK_VCODEC_MPEG2 "V_MPEG2"
47 #define MK_VCODEC_THEORA "V_THEORA"
48 #define MK_VCODEC_SNOW "V_SNOW"
49 #define MK_VCODEC_MP4ASP "V_MPEG4/ISO/ASP"
50 #define MK_VCODEC_MP4AVC "V_MPEG4/ISO/AVC"
52 /* Audio codecs */
53 #define MK_ACODEC_AC3 "A_AC3"
54 #define MK_ACODEC_MP3 "A_MPEG/L3"
55 #define MK_ACODEC_MP2 "A_MPEG/L2"
56 #define MK_ACODEC_MP1 "A_MPEG/L1"
57 #define MK_ACODEC_DTS "A_DTS"
58 #define MK_ACODEC_PCMINTLE "A_PCM/INT/LIT"
59 #define MK_ACODEC_PCMFLTLE "A_PCM/FLOAT/IEEE"
60 #define MK_ACODEC_TTA1 "A_TTA1"
61 #define MK_ACODEC_WAVPACK "A_WAVPACK4"
62 #define MK_ACODEC_VORBIS "A_VORBIS"
63 #define MK_ACODEC_FLAC "A_FLAC"
64 #define MK_ACODEC_AAC "A_AAC"
66 /* Subtitles */
67 #define MK_SUBTITLE_ASCII "S_TEXT/ASCII"
68 #define MK_SUBTITLE_UTF8 "S_TEXT/UTF8"
69 #define MK_SUBTITLE_SSA "S_TEXT/SSA"
70 #define MK_SUBTITLE_ASS "S_TEXT/ASS"
71 #define MK_SUBTITLE_USF "S_TEXT/USF"
72 #define MK_SUBTITLE_VOBSUB "S_VOBSUB"
74 #define MK_TRACK_VIDEO 0x01
75 #define MK_TRACK_AUDIO 0x02
76 #define MK_TRACK_COMPLEX 0x03
77 #define MK_TRACK_LOGO 0x10
78 #define MK_TRACK_SUBTITLE 0x11
79 #define MK_TRACK_BUTTONS 0x12
80 #define MK_TRACK_CONTROL 0x20
82 #define MK_LACING_NONE 0x00
83 #define MK_LACING_XIPH 0x01
84 #define MK_LACING_FIXED 0x02
85 #define MK_LACING_EBML 0x03
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
91 typedef struct mk_Writer_s mk_Writer;
92 typedef struct mk_Track_s mk_Track;
93 typedef struct mk_TrackConfig_s mk_TrackConfig;
95 struct mk_TrackConfig_s {
96 uint64_t trackUID; // Optional: Unique identifier for the track.
97 uint8_t trackType; // Required: 1 = Video, 2 = Audio.
98 int8_t flagEnabled; // Required: Set 1 if the track is used, 0 if unused. (Default: enabled)
99 int8_t flagDefault; // Required: Set 1 if this track is default, 0 if not default, -1 is undefined.
100 int8_t flagForced; // Optional: Set 1 if the track MUST be shown during playback (Default: disabled)
101 int8_t flagLacing; // Required: Set 1 if the track may contain blocks using lacing.
102 uint8_t minCache; // Optional: See Matroska spec. (Default: cache disabled)
103 uint8_t maxCache;
104 int64_t defaultDuration; // Optional: Number of nanoseconds per frame.
105 char *name;
106 char *language;
107 char *codecID; // Required: See codecs above.
108 void *codecPrivate;
109 unsigned codecPrivateSize;
110 char *codecName;
111 union {
112 struct {
113 char flagInterlaced;
114 unsigned pixelWidth; // Pixel width
115 unsigned pixelHeight; // Pixel height
116 unsigned pixelCrop[4]; // Pixel crop - 0 = bottom, 1 = top, 2 = left, 3 = right
117 unsigned displayWidth; // Display width
118 unsigned displayHeight; // Display height
119 char displayUnit; // Display Units - 0 = pixels, 1 = cm, 2 = in
120 } video;
121 struct {
122 float samplingFreq; // Sampling Frequency in Hz
123 unsigned channels; // Number of channels for this track
124 unsigned bitDepth; // Bits per sample (PCM)
125 } audio;
126 } extra;
129 mk_Writer *mk_createWriter(const char *filename, int64_t timescale, uint8_t vlc_compat);
130 /* vlc_compat writes the Seek entries at the top of the file because VLC stops parsing *
131 * once it finds the first cluster. However, this creates extra overhead in the file. */
132 mk_Track *mk_createTrack(mk_Writer *w, mk_TrackConfig *tc);
133 int mk_writeHeader(mk_Writer *w, const char *writingApp);
134 int mk_startFrame( mk_Writer *w, mk_Track *track );
135 int mk_addFrameData(mk_Writer *w, mk_Track *track, const void *data, unsigned size);
136 int mk_setFrameFlags(mk_Writer *w, mk_Track *track, int64_t timestamp, unsigned keyframe);
137 int mk_setFrameLacing(mk_Writer *w, mk_Track *track, uint8_t lacing, uint8_t num_frames, uint64_t sizes[]);
138 int mk_createChapterSimple(mk_Writer *w, uint64_t start, uint64_t end, char *name);
139 int mk_close( mk_Writer *w );
141 char *mk_laceXiph(uint64_t *sizes, uint8_t num_frames, uint64_t *output_size);
143 #ifdef __cplusplus
145 #endif
147 #endif