Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 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/host/fake_desktop_capturer.h" | 5 #include "remoting/protocol/fake_desktop_capturer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 12 | 11 |
| 13 namespace remoting { | 12 namespace remoting { |
| 14 | 13 |
| 15 // FakeDesktopCapturer generates a white picture of size kWidth x kHeight | 14 // FakeDesktopCapturer generates a white picture of size kWidth x kHeight |
| 16 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed | 15 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed |
| 17 // pixels per frame along both axes, and bounces off the sides of the screen. | 16 // pixels per frame along both axes, and bounces off the sides of the screen. |
| 18 static const int kWidth = FakeDesktopCapturer::kWidth; | 17 static const int kWidth = FakeDesktopCapturer::kWidth; |
| 19 static const int kHeight = FakeDesktopCapturer::kHeight; | 18 static const int kHeight = FakeDesktopCapturer::kHeight; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 old_box_pos_x, old_box_pos_y, kBoxWidth, kBoxHeight)); | 112 old_box_pos_x, old_box_pos_y, kBoxWidth, kBoxHeight)); |
| 114 frame->mutable_updated_region()->AddRect(webrtc::DesktopRect::MakeXYWH( | 113 frame->mutable_updated_region()->AddRect(webrtc::DesktopRect::MakeXYWH( |
| 115 box_pos_x_, box_pos_y_, kBoxWidth, kBoxHeight)); | 114 box_pos_x_, box_pos_y_, kBoxWidth, kBoxHeight)); |
| 116 } | 115 } |
| 117 | 116 |
| 118 return frame.Pass(); | 117 return frame.Pass(); |
| 119 } | 118 } |
| 120 | 119 |
| 121 } // namespace | 120 } // namespace |
| 122 | 121 |
| 123 FakeDesktopCapturer::FakeDesktopCapturer() | 122 FakeDesktopCapturer::FakeDesktopCapturer() |
|
kelvinp
2015/11/20 21:14:42
namespace protocol {
Sergey Ulanov
2015/11/21 01:41:23
Done.
| |
| 124 : callback_(nullptr) { | 123 : callback_(nullptr) { |
| 125 frame_generator_ = base::Bind(&DefaultFrameGenerator::GenerateFrame, | 124 frame_generator_ = base::Bind(&DefaultFrameGenerator::GenerateFrame, |
| 126 new DefaultFrameGenerator()); | 125 new DefaultFrameGenerator()); |
| 127 } | 126 } |
| 128 | 127 |
| 129 FakeDesktopCapturer::~FakeDesktopCapturer() {} | 128 FakeDesktopCapturer::~FakeDesktopCapturer() {} |
| 130 | 129 |
| 131 void FakeDesktopCapturer::set_frame_generator( | 130 void FakeDesktopCapturer::set_frame_generator( |
| 132 const FrameGenerator& frame_generator) { | 131 const FrameGenerator& frame_generator) { |
| 133 DCHECK(!callback_); | 132 DCHECK(!callback_); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 144 base::Time capture_start_time = base::Time::Now(); | 143 base::Time capture_start_time = base::Time::Now(); |
| 145 scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_); | 144 scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_); |
| 146 if (frame) { | 145 if (frame) { |
| 147 frame->set_capture_time_ms( | 146 frame->set_capture_time_ms( |
| 148 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); | 147 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); |
| 149 } | 148 } |
| 150 callback_->OnCaptureCompleted(frame.release()); | 149 callback_->OnCaptureCompleted(frame.release()); |
| 151 } | 150 } |
| 152 | 151 |
| 153 } // namespace remoting | 152 } // namespace remoting |
| OLD | NEW |