Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / remoting / test / test_video_renderer.h
blob7e66e9dc1806946d3fe0ed88254b0e3c6cb959c2
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 "remoting/client/video_renderer.h"
12 #include "remoting/protocol/session_config.h"
13 #include "remoting/protocol/video_stub.h"
15 namespace base {
16 class Thread;
17 class SingleThreadTaskRunner;
20 namespace webrtc {
21 class DesktopFrame;
22 class DesktopRect;
25 namespace remoting {
26 namespace test {
28 struct RGBValue;
30 // Processes video packets as they are received from the remote host. Must be
31 // used from a thread running a message loop and this class will use that
32 // message loop to execute the done callbacks passed by the caller of
33 // ProcessVideoPacket.
34 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub {
35 public:
36 TestVideoRenderer();
37 ~TestVideoRenderer() override;
39 // VideoRenderer interface.
40 void OnSessionConfig(const protocol::SessionConfig& config) override;
41 protocol::VideoStub* GetVideoStub() override;
43 // protocol::VideoStub interface.
44 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
45 const base::Closure& done) override;
47 // Initialize a decoder to decode video packets.
48 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec);
50 // Returns a copy of the current frame.
51 scoped_ptr<webrtc::DesktopFrame> GetCurrentFrameForTest() const;
53 // Gets a weak pointer for this object.
54 base::WeakPtr<TestVideoRenderer> GetWeakPtr() {
55 return weak_factory_.GetWeakPtr();
58 // Set expected rect and average color for comparison and the callback will be
59 // called when the pattern is matched.
60 void ExpectAverageColorInRect(
61 const webrtc::DesktopRect& expected_rect,
62 const RGBValue& expected_average_color,
63 const base::Closure& image_pattern_matched_callback);
65 // Turn on/off saving video frames to disk.
66 void SaveFrameDataToDisk(bool save_frame_data_to_disk);
68 private:
69 // The actual implementation resides in Core class.
70 class Core;
71 scoped_ptr<Core> core_;
73 // Used to ensure TestVideoRenderer methods are called on the same thread.
74 base::ThreadChecker thread_checker_;
76 // Used to decode and process video packets.
77 scoped_ptr<base::Thread> video_decode_thread_;
79 // Used to post tasks to video decode thread.
80 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_;
82 // Used to weakly bind |this| to methods.
83 // NOTE: Weak pointers must be invalidated before all other member variables.
84 base::WeakPtrFactory<TestVideoRenderer> weak_factory_;
86 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer);
89 } // namespace test
90 } // namespace remoting
92 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_