Don't do a thread jump for incoming frames.

We're now supposed to accept incoming frames from any thread.

BUG=webrtc:5902

Review-Url: https://codereview.webrtc.org/1987663002
Cr-Commit-Position: refs/heads/master@{#12844}
This commit is contained in:
nisse 2016-05-23 00:39:35 -07:00 committed by Commit bot
parent bab3ea202b
commit c82d0902e1
3 changed files with 17 additions and 8 deletions

View File

@ -180,7 +180,10 @@ void AndroidVideoCapturer::OnIncomingFrame(
const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
int rotation,
int64_t time_stamp) {
RTC_CHECK(thread_checker_.CalledOnValidThread());
// NOTE: The frame_factory hack isn't thread safe. It works because
// all calls to this method are from the same Java thread. In
// addition, calls are currently syncronized on the caller's
// AndroidVideoCapturerJni:capturer_lock_.
frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp);
SignalFrameCaptured(this, frame_factory_->GetCapturedFrame());
frame_factory_->ClearCapturedFrame();

View File

@ -181,9 +181,13 @@ void AndroidVideoCapturerJni::OnMemoryBufferFrame(void* video_frame,
buffer->MutableData(webrtc::kUPlane), buffer->stride(webrtc::kUPlane),
buffer->MutableData(webrtc::kVPlane), buffer->stride(webrtc::kVPlane),
width, height);
AsyncCapturerInvoke("OnIncomingFrame",
&webrtc::AndroidVideoCapturer::OnIncomingFrame,
buffer, rotation, timestamp_ns);
rtc::CritScope cs(&capturer_lock_);
if (!capturer_) {
LOG(LS_WARNING) << "OnMemoryBufferFrame() called for closed capturer.";
return;
}
capturer_->OnIncomingFrame(buffer, rotation, timestamp_ns);
}
void AndroidVideoCapturerJni::OnTextureFrame(int width,
@ -194,9 +198,12 @@ void AndroidVideoCapturerJni::OnTextureFrame(int width,
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer(
surface_texture_helper_->CreateTextureFrame(width, height, handle));
AsyncCapturerInvoke("OnIncomingFrame",
&webrtc::AndroidVideoCapturer::OnIncomingFrame,
buffer, rotation, timestamp_ns);
rtc::CritScope cs(&capturer_lock_);
if (!capturer_) {
LOG(LS_WARNING) << "OnTextureFrame() called for closed capturer.";
return;
}
capturer_->OnIncomingFrame(buffer, rotation, timestamp_ns);
}
void AndroidVideoCapturerJni::OnOutputFormatRequest(int width,

View File

@ -40,7 +40,6 @@ void VideoBroadcaster::RemoveSink(
}
bool VideoBroadcaster::frame_wanted() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
rtc::CritScope cs(&sinks_and_wants_lock_);
return !sink_pairs().empty();
}