applemedia: remove the unneeded buffer factory

This commit is contained in:
Andoni Morales Alastruey 2013-04-24 22:22:28 +02:00 committed by Sebastian Dröge
parent 97bb1edf6c
commit 9b168e6b4d
5 changed files with 4 additions and 136 deletions

View file

@ -3,7 +3,6 @@ plugin_LTLIBRARIES = libgstapplemedia.la
libgstapplemedia_la_SOURCES = \ libgstapplemedia_la_SOURCES = \
plugin.m \ plugin.m \
vtutil.c \ vtutil.c \
bufferfactory.m \
corevideobuffer.c \ corevideobuffer.c \
coremediabuffer.c \ coremediabuffer.c \
coremediactx.c \ coremediactx.c \
@ -47,7 +46,6 @@ noinst_HEADERS = \
vtenc.h \ vtenc.h \
vtdec.h \ vtdec.h \
vtutil.h \ vtutil.h \
bufferfactory.h \
corevideobuffer.h \ corevideobuffer.h \
coremediabuffer.h \ coremediabuffer.h \
coremediactx.h \ coremediactx.h \

View file

@ -19,10 +19,9 @@
#include "avfvideosrc.h" #include "avfvideosrc.h"
#import "bufferfactory.h"
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#include <gst/video/video.h> #include <gst/video/video.h>
#include "coremediabuffer.h"
#define DEFAULT_DEVICE_INDEX -1 #define DEFAULT_DEVICE_INDEX -1
#define DEFAULT_DO_STATS FALSE #define DEFAULT_DO_STATS FALSE
@ -82,7 +81,6 @@ static GstPushSrcClass * parent_class;
gint deviceIndex; gint deviceIndex;
BOOL doStats; BOOL doStats;
GstAMBufferFactory *bufferFactory;
AVCaptureSession *session; AVCaptureSession *session;
AVCaptureDeviceInput *input; AVCaptureDeviceInput *input;
AVCaptureVideoDataOutput *output; AVCaptureVideoDataOutput *output;
@ -176,15 +174,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
- (BOOL)openDevice - (BOOL)openDevice
{ {
BOOL success = NO, *successPtr = &success; 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, ^{ dispatch_async (mainQueue, ^{
NSString *mediaType = AVMediaTypeVideo; NSString *mediaType = AVMediaTypeVideo;
@ -239,11 +228,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
}); });
[self waitForMainQueueToDrain]; [self waitForMainQueueToDrain];
if (!success) {
[bufferFactory release];
bufferFactory = nil;
}
return success; return success;
} }
@ -268,9 +252,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
device = nil; device = nil;
}); });
[self waitForMainQueueToDrain]; [self waitForMainQueueToDrain];
[bufferFactory release];
bufferFactory = nil;
} }
#define GST_AVF_CAPS_NEW(format, w, h) \ #define GST_AVF_CAPS_NEW(format, w, h) \
@ -513,7 +494,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
[bufQueueLock unlockWithCondition: [bufQueueLock unlockWithCondition:
([bufQueue count] == 0) ? NO_BUFFERS : HAS_BUFFER_OR_STOP_REQUEST]; ([bufQueue count] == 0) ? NO_BUFFERS : HAS_BUFFER_OR_STOP_REQUEST];
*buf = [bufferFactory createGstBufferForSampleBuffer:sbuf]; *buf = gst_core_media_buffer_new (sbuf);
CFRelease (sbuf); CFRelease (sbuf);
[self timestampBuffer:*buf]; [self timestampBuffer:*buf];

View file

@ -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

View file

@ -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

View file

@ -19,7 +19,7 @@
#include "qtkitvideosrc.h" #include "qtkitvideosrc.h"
#import "bufferfactory.h" #import "corevideobuffer.h"
#import <QTKit/QTKit.h> #import <QTKit/QTKit.h>
@ -90,7 +90,6 @@ G_DEFINE_TYPE (GstQTKitVideoSrc, gst_qtkit_video_src, GST_TYPE_PUSH_SRC);
int deviceIndex; int deviceIndex;
GstAMBufferFactory *bufferFactory;
QTCaptureSession *session; QTCaptureSession *session;
QTCaptureDeviceInput *input; QTCaptureDeviceInput *input;
QTCaptureDecompressedVideoOutput *output; QTCaptureDecompressedVideoOutput *output;
@ -159,18 +158,9 @@ G_DEFINE_TYPE (GstQTKitVideoSrc, gst_qtkit_video_src, GST_TYPE_PUSH_SRC);
- (BOOL)openDevice - (BOOL)openDevice
{ {
GError *gerror;
NSString *mediaType = QTMediaTypeVideo; NSString *mediaType = QTMediaTypeVideo;
NSError *error = nil; 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) { if (deviceIndex == -1) {
device = [QTCaptureDevice defaultInputDeviceWithMediaType:mediaType]; device = [QTCaptureDevice defaultInputDeviceWithMediaType:mediaType];
if (device == nil) { if (device == nil) {
@ -206,9 +196,6 @@ openFailed:
[device release]; [device release];
device = nil; device = nil;
[bufferFactory release];
bufferFactory = nil;
return NO; return NO;
} }
} }
@ -228,9 +215,6 @@ openFailed:
[device release]; [device release];
device = nil; device = nil;
[bufferFactory release];
bufferFactory = nil;
} }
- (BOOL)setCaps:(GstCaps *)caps - (BOOL)setCaps:(GstCaps *)caps
@ -450,7 +434,7 @@ openFailed:
[queueLock unlockWithCondition: [queueLock unlockWithCondition:
([queue count] == 0) ? NO_FRAMES : HAS_FRAME_OR_STOP_REQUEST]; ([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); CVBufferRelease (frame);
[self timestampBuffer:*buf]; [self timestampBuffer:*buf];