Update V8 to version 4.6.55.
[chromium-blink-merge.git] / remoting / test / test_video_renderer.h
blobb0957e9c6a405b84e43ddf60d022f8f6a422b3a7
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"
16 namespace base {
17 class Thread;
18 class SingleThreadTaskRunner;
21 namespace webrtc {
22 class DesktopFrame;
23 class DesktopRect;
26 namespace remoting {
27 namespace test {
29 struct RGBValue;
31 // 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
33 // message loop to execute the done callbacks passed by the caller of
34 // ProcessVideoPacket.
35 class TestVideoRenderer : public VideoRenderer, public protocol::VideoStub {
36 public:
37 TestVideoRenderer();
38 ~TestVideoRenderer() override;
40 // VideoRenderer interface.
41 void OnSessionConfig(const protocol::SessionConfig& config) override;
42 ChromotingStats* GetStats() override;
43 protocol::VideoStub* GetVideoStub() override;
45 // protocol::VideoStub interface.
46 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
47 const base::Closure& done) override;
49 // Initialize a decoder to decode video packets.
50 void SetCodecForDecoding(const protocol::ChannelConfig::Codec codec);
52 // Returns a copy of the current frame.
53 scoped_ptr<webrtc::DesktopFrame> GetCurrentFrameForTest() const;
55 // Gets a weak pointer for this object.
56 base::WeakPtr<TestVideoRenderer> GetWeakPtr() {
57 return weak_factory_.GetWeakPtr();
60 // Set expected rect and average color for comparison and the callback will be
61 // called when the pattern is matched.
62 void ExpectAverageColorInRect(
63 const webrtc::DesktopRect& expected_rect,
64 const RGBValue& expected_average_color,
65 const base::Closure& image_pattern_matched_callback);
67 // Turn on/off saving video frames to disk.
68 void SaveFrameDataToDisk(bool save_frame_data_to_disk);
70 private:
71 // The actual implementation resides in Core class.
72 class Core;
73 scoped_ptr<Core> core_;
75 // Used to ensure TestVideoRenderer methods are called on the same thread.
76 base::ThreadChecker thread_checker_;
78 // Used to decode and process video packets.
79 scoped_ptr<base::Thread> video_decode_thread_;
81 // Used to post tasks to video decode thread.
82 scoped_refptr<base::SingleThreadTaskRunner> video_decode_task_runner_;
84 // Used to weakly bind |this| to methods.
85 // NOTE: Weak pointers must be invalidated before all other member variables.
86 base::WeakPtrFactory<TestVideoRenderer> weak_factory_;
88 DISALLOW_COPY_AND_ASSIGN(TestVideoRenderer);
91 } // namespace test
92 } // namespace remoting
94 #endif // REMOTING_TEST_TEST_VIDEO_RENDERER_H_