OLD | NEW |
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/fake_desktop_capturer.h" | 5 #include "remoting/host/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" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 | 14 |
15 // FakeDesktopCapturer generates a white picture of size kWidth x kHeight | 15 // FakeDesktopCapturer generates a white picture of size kWidth x kHeight |
16 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed | 16 // 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. | 17 // pixels per frame along both axes, and bounces off the sides of the screen. |
18 static const int kWidth = FakeDesktopCapturer::kWidth; | 18 static const int kWidth = FakeDesktopCapturer::kWidth; |
19 static const int kHeight = FakeDesktopCapturer::kHeight; | 19 static const int kHeight = FakeDesktopCapturer::kHeight; |
20 static const int kBoxWidth = 140; | 20 static const int kBoxWidth = 140; |
21 static const int kBoxHeight = 140; | 21 static const int kBoxHeight = 140; |
22 static const int kSpeed = 20; | 22 static const int kSpeed = 20; |
23 | 23 |
24 COMPILE_ASSERT(kBoxWidth < kWidth && kBoxHeight < kHeight, bad_box_size); | 24 static_assert(kBoxWidth < kWidth && kBoxHeight < kHeight, "bad box size"); |
25 COMPILE_ASSERT((kBoxWidth % kSpeed == 0) && (kWidth % kSpeed == 0) && | 25 static_assert((kBoxWidth % kSpeed == 0) && (kWidth % kSpeed == 0) && |
26 (kBoxHeight % kSpeed == 0) && (kHeight % kSpeed == 0), | 26 (kBoxHeight % kSpeed == 0) && (kHeight % kSpeed == 0), |
27 sizes_must_be_multiple_of_kSpeed); | 27 "sizes must be multiple of kSpeed"); |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 class DefaultFrameGenerator | 31 class DefaultFrameGenerator |
32 : public base::RefCountedThreadSafe<DefaultFrameGenerator> { | 32 : public base::RefCountedThreadSafe<DefaultFrameGenerator> { |
33 public: | 33 public: |
34 DefaultFrameGenerator() | 34 DefaultFrameGenerator() |
35 : bytes_per_row_(0), | 35 : bytes_per_row_(0), |
36 box_pos_x_(0), | 36 box_pos_x_(0), |
37 box_pos_y_(0), | 37 box_pos_y_(0), |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 void FakeDesktopCapturer::Capture(const webrtc::DesktopRegion& region) { | 143 void FakeDesktopCapturer::Capture(const webrtc::DesktopRegion& region) { |
144 base::Time capture_start_time = base::Time::Now(); | 144 base::Time capture_start_time = base::Time::Now(); |
145 scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_); | 145 scoped_ptr<webrtc::DesktopFrame> frame = frame_generator_.Run(callback_); |
146 frame->set_capture_time_ms( | 146 frame->set_capture_time_ms( |
147 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); | 147 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); |
148 callback_->OnCaptureCompleted(frame.release()); | 148 callback_->OnCaptureCompleted(frame.release()); |
149 } | 149 } |
150 | 150 |
151 } // namespace remoting | 151 } // namespace remoting |
OLD | NEW |