| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TEST_TEST_VIDEO_RENDERER_H_ | 5 #ifndef REMOTING_TEST_TEST_VIDEO_RENDERER_H_ |
| 6 #define REMOTING_TEST_TEST_VIDEO_RENDERER_H_ | 6 #define REMOTING_TEST_TEST_VIDEO_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/thread_checker.h" |
| 11 #include "media/base/video_frame.h" |
| 10 #include "remoting/client/video_renderer.h" | 12 #include "remoting/client/video_renderer.h" |
| 13 #include "remoting/protocol/session_config.h" |
| 11 #include "remoting/protocol/video_stub.h" | 14 #include "remoting/protocol/video_stub.h" |
| 12 | 15 |
| 16 namespace base { |
| 17 class Thread; |
| 18 class SingleThreadTaskRunner; |
| 19 } |
| 20 |
| 21 namespace webrtc { |
| 22 class DesktopFrame; |
| 23 } |
| 24 |
| 13 namespace remoting { | 25 namespace remoting { |
| 14 namespace test { | 26 namespace test { |
| 15 | 27 |
| 16 // Processes video packets as they are received from the remote host. | 28 // Processes video packets as they are received from the remote host. Must be |
| 29 // used from a thread running a message loop and this class will use that |
| 30 // message loop to execute the done callbacks passed by the caller of |
| 31 // ProcessVideoPacket. |
| 17 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { | 32 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { |
| 18 public: | 33 public: |
| 19 TestVideoRenderer(); | 34 TestVideoRenderer(); |
| 20 ~TestVideoRenderer() override; | 35 ~TestVideoRenderer() override; |
| 21 | 36 |
| 22 // VideoRenderer interface. | 37 // VideoRenderer interface. |
| 23 void OnSessionConfig(const protocol::SessionConfig& config) override; | 38 void OnSessionConfig(const protocol::SessionConfig& config) override; |
| 24 ChromotingStats* GetStats() override; | 39 ChromotingStats* GetStats() override; |
| 25 protocol::VideoStub* GetVideoStub() override; | 40 protocol::VideoStub* GetVideoStub() override; |
| 26 | 41 |
| 27 private: | |
| 28 // protocol::VideoStub interface. | 42 // protocol::VideoStub interface. |
| 29 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 43 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
| 30 const base::Closure& done) override; | 44 const base::Closure& done) override; |
| 31 | 45 |
| 32 // Track the number of populated video frames which have been received. | 46 // Initialize a decoder to decode video packets. |
| 33 int video_frames_processed_; | 47 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec); |
| 48 |
| 49 // Returns a copy of the current buffer. |
| 50 scoped_ptr<webrtc::DesktopFrame> GetBufferForTest() const; |
| 51 |
| 52 private: |
| 53 // The actual implementation resides in Core class. |
| 54 class Core; |
| 55 scoped_ptr<Core> core_; |
| 56 |
| 57 // Used to ensure TestVideoRenderer methods are called on the same thread. |
| 58 base::ThreadChecker thread_checker_; |
| 59 |
| 60 // Used to decode and process video packets. |
| 61 scoped_ptr<base::Thread> video_decode_thread_; |
| 62 |
| 63 // Used to post tasks to video decode thread. |
| 64 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; |
| 65 |
| 66 // Used to weakly bind |this| to methods. |
| 67 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 68 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; |
| 34 | 69 |
| 35 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); | 70 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); |
| 36 }; | 71 }; |
| 37 | 72 |
| 38 } // namespace test | 73 } // namespace test |
| 39 } // namespace remoting | 74 } // namespace remoting |
| 40 | 75 |
| 41 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ | 76 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ |
| OLD | NEW |