Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / client / software_video_renderer.h
blob595d22a1868409941281c0a444bd4fd443c632e1
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 "base/memory/weak_ptr.h"
11 #include "base/threading/thread_checker.h"
12 #include "remoting/client/chromoting_stats.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 webrtc {
22 class DesktopFrame;
23 } // namespace webrtc;
25 namespace remoting {
27 class ChromotingStats;
28 class FrameConsumer;
29 class VideoDecoder;
31 // Implementation of VideoRenderer interface that decodes frame on CPU (on a
32 // decode thread) and then passes decoded frames to a FrameConsumer.
33 class SoftwareVideoRenderer : public VideoRenderer,
34 public protocol::VideoStub {
35 public:
36 // Creates an update decoder on |main_task_runner_| and |decode_task_runner_|,
37 // outputting to |consumer|. The |main_task_runner_| is responsible for
38 // receiving and queueing packets. The |decode_task_runner_| is responsible
39 // for decoding the video packets.
40 SoftwareVideoRenderer(
41 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
42 FrameConsumer* 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 private:
55 void RenderFrame(base::TimeTicks decode_start_time,
56 const base::Closure& done,
57 scoped_ptr<webrtc::DesktopFrame> frame);
58 void OnFrameRendered(base::TimeTicks paint_start_time,
59 const base::Closure& done);
61 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_;
62 FrameConsumer* consumer_;
64 scoped_ptr<VideoDecoder> decoder_;
66 webrtc::DesktopSize source_size_;
67 webrtc::DesktopVector source_dpi_;
69 ChromotingStats stats_;
71 base::ThreadChecker thread_checker_;
73 base::WeakPtrFactory<SoftwareVideoRenderer> weak_factory_;
75 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer);
78 } // namespace remoting
80 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_