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

Unified Diff: remoting/client/shared_frame_video_renderer.h

Issue 2156713002: [Chromoting] Implement DualBufferFrameConsumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/client/shared_frame_video_renderer.h
diff --git a/remoting/client/shared_frame_video_renderer.h b/remoting/client/shared_frame_video_renderer.h
new file mode 100644
index 0000000000000000000000000000000000000000..c84364dd93ee239e0ee995f593d1960c9ecce824
--- /dev/null
+++ b/remoting/client/shared_frame_video_renderer.h
@@ -0,0 +1,73 @@
+// 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_CLIENT_OPENGL_GL_SOFTWARE_VIDEO_RENDERER_H_
+#define REMOTING_CLIENT_OPENGL_GL_SOFTWARE_VIDEO_RENDERER_H_
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/threading/thread_checker.h"
+#include "remoting/client/software_video_renderer.h"
+#include "remoting/protocol/frame_consumer.h"
+
+namespace webrtc {
+class SharedDesktopFrame;
+}
+
+namespace remoting {
+
+// This class uses one single BasicDesktopFrame buffer to decode all video
+// frames using the underlying video renderer.
+// There is no synchronization to prevent screen tearing if decoding and
Yuwei 2016/07/15 20:57:12 I'm not sure whether screen tearing is a concern I
Sergey Ulanov 2016/07/15 22:14:48 Ideally we want to avoid it. ScreenCaptures don't
Yuwei 2016/07/15 22:55:32 It will work if we just use the buffers to store u
Yuwei 2016/07/16 02:24:56 Hmm... I think it is possible to keep track of rec
Yuwei 2016/07/16 02:31:00 NVM... DesktopRegion::AddRect and DesktopRegion::S
Yuwei 2016/07/18 18:53:47 Done. Used dual buffers.
+// rendering happen at the same time.
+// This class should be used and destroyed on the same thread. If |task_runner|
+// is null |callback| will be run directly upon the stack of DrawFrame,
+// otherwise it will be run on the thread of |task_runner|.
+class SharedFrameVideoRenderer : public protocol::FrameConsumer,
Sergey Ulanov 2016/07/15 22:14:48 Do you actually need to implement VideoRenderer in
Yuwei 2016/07/15 22:55:32 This is basically managing to give VideoRenderer a
Yuwei 2016/07/18 18:53:47 Done. Made SoftwareVideoRenderer able to own a Fra
+ public protocol::VideoRenderer {
+ public:
+ SharedFrameVideoRenderer(
+ base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ PixelFormat format);
+ ~SharedFrameVideoRenderer() override;
+
+ // The underlying video renderer must be set before using this class.
+ void SetUnderlyingVideoRenderer(
+ std::unique_ptr<protocol::VideoRenderer> renderer);
+
+ // VideoRenderer interface. Function calls will just be forwarded to the
+ // underlying video renderer.
+ bool Initialize(const ClientContext& client_context,
+ protocol::FrameStatsConsumer* perf_tracker) override;
+ void OnSessionConfig(const protocol::SessionConfig& config) override;
+ protocol::VideoStub* GetVideoStub() override;
+ protocol::FrameConsumer* GetFrameConsumer() override;
+ protocol::FrameStatsConsumer* GetFrameStatsConsumer() override;
+
+ // FrameConsumer interface.
+ std::unique_ptr<webrtc::DesktopFrame> AllocateFrame(
+ const webrtc::DesktopSize& size) override;
+ void DrawFrame(std::unique_ptr<webrtc::DesktopFrame> frame,
+ const base::Closure& done) override;
+ PixelFormat GetPixelFormat() override;
+
+ private:
+ void OnFrameRendered(const base::Closure& done);
+
+ std::unique_ptr<protocol::VideoRenderer> underlying_video_renderer_;
+
+ std::unique_ptr<webrtc::SharedDesktopFrame> shared_frame_;
+ base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback_;
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ PixelFormat pixel_format_;
+ base::ThreadChecker thread_checker_;
+ base::WeakPtrFactory<SharedFrameVideoRenderer> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedFrameVideoRenderer);
+};
+
+} // namespace remoting
+#endif // REMOTING_CLIENT_OPENGL_GL_SOFTWARE_VIDEO_RENDERER_H_
« no previous file with comments | « no previous file | remoting/client/shared_frame_video_renderer.cc » ('j') | remoting/client/shared_frame_video_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698