summaryrefslogtreecommitdiff
path: root/sys/applemedia/mioapi.h
blob: fe2cbd8ec458ecbf9563d579505d4f8758926cab (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
 * Copyright (C) 2010 Ole André Vadla Ravnås <oleavr@soundrop.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_MIO_API_H__
#define __GST_MIO_API_H__

#include "cmapi.h"

#include <CoreFoundation/CoreFoundation.h>

G_BEGIN_DECLS

typedef struct _GstMIOApi GstMIOApi;
typedef struct _GstMIOApiClass GstMIOApiClass;

#define TUNDRA_SYSTEM_OBJECT_ID 1

typedef int TundraObjectID;
typedef int TundraDeviceID;
typedef int TundraUnitID;

typedef enum _TundraStatus TundraStatus;
typedef enum _TundraVendor TundraVendor;
typedef enum _TundraScope TundraScope;
typedef enum _TundraUnit TundraUnit;
typedef enum _TundraProperty TundraProperty;

typedef enum _TundraDeviceTransportType TundraDeviceTransportType;

typedef struct _TundraTargetSpec TundraTargetSpec;
typedef struct _TundraFramerate TundraFramerate;

typedef struct _TundraGraph TundraGraph;
typedef struct _TundraNode TundraNode;

typedef struct _TundraOutputDelegate TundraOutputDelegate;

enum _TundraStatus
{
  kTundraSuccess = 0,
  kTundraNotSupported = -67456
};

enum _TundraVendor
{
  kTundraVendorApple = 'appl'
};

enum _TundraScope
{
  kTundraScopeGlobal = 'glob',
  kTundraScopeDAL    = 'dal ',
  kTundraScope2PRC   = '2prc', /* TODO: Investigate this one */
  kTundraScopeInput  = 'inpt',
  kTundraScopeVSyn   = 'vsyn'
};

enum _TundraUnit
{
  kTundraUnitInput  = 'tinp',
  kTundraUnitOutput = 'tout',
  kTundraUnitSync   = 'tefc'
};

enum _TundraProperty
{
  kTundraSystemPropertyDevices = 'dev#',

  kTundraObjectPropertyClass = 'clas',
  kTundraObjectPropertyCreator = 'oplg',
  kTundraObjectPropertyName = 'lnam',
  kTundraObjectPropertyUID = 'uid ',
  kTundraObjectPropertyVendor = 'lmak',

  kTundraDevicePropertyConfigApp = 'capp', /* CFString: com.apple.mediaio.TundraDeviceSetup */
  kTundraDevicePropertyExclusiveMode = 'ixna',
  kTundraDevicePropertyHogMode = 'oink',
  kTundraDevicePropertyModelUID = 'muid',
  kTundraDevicePropertyStreams = 'stm#',
  kTundraDevicePropertySuspendedByUser = 'sbyu',
  kTundraDevicePropertyTransportType = 'tran',

  kTundraStreamPropertyFormatDescriptions = 'pfta',
  kTundraStreamPropertyFormatDescription = 'pft ',
  kTundraStreamPropertyFrameRates = 'nfr#',
  kTundraStreamPropertyFrameRate = 'nfrt'
};

struct _TundraTargetSpec
{
  FourCharCode name;
  FourCharCode scope;
  FourCharCode vendor;
  FourCharCode unk1;
  FourCharCode unk2;
};

struct _TundraFramerate
{
  gdouble value;
};

enum _TundraUnitProperty
{
  kTundraInputPropertyDeviceID                = 302,

  kTundraOutputPropertyDelegate               = 5903,

  kTundraInputUnitProperty_SourcePath         = 6780,

  kTundraSyncPropertyClockProvider            = 7100,
  kTundraSyncPropertyMasterSynchronizer       = 7102,
  kTundraSyncPropertySynchronizationDirection = 7104
};

enum _TundraDeviceTransportType
{
  kTundraDeviceTransportInvalid = 0,
  kTundraDeviceTransportBuiltin = 'bltn',
  kTundraDeviceTransportScreen  = 'scrn',
  kTundraDeviceTransportUSB     = 'usb ',
};

typedef TundraStatus (* TundraOutputRenderFunc) (gpointer instance,
    gpointer unk1, gpointer unk2, gpointer unk3, CMSampleBufferRef sampleBuf);
typedef TundraStatus (* TundraOutputInitializeFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputUninitializeFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputStartFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputStopFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputResetFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputDeallocateFunc) (gpointer instance);
typedef gboolean (* TundraOutputCanRenderNowFunc) (gpointer instance,
    guint * unk);
typedef CFArrayRef (* TundraOutputAvailableFormatsFunc) (gpointer instance,
    gboolean ensureOnly);
typedef TundraStatus (* TundraOutputCopyClockFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputGetPropertyInfoFunc) (gpointer instance,
    guint propId);
typedef TundraStatus (* TundraOutputGetPropertyFunc) (gpointer instance,
    guint propId);
typedef TundraStatus (* TundraOutputSetPropertyFunc) (gpointer instance,
    guint propId);

#pragma pack(push, 1)

struct _TundraOutputDelegate
{
  int unk1;
  gpointer instance;
  TundraOutputRenderFunc Render;
  TundraOutputInitializeFunc Initialize;
  TundraOutputUninitializeFunc Uninitialize;
  TundraOutputStartFunc Start;
  TundraOutputStopFunc Stop;
  TundraOutputResetFunc Reset;
  TundraOutputDeallocateFunc Deallocate;
  TundraOutputCanRenderNowFunc CanRenderNow;
  TundraOutputAvailableFormatsFunc AvailableFormats;
  TundraOutputCopyClockFunc CopyClock;
  TundraOutputGetPropertyInfoFunc GetPropertyInfo;
  TundraOutputGetPropertyFunc GetProperty;
  TundraOutputSetPropertyFunc SetProperty;
};

#pragma pack(pop)

struct _GstMIOApi
{
  GstDynApi parent;

  TundraStatus (* TundraGraphCreate) (CFAllocatorRef allocator,
      TundraGraph ** graph);
  void (* TundraGraphRelease) (TundraGraph * graph);
  TundraStatus (* TundraGraphCreateNode) (TundraGraph * graph,
      gint nodeId, UInt32 unk1, UInt32 unk2, TundraTargetSpec * spec,
      UInt32 unk3, TundraUnitID * node);
  TundraStatus (* TundraGraphGetNodeInfo) (TundraGraph * graph,
      gint nodeId, UInt32 unk1, UInt32 unk2, UInt32 unk3, UInt32 unk4,
      gpointer * info);
  TundraStatus (* TundraGraphSetProperty) (TundraGraph * graph,
      gint nodeId, UInt32 unk1, guint propId, UInt32 unk2, UInt32 unk3,
      gpointer data, guint size);
  TundraStatus (* TundraGraphConnectNodeInput) (TundraGraph * graph,
      TundraUnitID from_node, guint from_bus,
      TundraUnitID to_node, guint to_bus);
  TundraStatus (* TundraGraphInitialize) (TundraGraph * graph);
  TundraStatus (* TundraGraphUninitialize) (TundraGraph * graph);
  TundraStatus (* TundraGraphStart) (TundraGraph * graph);
  TundraStatus (* TundraGraphStop) (TundraGraph * graph);

  TundraStatus (* TundraObjectGetPropertyDataSize) (TundraObjectID obj,
      TundraTargetSpec * spec, UInt32 contextSize, void * context, guint * size);
  TundraStatus (* TundraObjectGetPropertyData) (TundraObjectID obj,
      TundraTargetSpec * spec, UInt32 contextSize, void * context, guint * size,
      gpointer data);
  TundraStatus (* TundraObjectIsPropertySettable) (TundraObjectID obj,
      TundraTargetSpec * spec, Boolean *isSettable);
  TundraStatus (* TundraObjectSetPropertyData) (TundraObjectID obj,
      TundraTargetSpec * spec, gpointer unk1, gpointer unk2, guint size,
      gpointer data);

  CFStringRef * kTundraSampleBufferAttachmentKey_SequenceNumber;
  CFStringRef * kTundraSampleBufferAttachmentKey_HostTime;
};

struct _GstMIOApiClass
{
  GstDynApiClass parent_class;
};

GstMIOApi * gst_mio_api_obtain (GError ** error);

gpointer gst_mio_object_get_pointer (gint obj, TundraTargetSpec * pspec,
    GstMIOApi * mio);
gchar * gst_mio_object_get_string (gint obj, TundraTargetSpec * pspec,
    GstMIOApi * mio);
guint32 gst_mio_object_get_uint32 (gint obj, TundraTargetSpec * pspec,
    GstMIOApi * mio);
gchar * gst_mio_object_get_fourcc (gint obj, TundraTargetSpec * pspec,
    GstMIOApi * mio);
GArray * gst_mio_object_get_array (gint obj, TundraTargetSpec * pspec,
    guint element_size, GstMIOApi * mio);
GArray * gst_mio_object_get_array_full (gint obj, TundraTargetSpec * pspec,
    guint ctx_size, gpointer ctx, guint element_size, GstMIOApi * mio);
gpointer gst_mio_object_get_raw (gint obj, TundraTargetSpec * pspec,
    guint * size, GstMIOApi * mio);

gchar * gst_mio_fourcc_to_string (guint32 fcc);

G_END_DECLS

#endif