Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1537)

Unified Diff: webrtc/api/videotrack.cc

Issue 1861633002: Extended proxy abstraction, to call certain methods to the worker thread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/videotrack.h ('k') | webrtc/api/videotrack_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/videotrack.cc
diff --git a/webrtc/api/videotrack.cc b/webrtc/api/videotrack.cc
index bd380254b2d0e5ab7ab961152799b9ba4c33af16..234b4cf7ae9a9dc72f3e2230fa555c9e47795648 100644
--- a/webrtc/api/videotrack.cc
+++ b/webrtc/api/videotrack.cc
@@ -20,6 +20,7 @@ VideoTrack::VideoTrack(const std::string& label,
VideoTrackSourceInterface* video_source)
: MediaStreamTrack<VideoTrackInterface>(label),
video_source_(video_source) {
+ worker_thread_checker_.DetachFromThread();
video_source_->RegisterObserver(this);
}
@@ -31,10 +32,12 @@ std::string VideoTrack::kind() const {
return kVideoKind;
}
+// AddOrUpdateSink and RemoveSink should be called on the worker
+// thread.
void VideoTrack::AddOrUpdateSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
const rtc::VideoSinkWants& wants) {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
VideoSourceBase::AddOrUpdateSink(sink, wants);
rtc::VideoSinkWants modified_wants = wants;
modified_wants.black_frames = !enabled();
@@ -43,23 +46,25 @@ void VideoTrack::AddOrUpdateSink(
void VideoTrack::RemoveSink(
rtc::VideoSinkInterface<cricket::VideoFrame>* sink) {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
VideoSourceBase::RemoveSink(sink);
video_source_->RemoveSink(sink);
}
bool VideoTrack::set_enabled(bool enable) {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread());
for (auto& sink_pair : sink_pairs()) {
rtc::VideoSinkWants modified_wants = sink_pair.wants;
modified_wants.black_frames = !enable;
+ // video_source_ is a proxy object, marshalling the call to the
+ // worker thread.
video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
}
return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
}
void VideoTrack::OnChanged() {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread());
if (video_source_->state() == MediaSourceInterface::kEnded) {
set_state(kEnded);
} else {
« no previous file with comments | « webrtc/api/videotrack.h ('k') | webrtc/api/videotrack_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698