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

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

Issue 2079253003: Move frame scheduling logic from WebrtcFrameScheduler to WebrtcVideoStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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
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_STREAM_H_ 5 #ifndef REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_
6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ 6 #define REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread_checker.h"
17 #include "base/timer/timer.h"
15 #include "remoting/codec/video_encoder.h" 18 #include "remoting/codec/video_encoder.h"
16 #include "remoting/protocol/video_stream.h" 19 #include "remoting/protocol/video_stream.h"
17 #include "remoting/protocol/webrtc_frame_scheduler.h" 20 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
18 21
19 namespace webrtc { 22 namespace webrtc {
20 class DesktopSize;
21 class DesktopCapturer;
22 class MediaStreamInterface; 23 class MediaStreamInterface;
23 class PeerConnectionInterface; 24 class PeerConnectionInterface;
24 class PeerConnectionFactoryInterface; 25 class PeerConnectionFactoryInterface;
25 class VideoTrackInterface; 26 class VideoTrackInterface;
26 } // namespace webrtc 27 } // namespace webrtc
27 28
28 namespace remoting { 29 namespace remoting {
29 namespace protocol { 30 namespace protocol {
30 31
31 class WebrtcVideoCapturerAdapter; 32 class WebrtcVideoCapturerAdapter;
33 class WebrtcTransport;
32 34
33 class WebrtcVideoStream : public VideoStream { 35 class WebrtcVideoStream : public VideoStream,
36 public webrtc::DesktopCapturer::Callback {
34 public: 37 public:
35 WebrtcVideoStream(); 38 WebrtcVideoStream();
36 ~WebrtcVideoStream() override; 39 ~WebrtcVideoStream() override;
37 40
38 bool Start( 41 bool Start(
39 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer, 42 std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer,
40 WebrtcTransport* webrtc_transport, 43 WebrtcTransport* webrtc_transport,
41 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, 44 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
42 std::unique_ptr<VideoEncoder> video_encoder); 45 std::unique_ptr<VideoEncoder> video_encoder);
43 46
44 // VideoStream interface. 47 // VideoStream interface.
45 void Pause(bool pause) override; 48 void Pause(bool pause) override;
46 void OnInputEventReceived(int64_t event_timestamp) override; 49 void OnInputEventReceived(int64_t event_timestamp) override;
47 void SetLosslessEncode(bool want_lossless) override; 50 void SetLosslessEncode(bool want_lossless) override;
48 void SetLosslessColor(bool want_lossless) override; 51 void SetLosslessColor(bool want_lossless) override;
49 void SetSizeCallback(const SizeCallback& size_callback) override; 52 void SetSizeCallback(const SizeCallback& size_callback) override;
50 53
51 private: 54 private:
52 scoped_refptr<webrtc::PeerConnectionInterface> connection_; 55 // webrtc::DesktopCapturer::Callback interface.
56 void OnCaptureResult(webrtc::DesktopCapturer::Result result,
57 std::unique_ptr<webrtc::DesktopFrame> frame) override;
58
59 // Starts |capture_timer_|.
60 void StartCaptureTimer();
61
62 // Called by |capture_timer_|.
63 void CaptureNextFrame();
64
65 void OnFrameEncoded(std::unique_ptr<VideoPacket> packet);
66
67 void SetKeyFrameRequest();
68 bool ClearAndGetKeyFrameRequest();
69 void SetTargetBitrate(int bitrate);
70
71 scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
53 scoped_refptr<webrtc::MediaStreamInterface> stream_; 72 scoped_refptr<webrtc::MediaStreamInterface> stream_;
54 73
55 // Owned by the dummy video capturer. 74 bool key_frame_request_ = false;
56 WebrtcFrameScheduler* webrtc_frame_scheduler_; 75 uint32_t target_bitrate_kbps_ = 1000; // Initial bitrate.
76
77 bool received_first_frame_request_ = false;
78
79 bool capture_pending_ = false;
80 bool encode_pending_ = false;
81
82 // Last time capture was started.
83 base::TimeTicks last_capture_started_ticks_;
84
85 webrtc::DesktopSize frame_size_;
86 webrtc::DesktopVector frame_dpi_;
87 SizeCallback size_callback_;
88
89 // Main task runner.
90 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
91
92 // Task runner used to run |encoder_|.
93 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
94
95 // Capturer used to capture the screen.
96 std::unique_ptr<webrtc::DesktopCapturer> capturer_;
97
98 std::unique_ptr<base::RepeatingTimer> capture_timer_;
99
100 // Used to send across encoded frames.
101 WebrtcTransport* webrtc_transport_ = nullptr;
102
103 // Used to encode captured frames. Always accessed on the encode thread.
104 std::unique_ptr<VideoEncoder> encoder_;
105
106 base::ThreadChecker thread_checker_;
107
108 base::WeakPtrFactory<WebrtcVideoStream> weak_factory_;
57 109
58 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoStream); 110 DISALLOW_COPY_AND_ASSIGN(WebrtcVideoStream);
59 }; 111 };
60 112
61 } // namespace protocol 113 } // namespace protocol
62 } // namespace remoting 114 } // namespace remoting
63 115
64 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_ 116 #endif // REMOTING_PROTOCOL_WEBRTC_VIDEO_STREAM_H_
OLDNEW
« no previous file with comments | « remoting/protocol/webrtc_video_encoder_factory.cc ('k') | remoting/protocol/webrtc_video_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698