Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_CLIENT_OPENGL_GL_SOFTWARE_VIDEO_RENDERER_H_ | |
| 6 #define REMOTING_CLIENT_OPENGL_GL_SOFTWARE_VIDEO_RENDERER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "remoting/client/software_video_renderer.h" | |
| 13 #include "remoting/protocol/frame_consumer.h" | |
| 14 | |
| 15 namespace webrtc { | |
| 16 class SharedDesktopFrame; | |
| 17 } | |
| 18 | |
| 19 namespace remoting { | |
| 20 | |
| 21 // This class uses one single BasicDesktopFrame buffer to decode all video | |
| 22 // frames using the underlying video renderer. | |
| 23 // 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.
| |
| 24 // rendering happen at the same time. | |
| 25 // This class should be used and destroyed on the same thread. If |task_runner| | |
| 26 // is null |callback| will be run directly upon the stack of DrawFrame, | |
| 27 // otherwise it will be run on the thread of |task_runner|. | |
| 28 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
| |
| 29 public protocol::VideoRenderer { | |
| 30 public: | |
| 31 SharedFrameVideoRenderer( | |
| 32 base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback, | |
| 33 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 34 PixelFormat format); | |
| 35 ~SharedFrameVideoRenderer() override; | |
| 36 | |
| 37 // The underlying video renderer must be set before using this class. | |
| 38 void SetUnderlyingVideoRenderer( | |
| 39 std::unique_ptr<protocol::VideoRenderer> renderer); | |
| 40 | |
| 41 // VideoRenderer interface. Function calls will just be forwarded to the | |
| 42 // underlying video renderer. | |
| 43 bool Initialize(const ClientContext& client_context, | |
| 44 protocol::FrameStatsConsumer* perf_tracker) override; | |
| 45 void OnSessionConfig(const protocol::SessionConfig& config) override; | |
| 46 protocol::VideoStub* GetVideoStub() override; | |
| 47 protocol::FrameConsumer* GetFrameConsumer() override; | |
| 48 protocol::FrameStatsConsumer* GetFrameStatsConsumer() override; | |
| 49 | |
| 50 // FrameConsumer interface. | |
| 51 std::unique_ptr<webrtc::DesktopFrame> AllocateFrame( | |
| 52 const webrtc::DesktopSize& size) override; | |
| 53 void DrawFrame(std::unique_ptr<webrtc::DesktopFrame> frame, | |
| 54 const base::Closure& done) override; | |
| 55 PixelFormat GetPixelFormat() override; | |
| 56 | |
| 57 private: | |
| 58 void OnFrameRendered(const base::Closure& done); | |
| 59 | |
| 60 std::unique_ptr<protocol::VideoRenderer> underlying_video_renderer_; | |
| 61 | |
| 62 std::unique_ptr<webrtc::SharedDesktopFrame> shared_frame_; | |
| 63 base::Callback<void(std::unique_ptr<webrtc::DesktopFrame>)> callback_; | |
| 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 65 PixelFormat pixel_format_; | |
| 66 base::ThreadChecker thread_checker_; | |
| 67 base::WeakPtrFactory<SharedFrameVideoRenderer> weak_factory_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(SharedFrameVideoRenderer); | |
| 70 }; | |
| 71 | |
| 72 } // namespace remoting | |
| 73 #endif // REMOTING_CLIENT_OPENGL_GL_SOFTWARE_VIDEO_RENDERER_H_ | |
| OLD | NEW |