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_PLUGIN_MEDIA_SOURCE_VIDEO_RENDERER_H_
6 #define REMOTING_CLIENT_PLUGIN_MEDIA_SOURCE_VIDEO_RENDERER_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/client/chromoting_stats.h"
14 #include "remoting/client/video_renderer.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
16 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
20 // VideoRenderer implementation that packs data into a WebM stream that can be
21 // passed to <video> tag using MediaSource API.
22 class MediaSourceVideoRenderer
: public VideoRenderer
{
27 virtual ~Delegate() {}
29 // Called when stream size changes.
30 virtual void OnMediaSourceSize(const webrtc::DesktopSize
& size
,
31 const webrtc::DesktopVector
& dpi
) = 0;
33 // Called when desktop shape changes.
34 virtual void OnMediaSourceShape(const webrtc::DesktopRegion
& shape
) = 0;
36 // Called when the MediaSource needs to be reset (e.g. because screen size
38 virtual void OnMediaSourceReset(const std::string
& format
) = 0;
40 // Called when new data becomes available.
41 virtual void OnMediaSourceData(uint8_t* buffer
, size_t buffer_size
,
45 explicit MediaSourceVideoRenderer(Delegate
* delegate
);
46 virtual ~MediaSourceVideoRenderer();
48 // VideoRenderer interface.
49 virtual void Initialize(const protocol::SessionConfig
& config
) OVERRIDE
;
50 virtual ChromotingStats
* GetStats() OVERRIDE
;
51 virtual void ProcessVideoPacket(scoped_ptr
<VideoPacket
> packet
,
52 const base::Closure
& done
) OVERRIDE
;
55 // Helper class used to generate WebM stream.
60 std::string format_string_
;
61 const char* codec_id_
;
63 scoped_ptr
<VideoWriter
> writer_
;
64 webrtc::DesktopVector frame_dpi_
;
65 webrtc::DesktopRegion desktop_shape_
;
67 ChromotingStats stats_
;
68 int64 latest_sequence_number_
;
70 DISALLOW_COPY_AND_ASSIGN(MediaSourceVideoRenderer
);
73 } // namespace remoting
75 #endif // REMOTING_CLIENT_PLUGIN_MEDIA_SOURCE_VIDEO_RENDERER_H_