applemedia: port vtapi to run on OS X 10.8
authorOle André Vadla Ravnås <oleavr@soundrop.com>
Sat, 16 Feb 2013 01:26:51 +0000 (02:26 +0100)
committerOle André Vadla Ravnås <oleavr@soundrop.com>
Sat, 16 Feb 2013 01:51:51 +0000 (02:51 +0100)
sys/applemedia/vtapi.c
sys/applemedia/vtapi.h
sys/applemedia/vtdec.c
sys/applemedia/vtenc.c

index 683ead7..0316893 100644 (file)
 
 #include "dynapi-internal.h"
 
-#define VT_FRAMEWORK_PATH "/System/Library/PrivateFrameworks/" \
+#include <gmodule.h>
+
+#define VT_FRAMEWORK_PATH "/System/Library/Frameworks/" \
+    "VideoToolbox.framework/VideoToolbox"
+#define VT_FRAMEWORK_PATH_OLD "/System/Library/PrivateFrameworks/" \
     "VideoToolbox.framework/VideoToolbox"
 
 G_DEFINE_TYPE (GstVTApi, gst_vt_api, GST_TYPE_DYN_API);
@@ -48,15 +52,11 @@ gst_vt_api_obtain (GError ** error)
     SYM_SPEC (VTCompressionSessionCreate),
     SYM_SPEC (VTCompressionSessionEncodeFrame),
     SYM_SPEC (VTCompressionSessionInvalidate),
-    SYM_SPEC (VTCompressionSessionRelease),
-    SYM_SPEC (VTCompressionSessionRetain),
     SYM_SPEC (VTCompressionSessionSetProperty),
 
     SYM_SPEC (VTDecompressionSessionCreate),
     SYM_SPEC (VTDecompressionSessionDecodeFrame),
     SYM_SPEC (VTDecompressionSessionInvalidate),
-    SYM_SPEC (VTDecompressionSessionRelease),
-    SYM_SPEC (VTDecompressionSessionRetain),
     SYM_SPEC (VTDecompressionSessionWaitForAsynchronousFrames),
 
     SYM_SPEC (kVTCompressionPropertyKey_AllowTemporalCompression),
@@ -82,7 +82,18 @@ gst_vt_api_obtain (GError ** error)
 
     {NULL, 0},
   };
+  GstVTApi *result;
+  GModule *module;
+
+  module = g_module_open (VT_FRAMEWORK_PATH, 0);
+  if (module != NULL) {
+    result = _gst_dyn_api_new (gst_vt_api_get_type (), VT_FRAMEWORK_PATH,
+        symbols, error);
+    g_module_close (module);
+  } else {
+    result = _gst_dyn_api_new (gst_vt_api_get_type (), VT_FRAMEWORK_PATH_OLD,
+        symbols, error);
+  }
 
-  return _gst_dyn_api_new (gst_vt_api_get_type (), VT_FRAMEWORK_PATH, symbols,
-      error);
+  return result;
 }
index cc3076e..b0ca2cf 100644 (file)
@@ -87,10 +87,6 @@ struct _GstVTApi
       void * sourceFrameRefCon);
   void (* VTCompressionSessionInvalidate)
       (VTCompressionSessionRef session);
-  void (* VTCompressionSessionRelease)
-      (VTCompressionSessionRef session);
-  VTCompressionSessionRef (* VTCompressionSessionRetain)
-      (VTCompressionSessionRef session);
   VTStatus (* VTCompressionSessionSetProperty)
       (VTCompressionSessionRef session, CFStringRef propName,
       CFTypeRef propValue);
@@ -107,10 +103,6 @@ struct _GstVTApi
       gsize unk2, gsize unk3);
   void (* VTDecompressionSessionInvalidate)
       (VTDecompressionSessionRef session);
-  void (* VTDecompressionSessionRelease)
-      (VTDecompressionSessionRef session);
-  VTDecompressionSessionRef (* VTDecompressionSessionRetain)
-      (VTDecompressionSessionRef session);
   VTStatus (* VTDecompressionSessionWaitForAsynchronousFrames)
       (VTDecompressionSessionRef session);
 
index 48e48bd..51613a4 100644 (file)
@@ -361,8 +361,8 @@ gst_vtdec_create_format_description_from_codec_data (GstVTDec * self,
   status =
       self->ctx->cm->
       FigVideoFormatDescriptionCreateWithSampleDescriptionExtensionAtom (NULL,
-      self->details->format_id, self->vinfo.width, self->vinfo.height,
-      'avcC', map.data, map.size, NULL, &fmt_desc);
+      self->details->format_id, self->vinfo.width, self->vinfo.height, 'avcC',
+      map.data, map.size, NULL, &fmt_desc);
 
   gst_buffer_unmap (codec_data, &map);
 
@@ -409,8 +409,10 @@ static void
 gst_vtdec_destroy_session (GstVTDec * self, VTDecompressionSessionRef * session)
 {
   self->ctx->vt->VTDecompressionSessionInvalidate (*session);
-  self->ctx->vt->VTDecompressionSessionRelease (*session);
-  *session = NULL;
+  if (*session != NULL) {
+    CFRelease (*session);
+    *session = NULL;
+  }
 }
 
 static GstFlowReturn
index 73adc22..5078095 100644 (file)
@@ -553,8 +553,10 @@ static void
 gst_vtenc_destroy_session (GstVTEnc * self, VTCompressionSessionRef * session)
 {
   self->ctx->vt->VTCompressionSessionInvalidate (*session);
-  self->ctx->vt->VTCompressionSessionRelease (*session);
-  *session = NULL;
+  if (*session != NULL) {
+    CFRelease (*session);
+    *session = NULL;
+  }
 }
 
 typedef struct