diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc index ef1300f9b6..3864ffa17e 100644 --- a/modules/video_capture/video_capture_impl.cc +++ b/modules/video_capture/video_capture_impl.cc @@ -167,10 +167,7 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame, int target_width = width; int target_height = abs(height); - // SetApplyRotation doesn't take any lock. Make a local copy here. - bool apply_rotation = apply_rotation_; - - if (apply_rotation) { + if (apply_rotation_) { // Rotating resolution when for 90/270 degree rotations. if (_rotateFrame == kVideoRotation_90 || _rotateFrame == kVideoRotation_270) { @@ -186,7 +183,7 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame, target_width, target_height, stride_y, stride_uv, stride_uv); libyuv::RotationMode rotation_mode = libyuv::kRotate0; - if (apply_rotation) { + if (apply_rotation_) { switch (_rotateFrame) { case kVideoRotation_0: rotation_mode = libyuv::kRotate0; @@ -221,7 +218,7 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame, .set_video_frame_buffer(buffer) .set_timestamp_rtp(0) .set_timestamp_ms(rtc::TimeMillis()) - .set_rotation(!apply_rotation ? _rotateFrame : kVideoRotation_0) + .set_rotation(!apply_rotation_ ? _rotateFrame : kVideoRotation_0) .build(); captureFrame.set_ntp_time_ms(captureTime); @@ -256,14 +253,13 @@ int32_t VideoCaptureImpl::SetCaptureRotation(VideoRotation rotation) { } bool VideoCaptureImpl::SetApplyRotation(bool enable) { - // We can't take any lock here as it'll cause deadlock with IncomingFrame. - - // The effect of this is the last caller wins. + MutexLock lock(&api_lock_); apply_rotation_ = enable; return true; } bool VideoCaptureImpl::GetApplyRotation() { + MutexLock lock(&api_lock_); return apply_rotation_; }