2 * Copyright (C) 2010 Ole André Vadla Ravnås <oravnas@cisco.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GST_CM_API_H__
21 #define __GST_CM_API_H__
25 #include <CoreFoundation/CoreFoundation.h>
30 typedef struct _GstCMApi GstCMApi;
31 typedef struct _GstCMApiClass GstCMApiClass;
33 typedef CFTypeRef FigBaseObjectRef;
34 typedef struct _FigBaseVTable FigBaseVTable;
35 typedef struct _FigBaseIface FigBaseIface;
37 typedef CFTypeRef CMFormatDescriptionRef;
38 typedef struct _CMVideoDimensions CMVideoDimensions;
39 typedef struct _CMTime CMTime;
41 typedef CFTypeRef CMBufferQueueRef;
42 typedef SInt32 CMBufferQueueTriggerCondition;
43 typedef struct _CMBufferQueueTriggerToken *CMBufferQueueTriggerToken;
44 typedef CFTypeRef CMSampleBufferRef;
45 typedef CFTypeRef CMBlockBufferRef;
47 typedef void (* CMBufferQueueTriggerCallback) (void *triggerRefcon,
48 CMBufferQueueTriggerToken triggerToken);
49 typedef Boolean (* CMBufferQueueValidationCallback) (CMBufferQueueRef queue,
50 CMSampleBufferRef buf, void *refCon);
54 kFigMediaTypeVideo = 'vide'
59 kComponentVideoUnsigned = 'yuvs',
60 kFigVideoCodecType_JPEG_OpenDML = 'dmb1',
61 kYUV420vCodecType = '420v'
64 enum _CMBufferQueueTriggerCondition
66 kCMBufferQueueTrigger_WhenDurationBecomesLessThan = 1,
67 kCMBufferQueueTrigger_WhenDurationBecomesLessThanOrEqualTo = 2,
68 kCMBufferQueueTrigger_WhenDurationBecomesGreaterThan = 3,
69 kCMBufferQueueTrigger_WhenDurationBecomesGreaterThanOrEqualTo = 4,
70 kCMBufferQueueTrigger_WhenMinPresentationTimeStampChanges = 5,
71 kCMBufferQueueTrigger_WhenMaxPresentationTimeStampChanges = 6,
72 kCMBufferQueueTrigger_WhenDataBecomesReady = 7,
73 kCMBufferQueueTrigger_WhenEndOfDataReached = 8,
74 kCMBufferQueueTrigger_WhenReset = 9,
75 kCMBufferQueueTrigger_WhenBufferCountBecomesLessThan = 10,
76 kCMBufferQueueTrigger_WhenBufferCountBecomesGreaterThan = 11
91 OSStatus (* Invalidate) (FigBaseObjectRef obj);
92 OSStatus (* Finalize) (FigBaseObjectRef obj);
94 OSStatus (* CopyProperty) (FigBaseObjectRef obj, CFTypeRef key, void *unk,
96 OSStatus (* SetProperty) (FigBaseObjectRef obj, CFTypeRef key,
100 struct _CMVideoDimensions
115 FigBaseVTable * (* FigBaseObjectGetVTable) (FigBaseObjectRef obj);
117 void * (* CMGetAttachment) (CFTypeRef obj, CFStringRef attachmentKey,
118 UInt32 * foundWherePtr);
120 void (* FigFormatDescriptionRelease) (CMFormatDescriptionRef desc);
121 CMFormatDescriptionRef (* FigFormatDescriptionRetain) (
122 CMFormatDescriptionRef desc);
123 Boolean (* CMFormatDescriptionEqual) (CMFormatDescriptionRef desc1,
124 CMFormatDescriptionRef desc2);
125 CFTypeRef (* CMFormatDescriptionGetExtension) (
126 const CMFormatDescriptionRef desc, CFStringRef extensionKey);
127 UInt32 (* CMFormatDescriptionGetMediaType) (
128 const CMFormatDescriptionRef desc);
129 UInt32 (* CMFormatDescriptionGetMediaSubType) (
130 const CMFormatDescriptionRef desc);
132 OSStatus (* CMVideoFormatDescriptionCreate) (
133 CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
134 CFDictionaryRef extensions, CMFormatDescriptionRef * desc);
135 OSStatus (* FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom)
136 (CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
137 UInt32 atomId, const UInt8 * data, CFIndex len,
138 CMFormatDescriptionRef * formatDesc);
139 CMVideoDimensions (* CMVideoFormatDescriptionGetDimensions) (
140 const CMFormatDescriptionRef desc);
142 CMTime (* CMTimeMake) (int64_t value, int32_t timescale);
144 OSStatus (* CMSampleBufferCreate) (CFAllocatorRef allocator,
145 CMBlockBufferRef blockBuf, Boolean unkBool, UInt32 unkDW1, UInt32 unkDW2,
146 CMFormatDescriptionRef fmtDesc, UInt32 unkCountA, UInt32 unkCountB,
147 const void * unkTimeData, UInt32 unkCountC, const void * unkDWordData,
148 CMSampleBufferRef * sampleBuffer);
149 Boolean (* CMSampleBufferDataIsReady) (
150 const CMSampleBufferRef buf);
151 CMBlockBufferRef (* CMSampleBufferGetDataBuffer) (
152 const CMSampleBufferRef buf);
153 CMFormatDescriptionRef (* CMSampleBufferGetFormatDescription) (
154 const CMSampleBufferRef buf);
155 CVImageBufferRef (* CMSampleBufferGetImageBuffer) (
156 const CMSampleBufferRef buf);
157 SInt32 (* CMSampleBufferGetNumSamples) (
158 const CMSampleBufferRef buf);
159 CFArrayRef (* CMSampleBufferGetSampleAttachmentsArray) (
160 const CMSampleBufferRef buf, SInt32 sampleIndex);
161 SInt32 (* CMSampleBufferGetSampleSize) (
162 const CMSampleBufferRef buf, SInt32 sampleIndex);
163 void (* FigSampleBufferRelease) (CMSampleBufferRef buf);
164 CMSampleBufferRef (* FigSampleBufferRetain) (CMSampleBufferRef buf);
166 OSStatus (* CMBlockBufferCreateWithMemoryBlock)
167 (CFAllocatorRef allocator, Byte * data, UInt32 size,
168 CFAllocatorRef dataAllocator, void *unk1, UInt32 sizeA, UInt32 sizeB,
169 Boolean unkBool, CMBlockBufferRef * blockBuffer);
170 SInt32 (* CMBlockBufferGetDataLength) (const CMBlockBufferRef buf);
171 OSStatus (* CMBlockBufferGetDataPointer) (
172 const CMBlockBufferRef buf, UInt32 unk1, UInt32 unk2, UInt32 unk3,
174 void (* FigBlockBufferRelease) (CMBlockBufferRef buf);
175 CMBlockBufferRef (* FigBlockBufferRetain) (CMBlockBufferRef buf);
177 CMSampleBufferRef (* CMBufferQueueDequeueAndRetain)
178 (CMBufferQueueRef queue);
179 CFIndex (* CMBufferQueueGetBufferCount) (CMBufferQueueRef queue);
180 OSStatus (* CMBufferQueueInstallTrigger) (CMBufferQueueRef queue,
181 CMBufferQueueTriggerCallback triggerCallback, void * triggerRefCon,
182 CMBufferQueueTriggerCondition triggerCondition, CMTime triggerTime,
183 CMBufferQueueTriggerToken * triggerTokenOut);
184 Boolean (* CMBufferQueueIsEmpty) (CMBufferQueueRef queue);
185 void (* FigBufferQueueRelease) (CMBufferQueueRef queue);
186 OSStatus (* CMBufferQueueRemoveTrigger) (CMBufferQueueRef queue,
187 CMBufferQueueTriggerToken triggerToken);
188 OSStatus (* CMBufferQueueSetValidationCallback) (CMBufferQueueRef queue,
189 CMBufferQueueValidationCallback func, void *refCon);
191 CFStringRef * kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms;
192 CFStringRef * kCMSampleAttachmentKey_DependsOnOthers;
193 CMTime * kCMTimeInvalid;
196 struct _GstCMApiClass
198 GstDynApiClass parent_class;
201 GType gst_cm_api_get_type (void);
203 GstCMApi * gst_cm_api_obtain (GError ** error);