From e34fe9fe70e643fb0370fc25e08df09ec6ee0003 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 9 Feb 2016 13:42:48 +1100 Subject: [PATCH] applemedia: avfvideosrc: implement GstElement::set_context Needed to properly handle gst.gl.app_context(s). --- sys/applemedia/avfvideosrc.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/applemedia/avfvideosrc.m b/sys/applemedia/avfvideosrc.m index 86eeff5e64..1c8f633971 100644 --- a/sys/applemedia/avfvideosrc.m +++ b/sys/applemedia/avfvideosrc.m @@ -150,6 +150,7 @@ G_DEFINE_TYPE (GstAVFVideoSrc, gst_avf_video_src, GST_TYPE_PUSH_SRC); - (BOOL)unlock; - (BOOL)unlockStop; - (BOOL)query:(GstQuery *)query; +- (void)setContext:(GstContext *)context; - (GstStateChangeReturn)changeState:(GstStateChange)transition; - (GstFlowReturn)create:(GstBuffer **)buf; - (GstCaps *)fixate:(GstCaps *)caps; @@ -1005,6 +1006,15 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer return TRUE; } +- (void)setContext:(GstContext *)context +{ + GST_INFO_OBJECT (element, "setting context %s", + gst_context_get_context_type (context)); + gst_gl_handle_set_context (element, context, + &ctxh->display, &ctxh->other_context); + GST_ELEMENT_CLASS (parent_class)->set_context (element, context); +} + - (void)getSampleBuffer:(CMSampleBufferRef)sbuf timestamp:(GstClockTime *)outTimestamp duration:(GstClockTime *)outDuration @@ -1137,6 +1147,8 @@ static GstCaps * gst_avf_video_src_fixate (GstBaseSrc * bsrc, GstCaps * caps); static gboolean gst_avf_video_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query); +static void gst_avf_video_src_set_context (GstElement * element, + GstContext * context); static void gst_avf_video_src_class_init (GstAVFVideoSrcClass * klass) @@ -1151,6 +1163,7 @@ gst_avf_video_src_class_init (GstAVFVideoSrcClass * klass) gobject_class->set_property = gst_avf_video_src_set_property; gstelement_class->change_state = gst_avf_video_src_change_state; + gstelement_class->set_context = gst_avf_video_src_set_context; gstbasesrc_class->get_caps = gst_avf_video_src_get_caps; gstbasesrc_class->set_caps = gst_avf_video_src_set_caps; @@ -1428,3 +1441,11 @@ gst_avf_video_src_decide_allocation (GstBaseSrc * bsrc, return ret; } + +static void +gst_avf_video_src_set_context (GstElement * element, GstContext * context) +{ + OBJC_CALLOUT_BEGIN (); + [GST_AVF_VIDEO_SRC_IMPL (element) setContext:context]; + OBJC_CALLOUT_END (); +}