| 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 #ifndef REMOTING_HOST_CAST_VIDEO_CAPTURER_ADAPTER_H_ | 5 #ifndef REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
| 6 #define REMOTING_HOST_CAST_VIDEO_CAPTURER_ADAPTER_H_ | 6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" | 14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" |
| 15 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 16 | 16 |
| 17 namespace base { | 17 namespace base { |
| 18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 19 } // namespace base | 19 } // namespace base |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 class DesktopFrame; | 22 class DesktopFrame; |
| 23 } // namespace webrtc | 23 } // namespace webrtc |
| 24 | 24 |
| 25 namespace remoting { | 25 namespace remoting { |
| 26 | 26 |
| 27 // This class controls the capture of video frames from the desktop and is used | 27 // This class controls the capture of video frames from the desktop and is used |
| 28 // to construct a VideoSource as part of the webrtc PeerConnection API. | 28 // to construct a VideoSource as part of the webrtc PeerConnection API. |
| 29 // CastVideoCapturerAdapter acts as an adapter between webrtc::DesktopCapturer | 29 // WebrtcVideoCapturerAdapter acts as an adapter between webrtc::DesktopCapturer |
| 30 // and the cricket::VideoCapturer interface, which it implements. It is used | 30 // and the cricket::VideoCapturer interface, which it implements. It is used |
| 31 // to construct a cricket::VideoSource for a PeerConnection, to capture frames | 31 // to construct a cricket::VideoSource for a PeerConnection, to capture frames |
| 32 // of the desktop. As indicated in the base implementation, Start() and Stop() | 32 // of the desktop. As indicated in the base implementation, Start() and Stop() |
| 33 // should be called on the same thread. | 33 // should be called on the same thread. |
| 34 class CastVideoCapturerAdapter : public cricket::VideoCapturer, | 34 class WebrtcVideoCapturerAdapter : public cricket::VideoCapturer, |
| 35 public webrtc::DesktopCapturer::Callback { | 35 public webrtc::DesktopCapturer::Callback { |
| 36 public: | 36 public: |
| 37 explicit CastVideoCapturerAdapter( | 37 explicit WebrtcVideoCapturerAdapter( |
| 38 scoped_ptr<webrtc::DesktopCapturer> capturer); | 38 scoped_ptr<webrtc::DesktopCapturer> capturer); |
| 39 | 39 |
| 40 ~CastVideoCapturerAdapter() override; | 40 ~WebrtcVideoCapturerAdapter() override; |
| 41 | 41 |
| 42 // webrtc::DesktopCapturer::Callback implementation. | 42 // webrtc::DesktopCapturer::Callback implementation. |
| 43 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; | 43 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; |
| 44 // Converts |frame| to a cricket::CapturedFrame and emits that via | 44 // Converts |frame| to a cricket::CapturedFrame and emits that via |
| 45 // SignalFrameCaptured for the base::VideoCapturer implementation to process. | 45 // SignalFrameCaptured for the base::VideoCapturer implementation to process. |
| 46 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; | 46 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; |
| 47 | 47 |
| 48 // cricket::VideoCapturer implementation. | 48 // cricket::VideoCapturer implementation. |
| 49 bool GetBestCaptureFormat(const cricket::VideoFormat& desired, | 49 bool GetBestCaptureFormat(const cricket::VideoFormat& desired, |
| 50 cricket::VideoFormat* best_format) override; | 50 cricket::VideoFormat* best_format) override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 | 63 |
| 64 // |thread_checker_| is bound to the peer connection worker thread. | 64 // |thread_checker_| is bound to the peer connection worker thread. |
| 65 base::ThreadChecker thread_checker_; | 65 base::ThreadChecker thread_checker_; |
| 66 | 66 |
| 67 // Used to capture frames. | 67 // Used to capture frames. |
| 68 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer_; | 68 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer_; |
| 69 | 69 |
| 70 // Used to schedule periodic screen captures. | 70 // Used to schedule periodic screen captures. |
| 71 scoped_ptr<base::RepeatingTimer> capture_timer_; | 71 scoped_ptr<base::RepeatingTimer> capture_timer_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(CastVideoCapturerAdapter); | 73 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoCapturerAdapter); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace remoting | 76 } // namespace remoting |
| 77 | 77 |
| 78 #endif // REMOTING_HOST_CAST_VIDEO_CAPTURER_ADAPTER_H_ | 78 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ |
| 79 | 79 |
| OLD | NEW |