diff options
author | sergeyu <sergeyu@chromium.org> | 2015-11-24 14:07:53 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-24 22:08:49 +0000 |
commit | 2536ddbba72ac599fe2bcedf2b9c29cb0d292dc9 (patch) | |
tree | c174c9ff5c118b12292b7d6b8f19a348f625c994 /remoting/protocol/webrtc_video_capturer_adapter.h | |
parent | ca374497a82e6bf64922d80f4e85e163c0489a64 (diff) | |
download | chromium_src-2536ddbba72ac599fe2bcedf2b9c29cb0d292dc9.zip chromium_src-2536ddbba72ac599fe2bcedf2b9c29cb0d292dc9.tar.gz chromium_src-2536ddbba72ac599fe2bcedf2b9c29cb0d292dc9.tar.bz2 |
Move and rename host/cast_video_capture_adapter to protocol/webrtc_video_capture_adapter
The adapter will be used in the protocol layer for WebRTC-based connections.
BUG=547158
Review URL: https://codereview.chromium.org/1472703006
Cr-Commit-Position: refs/heads/master@{#361465}
Diffstat (limited to 'remoting/protocol/webrtc_video_capturer_adapter.h')
-rw-r--r-- | remoting/protocol/webrtc_video_capturer_adapter.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/remoting/protocol/webrtc_video_capturer_adapter.h b/remoting/protocol/webrtc_video_capturer_adapter.h new file mode 100644 index 0000000..9c46178 --- /dev/null +++ b/remoting/protocol/webrtc_video_capturer_adapter.h @@ -0,0 +1,79 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ +#define REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ + +#include <vector> + +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "base/threading/thread_checker.h" +#include "base/timer/timer.h" +#include "third_party/libjingle/source/talk/media/base/videocapturer.h" +#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" + +namespace base { +class SingleThreadTaskRunner; +} // namespace base + +namespace webrtc { +class DesktopFrame; +} // namespace webrtc + +namespace remoting { + +// This class controls the capture of video frames from the desktop and is used +// to construct a VideoSource as part of the webrtc PeerConnection API. +// WebrtcVideoCapturerAdapter acts as an adapter between webrtc::DesktopCapturer +// and the cricket::VideoCapturer interface, which it implements. It is used +// to construct a cricket::VideoSource for a PeerConnection, to capture frames +// of the desktop. As indicated in the base implementation, Start() and Stop() +// should be called on the same thread. +class WebrtcVideoCapturerAdapter : public cricket::VideoCapturer, + public webrtc::DesktopCapturer::Callback { + public: + explicit WebrtcVideoCapturerAdapter( + scoped_ptr<webrtc::DesktopCapturer> capturer); + + ~WebrtcVideoCapturerAdapter() override; + + // webrtc::DesktopCapturer::Callback implementation. + webrtc::SharedMemory* CreateSharedMemory(size_t size) override; + // Converts |frame| to a cricket::CapturedFrame and emits that via + // SignalFrameCaptured for the base::VideoCapturer implementation to process. + void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; + + // cricket::VideoCapturer implementation. + bool GetBestCaptureFormat(const cricket::VideoFormat& desired, + cricket::VideoFormat* best_format) override; + cricket::CaptureState Start( + const cricket::VideoFormat& capture_format) override; + bool Pause(bool pause) override; + void Stop() override; + bool IsRunning() override; + bool IsScreencast() const override; + bool GetPreferredFourccs(std::vector<uint32>* fourccs) override; + + private: + // Kicks off the next frame capture using |desktop_capturer_|. + // The captured frame will be passed to OnCaptureCompleted(). + void CaptureNextFrame(); + + // |thread_checker_| is bound to the peer connection worker thread. + base::ThreadChecker thread_checker_; + + // Used to capture frames. + scoped_ptr<webrtc::DesktopCapturer> desktop_capturer_; + + // Used to schedule periodic screen captures. + scoped_ptr<base::RepeatingTimer> capture_timer_; + + DISALLOW_COPY_AND_ASSIGN(WebrtcVideoCapturerAdapter); +}; + +} // namespace remoting + +#endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ + |