| OLD | NEW | 
|   1 // Copyright 2014 The Chromium Authors. All rights reserved. |   1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
|   2 // Use of this source code is governed by a BSD-style license that can be |   2 // Use of this source code is governed by a BSD-style license that can be | 
|   3 // found in the LICENSE file. |   3 // found in the LICENSE file. | 
|   4  |   4  | 
|   5 #ifndef REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |   5 #ifndef REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 
|   6 #define REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |   6 #define REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 
|   7  |   7  | 
|   8 #include <stdint.h> |   8 #include <stdint.h> | 
|   9  |   9  | 
|  10 #include <memory> |  10 #include <memory> | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|  37  |  37  | 
|  38 // Implementation of VideoRenderer interface that decodes frame on CPU (on a |  38 // Implementation of VideoRenderer interface that decodes frame on CPU (on a | 
|  39 // decode thread) and then passes decoded frames to a FrameConsumer. |  39 // decode thread) and then passes decoded frames to a FrameConsumer. | 
|  40 class SoftwareVideoRenderer : public protocol::VideoRenderer, |  40 class SoftwareVideoRenderer : public protocol::VideoRenderer, | 
|  41                               public protocol::VideoStub { |  41                               public protocol::VideoStub { | 
|  42  public: |  42  public: | 
|  43   // The renderer can be created on any thread but afterwards all methods must |  43   // The renderer can be created on any thread but afterwards all methods must | 
|  44   // be called on the same thread. |  44   // be called on the same thread. | 
|  45   explicit SoftwareVideoRenderer(protocol::FrameConsumer* consumer); |  45   explicit SoftwareVideoRenderer(protocol::FrameConsumer* consumer); | 
|  46  |  46  | 
|  47   // Deprecated constructor. TODO(yuweih): remove. |  47   // Same as above, but take ownership of the |consumer|. | 
|  48   // Constructs the renderer and initializes it immediately. Caller should not |  48   explicit SoftwareVideoRenderer( | 
|  49   // call Initialize() after using this constructor. |  49       std::unique_ptr<protocol::FrameConsumer> consumer); | 
|  50   // All methods must be called on the same thread the renderer is created. The |  50  | 
|  51   // |decode_task_runner_| is used to decode the video packets. |consumer| and |  | 
|  52   // |stats_consumer| must outlive the renderer. |stats_consumer| may be |  | 
|  53   // nullptr, performance tracking is disabled in that case. |  | 
|  54   SoftwareVideoRenderer( |  | 
|  55       scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, |  | 
|  56       protocol::FrameConsumer* consumer, |  | 
|  57       protocol::FrameStatsConsumer* stats_consumer); |  | 
|  58   ~SoftwareVideoRenderer() override; |  51   ~SoftwareVideoRenderer() override; | 
|  59  |  52  | 
|  60   // VideoRenderer interface. |  53   // VideoRenderer interface. | 
|  61   bool Initialize(const ClientContext& client_context, |  54   bool Initialize(const ClientContext& client_context, | 
|  62                   protocol::FrameStatsConsumer* stats_consumer) override; |  55                   protocol::FrameStatsConsumer* stats_consumer) override; | 
|  63   void OnSessionConfig(const protocol::SessionConfig& config) override; |  56   void OnSessionConfig(const protocol::SessionConfig& config) override; | 
|  64   protocol::VideoStub* GetVideoStub() override; |  57   protocol::VideoStub* GetVideoStub() override; | 
|  65   protocol::FrameConsumer* GetFrameConsumer() override; |  58   protocol::FrameConsumer* GetFrameConsumer() override; | 
|  66   protocol::FrameStatsConsumer* GetFrameStatsConsumer() override; |  59   protocol::FrameStatsConsumer* GetFrameStatsConsumer() override; | 
|  67  |  60  | 
|  68   // protocol::VideoStub interface. |  61   // protocol::VideoStub interface. | 
|  69   void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, |  62   void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, | 
|  70                           const base::Closure& done) override; |  63                           const base::Closure& done) override; | 
|  71  |  64  | 
|  72  private: |  65  private: | 
|  73   void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, |  66   void RenderFrame(std::unique_ptr<protocol::FrameStats> stats, | 
|  74                    const base::Closure& done, |  67                    const base::Closure& done, | 
|  75                    std::unique_ptr<webrtc::DesktopFrame> frame); |  68                    std::unique_ptr<webrtc::DesktopFrame> frame); | 
|  76   void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, |  69   void OnFrameRendered(std::unique_ptr<protocol::FrameStats> stats, | 
|  77                        const base::Closure& done); |  70                        const base::Closure& done); | 
|  78  |  71  | 
|  79   scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; |  72   scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; | 
 |  73  | 
 |  74   // |owned_consumer_| and |consumer_| should refer to the same object if | 
 |  75   // |owned_consumer_| is not null. | 
 |  76   std::unique_ptr<protocol::FrameConsumer> owned_consumer_; | 
|  80   protocol::FrameConsumer* const consumer_; |  77   protocol::FrameConsumer* const consumer_; | 
 |  78  | 
|  81   protocol::FrameStatsConsumer* stats_consumer_ = nullptr; |  79   protocol::FrameStatsConsumer* stats_consumer_ = nullptr; | 
|  82  |  80  | 
|  83   std::unique_ptr<VideoDecoder> decoder_; |  81   std::unique_ptr<VideoDecoder> decoder_; | 
|  84  |  82  | 
|  85   webrtc::DesktopSize source_size_; |  83   webrtc::DesktopSize source_size_; | 
|  86   webrtc::DesktopVector source_dpi_; |  84   webrtc::DesktopVector source_dpi_; | 
|  87  |  85  | 
|  88   base::ThreadChecker thread_checker_; |  86   base::ThreadChecker thread_checker_; | 
|  89  |  87  | 
|  90   base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; |  88   base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_; | 
|  91  |  89  | 
|  92   DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); |  90   DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer); | 
|  93 }; |  91 }; | 
|  94  |  92  | 
|  95 }  // namespace remoting |  93 }  // namespace remoting | 
|  96  |  94  | 
|  97 #endif  // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ |  95 #endif  // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_ | 
| OLD | NEW |