avfvideosrc: BUFFER_QUEUE_SIZE too small
Submitted by Ilya Konstantinov
Assigned to Ilya Konstantinov
Link to original bug (#747270)
Description
In avfvideosrc.m, we have:
#define BUFFER_QUEUE_SIZE 2
This buffer queue is used in a producer-consumer fashion between the AV capture callbacks (on AVFoundation's thread) and the element (on the main thread).
With such a small queue, we were constantly:
a) losing performance due to the main thread going to sleep constantly
b) periodically dropping frames in this code:
if ([bufQueue count] == BUFFER_QUEUE_SIZE)
[bufQueue removeLastObject];
Increasing the queue size to e.g. 32 improves performance significantly. On iPhone 5s, improvement of ~7
% is seen in the following pipeline:
avfvideosrc device-index=0 ! video/x-raw,width=1280,height=720,framerate=30/1 ! vtenc_h264 bitrate=400 ! fakesink