OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef REMOTING_CLIENT_PLUGIN_MEDIA_SOURCE_VIDEO_RENDERER_H_ | |
6 #define REMOTING_CLIENT_PLUGIN_MEDIA_SOURCE_VIDEO_RENDERER_H_ | |
7 | |
8 #include <string> | |
9 | |
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" | |
17 | |
18 namespace remoting { | |
19 | |
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 { | |
23 public: | |
24 class Delegate { | |
25 public: | |
26 Delegate() {} | |
27 virtual ~Delegate() {} | |
28 | |
29 // Called when stream size changes. | |
30 virtual void OnMediaSourceSize(const webrtc::DesktopSize& size, | |
31 const webrtc::DesktopVector& dpi) = 0; | |
32 | |
33 // Called when desktop shape changes. | |
34 virtual void OnMediaSourceShape(const webrtc::DesktopRegion& shape) = 0; | |
35 | |
36 // Called when the MediaSource needs to be reset (e.g. because screen size | |
37 // has changed). | |
38 virtual void OnMediaSourceReset(const std::string& format) = 0; | |
39 | |
40 // Called when new data becomes available. | |
41 virtual void OnMediaSourceData(uint8_t* buffer, size_t buffer_size, | |
42 bool keyframe) = 0; | |
43 }; | |
44 | |
45 explicit MediaSourceVideoRenderer(Delegate* delegate); | |
46 ~MediaSourceVideoRenderer() override; | |
47 | |
48 // VideoRenderer interface. | |
49 void Initialize(const protocol::SessionConfig& config) override; | |
50 ChromotingStats* GetStats() override; | |
51 void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, | |
52 const base::Closure& done) override; | |
53 | |
54 private: | |
55 // Helper class used to generate WebM stream. | |
56 class VideoWriter; | |
57 | |
58 Delegate* delegate_; | |
59 | |
60 std::string format_string_; | |
61 const char* codec_id_; | |
62 | |
63 scoped_ptr<VideoWriter> writer_; | |
64 webrtc::DesktopVector frame_dpi_; | |
65 webrtc::DesktopRegion desktop_shape_; | |
66 | |
67 ChromotingStats stats_; | |
68 int64 latest_sequence_number_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(MediaSourceVideoRenderer); | |
71 }; | |
72 | |
73 } // namespace remoting | |
74 | |
75 #endif // REMOTING_CLIENT_PLUGIN_MEDIA_SOURCE_VIDEO_RENDERER_H_ | |
OLD | NEW |