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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « webrtc/api/videotrack.h ('k') | webrtc/api/videotrack_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/videotrack.h" 11 #include "webrtc/api/videotrack.h"
12 12
13 #include <string> 13 #include <string>
14 14
15 namespace webrtc { 15 namespace webrtc {
16 16
17 const char MediaStreamTrackInterface::kVideoKind[] = "video"; 17 const char MediaStreamTrackInterface::kVideoKind[] = "video";
18 18
19 VideoTrack::VideoTrack(const std::string& label, 19 VideoTrack::VideoTrack(const std::string& label,
20 VideoTrackSourceInterface* video_source) 20 VideoTrackSourceInterface* video_source)
21 : MediaStreamTrack<VideoTrackInterface>(label), 21 : MediaStreamTrack<VideoTrackInterface>(label),
22 video_source_(video_source) { 22 video_source_(video_source) {
23 video_source_->RegisterObserver(this);
23 } 24 }
24 25
25 VideoTrack::~VideoTrack() { 26 VideoTrack::~VideoTrack() {
27 video_source_->UnregisterObserver(this);
26 } 28 }
27 29
28 std::string VideoTrack::kind() const { 30 std::string VideoTrack::kind() const {
29 return kVideoKind; 31 return kVideoKind;
30 } 32 }
31 33
32 void VideoTrack::AddOrUpdateSink( 34 void VideoTrack::AddOrUpdateSink(
33 rtc::VideoSinkInterface<cricket::VideoFrame>* sink, 35 rtc::VideoSinkInterface<cricket::VideoFrame>* sink,
34 const rtc::VideoSinkWants& wants) { 36 const rtc::VideoSinkWants& wants) {
35 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 37 RTC_DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 13 matching lines...) Expand all
49 bool VideoTrack::set_enabled(bool enable) { 51 bool VideoTrack::set_enabled(bool enable) {
50 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 52 RTC_DCHECK(thread_checker_.CalledOnValidThread());
51 for (auto& sink_pair : sink_pairs()) { 53 for (auto& sink_pair : sink_pairs()) {
52 rtc::VideoSinkWants modified_wants = sink_pair.wants; 54 rtc::VideoSinkWants modified_wants = sink_pair.wants;
53 modified_wants.black_frames = !enable; 55 modified_wants.black_frames = !enable;
54 video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants); 56 video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants);
55 } 57 }
56 return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable); 58 return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
57 } 59 }
58 60
61 void VideoTrack::OnChanged() {
62 RTC_DCHECK(thread_checker_.CalledOnValidThread());
63 if (video_source_->state() == MediaSourceInterface::kEnded) {
64 set_state(kEnded);
65 } else {
66 set_state(kLive);
67 }
68 }
69
59 rtc::scoped_refptr<VideoTrack> VideoTrack::Create( 70 rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
60 const std::string& id, 71 const std::string& id,
61 VideoTrackSourceInterface* source) { 72 VideoTrackSourceInterface* source) {
62 rtc::RefCountedObject<VideoTrack>* track = 73 rtc::RefCountedObject<VideoTrack>* track =
63 new rtc::RefCountedObject<VideoTrack>(id, source); 74 new rtc::RefCountedObject<VideoTrack>(id, source);
64 return track; 75 return track;
65 } 76 }
66 77
67 } // namespace webrtc 78 } // namespace webrtc
OLDNEW
« 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