typedef struct _GstCelApi GstCelApi;
typedef struct _GstCelApiClass GstCelApiClass;
+enum
+{
+ kCelError_ResourceBusy = -12780
+};
+
struct _GstCelApi
{
GstDynApi parent;
- FigStatus (* FigCreateCaptureDevicesAndStreamsForPreset)
+ OSStatus (* FigCreateCaptureDevicesAndStreamsForPreset)
(CFAllocatorRef allocator, CFStringRef capturePreset,
CFDictionaryRef audioOptions,
FigCaptureDeviceRef * outVideoDevice,
#include "dynapi-internal.h"
-#define CM_FRAMEWORK_PATH "/System/Library/PrivateFrameworks/" \
+#include <gmodule.h>
+
+#define CM_FRAMEWORK_PATH "/System/Library/Frameworks/" \
+ "CoreMedia.framework/CoreMedia"
+#define CM_FRAMEWORK_PATH_OLD "/System/Library/PrivateFrameworks/" \
"CoreMedia.framework/CoreMedia"
G_DEFINE_TYPE (GstCMApi, gst_cm_api, GST_TYPE_DYN_API);
static const GstDynSymSpec symbols[] = {
SYM_SPEC (FigBaseObjectGetVTable),
- SYM_SPEC (FigGetAttachment),
+ SYM_SPEC (CMGetAttachment),
SYM_SPEC (FigFormatDescriptionRelease),
SYM_SPEC (FigFormatDescriptionRetain),
- SYM_SPEC (FigFormatDescriptionEqual),
- SYM_SPEC (FigFormatDescriptionGetExtension),
- SYM_SPEC (FigFormatDescriptionGetMediaType),
- SYM_SPEC (FigFormatDescriptionGetMediaSubType),
+ SYM_SPEC (CMFormatDescriptionEqual),
+ SYM_SPEC (CMFormatDescriptionGetExtension),
+ SYM_SPEC (CMFormatDescriptionGetMediaType),
+ SYM_SPEC (CMFormatDescriptionGetMediaSubType),
- SYM_SPEC (FigVideoFormatDescriptionCreate),
+ SYM_SPEC (CMVideoFormatDescriptionCreate),
SYM_SPEC
(FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom),
- SYM_SPEC (FigVideoFormatDescriptionGetDimensions),
-
- SYM_SPEC (FigTimeMake),
-
- SYM_SPEC (FigSampleBufferCreate),
- SYM_SPEC (FigSampleBufferDataIsReady),
- SYM_SPEC (FigSampleBufferGetDataBuffer),
- SYM_SPEC (FigSampleBufferGetFormatDescription),
- SYM_SPEC (FigSampleBufferGetImageBuffer),
- SYM_SPEC (FigSampleBufferGetNumSamples),
- SYM_SPEC (FigSampleBufferGetSampleAttachmentsArray),
- SYM_SPEC (FigSampleBufferGetSampleSize),
+ SYM_SPEC (CMVideoFormatDescriptionGetDimensions),
+
+ SYM_SPEC (CMTimeMake),
+
+ SYM_SPEC (CMSampleBufferCreate),
+ SYM_SPEC (CMSampleBufferDataIsReady),
+ SYM_SPEC (CMSampleBufferGetDataBuffer),
+ SYM_SPEC (CMSampleBufferGetFormatDescription),
+ SYM_SPEC (CMSampleBufferGetImageBuffer),
+ SYM_SPEC (CMSampleBufferGetNumSamples),
+ SYM_SPEC (CMSampleBufferGetSampleAttachmentsArray),
+ SYM_SPEC (CMSampleBufferGetSampleSize),
SYM_SPEC (FigSampleBufferRelease),
SYM_SPEC (FigSampleBufferRetain),
- SYM_SPEC (FigBlockBufferCreateWithMemoryBlock),
- SYM_SPEC (FigBlockBufferGetDataLength),
- SYM_SPEC (FigBlockBufferGetDataPointer),
+ SYM_SPEC (CMBlockBufferCreateWithMemoryBlock),
+ SYM_SPEC (CMBlockBufferGetDataLength),
+ SYM_SPEC (CMBlockBufferGetDataPointer),
SYM_SPEC (FigBlockBufferRelease),
SYM_SPEC (FigBlockBufferRetain),
- SYM_SPEC (FigBufferQueueDequeueAndRetain),
- SYM_SPEC (FigBufferQueueGetBufferCount),
- SYM_SPEC (FigBufferQueueIsEmpty),
+ SYM_SPEC (CMBufferQueueDequeueAndRetain),
+ SYM_SPEC (CMBufferQueueGetBufferCount),
+ SYM_SPEC (CMBufferQueueIsEmpty),
SYM_SPEC (FigBufferQueueRelease),
- SYM_SPEC (FigBufferQueueSetValidationCallback),
+ SYM_SPEC (CMBufferQueueSetValidationCallback),
- SYM_SPEC (kFigFormatDescriptionExtension_SampleDescriptionExtensionAtoms),
- SYM_SPEC (kFigSampleAttachmentKey_DependsOnOthers),
- SYM_SPEC (kFigTimeInvalid),
+ SYM_SPEC (kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms),
+ SYM_SPEC (kCMSampleAttachmentKey_DependsOnOthers),
+ SYM_SPEC (kCMTimeInvalid),
{NULL, 0},
};
-
- return _gst_dyn_api_new (gst_cm_api_get_type (), CM_FRAMEWORK_PATH, symbols,
- error);
+ GstCMApi *result;
+ GModule *module;
+
+ /* We cannot stat() the library as it may not be present on the filesystem.
+ * This is the case on newer versions of iOS where system libraries are all
+ * part of dyld_shared_cache... */
+ module = g_module_open (CM_FRAMEWORK_PATH, 0);
+ if (module != NULL) {
+ result = _gst_dyn_api_new (gst_cm_api_get_type (), CM_FRAMEWORK_PATH,
+ symbols, error);
+ g_module_close (module);
+ } else {
+ GstDynSymSpec *old_symbols;
+ guint i;
+
+ old_symbols = g_memdup (symbols, sizeof (symbols));
+ for (i = 0; old_symbols[i].name != NULL; i++) {
+ const gchar *name = old_symbols[i].name;
+ const gchar *translated_name;
+
+ if (g_str_has_prefix (name, "CM"))
+ translated_name = g_strconcat ("Fig", name + 2, NULL);
+ else if (g_str_has_prefix (name, "kCM"))
+ translated_name = g_strconcat ("kFig", name + 3, NULL);
+ else
+ translated_name = g_strdup (name);
+
+ old_symbols[i].name = translated_name;
+ }
+
+ result = _gst_dyn_api_new (gst_cm_api_get_type (), CM_FRAMEWORK_PATH_OLD,
+ old_symbols, error);
+
+ for (i = 0; old_symbols[i].name != NULL; i++)
+ g_free ((gpointer) old_symbols[i].name);
+ g_free (old_symbols);
+ }
+
+ return result;
}
typedef struct _GstCMApi GstCMApi;
typedef struct _GstCMApiClass GstCMApiClass;
-typedef enum _FigStatus FigStatus;
-
typedef CFTypeRef FigBaseObjectRef;
typedef struct _FigBaseVTable FigBaseVTable;
typedef struct _FigBaseIface FigBaseIface;
-typedef struct _FigFormatDescription FigFormatDescription;
-typedef struct _FigVideoDimensions FigVideoDimensions;
-typedef struct _FigTime FigTime;
-
-typedef CFTypeRef FigBufferQueueRef;
+typedef CFTypeRef CMFormatDescriptionRef;
+typedef struct _CMVideoDimensions CMVideoDimensions;
+typedef struct _CMTime CMTime;
-typedef struct _FigSampleBuffer FigSampleBuffer;
-typedef struct _FigDataBuffer FigDataBuffer;
-typedef struct _FigBlockBuffer FigBlockBuffer;
+typedef CFTypeRef CMBufferQueueRef;
-typedef Boolean (* FigBufferQueueValidateFunc) (FigBufferQueueRef queue,
- FigSampleBuffer *buf, void *refCon);
+typedef CFTypeRef CMSampleBufferRef;
+typedef CFTypeRef CMBlockBufferRef;
-enum _FigStatus
-{
- kFigSuccess = 0,
-
- kFigResourceBusy = -12780
-};
+typedef Boolean (* CMBufferQueueValidateFunc) (CMBufferQueueRef queue,
+ CMSampleBufferRef buf, void *refCon);
enum _FigMediaType
{
gsize unk1;
gsize unk2;
gsize unk3;
- FigStatus (* Invalidate) (FigBaseObjectRef obj);
- FigStatus (* Finalize) (FigBaseObjectRef obj);
+ OSStatus (* Invalidate) (FigBaseObjectRef obj);
+ OSStatus (* Finalize) (FigBaseObjectRef obj);
gpointer unk4;
- FigStatus (* CopyProperty) (FigBaseObjectRef obj, CFTypeRef key, void *unk,
+ OSStatus (* CopyProperty) (FigBaseObjectRef obj, CFTypeRef key, void *unk,
CFTypeRef * value);
- FigStatus (* SetProperty) (FigBaseObjectRef obj, CFTypeRef key,
+ OSStatus (* SetProperty) (FigBaseObjectRef obj, CFTypeRef key,
CFTypeRef value);
};
-struct _FigVideoDimensions
+struct _CMVideoDimensions
{
UInt32 width;
UInt32 height;
};
-struct _FigTime
+struct _CMTime
{
UInt8 data[24];
};
FigBaseVTable * (* FigBaseObjectGetVTable) (FigBaseObjectRef obj);
- void * (* FigGetAttachment) (void * obj, CFStringRef attachmentKey,
+ void * (* CMGetAttachment) (CFTypeRef obj, CFStringRef attachmentKey,
UInt32 * foundWherePtr);
- void (* FigFormatDescriptionRelease) (FigFormatDescription * desc);
- FigFormatDescription * (* FigFormatDescriptionRetain) (
- FigFormatDescription * desc);
- Boolean (* FigFormatDescriptionEqual) (FigFormatDescription * desc1,
- FigFormatDescription * desc2);
- CFTypeRef (* FigFormatDescriptionGetExtension) (
- const FigFormatDescription * desc, CFStringRef extensionKey);
- UInt32 (* FigFormatDescriptionGetMediaType) (
- const FigFormatDescription * desc);
- UInt32 (* FigFormatDescriptionGetMediaSubType) (
- const FigFormatDescription * desc);
-
- FigStatus (* FigVideoFormatDescriptionCreate) (
+ void (* FigFormatDescriptionRelease) (CMFormatDescriptionRef desc);
+ CMFormatDescriptionRef (* FigFormatDescriptionRetain) (
+ CMFormatDescriptionRef desc);
+ Boolean (* CMFormatDescriptionEqual) (CMFormatDescriptionRef desc1,
+ CMFormatDescriptionRef desc2);
+ CFTypeRef (* CMFormatDescriptionGetExtension) (
+ const CMFormatDescriptionRef desc, CFStringRef extensionKey);
+ UInt32 (* CMFormatDescriptionGetMediaType) (
+ const CMFormatDescriptionRef desc);
+ UInt32 (* CMFormatDescriptionGetMediaSubType) (
+ const CMFormatDescriptionRef desc);
+
+ OSStatus (* CMVideoFormatDescriptionCreate) (
CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
- CFDictionaryRef extensions, FigFormatDescription ** desc);
- FigStatus (* FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom)
+ CFDictionaryRef extensions, CMFormatDescriptionRef * desc);
+ OSStatus (* FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom)
(CFAllocatorRef allocator, UInt32 formatId, UInt32 width, UInt32 height,
UInt32 atomId, const UInt8 * data, CFIndex len,
- FigFormatDescription ** formatDesc);
- FigVideoDimensions (* FigVideoFormatDescriptionGetDimensions) (
- const FigFormatDescription * desc);
+ CMFormatDescriptionRef * formatDesc);
+ CMVideoDimensions (* CMVideoFormatDescriptionGetDimensions) (
+ const CMFormatDescriptionRef desc);
- FigTime (* FigTimeMake) (UInt64 numerator, UInt32 denominator);
+ CMTime (* CMTimeMake) (int64_t value, int32_t timescale);
- FigStatus (* FigSampleBufferCreate) (CFAllocatorRef allocator,
- FigBlockBuffer * blockBuf, Boolean unkBool, UInt32 unkDW1, UInt32 unkDW2,
- FigFormatDescription * fmtDesc, UInt32 unkCountA, UInt32 unkCountB,
+ OSStatus (* CMSampleBufferCreate) (CFAllocatorRef allocator,
+ CMBlockBufferRef blockBuf, Boolean unkBool, UInt32 unkDW1, UInt32 unkDW2,
+ CMFormatDescriptionRef fmtDesc, UInt32 unkCountA, UInt32 unkCountB,
const void * unkTimeData, UInt32 unkCountC, const void * unkDWordData,
- FigSampleBuffer ** sampleBuffer);
- Boolean (* FigSampleBufferDataIsReady) (
- const FigSampleBuffer * buf);
- FigBlockBuffer * (* FigSampleBufferGetDataBuffer) (
- const FigSampleBuffer * buf);
- FigFormatDescription * (* FigSampleBufferGetFormatDescription) (
- const FigSampleBuffer * buf);
- CVImageBufferRef (* FigSampleBufferGetImageBuffer) (
- const FigSampleBuffer * buf);
- SInt32 (* FigSampleBufferGetNumSamples) (
- const FigSampleBuffer * buf);
- CFArrayRef (* FigSampleBufferGetSampleAttachmentsArray) (
- const FigSampleBuffer * buf, SInt32 sampleIndex);
- SInt32 (* FigSampleBufferGetSampleSize) (
- const FigSampleBuffer * buf, SInt32 sampleIndex);
- void (* FigSampleBufferRelease) (FigSampleBuffer * buf);
- FigSampleBuffer * (* FigSampleBufferRetain) (FigSampleBuffer * buf);
-
- FigStatus (* FigBlockBufferCreateWithMemoryBlock)
+ CMSampleBufferRef * sampleBuffer);
+ Boolean (* CMSampleBufferDataIsReady) (
+ const CMSampleBufferRef buf);
+ CMBlockBufferRef (* CMSampleBufferGetDataBuffer) (
+ const CMSampleBufferRef buf);
+ CMFormatDescriptionRef (* CMSampleBufferGetFormatDescription) (
+ const CMSampleBufferRef buf);
+ CVImageBufferRef (* CMSampleBufferGetImageBuffer) (
+ const CMSampleBufferRef buf);
+ SInt32 (* CMSampleBufferGetNumSamples) (
+ const CMSampleBufferRef buf);
+ CFArrayRef (* CMSampleBufferGetSampleAttachmentsArray) (
+ const CMSampleBufferRef buf, SInt32 sampleIndex);
+ SInt32 (* CMSampleBufferGetSampleSize) (
+ const CMSampleBufferRef buf, SInt32 sampleIndex);
+ void (* FigSampleBufferRelease) (CMSampleBufferRef buf);
+ CMSampleBufferRef (* FigSampleBufferRetain) (CMSampleBufferRef buf);
+
+ OSStatus (* CMBlockBufferCreateWithMemoryBlock)
(CFAllocatorRef allocator, Byte * data, UInt32 size,
CFAllocatorRef dataAllocator, void *unk1, UInt32 sizeA, UInt32 sizeB,
- Boolean unkBool, FigBlockBuffer ** blockBuffer);
- SInt32 (* FigBlockBufferGetDataLength) (const FigBlockBuffer * buf);
- FigStatus (* FigBlockBufferGetDataPointer) (
- const FigBlockBuffer * buf, UInt32 unk1, UInt32 unk2, UInt32 unk3,
+ Boolean unkBool, CMBlockBufferRef * blockBuffer);
+ SInt32 (* CMBlockBufferGetDataLength) (const CMBlockBufferRef buf);
+ OSStatus (* CMBlockBufferGetDataPointer) (
+ const CMBlockBufferRef buf, UInt32 unk1, UInt32 unk2, UInt32 unk3,
Byte ** dataPtr);
- void (* FigBlockBufferRelease) (FigBlockBuffer * buf);
- FigBlockBuffer * (* FigBlockBufferRetain) (FigBlockBuffer * buf);
-
- FigSampleBuffer * (* FigBufferQueueDequeueAndRetain)
- (FigBufferQueueRef queue);
- CFIndex (* FigBufferQueueGetBufferCount) (FigBufferQueueRef queue);
- Boolean (* FigBufferQueueIsEmpty) (FigBufferQueueRef queue);
- void (* FigBufferQueueRelease) (FigBufferQueueRef queue);
- FigStatus (* FigBufferQueueSetValidationCallback)
- (FigBufferQueueRef queue, FigBufferQueueValidateFunc func, void *refCon);
-
- CFStringRef * kFigFormatDescriptionExtension_SampleDescriptionExtensionAtoms;
- CFStringRef * kFigSampleAttachmentKey_DependsOnOthers;
- FigTime * kFigTimeInvalid;
+ void (* FigBlockBufferRelease) (CMBlockBufferRef buf);
+ CMBlockBufferRef (* FigBlockBufferRetain) (CMBlockBufferRef buf);
+
+ CMSampleBufferRef (* CMBufferQueueDequeueAndRetain)
+ (CMBufferQueueRef queue);
+ CFIndex (* CMBufferQueueGetBufferCount) (CMBufferQueueRef queue);
+ Boolean (* CMBufferQueueIsEmpty) (CMBufferQueueRef queue);
+ void (* FigBufferQueueRelease) (CMBufferQueueRef queue);
+ OSStatus (* CMBufferQueueSetValidationCallback)
+ (CMBufferQueueRef queue, CMBufferQueueValidateFunc func, void *refCon);
+
+ CFStringRef * kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms;
+ CFStringRef * kCMSampleAttachmentKey_DependsOnOthers;
+ CMTime * kCMTimeInvalid;
};
struct _GstCMApiClass
}
GstBuffer *
-gst_core_media_buffer_new (GstCoreMediaCtx * ctx, FigSampleBuffer * sample_buf)
+gst_core_media_buffer_new (GstCoreMediaCtx * ctx, CMSampleBufferRef sample_buf)
{
GstCVApi *cv = ctx->cv;
GstCMApi *cm = ctx->cm;
CVImageBufferRef image_buf;
CVPixelBufferRef pixel_buf;
- FigBlockBuffer *block_buf;
+ CMBlockBufferRef block_buf;
Byte *data = NULL;
UInt32 size;
- FigStatus status;
+ OSStatus status;
GstCoreMediaBuffer *buf;
- image_buf = cm->FigSampleBufferGetImageBuffer (sample_buf);
+ image_buf = cm->CMSampleBufferGetImageBuffer (sample_buf);
pixel_buf = NULL;
- block_buf = cm->FigSampleBufferGetDataBuffer (sample_buf);
+ block_buf = cm->CMSampleBufferGetDataBuffer (sample_buf);
if (image_buf != NULL &&
CFGetTypeID (image_buf) == cv->CVPixelBufferGetTypeID ()) {
cv->CVPixelBufferGetHeight (pixel_buf);
}
} else if (block_buf != NULL) {
- status = cm->FigBlockBufferGetDataPointer (block_buf, 0, 0, 0, &data);
- if (status != kFigSuccess)
+ status = cm->CMBlockBufferGetDataPointer (block_buf, 0, 0, 0, &data);
+ if (status != noErr)
goto error;
- size = cm->FigBlockBufferGetDataLength (block_buf);
+ size = cm->CMBlockBufferGetDataLength (block_buf);
} else {
goto error;
}
GstBuffer buffer;
GstCoreMediaCtx * ctx;
- FigSampleBuffer * sample_buf;
+ CMSampleBufferRef sample_buf;
CVImageBufferRef image_buf;
CVPixelBufferRef pixel_buf;
- FigBlockBuffer * block_buf;
+ CMBlockBufferRef block_buf;
};
struct _GstCoreMediaBufferClass
GType gst_core_media_buffer_get_type (void) G_GNUC_CONST;
GstBuffer * gst_core_media_buffer_new (GstCoreMediaCtx * ctx,
- FigSampleBuffer * sample_buf);
+ CMSampleBufferRef sample_buf);
CVPixelBufferRef gst_core_media_buffer_get_pixel_buffer
(GstCoreMediaBuffer * buf);
static gboolean gst_iphone_camera_src_parse_imager_format
(GstIPhoneCameraSrc * self, guint index, CFDictionaryRef imager_format,
GstIPhoneCameraFormat * format);
-static FigStatus gst_iphone_camera_src_set_device_property_i32
+static OSStatus gst_iphone_camera_src_set_device_property_i32
(GstIPhoneCameraSrc * self, CFStringRef name, SInt32 value);
-static FigStatus gst_iphone_camera_src_set_device_property_cstr
+static OSStatus gst_iphone_camera_src_set_device_property_cstr
(GstIPhoneCameraSrc * self, const gchar * name, const gchar * value);
static GstPushSrcClass *parent_class;
}
static Boolean
-gst_iphone_camera_src_validate (FigBufferQueueRef queue, FigSampleBuffer * buf,
+gst_iphone_camera_src_validate (CMBufferQueueRef queue, CMSampleBufferRef buf,
void *refCon)
{
GstIPhoneCameraSrc *self = GST_IPHONE_CAMERA_SRC_CAST (refCon);
{
GstIPhoneCameraSrc *self = GST_IPHONE_CAMERA_SRC_CAST (pushsrc);
GstCMApi *cm = self->ctx->cm;
- FigSampleBuffer *sbuf = NULL;
+ CMSampleBufferRef sbuf = NULL;
GstClock *clock;
GstClockTime ts;
BUFQUEUE_LOCK (self);
while (self->running && !self->has_pending)
BUFQUEUE_WAIT (self);
- sbuf = cm->FigBufferQueueDequeueAndRetain (self->queue);
- self->has_pending = !cm->FigBufferQueueIsEmpty (self->queue);
+ sbuf = cm->CMBufferQueueDequeueAndRetain (self->queue);
+ self->has_pending = !cm->CMBufferQueueIsEmpty (self->queue);
BUFQUEUE_UNLOCK (self);
if (G_UNLIKELY (!self->running))
GstCMApi *cm = NULL;
GstMTApi *mt = NULL;
GstCelApi *cel = NULL;
- FigStatus status;
+ OSStatus status;
FigCaptureDeviceRef device = NULL;
FigBaseObjectRef device_base;
FigBaseVTable *device_vt;
FigBaseObjectRef stream_base;
FigBaseVTable *stream_vt;
FigCaptureStreamIface *stream_iface;
- FigBufferQueueRef queue = NULL;
+ CMBufferQueueRef queue = NULL;
ctx = gst_core_media_ctx_new (GST_API_CORE_VIDEO | GST_API_CORE_MEDIA
| GST_API_MEDIA_TOOLBOX | GST_API_CELESTIAL, &error);
status = cel->FigCreateCaptureDevicesAndStreamsForPreset (NULL,
*(cel->kFigRecorderCapturePreset_VideoRecording), NULL,
&device, &stream, NULL, NULL);
- if (status == kFigResourceBusy)
+ if (status == kCelError_ResourceBusy)
goto device_busy;
- else if (status != kFigSuccess)
+ else if (status != noErr)
goto unexpected_error;
device_base = mt->FigCaptureDeviceGetFigBaseObject (device);
status = stream_vt->base->CopyProperty (stream_base,
*(mt->kFigCaptureStreamProperty_BufferQueue), NULL, &queue);
- if (status != kFigSuccess)
+ if (status != noErr)
goto unexpected_error;
self->has_pending = FALSE;
- cm->FigBufferQueueSetValidationCallback (queue,
+ cm->CMBufferQueueSetValidationCallback (queue,
gst_iphone_camera_src_validate, self);
self->ctx = ctx;
unexpected_error:
{
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
- ("unexpected error while opening device (%d)", status), (NULL));
+ ("unexpected error while opening device (%d)", (gint) status), (NULL));
goto any_error;
}
any_error:
static void
gst_iphone_camera_src_ensure_device_caps_and_formats (GstIPhoneCameraSrc * self)
{
- FigStatus status;
+ OSStatus status;
CFArrayRef iformats = NULL;
CFIndex format_count, i;
status = self->device_iface_base->CopyProperty (self->device,
*(self->ctx->mt->kFigCaptureDeviceProperty_ImagerSupportedFormatsArray),
NULL, (CFTypeRef *) & iformats);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
format_count = CFArrayGetCount (iformats);
{
gboolean result = FALSE;
GstMTApi *mt = self->ctx->mt;
- FigStatus status;
+ OSStatus status;
SInt32 framerate;
status = gst_iphone_camera_src_set_device_property_i32 (self,
*(mt->kFigCaptureDeviceProperty_ImagerFormatDescription), format->index);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
framerate = format->fps_n / format->fps_d;
status = gst_iphone_camera_src_set_device_property_i32 (self,
*(mt->kFigCaptureDeviceProperty_ImagerFrameRate), framerate);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
status = gst_iphone_camera_src_set_device_property_i32 (self,
*(mt->kFigCaptureDeviceProperty_ImagerMinimumFrameRate), framerate);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
status = gst_iphone_camera_src_set_device_property_cstr (self,
"ColorRange", "ColorRangeSDVideo");
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
status = self->stream_iface->Start (self->stream);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
GST_DEBUG_OBJECT (self, "configured format %d (%d x %d @ %d Hz)",
{
GstCMApi *cm = self->ctx->cm;
GstMTApi *mt = self->ctx->mt;
- const FigFormatDescription *desc;
- FigVideoDimensions dim;
+ CMFormatDescriptionRef desc;
+ CMVideoDimensions dim;
UInt32 subtype;
CFNumberRef framerate_value;
SInt32 fps_n;
desc = CFDictionaryGetValue (imager_format,
*(mt->kFigImagerSupportedFormat_FormatDescription));
- dim = cm->FigVideoFormatDescriptionGetDimensions (desc);
+ dim = cm->CMVideoFormatDescriptionGetDimensions (desc);
format->width = dim.width;
format->height = dim.height;
- subtype = cm->FigFormatDescriptionGetMediaSubType (desc);
+ subtype = cm->CMFormatDescriptionGetMediaSubType (desc);
switch (subtype) {
case kComponentVideoUnsigned:
return FALSE;
}
-static FigStatus
+static OSStatus
gst_iphone_camera_src_set_device_property_i32 (GstIPhoneCameraSrc * self,
CFStringRef name, SInt32 value)
{
- FigStatus status;
+ OSStatus status;
CFNumberRef number;
number = CFNumberCreate (NULL, kCFNumberSInt32Type, &value);
return status;
}
-static FigStatus
+static OSStatus
gst_iphone_camera_src_set_device_property_cstr (GstIPhoneCameraSrc * self,
const gchar * name, const gchar * value)
{
- FigStatus status;
+ OSStatus status;
CFStringRef name_str, value_str;
name_str = CFStringCreateWithCStringNoCopy (NULL, name,
FigCaptureStreamRef stream;
FigBaseIface *stream_iface_base;
FigCaptureStreamIface *stream_iface;
- FigBufferQueueRef queue;
+ CMBufferQueueRef queue;
GstCaps *device_caps;
GArray *device_formats;
GstClockTime duration;
};
typedef TundraStatus (* TundraOutputRenderFunc) (gpointer instance,
- gpointer unk1, gpointer unk2, gpointer unk3, FigSampleBuffer * sampleBuf);
+ gpointer unk1, gpointer unk2, gpointer unk3, CMSampleBufferRef sampleBuf);
typedef TundraStatus (* TundraOutputInitializeFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputUninitializeFunc) (gpointer instance);
typedef TundraStatus (* TundraOutputStartFunc) (gpointer instance);
struct _GstMIOVideoFormat
{
TundraObjectID stream;
- FigFormatDescription *desc;
+ CMFormatDescriptionRef desc;
UInt32 type;
- FigVideoDimensions dim;
+ CMVideoDimensions dim;
};
struct _GstMIOSetFormatCtx
}
}
-FigFormatDescription *
+CMFormatDescriptionRef
gst_mio_video_device_get_selected_format (GstMIOVideoDevice * self)
{
return self->selected_format;
GstMIOVideoFormat fmt;
fmt.stream = stream;
- fmt.desc = (FigFormatDescription *)
+ fmt.desc = (CMFormatDescriptionRef)
CFArrayGetValueAtIndex (formats, fmt_idx);
- if (cm->FigFormatDescriptionGetMediaType (fmt.desc) != kFigMediaTypeVideo)
+ if (cm->CMFormatDescriptionGetMediaType (fmt.desc) != kFigMediaTypeVideo)
continue;
- fmt.type = cm->FigFormatDescriptionGetMediaSubType (fmt.desc);
- fmt.dim = cm->FigVideoFormatDescriptionGetDimensions (fmt.desc);
+ fmt.type = cm->CMFormatDescriptionGetMediaSubType (fmt.desc);
+ fmt.dim = cm->CMVideoFormatDescriptionGetDimensions (fmt.desc);
func (self, &fmt, user_data);
}
g_print (" <%u formats>\n", (guint) num_formats);
for (fmt_idx = 0; fmt_idx != num_formats; fmt_idx++) {
- const FigFormatDescription *fmt;
+ CMFormatDescriptionRef fmt;
gchar *media_type;
gchar *media_sub_type;
- FigVideoDimensions dim;
+ CMVideoDimensions dim;
GArray *rates;
guint rate_idx;
fmt = CFArrayGetValueAtIndex (formats, fmt_idx);
media_type = gst_mio_fourcc_to_string
- (cm->FigFormatDescriptionGetMediaType (fmt));
+ (cm->CMFormatDescriptionGetMediaType (fmt));
media_sub_type = gst_mio_fourcc_to_string
- (cm->FigFormatDescriptionGetMediaSubType (fmt));
- dim = cm->FigVideoFormatDescriptionGetDimensions (fmt);
+ (cm->CMFormatDescriptionGetMediaSubType (fmt));
+ dim = cm->CMVideoFormatDescriptionGetDimensions (fmt);
g_print (" format[%u]: MediaType='%s' MediaSubType='%s' %ux%u\n",
(guint) fmt_idx, media_type, media_sub_type,
gchar *cached_name;
TundraDeviceTransportType cached_transport;
GstCaps *cached_caps;
- FigFormatDescription *selected_format;
+ CMFormatDescriptionRef selected_format;
gint selected_fps_n, selected_fps_d;
};
GstCaps * gst_mio_video_device_get_available_caps (GstMIOVideoDevice * self);
gboolean gst_mio_video_device_set_caps (GstMIOVideoDevice * self,
GstCaps * caps);
-FigFormatDescription * gst_mio_video_device_get_selected_format (
+CMFormatDescriptionRef gst_mio_video_device_get_selected_format (
GstMIOVideoDevice * self);
GstClockTime gst_mio_video_device_get_duration (GstMIOVideoDevice * self);
{
GstMIOVideoSrc *self = GST_MIO_VIDEO_SRC_CAST (pushsrc);
GstCMApi *cm = self->ctx->cm;
- FigFormatDescription *format;
+ CMFormatDescriptionRef format;
FRAME_QUEUE_LOCK (self);
while (self->running && g_queue_is_empty (self->queue))
if (G_UNLIKELY (!self->running))
goto shutting_down;
- format = cm->FigSampleBufferGetFormatDescription
+ format = cm->CMSampleBufferGetFormatDescription
(GST_CORE_MEDIA_BUFFER (*buf)->sample_buf);
if (self->prev_format != NULL &&
- !cm->FigFormatDescriptionEqual (format, self->prev_format)) {
+ !cm->CMFormatDescriptionEqual (format, self->prev_format)) {
goto unexpected_format;
}
cm->FigFormatDescriptionRelease (self->prev_format);
}
static GstClockTime
-gst_mio_video_src_get_timestamp (GstMIOVideoSrc * self, FigSampleBuffer * sbuf)
+gst_mio_video_src_get_timestamp (GstMIOVideoSrc * self, CMSampleBufferRef sbuf)
{
GstClock *clock;
GstClockTime base_time;
/*
* If the current clock is GstSystemClock, we know that it's using the
* CoreAudio/CoreVideo clock. As such we may use the timestamp attached
- * to the FigSampleBuffer.
+ * to the CMSampleBuffer.
*/
if (G_TYPE_FROM_INSTANCE (clock) == GST_TYPE_SYSTEM_CLOCK) {
CFNumberRef number;
UInt64 ht;
- number = self->ctx->cm->FigGetAttachment (sbuf,
+ number = self->ctx->cm->CMGetAttachment (sbuf,
*self->ctx->mio->kTundraSampleBufferAttachmentKey_HostTime, NULL);
if (number != NULL && CFNumberGetValue (number, kCFNumberSInt64Type, &ht)) {
timestamp = gst_util_uint64_scale_int (ht,
static TundraStatus
gst_mio_video_src_output_render (gpointer instance, gpointer unk1,
- gpointer unk2, gpointer unk3, FigSampleBuffer * sample_buf)
+ gpointer unk2, gpointer unk3, CMSampleBufferRef sample_buf)
{
GstMIOVideoSrc *self = GST_MIO_VIDEO_SRC_CAST (instance);
GstBuffer *buf;
if (G_UNLIKELY (buf == NULL))
goto buffer_creation_failed;
- number = self->ctx->cm->FigGetAttachment (sample_buf,
+ number = self->ctx->cm->CMGetAttachment (sample_buf,
*self->ctx->mio->kTundraSampleBufferAttachmentKey_SequenceNumber, NULL);
if (number != NULL && CFNumberGetValue (number, kCFNumberSInt32Type, &seq)) {
GST_BUFFER_OFFSET (buf) = seq;
gboolean ensure_only)
{
GstMIOVideoSrc *self = GST_MIO_VIDEO_SRC (instance);
- FigFormatDescription *format_desc;
+ CMFormatDescriptionRef format_desc;
GST_DEBUG_OBJECT (self, "%s: ensure_only=%d", G_STRFUNC, ensure_only);
GMutex *qlock;
GCond *qcond;
guint64 prev_offset;
- FigFormatDescription * prev_format;
+ CMFormatDescriptionRef prev_format;
};
struct _GstMIOVideoSrcClass
struct _FigCaptureStreamIface
{
gsize unk;
- FigStatus (* Start) (FigCaptureStreamRef stream);
- FigStatus (* Stop) (FigCaptureStreamRef stream);
+ OSStatus (* Start) (FigCaptureStreamRef stream);
+ OSStatus (* Stop) (FigCaptureStreamRef stream);
};
struct _GstMTApi
typedef struct _VTDecompressionOutputCallback VTDecompressionOutputCallback;
typedef VTStatus (* VTCompressionOutputCallbackFunc) (void * data, int a2,
- int a3, int a4, FigSampleBuffer * sbuf, int a6, int a7);
+ int a3, int a4, CMSampleBufferRef sbuf, int a6, int a7);
typedef void (* VTDecompressionOutputCallbackFunc) (void * data, gsize unk1,
VTStatus result, gsize unk2, CVBufferRef cvbuf);
GstDynApi parent;
VTStatus (* VTCompressionSessionCompleteFrames)
- (VTCompressionSession * session, FigTime completeUntilDisplayTimestamp);
+ (VTCompressionSession * session, CMTime completeUntilDisplayTimestamp);
VTStatus (* VTCompressionSessionCopyProperty)
(VTCompressionSession * session, CFTypeRef key, void* unk,
CFTypeRef * value);
VTCompressionSession ** session);
VTStatus (* VTCompressionSessionEncodeFrame)
(VTCompressionSession * session, CVPixelBufferRef pixelBuffer,
- FigTime displayTimestamp, FigTime displayDuration,
+ CMTime displayTimestamp, CMTime displayDuration,
CFDictionaryRef frameOptions, void * sourceTrackingCallback,
void * sourceFrameRefCon);
void (* VTCompressionSessionInvalidate)
CFTypeRef propValue);
VTStatus (* VTDecompressionSessionCreate)
- (CFAllocatorRef allocator, FigFormatDescription * videoFormatDescription,
+ (CFAllocatorRef allocator, CMFormatDescriptionRef videoFormatDescription,
CFTypeRef sessionOptions, CFDictionaryRef destinationPixelBufferAttributes,
VTDecompressionOutputCallback * outputCallback,
VTDecompressionSession ** session);
VTStatus (* VTDecompressionSessionDecodeFrame)
- (VTDecompressionSession * session, FigSampleBuffer * sbuf, gsize unk1,
+ (VTDecompressionSession * session, CMSampleBufferRef sbuf, gsize unk1,
gsize unk2, gsize unk3);
void (* VTDecompressionSessionInvalidate)
(VTDecompressionSession * session);
static gboolean gst_vtdec_sink_setcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_vtdec_chain (GstPad * pad, GstBuffer * buf);
-static FigFormatDescription *gst_vtdec_create_format_description
+static CMFormatDescriptionRef gst_vtdec_create_format_description
(GstVTDec * self);
-static FigFormatDescription *gst_vtdec_create_format_description_from_codec_data
- (GstVTDec * self, GstBuffer * codec_data);
+static CMFormatDescriptionRef
+gst_vtdec_create_format_description_from_codec_data (GstVTDec * self,
+ GstBuffer * codec_data);
static VTDecompressionSession *gst_vtdec_create_session (GstVTDec * self,
- FigFormatDescription * fmt_desc);
+ CMFormatDescriptionRef fmt_desc);
static void gst_vtdec_destroy_session (GstVTDec * self,
VTDecompressionSession ** session);
static GstFlowReturn gst_vtdec_decode_buffer (GstVTDec * self, GstBuffer * buf);
static void gst_vtdec_output_frame (void *data, gsize unk1, VTStatus result,
gsize unk2, CVBufferRef cvbuf);
-static FigSampleBuffer *gst_vtdec_sample_buffer_from (GstVTDec * self,
+static CMSampleBufferRef gst_vtdec_sample_buffer_from (GstVTDec * self,
GstBuffer * buf);
static void
{
GstVTDec *self = GST_VTDEC_CAST (GST_PAD_PARENT (pad));
GstStructure *structure;
- FigFormatDescription *fmt_desc = NULL;
+ CMFormatDescriptionRef fmt_desc = NULL;
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (structure, "width", &self->negotiated_width))
return GST_FLOW_OK;
}
-static FigFormatDescription *
+static CMFormatDescriptionRef
gst_vtdec_create_format_description (GstVTDec * self)
{
- FigFormatDescription *fmt_desc;
- FigStatus status;
+ CMFormatDescriptionRef fmt_desc;
+ OSStatus status;
- status = self->ctx->cm->FigVideoFormatDescriptionCreate (NULL,
+ status = self->ctx->cm->CMVideoFormatDescriptionCreate (NULL,
self->details->format_id, self->negotiated_width, self->negotiated_height,
NULL, &fmt_desc);
- if (status == kFigSuccess)
+ if (status == noErr)
return fmt_desc;
else
return NULL;
}
-static FigFormatDescription *
+static CMFormatDescriptionRef
gst_vtdec_create_format_description_from_codec_data (GstVTDec * self,
GstBuffer * codec_data)
{
- FigFormatDescription *fmt_desc;
- FigStatus status;
+ CMFormatDescriptionRef fmt_desc;
+ OSStatus status;
status =
self->ctx->cm->
self->details->format_id, self->negotiated_width, self->negotiated_height,
'avcC', GST_BUFFER_DATA (codec_data), GST_BUFFER_SIZE (codec_data),
&fmt_desc);
- if (status == kFigSuccess)
+ if (status == noErr)
return fmt_desc;
else
return NULL;
}
static VTDecompressionSession *
-gst_vtdec_create_session (GstVTDec * self, FigFormatDescription * fmt_desc)
+gst_vtdec_create_session (GstVTDec * self, CMFormatDescriptionRef fmt_desc)
{
VTDecompressionSession *session = NULL;
GstCVApi *cv = self->ctx->cv;
gst_vtdec_decode_buffer (GstVTDec * self, GstBuffer * buf)
{
GstVTApi *vt = self->ctx->vt;
- FigSampleBuffer *sbuf;
+ CMSampleBufferRef sbuf;
VTStatus status;
self->cur_inbuf = buf;
return;
}
-static FigSampleBuffer *
+static CMSampleBufferRef
gst_vtdec_sample_buffer_from (GstVTDec * self, GstBuffer * buf)
{
GstCMApi *cm = self->ctx->cm;
- FigStatus status;
- FigBlockBuffer *bbuf = NULL;
- FigSampleBuffer *sbuf = NULL;
+ OSStatus status;
+ CMBlockBufferRef bbuf = NULL;
+ CMSampleBufferRef sbuf = NULL;
g_assert (self->fmt_desc != NULL);
- status = cm->FigBlockBufferCreateWithMemoryBlock (NULL,
+ status = cm->CMBlockBufferCreateWithMemoryBlock (NULL,
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), kCFAllocatorNull, NULL,
0, GST_BUFFER_SIZE (buf), FALSE, &bbuf);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
- status = cm->FigSampleBufferCreate (NULL, bbuf, TRUE, 0, 0, self->fmt_desc,
+ status = cm->CMSampleBufferCreate (NULL, bbuf, TRUE, 0, 0, self->fmt_desc,
1, 0, NULL, 0, NULL, &sbuf);
- if (status != kFigSuccess)
+ if (status != noErr)
goto beach;
beach:
gint negotiated_fps_n, negotiated_fps_d;
gint caps_width, caps_height;
gint caps_fps_n, caps_fps_d;
- FigFormatDescription * fmt_desc;
+ CMFormatDescriptionRef fmt_desc;
VTDecompressionSession * session;
GstBuffer * cur_inbuf;
static GstFlowReturn gst_vtenc_encode_frame (GstVTEnc * self, GstBuffer * buf);
static VTStatus gst_vtenc_output_buffer (void *data, int a2, int a3, int a4,
- FigSampleBuffer * sbuf, int a6, int a7);
+ CMSampleBufferRef sbuf, int a6, int a7);
static gboolean gst_vtenc_buffer_is_keyframe (GstVTEnc * self,
- FigSampleBuffer * sbuf);
+ CMSampleBufferRef sbuf);
static void
gst_vtenc_base_init (GstVTEncClass * klass)
}
static gboolean
-gst_vtenc_negotiate_downstream (GstVTEnc * self, FigSampleBuffer * sbuf)
+gst_vtenc_negotiate_downstream (GstVTEnc * self, CMSampleBufferRef sbuf)
{
gboolean result;
GstCMApi *cm = self->ctx->cm;
self->negotiated_fps_n, self->negotiated_fps_d, NULL);
if (self->details->format_id == kVTFormatH264) {
- FigFormatDescription *fmt;
+ CMFormatDescriptionRef fmt;
CFDictionaryRef atoms;
CFStringRef avccKey;
CFDataRef avcc;
GstBuffer *codec_data;
- fmt = cm->FigSampleBufferGetFormatDescription (sbuf);
- atoms = cm->FigFormatDescriptionGetExtension (fmt,
- *(cm->kFigFormatDescriptionExtension_SampleDescriptionExtensionAtoms));
+ fmt = cm->CMSampleBufferGetFormatDescription (sbuf);
+ atoms = cm->CMFormatDescriptionGetExtension (fmt,
+ *(cm->kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms));
avccKey = CFStringCreateWithCString (NULL, "avcC", kCFStringEncodingUTF8);
avcc = CFDictionaryGetValue (atoms, avccKey);
CFRelease (avccKey);
{
GstCVApi *cv = self->ctx->cv;
GstVTApi *vt = self->ctx->vt;
- FigTime ts, duration;
+ CMTime ts, duration;
CVPixelBufferRef pbuf = NULL;
VTStatus vt_status;
self->cur_inbuf = buf;
self->cur_flowret = GST_FLOW_OK;
- ts = self->ctx->cm->FigTimeMake
+ ts = self->ctx->cm->CMTimeMake
(GST_TIME_AS_MSECONDS (GST_BUFFER_TIMESTAMP (buf)), 1000);
- duration = self->ctx->cm->FigTimeMake
+ duration = self->ctx->cm->CMTimeMake
(GST_TIME_AS_MSECONDS (GST_BUFFER_DURATION (buf)), 1000);
if (GST_IS_CORE_MEDIA_BUFFER (buf)) {
}
self->ctx->vt->VTCompressionSessionCompleteFrames (self->session,
- *(self->ctx->cm->kFigTimeInvalid));
+ *(self->ctx->cm->kCMTimeInvalid));
if (!self->expect_keyframe) {
CFDictionaryRemoveValue (self->options,
static VTStatus
gst_vtenc_output_buffer (void *data, int a2, int a3, int a4,
- FigSampleBuffer * sbuf, int a6, int a7)
+ CMSampleBufferRef sbuf, int a6, int a7)
{
GstVTEnc *self = data;
gboolean is_keyframe;
}
static gboolean
-gst_vtenc_buffer_is_keyframe (GstVTEnc * self, FigSampleBuffer * sbuf)
+gst_vtenc_buffer_is_keyframe (GstVTEnc * self, CMSampleBufferRef sbuf)
{
gboolean result = FALSE;
CFArrayRef attachments_for_sample;
attachments_for_sample =
- self->ctx->cm->FigSampleBufferGetSampleAttachmentsArray (sbuf, 0);
+ self->ctx->cm->CMSampleBufferGetSampleAttachmentsArray (sbuf, 0);
if (attachments_for_sample != NULL) {
CFDictionaryRef attachments;
CFBooleanRef depends_on_others;
attachments = CFArrayGetValueAtIndex (attachments_for_sample, 0);
depends_on_others = CFDictionaryGetValue (attachments,
- *(self->ctx->cm->kFigSampleAttachmentKey_DependsOnOthers));
+ *(self->ctx->cm->kCMSampleAttachmentKey_DependsOnOthers));
result = (depends_on_others == kCFBooleanFalse);
}