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. |
joedow
2015/06/30 20:07:12
Can you add a comment here about how threads and T
| |
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 SetDecoderForDecoding(const protocol::ChannelConfig::Codec codec); |
joedow
2015/06/30 20:07:12
SetCodecForDecoding (or just SetCodec)
liaoyuke
2015/06/30 21:15:01
Done.
| |
45 | |
46 // Returns a copy of the current buffer. | |
47 scoped_ptr<webrtc::DesktopFrame> GetBufferForTest() const; | |
48 | |
49 private: | |
50 // The actual implementation resides in Core class. | |
51 class Core; | |
52 scoped_ptr<Core> core_; | |
53 | |
54 // Used to ensure TestVideoRenderer methods are called on the same thread. | |
55 base::ThreadChecker thread_checker_; | |
56 | |
57 // Used to decode and process video packets. | |
58 scoped_ptr<base::Thread> video_decode_thread_; | |
59 | |
60 // Used to post tasks to video decode thread. | |
61 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_; | |
62 | |
63 // Used to weakly bind |this| to methods. | |
64 // NOTE: Weak pointers must be invalidated before all other member variables. | |
65 base::WeakPtrFactory<TestVideoRenderer> weak_factory_; | |
34 | 66 |
35 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); | 67 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer); |
36 }; | 68 }; |
37 | 69 |
38 } // namespace test | 70 } // namespace test |
39 } // namespace remoting | 71 } // namespace remoting |
40 | 72 |
41 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ | 73 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_ |
OLD | NEW |