| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/video/capture/screen/screen_capturer_fake.h" | 5 #include "remoting/host/screen_capturer_fake.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 9 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 10 | 10 |
| 11 namespace media { | 11 namespace remoting { |
| 12 | 12 |
| 13 // ScreenCapturerFake generates a white picture of size kWidth x kHeight | 13 // ScreenCapturerFake generates a white picture of size kWidth x kHeight |
| 14 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed | 14 // with a rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed |
| 15 // pixels per frame along both axes, and bounces off the sides of the screen. | 15 // pixels per frame along both axes, and bounces off the sides of the screen. |
| 16 static const int kWidth = ScreenCapturerFake::kWidth; | 16 static const int kWidth = ScreenCapturerFake::kWidth; |
| 17 static const int kHeight = ScreenCapturerFake::kHeight; | 17 static const int kHeight = ScreenCapturerFake::kHeight; |
| 18 static const int kBoxWidth = 140; | 18 static const int kBoxWidth = 140; |
| 19 static const int kBoxHeight = 140; | 19 static const int kBoxHeight = 140; |
| 20 static const int kSpeed = 20; | 20 static const int kSpeed = 20; |
| 21 | 21 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 webrtc::SharedMemory* shared_memory = | 54 webrtc::SharedMemory* shared_memory = |
| 55 callback_->CreateSharedMemory(buffer_size); | 55 callback_->CreateSharedMemory(buffer_size); |
| 56 scoped_ptr<webrtc::DesktopFrame> frame; | 56 scoped_ptr<webrtc::DesktopFrame> frame; |
| 57 webrtc::DesktopSize frame_size(size_.width(), size_.height()); | 57 webrtc::DesktopSize frame_size(size_.width(), size_.height()); |
| 58 if (shared_memory) { | 58 if (shared_memory) { |
| 59 frame.reset(new webrtc::SharedMemoryDesktopFrame( | 59 frame.reset(new webrtc::SharedMemoryDesktopFrame( |
| 60 frame_size, bytes_per_row_, shared_memory)); | 60 frame_size, bytes_per_row_, shared_memory)); |
| 61 } else { | 61 } else { |
| 62 frame.reset(new webrtc::BasicDesktopFrame(frame_size)); | 62 frame.reset(new webrtc::BasicDesktopFrame(frame_size)); |
| 63 } | 63 } |
| 64 queue_.ReplaceCurrentFrame(frame.Pass()); | 64 queue_.ReplaceCurrentFrame(frame.release()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 DCHECK(queue_.current_frame()); | 67 DCHECK(queue_.current_frame()); |
| 68 GenerateImage(); | 68 GenerateImage(); |
| 69 | 69 |
| 70 queue_.current_frame()->mutable_updated_region()->SetRect( | 70 queue_.current_frame()->mutable_updated_region()->SetRect( |
| 71 webrtc::DesktopRect::MakeSize(size_)); | 71 webrtc::DesktopRect::MakeSize(size_)); |
| 72 queue_.current_frame()->set_capture_time_ms( | 72 queue_.current_frame()->set_capture_time_ms( |
| 73 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); | 73 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); |
| 74 | 74 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 row += bytes_per_row_; | 118 row += bytes_per_row_; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 void ScreenCapturerFake::ScreenConfigurationChanged() { | 122 void ScreenCapturerFake::ScreenConfigurationChanged() { |
| 123 size_.set(kWidth, kHeight); | 123 size_.set(kWidth, kHeight); |
| 124 queue_.Reset(); | 124 queue_.Reset(); |
| 125 bytes_per_row_ = size_.width() * webrtc::DesktopFrame::kBytesPerPixel; | 125 bytes_per_row_ = size_.width() * webrtc::DesktopFrame::kBytesPerPixel; |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace media | 128 } // namespace remoting |
| OLD | NEW |