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
3 // found in the LICENSE file.
5 #ifndef REMOTING_TEST_TEST_VIDEO_RENDERER_H_
6 #define REMOTING_TEST_TEST_VIDEO_RENDERER_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"
12 #include "remoting/client/video_renderer.h"
13 #include "remoting/protocol/session_config.h"
14 #include "remoting/protocol/video_stub.h"
18 class SingleThreadTaskRunner
;
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.
32 class TestVideoRenderer
: public VideoRenderer
, public protocol::VideoStub
{
35 ~TestVideoRenderer() override
;
37 // VideoRenderer interface.
38 void OnSessionConfig(const protocol::SessionConfig
& config
) override
;
39 ChromotingStats
* GetStats() override
;
40 protocol::VideoStub
* GetVideoStub() override
;
42 // protocol::VideoStub interface.
43 void ProcessVideoPacket(scoped_ptr
<VideoPacket
> video_packet
,
44 const base::Closure
& done
) override
;
46 // Initialize a decoder to decode video packets.
47 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec
);
49 // Returns a copy of the current buffer.
50 scoped_ptr
<webrtc::DesktopFrame
> GetBufferForTest() const;
53 // The actual implementation resides in Core class.
55 scoped_ptr
<Core
> core_
;
57 // Used to ensure TestVideoRenderer methods are called on the same thread.
58 base::ThreadChecker thread_checker_
;
60 // Used to decode and process video packets.
61 scoped_ptr
<base::Thread
> video_decode_thread_
;
63 // Used to post tasks to video decode thread.
64 scoped_refptr
<base::SingleThreadTaskRunner
> video_decode_task_runner_
;
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_
;
70 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer
);
74 } // namespace remoting
76 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_