From 84ab11afdbfd87bf1aa916cc7803163536513339 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 18 Feb 2015 19:06:09 +0200 Subject: [PATCH] avfvideosrc: Only set latency if we already know our caps Otherwise we might set bogus values or GST_CLOCK_TIME_NONE. Also make sure to reset the caps field to NULL after unreffing the caps to prevent accidential use afterwards, and unref any old caps before we remember new caps. --- sys/applemedia/avfvideosrc.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/applemedia/avfvideosrc.m b/sys/applemedia/avfvideosrc.m index 2ed8e22..ec22549 100644 --- a/sys/applemedia/avfvideosrc.m +++ b/sys/applemedia/avfvideosrc.m @@ -326,6 +326,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer if (caps) gst_caps_unref (caps); + caps = NULL; }); } @@ -663,6 +664,8 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer dictionaryWithObject:[NSNumber numberWithInt:newformat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; + if (caps) + gst_caps_unref (caps); caps = gst_caps_copy (new_caps); [session startRunning]; @@ -716,7 +719,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer BOOL result = NO; if (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY) { - if (device != nil) { + if (device != nil && caps != NULL) { GstClockTime min_latency, max_latency; min_latency = max_latency = latency; -- 2.7.4