OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 return capturer; | 53 return capturer; |
54 } | 54 } |
55 | 55 |
56 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, | 56 FrameGeneratorCapturer::FrameGeneratorCapturer(Clock* clock, |
57 FrameGenerator* frame_generator, | 57 FrameGenerator* frame_generator, |
58 int target_fps) | 58 int target_fps) |
59 : clock_(clock), | 59 : clock_(clock), |
60 sending_(false), | 60 sending_(false), |
61 sink_(nullptr), | 61 sink_(nullptr), |
| 62 sink_wants_observer_(nullptr), |
62 tick_(EventTimerWrapper::Create()), | 63 tick_(EventTimerWrapper::Create()), |
63 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"), | 64 thread_(FrameGeneratorCapturer::Run, this, "FrameGeneratorCapturer"), |
64 frame_generator_(frame_generator), | 65 frame_generator_(frame_generator), |
65 target_fps_(target_fps), | 66 target_fps_(target_fps), |
66 first_frame_capture_time_(-1) { | 67 first_frame_capture_time_(-1) { |
67 RTC_DCHECK(frame_generator); | 68 RTC_DCHECK(frame_generator); |
68 RTC_DCHECK_GT(target_fps, 0); | 69 RTC_DCHECK_GT(target_fps, 0); |
69 } | 70 } |
70 | 71 |
71 FrameGeneratorCapturer::~FrameGeneratorCapturer() { | 72 FrameGeneratorCapturer::~FrameGeneratorCapturer() { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 void FrameGeneratorCapturer::Stop() { | 123 void FrameGeneratorCapturer::Stop() { |
123 rtc::CritScope cs(&lock_); | 124 rtc::CritScope cs(&lock_); |
124 sending_ = false; | 125 sending_ = false; |
125 } | 126 } |
126 | 127 |
127 void FrameGeneratorCapturer::ChangeResolution(size_t width, size_t height) { | 128 void FrameGeneratorCapturer::ChangeResolution(size_t width, size_t height) { |
128 rtc::CritScope cs(&lock_); | 129 rtc::CritScope cs(&lock_); |
129 frame_generator_->ChangeResolution(width, height); | 130 frame_generator_->ChangeResolution(width, height); |
130 } | 131 } |
131 | 132 |
| 133 void FrameGeneratorCapturer::SetSinkWantsObserver(SinkWantsObserver* observer) { |
| 134 rtc::CritScope cs(&lock_); |
| 135 RTC_DCHECK(!sink_wants_observer_); |
| 136 sink_wants_observer_ = observer; |
| 137 } |
| 138 |
132 void FrameGeneratorCapturer::AddOrUpdateSink( | 139 void FrameGeneratorCapturer::AddOrUpdateSink( |
133 rtc::VideoSinkInterface<VideoFrame>* sink, | 140 rtc::VideoSinkInterface<VideoFrame>* sink, |
134 const rtc::VideoSinkWants& wants) { | 141 const rtc::VideoSinkWants& wants) { |
135 rtc::CritScope cs(&lock_); | 142 rtc::CritScope cs(&lock_); |
136 RTC_CHECK(!sink_); | 143 RTC_CHECK(!sink_ || sink_ == sink); |
137 sink_ = sink; | 144 sink_ = sink; |
| 145 if (sink_wants_observer_) |
| 146 sink_wants_observer_->OnSinkWantsChanged(sink, wants); |
138 } | 147 } |
139 | 148 |
140 void FrameGeneratorCapturer::RemoveSink( | 149 void FrameGeneratorCapturer::RemoveSink( |
141 rtc::VideoSinkInterface<VideoFrame>* sink) { | 150 rtc::VideoSinkInterface<VideoFrame>* sink) { |
142 rtc::CritScope cs(&lock_); | 151 rtc::CritScope cs(&lock_); |
143 RTC_CHECK(sink_ == sink); | 152 RTC_CHECK(sink_ == sink); |
144 sink_ = nullptr; | 153 sink_ = nullptr; |
145 } | 154 } |
146 | 155 |
147 void FrameGeneratorCapturer::ForceFrame() { | 156 void FrameGeneratorCapturer::ForceFrame() { |
148 tick_->Set(); | 157 tick_->Set(); |
149 } | 158 } |
150 } // test | 159 } // test |
151 } // webrtc | 160 } // webrtc |
OLD | NEW |