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/video_renderer.h"
13 #include "remoting/protocol/performance_tracker.h"
14 #include "remoting/protocol/video_stub.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
18 class SingleThreadTaskRunner
;
31 class PerformanceTracker
;
32 } // namespace protocol
34 // Implementation of VideoRenderer interface that decodes frame on CPU (on a
35 // decode thread) and then passes decoded frames to a FrameConsumer.
36 class SoftwareVideoRenderer
: public VideoRenderer
,
37 public protocol::VideoStub
{
39 // All methods must be called on the same thread the renderer is created. The
40 // |decode_task_runner_| is used to decode the video packets. |perf_tracker|
41 // must outlive the renderer. |perf_tracker| may be nullptr, performance
42 // tracking is disabled in that case.
43 SoftwareVideoRenderer(
44 scoped_refptr
<base::SingleThreadTaskRunner
> decode_task_runner
,
45 FrameConsumer
* consumer
,
46 protocol::PerformanceTracker
* perf_tracker
);
47 ~SoftwareVideoRenderer() override
;
49 // VideoRenderer interface.
50 void OnSessionConfig(const protocol::SessionConfig
& config
) override
;
51 protocol::VideoStub
* GetVideoStub() override
;
53 // protocol::VideoStub interface.
54 void ProcessVideoPacket(scoped_ptr
<VideoPacket
> packet
,
55 const base::Closure
& done
) override
;
58 void RenderFrame(base::TimeTicks decode_start_time
,
59 const base::Closure
& done
,
60 scoped_ptr
<webrtc::DesktopFrame
> frame
);
61 void OnFrameRendered(base::TimeTicks paint_start_time
,
62 const base::Closure
& done
);
64 scoped_refptr
<base::SingleThreadTaskRunner
> decode_task_runner_
;
65 FrameConsumer
* consumer_
;
66 protocol::PerformanceTracker
* perf_tracker_
;
68 scoped_ptr
<VideoDecoder
> decoder_
;
70 webrtc::DesktopSize source_size_
;
71 webrtc::DesktopVector source_dpi_
;
73 base::ThreadChecker thread_checker_
;
75 base::WeakPtrFactory
<SoftwareVideoRenderer
> weak_factory_
;
77 DISALLOW_COPY_AND_ASSIGN(SoftwareVideoRenderer
);
80 } // namespace remoting
82 #endif // REMOTING_CLIENT_SOFTWARE_VIDEO_RENDERER_H_