Move enabled() methods for VideoTrack over to signaling
Bug: webrtc:13680 Change-Id: I0faf0d03541fce2b93c03857e01e85588389ccd1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251720 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36009}
This commit is contained in:
parent
0c6e34ce5c
commit
250c31df00
@ -44,8 +44,8 @@ PROXY_PRIMARY_THREAD_DESTRUCTOR()
|
|||||||
BYPASS_PROXY_CONSTMETHOD0(std::string, kind)
|
BYPASS_PROXY_CONSTMETHOD0(std::string, kind)
|
||||||
BYPASS_PROXY_CONSTMETHOD0(std::string, id)
|
BYPASS_PROXY_CONSTMETHOD0(std::string, id)
|
||||||
PROXY_SECONDARY_CONSTMETHOD0(TrackState, state)
|
PROXY_SECONDARY_CONSTMETHOD0(TrackState, state)
|
||||||
PROXY_SECONDARY_CONSTMETHOD0(bool, enabled)
|
PROXY_CONSTMETHOD0(bool, enabled)
|
||||||
PROXY_SECONDARY_METHOD1(bool, set_enabled, bool)
|
PROXY_METHOD1(bool, set_enabled, bool)
|
||||||
PROXY_SECONDARY_CONSTMETHOD0(ContentHint, content_hint)
|
PROXY_SECONDARY_CONSTMETHOD0(ContentHint, content_hint)
|
||||||
PROXY_SECONDARY_METHOD1(void, set_content_hint, ContentHint)
|
PROXY_SECONDARY_METHOD1(void, set_content_hint, ContentHint)
|
||||||
PROXY_SECONDARY_METHOD2(void,
|
PROXY_SECONDARY_METHOD2(void,
|
||||||
|
|||||||
@ -53,7 +53,7 @@ void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
|
|||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||||
VideoSourceBaseGuarded::AddOrUpdateSink(sink, wants);
|
VideoSourceBaseGuarded::AddOrUpdateSink(sink, wants);
|
||||||
rtc::VideoSinkWants modified_wants = wants;
|
rtc::VideoSinkWants modified_wants = wants;
|
||||||
modified_wants.black_frames = !enabled();
|
modified_wants.black_frames = !enabled_w_;
|
||||||
video_source_->AddOrUpdateSink(sink, modified_wants);
|
video_source_->AddOrUpdateSink(sink, modified_wants);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,17 +87,29 @@ void VideoTrack::set_content_hint(ContentHint hint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool VideoTrack::set_enabled(bool enable) {
|
bool VideoTrack::set_enabled(bool enable) {
|
||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
RTC_DCHECK_RUN_ON(&signaling_thread_);
|
||||||
for (auto& sink_pair : sink_pairs()) {
|
|
||||||
rtc::VideoSinkWants modified_wants = sink_pair.wants;
|
bool ret = MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
|
||||||
modified_wants.black_frames = !enable;
|
|
||||||
video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
|
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() {
|
||||||
}
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||||
return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
|
enabled_w_ = enable;
|
||||||
|
for (auto& sink_pair : sink_pairs()) {
|
||||||
|
rtc::VideoSinkWants modified_wants = sink_pair.wants;
|
||||||
|
modified_wants.black_frames = !enable;
|
||||||
|
video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoTrack::enabled() const {
|
bool VideoTrack::enabled() const {
|
||||||
RTC_DCHECK_RUN_ON(worker_thread_);
|
if (worker_thread_->IsCurrent()) {
|
||||||
|
RTC_DCHECK_RUN_ON(worker_thread_);
|
||||||
|
return enabled_w_;
|
||||||
|
}
|
||||||
|
RTC_DCHECK_RUN_ON(&signaling_thread_);
|
||||||
return MediaStreamTrack<VideoTrackInterface>::enabled();
|
return MediaStreamTrack<VideoTrackInterface>::enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,11 @@ class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
|
|||||||
rtc::Thread* const worker_thread_;
|
rtc::Thread* const worker_thread_;
|
||||||
const rtc::scoped_refptr<VideoTrackSourceInterface> video_source_;
|
const rtc::scoped_refptr<VideoTrackSourceInterface> video_source_;
|
||||||
ContentHint content_hint_ RTC_GUARDED_BY(worker_thread_);
|
ContentHint content_hint_ RTC_GUARDED_BY(worker_thread_);
|
||||||
|
// Cached `enabled` state for the worker thread. This is kept in sync with
|
||||||
|
// the state maintained on the signaling thread via set_enabled() but can
|
||||||
|
// be queried without blocking on the worker thread by callers that don't
|
||||||
|
// use an api proxy to call the `enabled()` method.
|
||||||
|
bool enabled_w_ RTC_GUARDED_BY(worker_thread_) = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user