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.
This commit is contained in:
Sebastian Dröge 2015-02-18 19:06:09 +02:00
parent c37e82587c
commit 84ab11afdb

View file

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