| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_ | 5 #ifndef REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_ |
| 6 #define REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_ | 6 #define REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" |
| 8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 9 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| 10 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 11 #include "third_party/webrtc/modules/desktop_capture/screen_capture_frame_queue.
h" | 12 #include "third_party/webrtc/modules/desktop_capture/screen_capture_frame_queue.
h" |
| 12 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 13 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 13 | 14 |
| 14 namespace remoting { | 15 namespace remoting { |
| 15 | 16 |
| 16 // A FakeScreenCapturer generates artificial image for testing purpose. | 17 // A FakeScreenCapturer generates artificial image for testing purpose. |
| 17 // | 18 // |
| 18 // FakeScreenCapturer is double-buffered as required by ScreenCapturer. | 19 // FakeScreenCapturer is double-buffered as required by ScreenCapturer. |
| 19 class FakeScreenCapturer : public webrtc::ScreenCapturer { | 20 class FakeScreenCapturer : public webrtc::ScreenCapturer { |
| 20 public: | 21 public: |
| 21 // FakeScreenCapturer generates a picture of size kWidth x kHeight. | 22 // By default FakeScreenCapturer generates frames of size kWidth x kHeight, |
| 23 // but custom frame generator set using set_frame_generator() may generate |
| 24 // frames of different size. |
| 22 static const int kWidth = 800; | 25 static const int kWidth = 800; |
| 23 static const int kHeight = 600; | 26 static const int kHeight = 600; |
| 24 | 27 |
| 28 typedef base::Callback<scoped_ptr<webrtc::DesktopFrame>( |
| 29 webrtc::ScreenCapturer::Callback* callback)> FrameGenerator; |
| 30 |
| 25 FakeScreenCapturer(); | 31 FakeScreenCapturer(); |
| 26 virtual ~FakeScreenCapturer(); | 32 virtual ~FakeScreenCapturer(); |
| 27 | 33 |
| 34 void set_frame_generator(const FrameGenerator& frame_generator); |
| 35 |
| 28 // webrtc::DesktopCapturer interface. | 36 // webrtc::DesktopCapturer interface. |
| 29 virtual void Start(Callback* callback) OVERRIDE; | 37 virtual void Start(Callback* callback) OVERRIDE; |
| 30 virtual void Capture(const webrtc::DesktopRegion& rect) OVERRIDE; | 38 virtual void Capture(const webrtc::DesktopRegion& rect) OVERRIDE; |
| 31 | 39 |
| 32 // ScreenCapturer interface. | 40 // webrtc::ScreenCapturer interface. |
| 33 virtual void SetMouseShapeObserver( | 41 virtual void SetMouseShapeObserver( |
| 34 MouseShapeObserver* mouse_shape_observer) OVERRIDE; | 42 MouseShapeObserver* mouse_shape_observer) OVERRIDE; |
| 35 virtual bool GetScreenList(ScreenList* screens) OVERRIDE; | 43 virtual bool GetScreenList(ScreenList* screens) OVERRIDE; |
| 36 virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE; | 44 virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE; |
| 37 | 45 |
| 38 private: | 46 private: |
| 39 // Generates an image in the front buffer. | 47 FrameGenerator frame_generator_; |
| 40 void GenerateImage(); | |
| 41 | |
| 42 // Called when the screen configuration is changed. | |
| 43 void ScreenConfigurationChanged(); | |
| 44 | 48 |
| 45 Callback* callback_; | 49 Callback* callback_; |
| 46 MouseShapeObserver* mouse_shape_observer_; | 50 MouseShapeObserver* mouse_shape_observer_; |
| 47 | 51 |
| 48 webrtc::DesktopSize size_; | |
| 49 int bytes_per_row_; | |
| 50 int box_pos_x_; | |
| 51 int box_pos_y_; | |
| 52 int box_speed_x_; | |
| 53 int box_speed_y_; | |
| 54 | |
| 55 webrtc::ScreenCaptureFrameQueue queue_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(FakeScreenCapturer); | 52 DISALLOW_COPY_AND_ASSIGN(FakeScreenCapturer); |
| 58 }; | 53 }; |
| 59 | 54 |
| 60 } // namespace remoting | 55 } // namespace remoting |
| 61 | 56 |
| 62 #endif // REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_ | 57 #endif // REMOTING_HOST_FAKE_SCREEN_CAPTURER_H_ |
| OLD | NEW |