Commit ff7b103d authored by Mickaël Turnel's avatar Mickaël Turnel

Fix iOS camera crashing during a video call

parent c04aee24
......@@ -70,6 +70,7 @@ static AVCaptureVideoOrientation Angle2AVCaptureVideoOrientation(int deviceOrien
MSYuvBufAllocator* bufAllocator;
MSFilter *filter;
MSFrameRateController framerate_controller;
bool_t filterIsRunning;
};
- (void)initIOSCapture;
......@@ -168,6 +169,14 @@ static void capture_queue_cleanup(void* p) {
CVImageBufferRef frame = nil;
@synchronized(self) {
@try {
ms_mutex_lock(&mutex);
if (!filterIsRunning || !ms_video_capture_new_frame(&framerate_controller, filter->ticker->time)) {
ms_mutex_unlock(&mutex);
return;
}
ms_mutex_unlock(&mutex);
frame = CMSampleBufferGetImageBuffer(sampleBuffer);
CVReturn status = CVPixelBufferLockBaseAddress(frame, 0);
if (kCVReturnSuccess != status) {
......@@ -175,8 +184,6 @@ static void capture_queue_cleanup(void* p) {
frame=nil;
return;
}
if (!ms_video_capture_new_frame(&framerate_controller, filter->ticker->time)) return;
/*kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange*/
size_t plane_width = CVPixelBufferGetWidthOfPlane(frame, 0);
......@@ -608,10 +615,20 @@ static void ioscapture_preprocess(MSFilter *f) {
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
[thiz performSelectorInBackground:@selector(start) withObject:nil];
[myPool drain];
ms_mutex_lock(&thiz->mutex);
thiz->filterIsRunning = 1;
ms_mutex_unlock(&thiz->mutex);
}
}
static void ioscapture_postprocess(MSFilter *f) {
IOSCapture *thiz = (IOSCapture*)f->data;
if (thiz != NULL) {
ms_mutex_lock(&thiz->mutex);
thiz->filterIsRunning = 0;
ms_mutex_unlock(&thiz->mutex);
}
}
static int ioscapture_get_fps(MSFilter *f, void *arg) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment