applemedia: remove the unneeded buffer factory
authorAndoni Morales Alastruey <ylatuya@gmail.com>
Wed, 24 Apr 2013 20:22:28 +0000 (22:22 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 20 May 2013 11:31:02 +0000 (13:31 +0200)
sys/applemedia/Makefile.am
sys/applemedia/avfvideosrc.m
sys/applemedia/bufferfactory.h [deleted file]
sys/applemedia/bufferfactory.m [deleted file]
sys/applemedia/qtkitvideosrc.m

index 95401c2..e043fd7 100644 (file)
@@ -3,7 +3,6 @@ plugin_LTLIBRARIES = libgstapplemedia.la
 libgstapplemedia_la_SOURCES =                  \
        plugin.m                                \
        vtutil.c                                \
-       bufferfactory.m                         \
        corevideobuffer.c                       \
        coremediabuffer.c                       \
        coremediactx.c                          \
@@ -47,7 +46,6 @@ noinst_HEADERS =                              \
        vtenc.h                                 \
        vtdec.h                                 \
        vtutil.h                                \
-       bufferfactory.h                         \
        corevideobuffer.h                       \
        coremediabuffer.h                       \
        coremediactx.h                          \
index 3c570b1..d2db4a8 100644 (file)
 
 #include "avfvideosrc.h"
 
-#import "bufferfactory.h"
-
 #import <AVFoundation/AVFoundation.h>
 #include <gst/video/video.h>
+#include "coremediabuffer.h"
 
 #define DEFAULT_DEVICE_INDEX  -1
 #define DEFAULT_DO_STATS      FALSE
@@ -82,7 +81,6 @@ static GstPushSrcClass * parent_class;
   gint deviceIndex;
   BOOL doStats;
 
-  GstAMBufferFactory *bufferFactory;
   AVCaptureSession *session;
   AVCaptureDeviceInput *input;
   AVCaptureVideoDataOutput *output;
@@ -176,15 +174,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
 - (BOOL)openDevice
 {
   BOOL success = NO, *successPtr = &success;
-  GError *error;
-
-  bufferFactory = [[GstAMBufferFactory alloc] initWithError:&error];
-  if (bufferFactory == nil) {
-    GST_ELEMENT_ERROR (element, RESOURCE, FAILED, ("API error"),
-        ("%s", error->message));
-    g_clear_error (&error);
-    return NO;
-  }
 
   dispatch_async (mainQueue, ^{
     NSString *mediaType = AVMediaTypeVideo;
@@ -239,11 +228,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
   });
   [self waitForMainQueueToDrain];
 
-  if (!success) {
-    [bufferFactory release];
-    bufferFactory = nil;
-  }
-
   return success;
 }
 
@@ -268,9 +252,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
     device = nil;
   });
   [self waitForMainQueueToDrain];
-
-  [bufferFactory release];
-  bufferFactory = nil;
 }
 
 #define GST_AVF_CAPS_NEW(format, w, h)                    \
@@ -513,7 +494,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
   [bufQueueLock unlockWithCondition:
       ([bufQueue count] == 0) ? NO_BUFFERS : HAS_BUFFER_OR_STOP_REQUEST];
 
-  *buf = [bufferFactory createGstBufferForSampleBuffer:sbuf];
+  *buf = gst_core_media_buffer_new (sbuf);
   CFRelease (sbuf);
 
   [self timestampBuffer:*buf];
diff --git a/sys/applemedia/bufferfactory.h b/sys/applemedia/bufferfactory.h
deleted file mode 100644 (file)
index 132b953..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-#import <Foundation/Foundation.h>
-
-#include <gst/gst.h>
-
-@interface GstAMBufferFactory : NSObject {
-  gpointer coreMediaCtx;
-}
-
-- (id)initWithError:(GError **)error;
-- (void)finalize;
-
-- (GstBuffer *)createGstBufferForCoreVideoBuffer:(CFTypeRef)cvbuf;
-- (GstBuffer *)createGstBufferForSampleBuffer:(CFTypeRef)sbuf;
-
-@end
diff --git a/sys/applemedia/bufferfactory.m b/sys/applemedia/bufferfactory.m
deleted file mode 100644 (file)
index 7b2e845..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.
- */
-
-#import "bufferfactory.h"
-
-#include "coremediabuffer.h"
-#include "corevideobuffer.h"
-
-@implementation GstAMBufferFactory
-
-- (id)initWithError:(GError **)error
-{
-  GstCoreMediaCtx *ctx;
-
-  ctx =
-      gst_core_media_ctx_new (GST_API_CORE_VIDEO | GST_API_CORE_MEDIA, error);
-  if (ctx == NULL)
-    return nil;
-
-  if ((self = [super init]))
-    coreMediaCtx = ctx;
-  else
-    g_object_unref (ctx);
-
-  return self;
-}
-
-- (void)finalize
-{
-  g_object_unref (coreMediaCtx);
-
-  [super finalize];
-}
-
-- (GstBuffer *)createGstBufferForCoreVideoBuffer:(CFTypeRef)cvbuf
-{
-  return gst_core_video_buffer_new (coreMediaCtx, (CVBufferRef) cvbuf, NULL);
-}
-
-- (GstBuffer *)createGstBufferForSampleBuffer:(CFTypeRef)sbuf
-{
-  return gst_core_media_buffer_new (coreMediaCtx, sbuf);
-}
-
-@end
index 32e18b8..e6b427f 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "qtkitvideosrc.h"
 
-#import "bufferfactory.h"
+#import "corevideobuffer.h"
 
 #import <QTKit/QTKit.h>
 
@@ -90,7 +90,6 @@ G_DEFINE_TYPE (GstQTKitVideoSrc, gst_qtkit_video_src, GST_TYPE_PUSH_SRC);
 
   int deviceIndex;
 
-  GstAMBufferFactory *bufferFactory;
   QTCaptureSession *session;
   QTCaptureDeviceInput *input;
   QTCaptureDecompressedVideoOutput *output;
@@ -159,18 +158,9 @@ G_DEFINE_TYPE (GstQTKitVideoSrc, gst_qtkit_video_src, GST_TYPE_PUSH_SRC);
 
 - (BOOL)openDevice
 {
-  GError *gerror;
   NSString *mediaType = QTMediaTypeVideo;
   NSError *error = nil;
 
-  bufferFactory = [[GstAMBufferFactory alloc] initWithError:&gerror];
-  if (bufferFactory == nil) {
-    GST_ELEMENT_ERROR (element, RESOURCE, FAILED, ("API error"),
-        ("%s", gerror->message));
-    g_clear_error (&gerror);
-    goto openFailed;
-  }
-
   if (deviceIndex == -1) {
     device = [QTCaptureDevice defaultInputDeviceWithMediaType:mediaType];
     if (device == nil) {
@@ -206,9 +196,6 @@ openFailed:
     [device release];
     device = nil;
 
-    [bufferFactory release];
-    bufferFactory = nil;
-
     return NO;
   }
 }
@@ -228,9 +215,6 @@ openFailed:
 
   [device release];
   device = nil;
-
-  [bufferFactory release];
-  bufferFactory = nil;
 }
 
 - (BOOL)setCaps:(GstCaps *)caps
@@ -450,7 +434,7 @@ openFailed:
   [queueLock unlockWithCondition:
       ([queue count] == 0) ? NO_FRAMES : HAS_FRAME_OR_STOP_REQUEST];
 
-  *buf = [bufferFactory createGstBufferForCoreVideoBuffer:frame];
+  *buf = gst_core_video_buffer_new ((CVBufferRef)frame, NULL);
   CVBufferRelease (frame);
 
   [self timestampBuffer:*buf];