Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: remoting/client/plugin/pepper_video_renderer_3d.h

Issue 820823002: Implement video renderer based on VideoDecode API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_PEPPER_VIDEO_RENDERER_3D_H_
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_
7
8 #include <deque>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ppapi/cpp/graphics_3d.h"
15 #include "ppapi/cpp/instance_handle.h"
16 #include "ppapi/cpp/video_decoder.h"
17 #include "ppapi/utility/completion_callback_factory.h"
18 #include "remoting/client/chromoting_stats.h"
19 #include "remoting/client/plugin/pepper_video_renderer.h"
20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
21 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
22
23 struct PPB_OpenGLES2;
24
25 namespace remoting {
26
27 // PepperVideoRenderer that uses the PPB_VideoDecoder interface for video
28 // decoding and Graphics3D for rendering.
29 class PepperVideoRenderer3D : public PepperVideoRenderer {
30 public:
31 PepperVideoRenderer3D();
32 ~PepperVideoRenderer3D() override;
33
34 // PepperVideoRenderer interface.
35 bool Initialize(pp::Instance* instance,
36 const ClientContext& context,
37 EventHandler* event_handler) override;
38 void OnViewChanged(const pp::View& view) override;
39 void OnSessionConfig(const protocol::SessionConfig& config) override;
40 ChromotingStats* GetStats() override;
41 void ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
42 const base::Closure& done) override;
43
44 private:
45 class PendingPacket;
46 class Picture;
47
48 struct FrameDecodeTimestamp {
49 FrameDecodeTimestamp(uint32_t frame_id,
50 base::TimeTicks decode_started_time);
51 uint32_t frame_id;
52 base::TimeTicks decode_started_time;
53 };
54
55 // Callback for pp::VideoDecoder::Initialize().
56 void OnInitialized(int32_t result);
57
58 // Passes one picture from |pending_packets_| to the |video_decoder_|.
59 void DecodeNextPacket();
60
61 // Callback for pp::VideoDecoder::Decode().
62 void OnDecodeDone(int32_t result);
63
64 // Fetches next picture from the |video_decoder_|.
65 void GetNextPicture();
66
67 // Callback for pp::VideoDecoder::GetPicture().
68 void OnPictureReady(int32_t result, PP_VideoPicture picture);
69
70 // Copies |next_picture_| to |current_picture_| if |next_picture_| is set and
71 // then renders |current_picture_|. Doesn't do anything if |need_repaint_| is
72 // false.
73 void Paint();
Wez 2015/01/06 22:17:10 Suggest renaming to PaintIfNeeded().
Sergey Ulanov 2015/01/07 19:37:31 Done.
74
75 // Callback for pp::Graphics3D::SwapBuffers().
76 void OnPaintDone(int32_t result);
77
78 // Initializes |shader_program_| for |texture_target|.
79 void EnsureProgramForTexture(uint32_t texture_target);
80
81 // Initializes |shader_program_| with the given shaders.
82 void CreateProgram(const char* vertex_shader, const char* fragment_shader);
83
84 // Creates a new shader and compiles |source| for it.
85 void CreateShaderProgram(int type, const char* source);
86
87 // CHECKs that the last OpenGL call has completed successfully.
88 void CheckGLError();
89
90 EventHandler* event_handler_;
91
92 pp::Graphics3D graphics_;
93 const PPB_OpenGLES2* gles2_if_;
94 pp::VideoDecoder video_decoder_;
95
96 webrtc::DesktopSize frame_size_;
97 webrtc::DesktopVector frame_dpi_;
98 webrtc::DesktopRegion desktop_shape_;
99
100 webrtc::DesktopSize view_size_;
101
102 ChromotingStats stats_;
103 int64 last_input_event_timestamp_ ;
104
105 bool initialization_finished_;
106 bool decode_pending_;
107 bool get_picture_pending_;
108 bool paint_pending_;
109
110 uint32_t last_frame_id_;
111
112 // Queue of packets that that have been received, but haven't been passed to
113 // the decoder yet.
114 std::deque<PendingPacket*> pending_packets_;
115
116 // Timestamps for all frames currently being processed by the decoder.
117 std::deque<FrameDecodeTimestamp> frame_decode_timestamps_;
118
119 // The current picture shown on the screen or being rendered.
120 scoped_ptr<Picture> current_picture_;
121
122 // The next picture to be rendered. Paint() will copy it to |current_picture_|
123 // and render it after that.
124 scoped_ptr<Picture> next_picture_;
Wez 2015/01/06 22:17:10 nit: Might be worth noting that this and current_p
Sergey Ulanov 2015/01/07 19:37:30 Done.
125
126 // Set to true if the screen needs to be repainted because a new frame was
127 // received of the plugin was resized.
Wez 2015/01/06 22:17:10 s/of/or
Sergey Ulanov 2015/01/07 19:37:31 Done.
128 bool need_repaint_;
129
130 // Time the last paint operation was started.
131 base::TimeTicks last_paint_started_time_;
132
133 // The texture type for which |shader_program| was initialized. Can be either
134 // 0, GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB or GL_TEXTURE_EXTERNAL_OES.
Wez 2015/01/06 22:17:10 What does a value of 0 mean, though?
Sergey Ulanov 2015/01/07 19:37:31 Done.
135 uint32_t current_shader_program_texture_target_;
136
137 // Shader program ID.
138 unsigned int shader_program_;
139
140 // Location of the scale value to be passed to the |shader_program_|.
141 int shader_texcoord_scale_location_;
142
143 pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_;
144
145 DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D);
146 };
147
148 } // namespace remoting
149
150 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698