OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/protocol/webrtc_video_capturer_adapter.h" | 5 #include "remoting/protocol/webrtc_video_capturer_adapter.h" |
6 | 6 |
7 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 7 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
11 // Number of frames to be captured per second. | 11 // Number of frames to be captured per second. |
12 const int kFramesPerSec = 10; | 12 const int kFramesPerSec = 30; |
13 | 13 |
14 WebrtcVideoCapturerAdapter::WebrtcVideoCapturerAdapter( | 14 WebrtcVideoCapturerAdapter::WebrtcVideoCapturerAdapter( |
15 scoped_ptr<webrtc::DesktopCapturer> capturer) | 15 scoped_ptr<webrtc::DesktopCapturer> capturer) |
16 : desktop_capturer_(capturer.Pass()) { | 16 : desktop_capturer_(capturer.Pass()) { |
17 DCHECK(desktop_capturer_); | 17 DCHECK(desktop_capturer_); |
18 | 18 |
19 thread_checker_.DetachFromThread(); | 19 thread_checker_.DetachFromThread(); |
20 | 20 |
21 // Disable video adaptation since we don't intend to use it. | 21 // Disable video adaptation since we don't intend to use it. |
22 set_enable_video_adapter(false); | 22 set_enable_video_adapter(false); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 VLOG(1) << "WebrtcVideoCapturerAdapter unpaused."; | 150 VLOG(1) << "WebrtcVideoCapturerAdapter unpaused."; |
151 } | 151 } |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 void WebrtcVideoCapturerAdapter::Stop() { | 155 void WebrtcVideoCapturerAdapter::Stop() { |
156 DCHECK(thread_checker_.CalledOnValidThread()); | 156 DCHECK(thread_checker_.CalledOnValidThread()); |
157 DCHECK_NE(capture_state(), cricket::CS_STOPPED); | 157 DCHECK_NE(capture_state(), cricket::CS_STOPPED); |
158 | 158 |
159 capture_timer_.reset(); | 159 capture_timer_.reset(); |
| 160 desktop_capturer_.reset(); |
160 | 161 |
161 SetCaptureFormat(nullptr); | 162 SetCaptureFormat(nullptr); |
162 SetCaptureState(cricket::CS_STOPPED); | 163 SetCaptureState(cricket::CS_STOPPED); |
163 | 164 |
164 VLOG(1) << "WebrtcVideoCapturerAdapter stopped."; | 165 VLOG(1) << "WebrtcVideoCapturerAdapter stopped."; |
165 } | 166 } |
166 | 167 |
167 | |
168 bool WebrtcVideoCapturerAdapter::IsRunning() { | 168 bool WebrtcVideoCapturerAdapter::IsRunning() { |
169 DCHECK(thread_checker_.CalledOnValidThread()); | 169 DCHECK(thread_checker_.CalledOnValidThread()); |
170 | 170 |
171 return capture_timer_->IsRunning(); | 171 return capture_timer_->IsRunning(); |
172 } | 172 } |
173 | 173 |
174 bool WebrtcVideoCapturerAdapter::IsScreencast() const { | 174 bool WebrtcVideoCapturerAdapter::IsScreencast() const { |
175 return true; | 175 return true; |
176 } | 176 } |
177 | 177 |
178 bool WebrtcVideoCapturerAdapter::GetPreferredFourccs( | 178 bool WebrtcVideoCapturerAdapter::GetPreferredFourccs( |
179 std::vector<uint32>* fourccs) { | 179 std::vector<uint32>* fourccs) { |
180 DCHECK(thread_checker_.CalledOnValidThread()); | 180 DCHECK(thread_checker_.CalledOnValidThread()); |
181 if (!fourccs) | 181 if (!fourccs) |
182 return false; | 182 return false; |
183 fourccs->push_back(cricket::FOURCC_ARGB); | 183 fourccs->push_back(cricket::FOURCC_ARGB); |
184 return true; | 184 return true; |
185 } | 185 } |
186 | 186 |
187 void WebrtcVideoCapturerAdapter::CaptureNextFrame() { | 187 void WebrtcVideoCapturerAdapter::CaptureNextFrame() { |
188 // If we are paused, then don't capture. | 188 // If we are paused, then don't capture. |
189 if (!IsRunning()) | 189 if (!IsRunning()) |
190 return; | 190 return; |
191 | 191 |
192 desktop_capturer_->Capture(webrtc::DesktopRegion()); | 192 desktop_capturer_->Capture(webrtc::DesktopRegion()); |
193 } | 193 } |
194 | 194 |
195 } // namespace remoting | 195 } // namespace remoting |
OLD | NEW |