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

Side by Side Diff: remoting/host/cast_video_capturer_adapter.cc

Issue 399253002: CastExtension Impl for Chromoting Host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final Fixes Created 6 years, 4 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 | « remoting/host/cast_video_capturer_adapter.h ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/host/cast_video_capturer_adapter.h" 5 #include "remoting/host/cast_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 = 10;
13 13
14 CastVideoCapturerAdapter::CastVideoCapturerAdapter( 14 CastVideoCapturerAdapter::CastVideoCapturerAdapter(
15 scoped_ptr<webrtc::ScreenCapturer> capturer) 15 scoped_ptr<webrtc::DesktopCapturer> capturer)
16 : screen_capturer_(capturer.Pass()) { 16 : desktop_capturer_(capturer.Pass()) {
17 DCHECK(screen_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);
23 } 23 }
24 24
25 CastVideoCapturerAdapter::~CastVideoCapturerAdapter() { 25 CastVideoCapturerAdapter::~CastVideoCapturerAdapter() {
26 DCHECK(!capture_timer_); 26 DCHECK(!capture_timer_);
27 } 27 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 best_format->interval = FPS_TO_INTERVAL(kFramesPerSec); 73 best_format->interval = FPS_TO_INTERVAL(kFramesPerSec);
74 return true; 74 return true;
75 } 75 }
76 76
77 cricket::CaptureState CastVideoCapturerAdapter::Start( 77 cricket::CaptureState CastVideoCapturerAdapter::Start(
78 const cricket::VideoFormat& capture_format) { 78 const cricket::VideoFormat& capture_format) {
79 DCHECK(thread_checker_.CalledOnValidThread()); 79 DCHECK(thread_checker_.CalledOnValidThread());
80 DCHECK(!capture_timer_); 80 DCHECK(!capture_timer_);
81 DCHECK_EQ(capture_format.fourcc, (static_cast<uint32>(cricket::FOURCC_ARGB))); 81 DCHECK_EQ(capture_format.fourcc, (static_cast<uint32>(cricket::FOURCC_ARGB)));
82 82
83 if (!screen_capturer_) { 83 if (!desktop_capturer_) {
84 VLOG(1) << "CastVideoCapturerAdapter failed to start."; 84 VLOG(1) << "CastVideoCapturerAdapter failed to start.";
85 return cricket::CS_FAILED; 85 return cricket::CS_FAILED;
86 } 86 }
87 87
88 // This is required to tell the cricket::VideoCapturer base class what the 88 // This is required to tell the cricket::VideoCapturer base class what the
89 // capture format will be. 89 // capture format will be.
90 SetCaptureFormat(&capture_format); 90 SetCaptureFormat(&capture_format);
91 91
92 screen_capturer_->Start(this); 92 desktop_capturer_->Start(this);
93 93
94 // Save the Start() time of |screen_capturer_|. This will be used 94 // Save the Start() time of |desktop_capturer_|. This will be used
95 // to estimate the creation time of the frame source, to set the elapsed_time 95 // to estimate the creation time of the frame source, to set the elapsed_time
96 // of future CapturedFrames in OnCaptureCompleted(). 96 // of future CapturedFrames in OnCaptureCompleted().
97 start_time_ = base::TimeTicks::Now(); 97 start_time_ = base::TimeTicks::Now();
98 capture_timer_.reset(new base::RepeatingTimer<CastVideoCapturerAdapter>()); 98 capture_timer_.reset(new base::RepeatingTimer<CastVideoCapturerAdapter>());
99 capture_timer_->Start(FROM_HERE, 99 capture_timer_->Start(FROM_HERE,
100 base::TimeDelta::FromMicroseconds( 100 base::TimeDelta::FromMicroseconds(
101 GetCaptureFormat()->interval / 101 GetCaptureFormat()->interval /
102 (base::Time::kNanosecondsPerMicrosecond)), 102 (base::Time::kNanosecondsPerMicrosecond)),
103 this, 103 this,
104 &CastVideoCapturerAdapter::CaptureNextFrame); 104 &CastVideoCapturerAdapter::CaptureNextFrame);
105 105
106 return cricket::CS_RUNNING; 106 return cricket::CS_RUNNING;
107 } 107 }
108 108
109 // Similar to the base class implementation with some important differences: 109 // Similar to the base class implementation with some important differences:
110 // 1. Does not call either Stop() or Start(), as those would affect the state of 110 // 1. Does not call either Stop() or Start(), as those would affect the state of
111 // |screen_capturer_|. 111 // |desktop_capturer_|.
112 // 2. Does not support unpausing after stopping the capturer. It is unclear 112 // 2. Does not support unpausing after stopping the capturer. It is unclear
113 // if that flow needs to be supported. 113 // if that flow needs to be supported.
114 bool CastVideoCapturerAdapter::Pause(bool pause) { 114 bool CastVideoCapturerAdapter::Pause(bool pause) {
115 DCHECK(thread_checker_.CalledOnValidThread()); 115 DCHECK(thread_checker_.CalledOnValidThread());
116 116
117 if (pause) { 117 if (pause) {
118 if (capture_state() == cricket::CS_PAUSED) 118 if (capture_state() == cricket::CS_PAUSED)
119 return true; 119 return true;
120 120
121 bool running = capture_state() == cricket::CS_STARTING || 121 bool running = capture_state() == cricket::CS_STARTING ||
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return false; 187 return false;
188 fourccs->push_back(cricket::FOURCC_ARGB); 188 fourccs->push_back(cricket::FOURCC_ARGB);
189 return true; 189 return true;
190 } 190 }
191 191
192 void CastVideoCapturerAdapter::CaptureNextFrame() { 192 void CastVideoCapturerAdapter::CaptureNextFrame() {
193 // If we are paused, then don't capture. 193 // If we are paused, then don't capture.
194 if (!IsRunning()) 194 if (!IsRunning())
195 return; 195 return;
196 196
197 screen_capturer_->Capture(webrtc::DesktopRegion()); 197 desktop_capturer_->Capture(webrtc::DesktopRegion());
198 } 198 }
199 199
200 } // namespace remoting 200 } // namespace remoting
201 201
OLDNEW
« no previous file with comments | « remoting/host/cast_video_capturer_adapter.h ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698