Chromium Code Reviews| 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. |
| 17 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { | 29 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub { |
| 18 public: | 30 public: |
| 19 TestVideoRenderer(); | 31 TestVideoRenderer(); |
| 20 ~TestVideoRenderer() override; | 32 ~TestVideoRenderer() override; |
| 21 | 33 |
| 22 // VideoRenderer interface. | 34 // VideoRenderer interface. |
| 23 void OnSessionConfig(const protocol::SessionConfig& config) override; | 35 void OnSessionConfig(const protocol::SessionConfig& config) override; |
| 24 ChromotingStats* GetStats() override; | 36 ChromotingStats* GetStats() override; |
| 25 protocol::VideoStub* GetVideoStub() override; | 37 protocol::VideoStub* GetVideoStub() override; |
| 26 | 38 |
| 27 private: | |
| 28 // protocol::VideoStub interface. | 39 // protocol::VideoStub interface. |
| 29 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 40 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
| 30 const base::Closure& done) override; | 41 const base::Closure& done) override; |
| 31 | 42 |
| 32 // Track the number of populated video frames which have been received. | 43 // Initialize a decoder to decode video packets. |
| 33 int video_frames_processed_; | 44 void SetDecoder(const protocol::ChannelConfig::Codec codec); |
|
joedow
2015/06/30 17:52:27
Should this be renamed "SetCodecForDecoding"?
liaoyuke
2015/06/30 19:34:59
Done.
| |
| 45 | |
| 46 // Runs a RunLoop until the video packet is processed. | |
|
joedow
2015/06/30 17:52:27
Interface comments shouldn't document internal imp
liaoyuke
2015/06/30 19:35:00
Done.
| |
| 47 void WaitForPacketDone(const base::Closure& done); | |
| 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 // Signals when is packet is processed. | |
| 58 void OnPacketDone(); | |
| 59 | |
| 60 // Used to quit the RunLoop of main thread. | |
| 61 base::Closure main_closure_; | |
|
joedow
2015/06/30 17:52:27
I think we should go with the approach I mention a
liaoyuke
2015/06/30 19:34:59
Done.
| |
| 62 | |
| 63 // Used to ensure TestVideoRenderer methods are called on the same thread. | |
| 64 base::ThreadChecker thread_checker_; | |
| 65 | |
| 66 // Used to decode and process video packets. | |
| 67 scoped_ptr<base::Thread> video_decode_thread_; | |
| 68 | |
| 69 // Used to post tasks to video decode thread. | |
| 70 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; | |
| 71 | |
| 72 // Used to weakly bind |this| to |OnPacketDone| method. | |
| 73 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; | |
| 34 | 74 |
| 35 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); | 75 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); |
| 36 }; | 76 }; |
| 37 | 77 |
| 38 } // namespace test | 78 } // namespace test |
| 39 } // namespace remoting | 79 } // namespace remoting |
| 40 | 80 |
| 41 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ | 81 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ |
| OLD | NEW |