From 2e349576eb9b82430e7622ac1062d04caca37fb5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Tue, 2 Nov 2010 22:53:33 +0100 Subject: [PATCH] applemedia: support public version of CoreMedia Also rename the relevant API so we mirror the public API more closely, and switch to CoreFoundation CFTypeRef style typedefs. We still support the old private CoreMedia in order to not break OS X support. This means that vtenc and vtdec are now compatible with iOS 4.x, and in theory also future versions of OS X, where this API may turn public like it has on iOS. --- sys/applemedia/celapi.h | 7 +- sys/applemedia/cmapi.c | 104 ++++++++++++++++++-------- sys/applemedia/cmapi.h | 158 ++++++++++++++++++--------------------- sys/applemedia/coremediabuffer.c | 16 ++-- sys/applemedia/coremediabuffer.h | 6 +- sys/applemedia/iphonecamerasrc.c | 58 +++++++------- sys/applemedia/iphonecamerasrc.h | 2 +- sys/applemedia/mioapi.h | 2 +- sys/applemedia/miovideodevice.c | 24 +++--- sys/applemedia/miovideodevice.h | 4 +- sys/applemedia/miovideosrc.c | 18 ++--- sys/applemedia/miovideosrc.h | 2 +- sys/applemedia/mtapi.h | 4 +- sys/applemedia/vtapi.h | 10 +-- sys/applemedia/vtdec.c | 51 ++++++------- sys/applemedia/vtdec.h | 2 +- sys/applemedia/vtenc.c | 30 ++++---- 17 files changed, 267 insertions(+), 231 deletions(-) diff --git a/sys/applemedia/celapi.h b/sys/applemedia/celapi.h index bbd651b..cbfb9dc 100644 --- a/sys/applemedia/celapi.h +++ b/sys/applemedia/celapi.h @@ -27,11 +27,16 @@ G_BEGIN_DECLS 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, diff --git a/sys/applemedia/cmapi.c b/sys/applemedia/cmapi.c index 8602ffc..3afe485 100644 --- a/sys/applemedia/cmapi.c +++ b/sys/applemedia/cmapi.c @@ -21,7 +21,11 @@ #include "dynapi-internal.h" -#define CM_FRAMEWORK_PATH "/System/Library/PrivateFrameworks/" \ +#include + +#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); @@ -44,52 +48,88 @@ gst_cm_api_obtain (GError ** error) 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; } diff --git a/sys/applemedia/cmapi.h b/sys/applemedia/cmapi.h index 8a0d141..50153b2 100644 --- a/sys/applemedia/cmapi.h +++ b/sys/applemedia/cmapi.h @@ -30,31 +30,21 @@ G_BEGIN_DECLS 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 { @@ -80,22 +70,22 @@ struct _FigBaseIface 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]; }; @@ -106,77 +96,77 @@ struct _GstCMApi 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 diff --git a/sys/applemedia/coremediabuffer.c b/sys/applemedia/coremediabuffer.c index fa80542..44c101f 100644 --- a/sys/applemedia/coremediabuffer.c +++ b/sys/applemedia/coremediabuffer.c @@ -44,21 +44,21 @@ gst_core_media_buffer_finalize (GstMiniObject * mini_object) } 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 ()) { @@ -84,10 +84,10 @@ gst_core_media_buffer_new (GstCoreMediaCtx * ctx, FigSampleBuffer * sample_buf) 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; } diff --git a/sys/applemedia/coremediabuffer.h b/sys/applemedia/coremediabuffer.h index 5e3a346..a22fd28 100644 --- a/sys/applemedia/coremediabuffer.h +++ b/sys/applemedia/coremediabuffer.h @@ -42,10 +42,10 @@ struct _GstCoreMediaBuffer GstBuffer buffer; GstCoreMediaCtx * ctx; - FigSampleBuffer * sample_buf; + CMSampleBufferRef sample_buf; CVImageBufferRef image_buf; CVPixelBufferRef pixel_buf; - FigBlockBuffer * block_buf; + CMBlockBufferRef block_buf; }; struct _GstCoreMediaBufferClass @@ -55,7 +55,7 @@ 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); diff --git a/sys/applemedia/iphonecamerasrc.c b/sys/applemedia/iphonecamerasrc.c index fad264f..d70011e 100644 --- a/sys/applemedia/iphonecamerasrc.c +++ b/sys/applemedia/iphonecamerasrc.c @@ -71,9 +71,9 @@ static gboolean gst_iphone_camera_src_select_format (GstIPhoneCameraSrc * self, 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; @@ -333,7 +333,7 @@ gst_iphone_camera_src_unlock_stop (GstBaseSrc * basesrc) } 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); @@ -351,15 +351,15 @@ gst_iphone_camera_src_create (GstPushSrc * pushsrc, GstBuffer ** buf) { 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)) @@ -414,7 +414,7 @@ gst_iphone_camera_src_open_device (GstIPhoneCameraSrc * self) GstCMApi *cm = NULL; GstMTApi *mt = NULL; GstCelApi *cel = NULL; - FigStatus status; + OSStatus status; FigCaptureDeviceRef device = NULL; FigBaseObjectRef device_base; FigBaseVTable *device_vt; @@ -422,7 +422,7 @@ gst_iphone_camera_src_open_device (GstIPhoneCameraSrc * self) 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); @@ -435,9 +435,9 @@ gst_iphone_camera_src_open_device (GstIPhoneCameraSrc * self) 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); @@ -449,12 +449,12 @@ gst_iphone_camera_src_open_device (GstIPhoneCameraSrc * self) 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; @@ -487,7 +487,7 @@ device_busy: 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: @@ -533,7 +533,7 @@ gst_iphone_camera_src_close_device (GstIPhoneCameraSrc * self) static void gst_iphone_camera_src_ensure_device_caps_and_formats (GstIPhoneCameraSrc * self) { - FigStatus status; + OSStatus status; CFArrayRef iformats = NULL; CFIndex format_count, i; @@ -547,7 +547,7 @@ gst_iphone_camera_src_ensure_device_caps_and_formats (GstIPhoneCameraSrc * self) 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); @@ -601,33 +601,33 @@ gst_iphone_camera_src_select_format (GstIPhoneCameraSrc * self, { 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)", @@ -648,8 +648,8 @@ gst_iphone_camera_src_parse_imager_format (GstIPhoneCameraSrc * self, { 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; @@ -659,11 +659,11 @@ gst_iphone_camera_src_parse_imager_format (GstIPhoneCameraSrc * self, 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: @@ -690,11 +690,11 @@ unsupported_format: 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); @@ -704,11 +704,11 @@ gst_iphone_camera_src_set_device_property_i32 (GstIPhoneCameraSrc * self, 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, diff --git a/sys/applemedia/iphonecamerasrc.h b/sys/applemedia/iphonecamerasrc.h index fc5a22d..c5052ed 100644 --- a/sys/applemedia/iphonecamerasrc.h +++ b/sys/applemedia/iphonecamerasrc.h @@ -55,7 +55,7 @@ struct _GstIPhoneCameraSrc FigCaptureStreamRef stream; FigBaseIface *stream_iface_base; FigCaptureStreamIface *stream_iface; - FigBufferQueueRef queue; + CMBufferQueueRef queue; GstCaps *device_caps; GArray *device_formats; GstClockTime duration; diff --git a/sys/applemedia/mioapi.h b/sys/applemedia/mioapi.h index 02b0588..cbd6e8e 100644 --- a/sys/applemedia/mioapi.h +++ b/sys/applemedia/mioapi.h @@ -138,7 +138,7 @@ enum _TundraDeviceTransportType }; 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); diff --git a/sys/applemedia/miovideodevice.c b/sys/applemedia/miovideodevice.c index ca872dc..7ed9a52 100644 --- a/sys/applemedia/miovideodevice.c +++ b/sys/applemedia/miovideodevice.c @@ -46,10 +46,10 @@ typedef struct _GstMIOFindRateCtx GstMIOFindRateCtx; struct _GstMIOVideoFormat { TundraObjectID stream; - FigFormatDescription *desc; + CMFormatDescriptionRef desc; UInt32 type; - FigVideoDimensions dim; + CMVideoDimensions dim; }; struct _GstMIOSetFormatCtx @@ -553,7 +553,7 @@ gst_mio_video_device_find_closest_framerate (GstMIOVideoDevice * self, } } -FigFormatDescription * +CMFormatDescriptionRef gst_mio_video_device_get_selected_format (GstMIOVideoDevice * self) { return self->selected_format; @@ -599,12 +599,12 @@ gst_mio_video_device_formats_foreach (GstMIOVideoDevice * self, 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); } @@ -696,19 +696,19 @@ gst_mio_video_device_print_debug_info (GstMIOVideoDevice * self) 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, diff --git a/sys/applemedia/miovideodevice.h b/sys/applemedia/miovideodevice.h index fedbf46..b622286 100644 --- a/sys/applemedia/miovideodevice.h +++ b/sys/applemedia/miovideodevice.h @@ -53,7 +53,7 @@ struct _GstMIOVideoDevice gchar *cached_name; TundraDeviceTransportType cached_transport; GstCaps *cached_caps; - FigFormatDescription *selected_format; + CMFormatDescriptionRef selected_format; gint selected_fps_n, selected_fps_d; }; @@ -76,7 +76,7 @@ void gst_mio_video_device_close (GstMIOVideoDevice * self); 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); diff --git a/sys/applemedia/miovideosrc.c b/sys/applemedia/miovideosrc.c index e80395e..b35e16f 100644 --- a/sys/applemedia/miovideosrc.c +++ b/sys/applemedia/miovideosrc.c @@ -407,7 +407,7 @@ gst_mio_video_src_create (GstPushSrc * pushsrc, GstBuffer ** buf) { 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)) @@ -418,10 +418,10 @@ gst_mio_video_src_create (GstPushSrc * pushsrc, GstBuffer ** buf) 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); @@ -690,7 +690,7 @@ any_error: } 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; @@ -711,13 +711,13 @@ gst_mio_video_src_get_timestamp (GstMIOVideoSrc * self, FigSampleBuffer * sbuf) /* * 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, @@ -744,7 +744,7 @@ no_clock: 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; @@ -755,7 +755,7 @@ gst_mio_video_src_output_render (gpointer instance, gpointer unk1, 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; @@ -844,7 +844,7 @@ gst_mio_video_src_output_available_formats (gpointer instance, 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); diff --git a/sys/applemedia/miovideosrc.h b/sys/applemedia/miovideosrc.h index 741ede5..312776d 100644 --- a/sys/applemedia/miovideosrc.h +++ b/sys/applemedia/miovideosrc.h @@ -68,7 +68,7 @@ struct _GstMIOVideoSrc GMutex *qlock; GCond *qcond; guint64 prev_offset; - FigFormatDescription * prev_format; + CMFormatDescriptionRef prev_format; }; struct _GstMIOVideoSrcClass diff --git a/sys/applemedia/mtapi.h b/sys/applemedia/mtapi.h index fe0e2be..7fc7367 100644 --- a/sys/applemedia/mtapi.h +++ b/sys/applemedia/mtapi.h @@ -34,8 +34,8 @@ typedef struct _FigCaptureStreamIface FigCaptureStreamIface; struct _FigCaptureStreamIface { gsize unk; - FigStatus (* Start) (FigCaptureStreamRef stream); - FigStatus (* Stop) (FigCaptureStreamRef stream); + OSStatus (* Start) (FigCaptureStreamRef stream); + OSStatus (* Stop) (FigCaptureStreamRef stream); }; struct _GstMTApi diff --git a/sys/applemedia/vtapi.h b/sys/applemedia/vtapi.h index 1ea4aa1..69c4fa3 100644 --- a/sys/applemedia/vtapi.h +++ b/sys/applemedia/vtapi.h @@ -37,7 +37,7 @@ typedef struct _VTCompressionOutputCallback VTCompressionOutputCallback; 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); @@ -69,7 +69,7 @@ struct _GstVTApi GstDynApi parent; VTStatus (* VTCompressionSessionCompleteFrames) - (VTCompressionSession * session, FigTime completeUntilDisplayTimestamp); + (VTCompressionSession * session, CMTime completeUntilDisplayTimestamp); VTStatus (* VTCompressionSessionCopyProperty) (VTCompressionSession * session, CFTypeRef key, void* unk, CFTypeRef * value); @@ -82,7 +82,7 @@ struct _GstVTApi VTCompressionSession ** session); VTStatus (* VTCompressionSessionEncodeFrame) (VTCompressionSession * session, CVPixelBufferRef pixelBuffer, - FigTime displayTimestamp, FigTime displayDuration, + CMTime displayTimestamp, CMTime displayDuration, CFDictionaryRef frameOptions, void * sourceTrackingCallback, void * sourceFrameRefCon); void (* VTCompressionSessionInvalidate) @@ -96,12 +96,12 @@ struct _GstVTApi 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); diff --git a/sys/applemedia/vtdec.c b/sys/applemedia/vtdec.c index a6a35b5..6b00756 100644 --- a/sys/applemedia/vtdec.c +++ b/sys/applemedia/vtdec.c @@ -35,19 +35,20 @@ static GstStateChangeReturn gst_vtdec_change_state (GstElement * element, 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 @@ -180,7 +181,7 @@ gst_vtdec_sink_setcaps (GstPad * pad, GstCaps * caps) { 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)) @@ -298,27 +299,27 @@ pending_caps: 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-> @@ -326,14 +327,14 @@ gst_vtdec_create_format_description_from_codec_data (GstVTDec * self, 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; @@ -377,7 +378,7 @@ static GstFlowReturn gst_vtdec_decode_buffer (GstVTDec * self, GstBuffer * buf) { GstVTApi *vt = self->ctx->vt; - FigSampleBuffer *sbuf; + CMSampleBufferRef sbuf; VTStatus status; self->cur_inbuf = buf; @@ -429,25 +430,25 @@ beach: 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: diff --git a/sys/applemedia/vtdec.h b/sys/applemedia/vtdec.h index 52cd278..e8c6a85 100644 --- a/sys/applemedia/vtdec.h +++ b/sys/applemedia/vtdec.h @@ -66,7 +66,7 @@ struct _GstVTDec 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; diff --git a/sys/applemedia/vtenc.c b/sys/applemedia/vtenc.c index 604ad1c..51046d4 100644 --- a/sys/applemedia/vtenc.c +++ b/sys/applemedia/vtenc.c @@ -78,9 +78,9 @@ static VTStatus gst_vtenc_session_configure_property_double (GstVTEnc * self, 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) @@ -362,7 +362,7 @@ gst_vtenc_is_negotiated (GstVTEnc * self) } 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; @@ -385,15 +385,15 @@ gst_vtenc_negotiate_downstream (GstVTEnc * self, FigSampleBuffer * sbuf) 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); @@ -720,16 +720,16 @@ gst_vtenc_encode_frame (GstVTEnc * self, GstBuffer * buf) { 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)) { @@ -789,7 +789,7 @@ gst_vtenc_encode_frame (GstVTEnc * self, GstBuffer * buf) } self->ctx->vt->VTCompressionSessionCompleteFrames (self->session, - *(self->ctx->cm->kFigTimeInvalid)); + *(self->ctx->cm->kCMTimeInvalid)); if (!self->expect_keyframe) { CFDictionaryRemoveValue (self->options, @@ -827,7 +827,7 @@ cv_error: 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; @@ -874,20 +874,20 @@ expected_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); } -- 2.7.4