OLD | NEW |
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 content_hint_(ContentHint::kNone) { |
23 worker_thread_checker_.DetachFromThread(); | 24 worker_thread_checker_.DetachFromThread(); |
24 video_source_->RegisterObserver(this); | 25 video_source_->RegisterObserver(this); |
25 } | 26 } |
26 | 27 |
27 VideoTrack::~VideoTrack() { | 28 VideoTrack::~VideoTrack() { |
28 video_source_->UnregisterObserver(this); | 29 video_source_->UnregisterObserver(this); |
29 } | 30 } |
30 | 31 |
31 std::string VideoTrack::kind() const { | 32 std::string VideoTrack::kind() const { |
32 return kVideoKind; | 33 return kVideoKind; |
33 } | 34 } |
34 | 35 |
35 // AddOrUpdateSink and RemoveSink should be called on the worker | 36 // AddOrUpdateSink and RemoveSink should be called on the worker |
36 // thread. | 37 // thread. |
37 void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, | 38 void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
38 const rtc::VideoSinkWants& wants) { | 39 const rtc::VideoSinkWants& wants) { |
39 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 40 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
40 VideoSourceBase::AddOrUpdateSink(sink, wants); | 41 VideoSourceBase::AddOrUpdateSink(sink, wants); |
41 rtc::VideoSinkWants modified_wants = wants; | 42 rtc::VideoSinkWants modified_wants = wants; |
42 modified_wants.black_frames = !enabled(); | 43 modified_wants.black_frames = !enabled(); |
43 video_source_->AddOrUpdateSink(sink, modified_wants); | 44 video_source_->AddOrUpdateSink(sink, modified_wants); |
44 } | 45 } |
45 | 46 |
46 void VideoTrack::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) { | 47 void VideoTrack::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) { |
47 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 48 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
48 VideoSourceBase::RemoveSink(sink); | 49 VideoSourceBase::RemoveSink(sink); |
49 video_source_->RemoveSink(sink); | 50 video_source_->RemoveSink(sink); |
50 } | 51 } |
51 | 52 |
| 53 VideoTrackInterface::ContentHint VideoTrack::content_hint() const { |
| 54 RTC_DCHECK_RUN_ON(&signaling_thread_checker_); |
| 55 return content_hint_; |
| 56 } |
| 57 |
| 58 void VideoTrack::set_content_hint(ContentHint hint) { |
| 59 RTC_DCHECK_RUN_ON(&signaling_thread_checker_); |
| 60 if (content_hint_ == hint) |
| 61 return; |
| 62 content_hint_ = hint; |
| 63 Notifier<VideoTrackInterface>::FireOnChanged(); |
| 64 } |
| 65 |
52 bool VideoTrack::set_enabled(bool enable) { | 66 bool VideoTrack::set_enabled(bool enable) { |
53 RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 67 RTC_DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
54 for (auto& sink_pair : sink_pairs()) { | 68 for (auto& sink_pair : sink_pairs()) { |
55 rtc::VideoSinkWants modified_wants = sink_pair.wants; | 69 rtc::VideoSinkWants modified_wants = sink_pair.wants; |
56 modified_wants.black_frames = !enable; | 70 modified_wants.black_frames = !enable; |
57 // video_source_ is a proxy object, marshalling the call to the | 71 // video_source_ is a proxy object, marshalling the call to the |
58 // worker thread. | 72 // worker thread. |
59 video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants); | 73 video_source_->AddOrUpdateSink(sink_pair.sink, modified_wants); |
60 } | 74 } |
61 return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable); | 75 return MediaStreamTrack<VideoTrackInterface>::set_enabled(enable); |
(...skipping 10 matching lines...) Expand all Loading... |
72 | 86 |
73 rtc::scoped_refptr<VideoTrack> VideoTrack::Create( | 87 rtc::scoped_refptr<VideoTrack> VideoTrack::Create( |
74 const std::string& id, | 88 const std::string& id, |
75 VideoTrackSourceInterface* source) { | 89 VideoTrackSourceInterface* source) { |
76 rtc::RefCountedObject<VideoTrack>* track = | 90 rtc::RefCountedObject<VideoTrack>* track = |
77 new rtc::RefCountedObject<VideoTrack>(id, source); | 91 new rtc::RefCountedObject<VideoTrack>(id, source); |
78 return track; | 92 return track; |
79 } | 93 } |
80 | 94 |
81 } // namespace webrtc | 95 } // namespace webrtc |
OLD | NEW |