This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
MatroskaExport.h
121 lines (102 loc) · 4.04 KB
/
MatroskaExport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* MatroskaExport.h
*
* MatroskaExport.h - Structs for the Matroska exporter
*
*
* Copyright (c) 2006 David Conrad
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef __MATROSKAEXPORT_H__
#define __MATROSKAEXPORT_H__
#include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h>
#include <vector>
#include <ebml/c/libebml_t.h>
#include <ebml/IOCallback.h>
#include <ebml/EbmlVoid.h>
#include <matroska/KaxCues.h>
#include <matroska/KaxCluster.h>
#include <matroska/KaxSegment.h>
#include <matroska/KaxSeekHead.h>
using namespace libebml;
using namespace libmatroska;
using namespace std;
typedef struct OutputTrackRecord {
long trackID;
MovieExportGetPropertyUPP getPropertyProc;
MovieExportGetDataUPP getDataProc;
void *refCon;
TimeScale sourceTimeScale;
KaxTrackEntry *kaxTrack;
Track theTrack;
TimeValue64 currentTime; // decode time
} OutputTrack, *OutputTrackPtr;
typedef struct {
ComponentInstance self;
ComponentInstance quickTimeMovieExporter;
vector<OutputTrack> *outputTracks;
MovieProgressUPP progressProc;
long progressRefcon;
Boolean canceled;
Movie theMovie;
Track onlyThisTrack;
uint64 timecodeScale; // default: milliseconds (can't be changed)
TimeRecord duration;
IOCallback *ioHandler;
KaxSegment *segment;
uint64 segmentSize; // the initial size of the segment
uint64 actSegmentSize; // the actual size of the segment, calculated from its elements
EbmlVoid *metaSeekPlaceholder; // this saves space for the first seek head
KaxSeekHead *metaSeek; // this seek head indexes everything except clusters
KaxSeekHead *clusterMetaSeek; // this seek head indexes clusters, and is at the end
KaxCues *cues;
KaxCluster *currentCluster;
TimeValue64 currentClusterDuration;
// in ms
#define MAX_CLUSTER_DURATION 5000
Ptr sampleBuffer;
} MatroskaExportGlobalsRecord, *MatroskaExportGlobals;
enum {
kMatroskaExportFileNameExtention = 'mkv '
};
// Component data types, these are not yet public but they're just a FourCC
// indicating the value type - turn this off if one day they do go public
#if 1
enum {
kComponentDataTypeFixed = 'fixd', // Fixed (same as typeFixed )
kComponentDataTypeInt16 = 'shor', // SInt16 (same as typeSInt16)
kComponentDataTypeCFDataRef = 'cfdt' // CFDataRef
};
#endif
// Component Properties specific to the Matroska Exporter component
enum {
kComponentPropertyClass_Matroska = 'MkvF', // Matroska Component property class
};
static const ComponentPropertyInfo kExportProperties[] =
{
{ kComponentPropertyClassPropertyInfo, kComponentPropertyInfoList, kComponentDataTypeCFDataRef, sizeof(CFDataRef), kComponentPropertyFlagCanGetNow | kComponentPropertyFlagValueIsCFTypeRef | kComponentPropertyFlagValueMustBeReleased },
};
static const OSType kSupportedMediaTypes[] =
{
VideoMediaType,
SoundMediaType
};
// Prototypes
static OSErr ConfigureQuickTimeMovieExporter(MatroskaExportGlobals store);
static void GetExportProperty(MatroskaExportGlobals store);
#endif