Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: remoting/protocol/webrtc_video_capturer_adapter.h

Issue 1844143002: Add VideoLayout message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/video_stream.h ('k') | remoting/protocol/webrtc_video_capturer_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 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_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_
6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "remoting/protocol/video_stream.h"
18 #include "third_party/webrtc/media/base/videocapturer.h" 19 #include "third_party/webrtc/media/base/videocapturer.h"
19 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 20 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
20 21
21 namespace base { 22 namespace base {
22 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
23 } // namespace base 24 } // namespace base
24 25
25 namespace cricket { 26 namespace cricket {
26 class VideoFrame; 27 class VideoFrame;
27 } // namespace cricket 28 } // namespace cricket
28 29
29 namespace webrtc { 30 namespace webrtc {
30 class DesktopFrame; 31 class DesktopFrame;
31 } // namespace webrtc 32 } // namespace webrtc
32 33
33 namespace remoting { 34 namespace remoting {
34 namespace protocol { 35 namespace protocol {
35 36
36 // This class controls the capture of video frames from the desktop and is used 37 // This class controls the capture of video frames from the desktop and is used
37 // to construct a VideoSource as part of the webrtc PeerConnection API. 38 // to construct a VideoSource as part of the webrtc PeerConnection API.
38 // WebrtcVideoCapturerAdapter acts as an adapter between webrtc::DesktopCapturer 39 // WebrtcVideoCapturerAdapter acts as an adapter between webrtc::DesktopCapturer
39 // and the cricket::VideoCapturer interface, which it implements. It is used 40 // and the cricket::VideoCapturer interface, which it implements. It is used
40 // to construct a cricket::VideoSource for a PeerConnection, to capture frames 41 // to construct a cricket::VideoSource for a PeerConnection, to capture frames
41 // of the desktop. As indicated in the base implementation, Start() and Stop() 42 // of the desktop. As indicated in the base implementation, Start() and Stop()
42 // should be called on the same thread. 43 // should be called on the same thread.
43 class WebrtcVideoCapturerAdapter : public cricket::VideoCapturer, 44 class WebrtcVideoCapturerAdapter : public cricket::VideoCapturer,
44 public webrtc::DesktopCapturer::Callback { 45 public webrtc::DesktopCapturer::Callback {
45 public: 46 public:
46 typedef base::Callback<void(const webrtc::DesktopSize& size)> SizeCallback;
47
48 explicit WebrtcVideoCapturerAdapter( 47 explicit WebrtcVideoCapturerAdapter(
49 scoped_ptr<webrtc::DesktopCapturer> capturer); 48 scoped_ptr<webrtc::DesktopCapturer> capturer);
50 ~WebrtcVideoCapturerAdapter() override; 49 ~WebrtcVideoCapturerAdapter() override;
51 50
52 void SetSizeCallback(const SizeCallback& size_callback); 51 void SetSizeCallback(const VideoStream::SizeCallback& size_callback);
53 bool PauseCapturer(bool pause); 52 bool PauseCapturer(bool pause);
54 base::WeakPtr<WebrtcVideoCapturerAdapter> GetWeakPtr(); 53 base::WeakPtr<WebrtcVideoCapturerAdapter> GetWeakPtr();
55 54
56 // cricket::VideoCapturer implementation. 55 // cricket::VideoCapturer implementation.
57 bool GetBestCaptureFormat(const cricket::VideoFormat& desired, 56 bool GetBestCaptureFormat(const cricket::VideoFormat& desired,
58 cricket::VideoFormat* best_format) override; 57 cricket::VideoFormat* best_format) override;
59 cricket::CaptureState Start( 58 cricket::CaptureState Start(
60 const cricket::VideoFormat& capture_format) override; 59 const cricket::VideoFormat& capture_format) override;
61 void Stop() override; 60 void Stop() override;
62 bool IsRunning() override; 61 bool IsRunning() override;
63 bool IsScreencast() const override; 62 bool IsScreencast() const override;
64 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override; 63 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override;
65 64
66 private: 65 private:
67 // webrtc::DesktopCapturer::Callback implementation. 66 // webrtc::DesktopCapturer::Callback implementation.
68 webrtc::SharedMemory* CreateSharedMemory(size_t size) override; 67 webrtc::SharedMemory* CreateSharedMemory(size_t size) override;
69 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override; 68 void OnCaptureCompleted(webrtc::DesktopFrame* frame) override;
70 69
71 // Kicks off the next frame capture using |desktop_capturer_|. The captured 70 // Kicks off the next frame capture using |desktop_capturer_|. The captured
72 // frame will be passed to OnCaptureCompleted(). 71 // frame will be passed to OnCaptureCompleted().
73 void CaptureNextFrame(); 72 void CaptureNextFrame();
74 73
75 base::ThreadChecker thread_checker_; 74 base::ThreadChecker thread_checker_;
76 75
77 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer_; 76 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer_;
78 77
79 SizeCallback size_callback_; 78 VideoStream::SizeCallback size_callback_;
80 79
81 // Timer to call CaptureNextFrame(). 80 // Timer to call CaptureNextFrame().
82 scoped_ptr<base::RepeatingTimer> capture_timer_; 81 scoped_ptr<base::RepeatingTimer> capture_timer_;
83 82
84 // Video frame is kept between captures to avoid YUV conversion for static 83 // Video frame is kept between captures to avoid YUV conversion for static
85 // parts of the screen. 84 // parts of the screen.
86 scoped_ptr<cricket::VideoFrame> yuv_frame_; 85 scoped_ptr<cricket::VideoFrame> yuv_frame_;
87 86
88 bool capture_pending_ = false; 87 bool capture_pending_ = false;
89 bool paused_ = false; 88 bool paused_ = false;
90 89
91 base::WeakPtrFactory<WebrtcVideoCapturerAdapter> weak_factory_; 90 base::WeakPtrFactory<WebrtcVideoCapturerAdapter> weak_factory_;
92 91
93 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoCapturerAdapter); 92 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoCapturerAdapter);
94 }; 93 };
95 94
96 } // namespace protocol 95 } // namespace protocol
97 } // namespace remoting 96 } // namespace remoting
98 97
99 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_ 98 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_CAPTURER_ADAPTER_H_
100 99
OLDNEW
« no previous file with comments | « remoting/protocol/video_stream.h ('k') | remoting/protocol/webrtc_video_capturer_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698