mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 09:04:15 +00:00
avfvideosrc: get connection and input clock early
This commit is contained in:
parent
ed27244c03
commit
a02a948a5d
1 changed files with 9 additions and 5 deletions
|
@ -83,6 +83,7 @@ G_DEFINE_TYPE (GstAVFVideoSrc, gst_avf_video_src, GST_TYPE_PUSH_SRC);
|
||||||
AVCaptureInput *input;
|
AVCaptureInput *input;
|
||||||
AVCaptureVideoDataOutput *output;
|
AVCaptureVideoDataOutput *output;
|
||||||
AVCaptureDevice *device;
|
AVCaptureDevice *device;
|
||||||
|
AVCaptureConnection *connection;
|
||||||
CMClockRef inputClock;
|
CMClockRef inputClock;
|
||||||
|
|
||||||
dispatch_queue_t mainQueue;
|
dispatch_queue_t mainQueue;
|
||||||
|
@ -296,6 +297,10 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
[session addInput:input];
|
[session addInput:input];
|
||||||
[session addOutput:output];
|
[session addOutput:output];
|
||||||
|
|
||||||
|
/* retained by session */
|
||||||
|
connection = [[output connections] firstObject];
|
||||||
|
inputClock = ((AVCaptureInputPort *)connection.inputPorts[0]).clock;
|
||||||
|
|
||||||
*successPtr = YES;
|
*successPtr = YES;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -311,6 +316,9 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
dispatch_sync (mainQueue, ^{
|
dispatch_sync (mainQueue, ^{
|
||||||
g_assert (![session isRunning]);
|
g_assert (![session isRunning]);
|
||||||
|
|
||||||
|
connection = nil;
|
||||||
|
inputClock = nil;
|
||||||
|
|
||||||
[session removeInput:input];
|
[session removeInput:input];
|
||||||
[session removeOutput:output];
|
[session removeOutput:output];
|
||||||
|
|
||||||
|
@ -710,7 +718,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
latency = GST_CLOCK_TIME_NONE;
|
latency = GST_CLOCK_TIME_NONE;
|
||||||
inputClock = nil;
|
|
||||||
|
|
||||||
lastSampling = GST_CLOCK_TIME_NONE;
|
lastSampling = GST_CLOCK_TIME_NONE;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -728,7 +735,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
bufQueueLock = nil;
|
bufQueueLock = nil;
|
||||||
[bufQueue release];
|
[bufQueue release];
|
||||||
bufQueue = nil;
|
bufQueue = nil;
|
||||||
inputClock = nil;
|
|
||||||
|
|
||||||
if (textureCache)
|
if (textureCache)
|
||||||
gst_core_video_texture_cache_free (textureCache);
|
gst_core_video_texture_cache_free (textureCache);
|
||||||
|
@ -834,7 +840,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
|
|
||||||
- (void)captureOutput:(AVCaptureOutput *)captureOutput
|
- (void)captureOutput:(AVCaptureOutput *)captureOutput
|
||||||
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
fromConnection:(AVCaptureConnection *)connection
|
fromConnection:(AVCaptureConnection *)aConnection
|
||||||
{
|
{
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
|
|
||||||
|
@ -845,8 +851,6 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputClock == nil)
|
|
||||||
inputClock = ((AVCaptureInputPort *)connection.inputPorts[0]).clock;
|
|
||||||
[self getSampleBuffer:sampleBuffer timestamp:×tamp duration:&duration];
|
[self getSampleBuffer:sampleBuffer timestamp:×tamp duration:&duration];
|
||||||
|
|
||||||
if ([bufQueue count] == BUFFER_QUEUE_SIZE)
|
if ([bufQueue count] == BUFFER_QUEUE_SIZE)
|
||||||
|
|
Loading…
Reference in a new issue