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

Unified Diff: webrtc/api/videotrack.cc

Issue 1790633002: Propagate MediaStreamSource state to video tracks the same way as audio. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@refactor_track
Patch Set: Fix bug with wrong enum values. Created 4 years, 9 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 54c3cce91a11d084ee99b475c53149fe66f53e37..bd380254b2d0e5ab7ab961152799b9ba4c33af16 100644
--- a/webrtc/api/videotrack.cc
+++ b/webrtc/api/videotrack.cc
@@ -20,9 +20,11 @@ VideoTrack::VideoTrack(const std::string& label,
VideoTrackSourceInterface* video_source)
: MediaStreamTrack<VideoTrackInterface>(label),
video_source_(video_source) {
+ video_source_->RegisterObserver(this);
}
VideoTrack::~VideoTrack() {
+ video_source_->UnregisterObserver(this);
}
std::string VideoTrack::kind() const {
@@ -56,6 +58,15 @@ bool VideoTrack::set_enabled(bool enable) {
return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
}
+void VideoTrack::OnChanged() {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ if (video_source_->state() == MediaSourceInterface::kEnded) {
+ set_state(kEnded);
+ } else {
+ set_state(kLive);
+ }
+}
+
rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
const std::string& id,
VideoTrackSourceInterface* source) {
« 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