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

Unified Diff: remoting/protocol/webrtc_frame_scheduler.h

Issue 1846893002: Interface with webrtc through encoded frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sergey comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/webrtc_dummy_video_capturer.cc ('k') | remoting/protocol/webrtc_frame_scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/webrtc_frame_scheduler.h
diff --git a/remoting/protocol/webrtc_frame_scheduler.h b/remoting/protocol/webrtc_frame_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..0e9f3fce026fa22da3a288f7c79164fa724a0f07
--- /dev/null
+++ b/remoting/protocol/webrtc_frame_scheduler.h
@@ -0,0 +1,101 @@
+// Copyright 2016 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_FRAME_SCHEDULER_H_
+#define REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "base/task/cancelable_task_tracker.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_transport.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
+
+namespace remoting {
+namespace protocol {
+
+// Class responsible for scheduling frames for encode and hand-over to
+// WebRtc transport for sending across the network.
+class WebRtcFrameScheduler : public webrtc::DesktopCapturer::Callback {
+ public:
+ WebRtcFrameScheduler(
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner,
+ std::unique_ptr<webrtc::DesktopCapturer> capturer,
+ WebrtcTransport* webrtc_transport,
+ std::unique_ptr<VideoEncoder> encoder);
+ ~WebRtcFrameScheduler() override;
+
+ // Starts scheduling frames to be encoded and transported.
+ void Start();
+ // Stops scheduling frames.
+ void Stop();
+
+ void Pause(bool pause);
+
+ void SetSizeCallback(const VideoStream::SizeCallback& size_callback);
+
+ private:
+ // webrtc::DesktopCapturer::Callback interface.
+ webrtc::SharedMemory* CreateSharedMemory(size_t size) override;
+ void OnCaptureCompleted(webrtc::DesktopFrame* frame) override;
+
+ // Callback for CaptureScheduler.
+ void CaptureNextFrame();
+
+ // Task running on the encoder thread to encode the |frame|.
+ static std::unique_ptr<VideoPacket> EncodeFrame(
+ VideoEncoder* encoder,
+ std::unique_ptr<webrtc::DesktopFrame> frame,
+ bool key_frame_request);
+ void OnFrameEncoded(std::unique_ptr<VideoPacket> packet);
+
+ void SetKeyFrameRequest();
+ bool ClearAndGetKeyFrameRequest();
+
+ // Protects |key_frame_request_|.
+ base::Lock lock_;
+ bool key_frame_request_ = false;
+
+ bool capture_pending_ = false;
+ bool encode_pending_ = false;
+
+ webrtc::DesktopSize frame_size_;
+ webrtc::DesktopVector frame_dpi_;
+ VideoStream::SizeCallback size_callback_;
+
+ // Task runner used to run |encoder_|.
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
+ base::CancelableTaskTracker task_tracker_;
+
+ // 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_;
+
+ // Used to encode captured frames. Always accessed on the encode thread.
+ std::unique_ptr<VideoEncoder> encoder_;
+
+ base::ThreadChecker thread_checker_;
+ base::TimeTicks last_capture_ticks_;
+
+ base::WeakPtrFactory<WebRtcFrameScheduler> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebRtcFrameScheduler);
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_WEBRTC_FRAME_SCHEDULER_H_
« no previous file with comments | « remoting/protocol/webrtc_dummy_video_capturer.cc ('k') | remoting/protocol/webrtc_frame_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698