diff --git a/sys/applemedia/Makefile.am b/sys/applemedia/Makefile.am index 95401c2a61..e043fd7e0c 100644 --- a/sys/applemedia/Makefile.am +++ b/sys/applemedia/Makefile.am @@ -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 \ diff --git a/sys/applemedia/avfvideosrc.m b/sys/applemedia/avfvideosrc.m index 3c570b1a68..d2db4a883f 100644 --- a/sys/applemedia/avfvideosrc.m +++ b/sys/applemedia/avfvideosrc.m @@ -19,10 +19,9 @@ #include "avfvideosrc.h" -#import "bufferfactory.h" - #import #include +#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 index 132b953ef4..0000000000 --- a/sys/applemedia/bufferfactory.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2010 Ole André Vadla Ravnås - * - * 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 - -#include - -@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 index 7b2e845cc2..0000000000 --- a/sys/applemedia/bufferfactory.m +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2010 Ole André Vadla Ravnås - * - * 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 diff --git a/sys/applemedia/qtkitvideosrc.m b/sys/applemedia/qtkitvideosrc.m index 32e18b8a48..e6b427f87b 100644 --- a/sys/applemedia/qtkitvideosrc.m +++ b/sys/applemedia/qtkitvideosrc.m @@ -19,7 +19,7 @@ #include "qtkitvideosrc.h" -#import "bufferfactory.h" +#import "corevideobuffer.h" #import @@ -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];