| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
| 12 #include "remoting/client/video_renderer.h" | 12 #include "remoting/client/video_renderer.h" |
| 13 #include "remoting/protocol/session_config.h" | 13 #include "remoting/protocol/session_config.h" |
| 14 #include "remoting/protocol/video_stub.h" | 14 #include "remoting/protocol/video_stub.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class Thread; | 17 class Thread; |
| 18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 class DesktopFrame; | 22 class DesktopFrame; |
| 23 class DesktopRect; | 23 class DesktopRect; |
| 24 } | 24 } |
| 25 | 25 |
| 26 typedef uint32 RgbaColor; | |
| 27 | |
| 28 namespace remoting { | 26 namespace remoting { |
| 29 namespace test { | 27 namespace test { |
| 30 | 28 |
| 31 // Processes video packets as they are received from the remote host. Must be | 29 // Processes video packets as they are received from the remote host. Must be |
| 32 // used from a thread running a message loop and this class will use that | 30 // used from a thread running a message loop and this class will use that |
| 33 // message loop to execute the done callbacks passed by the caller of | 31 // message loop to execute the done callbacks passed by the caller of |
| 34 // ProcessVideoPacket. | 32 // ProcessVideoPacket. |
| 35 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { | 33 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { |
| 36 public: | 34 public: |
| 37 TestVideoRenderer(); | 35 TestVideoRenderer(); |
| 38 ~TestVideoRenderer() override; | 36 ~TestVideoRenderer() override; |
| 39 | 37 |
| 40 // VideoRenderer interface. | 38 // VideoRenderer interface. |
| 41 void OnSessionConfig(const protocol::SessionConfig& config) override; | 39 void OnSessionConfig(const protocol::SessionConfig& config) override; |
| 42 ChromotingStats* GetStats() override; | 40 ChromotingStats* GetStats() override; |
| 43 protocol::VideoStub* GetVideoStub() override; | 41 protocol::VideoStub* GetVideoStub() override; |
| 44 | 42 |
| 45 // protocol::VideoStub interface. | 43 // protocol::VideoStub interface. |
| 46 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 44 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
| 47 const base::Closure& done) override; | 45 const base::Closure& done) override; |
| 48 | 46 |
| 49 // Initialize a decoder to decode video packets. | 47 // Initialize a decoder to decode video packets. |
| 50 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec); | 48 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec); |
| 51 | 49 |
| 52 // Returns a copy of the current buffer. | 50 // Returns a copy of the current frame. |
| 53 scoped_ptr<webrtc::DesktopFrame> GetBufferForTest() const; | 51 scoped_ptr<webrtc::DesktopFrame> GetCurrentFrameForTest() const; |
| 54 | 52 |
| 55 // Gets a weak pointer for this object. | 53 // Gets a weak pointer for this object. |
| 56 base::WeakPtr<TestVideoRenderer> GetWeakPtr() { | 54 base::WeakPtr<TestVideoRenderer> GetWeakPtr() { |
| 57 return weak_factory_.GetWeakPtr(); | 55 return weak_factory_.GetWeakPtr(); |
| 58 } | 56 } |
| 59 | 57 |
| 60 // Set expected image pattern for comparison and the callback will be called | 58 // Set expected rect and average color for comparison and the callback will be |
| 61 // when the pattern is matched. | 59 // called when the pattern is matched. |
| 62 void SetImagePatternAndMatchedCallback( | 60 void ExpectAverageColorInRect( |
| 63 const webrtc::DesktopRect& expected_rect, | 61 const webrtc::DesktopRect& expected_rect, |
| 64 const RgbaColor& expected_color, | 62 uint32_t expected_average_color, |
| 65 const base::Closure& image_pattern_matched_callback); | 63 const base::Closure& image_pattern_matched_callback); |
| 66 | 64 |
| 67 private: | 65 private: |
| 68 // The actual implementation resides in Core class. | 66 // The actual implementation resides in Core class. |
| 69 class Core; | 67 class Core; |
| 70 scoped_ptr<Core> core_; | 68 scoped_ptr<Core> core_; |
| 71 | 69 |
| 72 // Used to ensure TestVideoRenderer methods are called on the same thread. | 70 // Used to ensure TestVideoRenderer methods are called on the same thread. |
| 73 base::ThreadChecker thread_checker_; | 71 base::ThreadChecker thread_checker_; |
| 74 | 72 |
| 75 // Used to decode and process video packets. | 73 // Used to decode and process video packets. |
| 76 scoped_ptr<base::Thread> video_decode_thread_; | 74 scoped_ptr<base::Thread> video_decode_thread_; |
| 77 | 75 |
| 78 // Used to post tasks to video decode thread. | 76 // Used to post tasks to video decode thread. |
| 79 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; | 77 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; |
| 80 | 78 |
| 81 // Used to weakly bind |this| to methods. | 79 // Used to weakly bind |this| to methods. |
| 82 // NOTE: Weak pointers must be invalidated before all other member variables. | 80 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 83 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; | 81 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; |
| 84 | 82 |
| 85 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); | 83 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); |
| 86 }; | 84 }; |
| 87 | 85 |
| 88 } // namespace test | 86 } // namespace test |
| 89 } // namespace remoting | 87 } // namespace remoting |
| 90 | 88 |
| 91 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ | 89 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ |
| OLD | NEW |