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) { |