diff options
author | Alessandro Decina <alessandro.d@gmail.com> | 2016-08-26 17:37:54 +1000 |
---|---|---|
committer | Alessandro Decina <alessandro.d@gmail.com> | 2016-08-26 17:44:48 +1000 |
commit | 7898bc581053b1716e9d7ecaeb148ec8d60d1c29 (patch) | |
tree | 292f7815247e629cb6a96a7f085cf90d045868cd /sys/applemedia/qtkitvideosrc.m | |
parent | 91fea30ff47f2402385808f270a0ced7fdfc4625 (diff) | |
download | gstreamer-plugins-bad-7898bc581053b1716e9d7ecaeb148ec8d60d1c29.tar.gz |
applemedia: changes to make GL memory mappable on CPU on iOS
This commit introduces IOSGLMemory which is a GLMemory that falls back to
GstAppleCoreVideoMemory for CPU access. This is a temporary solution until
IOSurface gets exposed as a public framework on iOS and so we can use
IOSurfaceMemory on both MacOS and iOS.
https://bugzilla.gnome.org/show_bug.cgi?id=769210
Diffstat (limited to 'sys/applemedia/qtkitvideosrc.m')
-rw-r--r-- | sys/applemedia/qtkitvideosrc.m | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/sys/applemedia/qtkitvideosrc.m b/sys/applemedia/qtkitvideosrc.m index 40170845a..a69e70f55 100644 --- a/sys/applemedia/qtkitvideosrc.m +++ b/sys/applemedia/qtkitvideosrc.m @@ -18,8 +18,8 @@ */ #include "qtkitvideosrc.h" - #import "corevideobuffer.h" +#include "glcontexthelper.h" #import <QTKit/QTKit.h> @@ -100,9 +100,12 @@ G_DEFINE_TYPE (GstQTKitVideoSrc, gst_qtkit_video_src, GST_TYPE_PUSH_SRC); BOOL stopRequest; gint width, height; - gint fps_n, fps_d; + gint fps_n, fps_d; GstClockTime duration; guint64 offset; + GstGLContextHelper *ctxh; + GstVideoTextureCache *textureCache; + GstVideoInfo outputInfo; } - (id)init; @@ -149,6 +152,10 @@ G_DEFINE_TYPE (GstQTKitVideoSrc, gst_qtkit_video_src, GST_TYPE_PUSH_SRC); gst_base_src_set_live (baseSrc, TRUE); gst_base_src_set_format (baseSrc, GST_FORMAT_TIME); + + self->ctxh = NULL; + textureCache = NULL; + gst_video_info_init (&outputInfo); } return self; @@ -272,6 +279,17 @@ openFailed: error:nil]; g_assert (success); + gst_gl_context_helper_ensure_context (ctxh); + GST_INFO_OBJECT (element, "pushing textures, context %p old context %p", + ctxh->context, textureCache ? textureCache->ctx : NULL); + if (textureCache && textureCache->ctx != ctxh->context) { + gst_video_texture_cache_free (textureCache); + textureCache = NULL; + } + textureCache = gst_video_texture_cache_new (ctxh->context); + gst_video_texture_cache_set_format (textureCache, GST_VIDEO_FORMAT_UYVY, caps); + gst_video_info_set_format (&outputInfo, GST_VIDEO_FORMAT_UYVY, width, height); + [output setDelegate:self]; [session startRunning]; @@ -291,6 +309,7 @@ openFailed: fps_n = 0; fps_d = 1; duration = GST_CLOCK_TIME_NONE; + ctxh = gst_gl_context_helper_new (element); /* this will trigger negotiation and open the device in setCaps */ gst_base_src_start_complete (baseSrc, GST_FLOW_OK); @@ -306,7 +325,6 @@ openFailed: [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; } - return YES; } @@ -320,6 +338,12 @@ openFailed: [queue release]; queue = nil; + gst_gl_context_helper_free (ctxh); + ctxh = NULL; + if (textureCache) + gst_video_texture_cache_free (textureCache); + textureCache = NULL; + return YES; } @@ -434,7 +458,7 @@ openFailed: [queueLock unlockWithCondition: ([queue count] == 0) ? NO_FRAMES : HAS_FRAME_OR_STOP_REQUEST]; - *buf = gst_core_video_buffer_new ((CVBufferRef)frame, NULL); + *buf = gst_core_video_buffer_new ((CVBufferRef)frame, &outputInfo, textureCache); CVBufferRelease (frame); [self timestampBuffer:*buf]; |