Tizen 2.0 Release
[framework/multimedia/gst-plugins-bad0.10.git] / sys / applemedia / cmapi.h
1 /*
2  * Copyright (C) 2010 Ole André Vadla Ravnås <oravnas@cisco.com>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef __GST_CM_API_H__
21 #define __GST_CM_API_H__
22
23 #include "dynapi.h"
24
25 #include <CoreFoundation/CoreFoundation.h>
26 #include "cvapi.h"
27
28 G_BEGIN_DECLS
29
30 typedef struct _GstCMApi GstCMApi;
31 typedef struct _GstCMApiClass GstCMApiClass;
32
33 typedef CFTypeRef FigBaseObjectRef;
34 typedef struct _FigBaseVTable FigBaseVTable;
35 typedef struct _FigBaseIface FigBaseIface;
36
37 typedef CFTypeRef CMFormatDescriptionRef;
38 typedef struct _CMVideoDimensions CMVideoDimensions;
39 typedef struct _CMTime CMTime;
40
41 typedef CFTypeRef CMBufferQueueRef;
42 typedef SInt32 CMBufferQueueTriggerCondition;
43 typedef struct _CMBufferQueueTriggerToken *CMBufferQueueTriggerToken;
44 typedef CFTypeRef CMSampleBufferRef;
45 typedef CFTypeRef CMBlockBufferRef;
46
47 typedef void (* CMBufferQueueTriggerCallback) (void *triggerRefcon,
48     CMBufferQueueTriggerToken triggerToken);
49 typedef Boolean (* CMBufferQueueValidationCallback) (CMBufferQueueRef queue,
50     CMSampleBufferRef buf, void *refCon);
51
52 enum _FigMediaType
53 {
54   kFigMediaTypeVideo = 'vide'
55 };
56
57 enum _FigCodecType
58 {
59   kComponentVideoUnsigned           = 'yuvs',
60   kFigVideoCodecType_JPEG_OpenDML   = 'dmb1',
61   kYUV420vCodecType                 = '420v'
62 };
63
64 enum _CMBufferQueueTriggerCondition
65 {
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
77 };
78
79 struct _FigBaseVTable
80 {
81   gsize unk;
82   FigBaseIface * base;
83   void * derived;
84 };
85
86 struct _FigBaseIface
87 {
88   gsize unk1;
89   gsize unk2;
90   gsize unk3;
91   OSStatus (* Invalidate) (FigBaseObjectRef obj);
92   OSStatus (* Finalize) (FigBaseObjectRef obj);
93   gpointer unk4;
94   OSStatus (* CopyProperty) (FigBaseObjectRef obj, CFTypeRef key, void *unk,
95       CFTypeRef * value);
96   OSStatus (* SetProperty) (FigBaseObjectRef obj, CFTypeRef key,
97       CFTypeRef value);
98 };
99
100 struct _CMVideoDimensions
101 {
102   UInt32 width;
103   UInt32 height;
104 };
105
106 struct _CMTime
107 {
108   UInt8 data[24];
109 };
110
111 struct _GstCMApi
112 {
113   GstDynApi parent;
114
115   FigBaseVTable * (* FigBaseObjectGetVTable) (FigBaseObjectRef obj);
116
117   void * (* CMGetAttachment) (CFTypeRef obj, CFStringRef attachmentKey,
118       UInt32 * foundWherePtr);
119
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);
131
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);
141
142   CMTime (* CMTimeMake) (int64_t value, int32_t timescale);
143
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);
165
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,
173       Byte ** dataPtr);
174   void (* FigBlockBufferRelease) (CMBlockBufferRef buf);
175   CMBlockBufferRef (* FigBlockBufferRetain) (CMBlockBufferRef buf);
176
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);
190
191   CFStringRef * kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms;
192   CFStringRef * kCMSampleAttachmentKey_DependsOnOthers;
193   CMTime * kCMTimeInvalid;
194 };
195
196 struct _GstCMApiClass
197 {
198   GstDynApiClass parent_class;
199 };
200
201 GType gst_cm_api_get_type (void);
202
203 GstCMApi * gst_cm_api_obtain (GError ** error);
204
205 G_END_DECLS
206
207 #endif