Add missing 'gpu_tests' config to MB, fix typo in MB.
[chromium-blink-merge.git] / remoting / client / software_video_renderer.h
blobe6a9a5eed2248fdbc67755f8ed2229e594f2cc8c
1 // Copyright 2014 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_CLIENT_SOFTWARE_VIDEO_RENDERER_H_
6 #define REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "remoting/client/chromoting_stats.h"
11 #include "remoting/client/frame_consumer_proxy.h"
12 #include "remoting/client/frame_producer.h"
13 #include "remoting/client/video_renderer.h"
14 #include "remoting/protocol/video_stub.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
17 namespace base {
18 class SingleThreadTaskRunner;
19 } // namespace base
21 namespace remoting {
23 class ChromotingStats;
25 // Implementation of VideoRenderer interface that decodes frame on CPU (on a
26 // decode thread) and then passes decoded frames to a FrameConsumer.
27 // FrameProducer methods can be called on any thread. All other methods must be
28 // called on the main thread. Owned must ensure that this class outlives
29 // FrameConsumer (which calls FrameProducer interface).
30 class SoftwareVideoRenderer : public VideoRenderer,
31 public protocol::VideoStub,
32 public FrameProducer,
33 public base::NonThreadSafe {
34 public:
35 // Creates an update decoder on |main_task_runner_| and |decode_task_runner_|,
36 // outputting to |consumer|. The |main_task_runner_| is responsible for
37 // receiving and queueing packets. The |decode_task_runner_| is responsible
38 // for decoding the video packets.
39 SoftwareVideoRenderer(
40 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
41 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
42 scoped_ptr<FrameConsumerProxy> consumer);
43 ~SoftwareVideoRenderer() override;
45 // VideoRenderer interface.
46 void OnSessionConfig(const protocol::SessionConfig& config) override;
47 ChromotingStats* GetStats() override;
48 protocol::VideoStub* GetVideoStub() override;
50 // protocol::VideoStub interface.
51 void ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
52 const base::Closure& done) override;
54 // FrameProducer implementation. These methods may be called before we are
55 // Initialize()d, or we know the source screen size. These methods may be
56 // called on any thread.
58 // TODO(sergeyu): On Android a separate display thread is used for drawing.
59 // FrameConsumer calls FrameProducer on that thread. Can we avoid having a
60 // separate display thread? E.g. can we do everything on the decode thread?
61 void DrawBuffer(webrtc::DesktopFrame* buffer) override;
62 void InvalidateRegion(const webrtc::DesktopRegion& region) override;
63 void RequestReturnBuffers(const base::Closure& done) override;
64 void SetOutputSizeAndClip(const webrtc::DesktopSize& view_size,
65 const webrtc::DesktopRect& clip_area) override;
67 private:
68 class Core;
70 // Callback method when a VideoPacket is processed. |decode_start| contains
71 // the timestamp when the packet will start to be processed.
72 void OnPacketDone(base::Time decode_start, const base::Closure& done);
74 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_;
75 scoped_ptr<Core> core_;
77 ChromotingStats stats_;
79 // Keep track of the latest event timestamp bounced back from the host.
80 int64 latest_event_timestamp_;
82 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_;
84 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer);
87 } // namespace remoting
89 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_