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

Unified Diff: remoting/protocol/webrtc_video_stream.h

Issue 2200273003: Enable video stats reporting when using WebRTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TODO Created 4 years, 4 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
Index: remoting/protocol/webrtc_video_stream.h
diff --git a/remoting/protocol/webrtc_video_stream.h b/remoting/protocol/webrtc_video_stream.h
index 1ce0b47b9a69b75019964d2a16c071a23be8d6ef..a837cde993640f74ed7ac0f5a444500ad280daff 100644
--- a/remoting/protocol/webrtc_video_stream.h
+++ b/remoting/protocol/webrtc_video_stream.h
@@ -16,6 +16,7 @@
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
#include "remoting/codec/video_encoder.h"
+#include "remoting/protocol/host_video_stats_dispatcher.h"
#include "remoting/protocol/video_stream.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
@@ -29,11 +30,13 @@ class VideoTrackInterface;
namespace remoting {
namespace protocol {
+class HostVideoStatsDispatcher;
class WebrtcVideoCapturerAdapter;
class WebrtcTransport;
class WebrtcVideoStream : public VideoStream,
- public webrtc::DesktopCapturer::Callback {
+ public webrtc::DesktopCapturer::Callback,
+ public HostVideoStatsDispatcher::EventHandler {
public:
WebrtcVideoStream();
~WebrtcVideoStream() override;
@@ -52,25 +55,56 @@ class WebrtcVideoStream : public VideoStream,
void SetObserver(Observer* observer) override;
private:
+ struct FrameTimestamps;
+ struct PacketWithTimestamps;
+
// webrtc::DesktopCapturer::Callback interface.
void OnCaptureResult(webrtc::DesktopCapturer::Result result,
std::unique_ptr<webrtc::DesktopFrame> frame) override;
+ // HostVideoStatsDispatcher::EventHandler interface.
+ void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override;
+ void OnChannelClosed(ChannelDispatcherBase* channel_dispatcher) override;
+
// Starts |capture_timer_|.
void StartCaptureTimer();
// Called by |capture_timer_|.
void CaptureNextFrame();
- void OnFrameEncoded(std::unique_ptr<VideoPacket> packet);
+ // Task running on the encoder thread to encode the |frame|.
+ static PacketWithTimestamps EncodeFrame(
+ VideoEncoder* encoder,
+ std::unique_ptr<webrtc::DesktopFrame> frame,
+ std::unique_ptr<WebrtcVideoStream::FrameTimestamps> timestamps,
+ uint32_t target_bitrate_kbps,
+ bool key_frame_request);
+ void OnFrameEncoded(PacketWithTimestamps packet);
void SetKeyFrameRequest();
bool ClearAndGetKeyFrameRequest();
void SetTargetBitrate(int bitrate);
+ // Capturer used to capture the screen.
+ std::unique_ptr<webrtc::DesktopCapturer> capturer_;
+ // Used to send across encoded frames.
+ WebrtcTransport* webrtc_transport_ = nullptr;
+ // Task runner used to run |encoder_|.
+ scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner_;
+ // Used to encode captured frames. Always accessed on the encode thread.
+ std::unique_ptr<VideoEncoder> encoder_;
+
scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
scoped_refptr<webrtc::MediaStreamInterface> stream_;
+ HostVideoStatsDispatcher video_stats_dispatcher_;
+
+ // Timestamps for the frame to be captured next.
+ std::unique_ptr<FrameTimestamps> next_frame_timestamps_;
+
+ // Timestamps for the frame that's being captured.
+ std::unique_ptr<FrameTimestamps> captured_frame_timestamps_;
+
bool key_frame_request_ = false;
uint32_t target_bitrate_kbps_ = 1000; // Initial bitrate.
@@ -86,22 +120,7 @@ class WebrtcVideoStream : public VideoStream,
webrtc::DesktopVector frame_dpi_;
Observer* observer_ = nullptr;
- // 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::RepeatingTimer capture_timer_;
base::ThreadChecker thread_checker_;

Powered by Google App Engine
This is Rietveld 408576698