| Index: remoting/protocol/webrtc_video_stream.h
|
| diff --git a/remoting/protocol/webrtc_video_stream.h b/remoting/protocol/webrtc_video_stream.h
|
| index 59230a690ca5ea312e6dc270d7f1045be844fa69..5db4750cbfb14a2c063f06bfcfd7c9e5e408ded6 100644
|
| --- a/remoting/protocol/webrtc_video_stream.h
|
| +++ b/remoting/protocol/webrtc_video_stream.h
|
| @@ -9,16 +9,17 @@
|
|
|
| #include <memory>
|
|
|
| +#include "base/callback.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/threading/thread_checker.h"
|
| +#include "base/timer/timer.h"
|
| #include "remoting/codec/video_encoder.h"
|
| #include "remoting/protocol/video_stream.h"
|
| -#include "remoting/protocol/webrtc_frame_scheduler.h"
|
| +#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
|
|
|
| namespace webrtc {
|
| -class DesktopSize;
|
| -class DesktopCapturer;
|
| class MediaStreamInterface;
|
| class PeerConnectionInterface;
|
| class PeerConnectionFactoryInterface;
|
| @@ -29,8 +30,10 @@ namespace remoting {
|
| namespace protocol {
|
|
|
| class WebrtcVideoCapturerAdapter;
|
| +class WebrtcTransport;
|
|
|
| -class WebrtcVideoStream : public VideoStream {
|
| +class WebrtcVideoStream : public VideoStream,
|
| + public webrtc::DesktopCapturer::Callback {
|
| public:
|
| WebrtcVideoStream();
|
| ~WebrtcVideoStream() override;
|
| @@ -38,7 +41,7 @@ class WebrtcVideoStream : public VideoStream {
|
| bool Start(
|
| std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer,
|
| WebrtcTransport* webrtc_transport,
|
| - scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner,
|
| + scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
|
| std::unique_ptr<VideoEncoder> video_encoder);
|
|
|
| // VideoStream interface.
|
| @@ -49,11 +52,60 @@ class WebrtcVideoStream : public VideoStream {
|
| void SetSizeCallback(const SizeCallback& size_callback) override;
|
|
|
| private:
|
| - scoped_refptr<webrtc::PeerConnectionInterface> connection_;
|
| + // webrtc::DesktopCapturer::Callback interface.
|
| + void OnCaptureResult(webrtc::DesktopCapturer::Result result,
|
| + std::unique_ptr<webrtc::DesktopFrame> frame) override;
|
| +
|
| + // Starts |capture_timer_|.
|
| + void StartCaptureTimer();
|
| +
|
| + // Called by |capture_timer_|.
|
| + void CaptureNextFrame();
|
| +
|
| + void OnFrameEncoded(std::unique_ptr<VideoPacket> packet);
|
| +
|
| + void SetKeyFrameRequest();
|
| + bool ClearAndGetKeyFrameRequest();
|
| + void SetTargetBitrate(int bitrate);
|
| +
|
| + scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
|
| scoped_refptr<webrtc::MediaStreamInterface> stream_;
|
|
|
| - // Owned by the dummy video capturer.
|
| - WebrtcFrameScheduler* webrtc_frame_scheduler_;
|
| + bool key_frame_request_ = false;
|
| + uint32_t target_bitrate_kbps_ = 1000; // Initial bitrate.
|
| +
|
| + bool received_first_frame_request_ = false;
|
| +
|
| + bool capture_pending_ = false;
|
| + bool encode_pending_ = false;
|
| +
|
| + // Last time capture was started.
|
| + base::TimeTicks last_capture_started_ticks_;
|
| +
|
| + webrtc::DesktopSize frame_size_;
|
| + webrtc::DesktopVector frame_dpi_;
|
| + SizeCallback size_callback_;
|
| +
|
| + // Main task runner.
|
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
|
| +
|
| + // Task runner used to run |encoder_|.
|
| + scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
|
| +
|
| + // Capturer used to capture the screen.
|
| + std::unique_ptr<webrtc::DesktopCapturer> capturer_;
|
| +
|
| + std::unique_ptr<base::RepeatingTimer> capture_timer_;
|
| +
|
| + // Used to send across encoded frames.
|
| + WebrtcTransport* webrtc_transport_ = nullptr;
|
| +
|
| + // Used to encode captured frames. Always accessed on the encode thread.
|
| + std::unique_ptr<VideoEncoder> encoder_;
|
| +
|
| + base::ThreadChecker thread_checker_;
|
| +
|
| + base::WeakPtrFactory<WebrtcVideoStream> weak_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WebrtcVideoStream);
|
| };
|
|
|