Lock frame in ViECapturer::IncomingFrameI420.

r5160 explicitly assumed that IncomingFrameI420 was never called
sequentially. This assumption was found to be incorrect when some users
were changing beween existing capturers.

BUG=2657
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/4619004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5189 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2013-11-28 13:26:33 +00:00
parent 13d38a13e3
commit 1f7c8d8b6a
3 changed files with 8 additions and 5 deletions

View File

@ -114,7 +114,6 @@ class WEBRTC_DLLEXPORT ViEExternalCapture {
// This method is specifically for delivering a new captured I420 frame to
// VideoEngine.
// |capture_time| must be specified in the NTP time format in milliseconds.
// This method uses an internal buffer and must be called sequentially.
virtual int IncomingFrameI420(
const ViEVideoFrameI420& video_frame,
unsigned long long capture_time = 0) = 0;

View File

@ -43,6 +43,7 @@ ViECapturer::ViECapturer(int capture_id,
external_capture_module_(NULL),
module_process_thread_(module_process_thread),
capture_id_(capture_id),
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
capture_thread_(*ThreadWrapper::CreateThread(ViECaptureThreadFunction,
this, kHighPriority,
"ViECaptureThread")),
@ -332,7 +333,8 @@ int ViECapturer::IncomingFrameI420(const ViEVideoFrameI420& video_frame,
int size_y = video_frame.height * video_frame.y_pitch;
int size_u = video_frame.u_pitch * ((video_frame.height + 1) / 2);
int size_v = video_frame.v_pitch * ((video_frame.height + 1) / 2);
int ret = capture_frame_.CreateFrame(size_y,
CriticalSectionScoped cs(incoming_frame_cs_.get());
int ret = incoming_frame_.CreateFrame(size_y,
video_frame.y_plane,
size_u,
video_frame.u_plane,
@ -352,7 +354,7 @@ int ViECapturer::IncomingFrameI420(const ViEVideoFrameI420& video_frame,
return -1;
}
return external_capture_module_->IncomingI420VideoFrame(&capture_frame_,
return external_capture_module_->IncomingI420VideoFrame(&incoming_frame_,
capture_time);
}

View File

@ -157,6 +157,10 @@ class ViECapturer
ProcessThread& module_process_thread_;
const int capture_id_;
// Frame used in IncomingFrameI420.
scoped_ptr<CriticalSectionWrapper> incoming_frame_cs_;
I420VideoFrame incoming_frame_;
// Capture thread.
ThreadWrapper& capture_thread_;
EventWrapper& capture_event_;
@ -181,8 +185,6 @@ class ViECapturer
CaptureCapability requested_capability_;
I420VideoFrame capture_frame_;
scoped_ptr<OveruseFrameDetector> overuse_detector_;
};