Chromium Code Reviews| Index: remoting/client/plugin/pepper_video_renderer_3d.h |
| diff --git a/remoting/client/plugin/pepper_video_renderer_3d.h b/remoting/client/plugin/pepper_video_renderer_3d.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..addaa857649a2dc47f17d057ddfb85ad4b50fc42 |
| --- /dev/null |
| +++ b/remoting/client/plugin/pepper_video_renderer_3d.h |
| @@ -0,0 +1,120 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ |
| +#define REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ |
| + |
| +#include <deque> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "ppapi/cpp/graphics_3d.h" |
| +#include "ppapi/cpp/instance_handle.h" |
| +#include "ppapi/cpp/video_decoder.h" |
| +#include "ppapi/lib/gl/include/GLES2/gl2.h" |
|
Wez
2014/12/24 17:11:15
nit: It's really unfortunate to have to pollute th
Sergey Ulanov
2015/01/06 01:16:33
This header was necessary only for GL[u]int types.
|
| +#include "ppapi/utility/completion_callback_factory.h" |
| +#include "remoting/client/chromoting_stats.h" |
| +#include "remoting/client/plugin/pepper_video_renderer.h" |
| +#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| +#include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| + |
| +struct PPB_OpenGLES2; |
| + |
| +namespace remoting { |
| + |
| +// PepperVideoRenderer that uses PPB_VideoDecoder interface for video decoding |
|
Wez
2014/12/24 17:11:15
nit: "... uses the PPB_VideoDecoder interface for
Sergey Ulanov
2015/01/06 01:16:33
Done.
|
| +// and Graphics3D for rendering. |
| +class PepperVideoRenderer3D : public PepperVideoRenderer { |
| + public: |
| + explicit PepperVideoRenderer3D(); |
|
Wez
2014/12/24 17:11:15
nit: No need for explicit here.
Sergey Ulanov
2015/01/06 01:16:33
Done.
|
| + ~PepperVideoRenderer3D() override; |
| + |
| + // PepperVideoRenderer interface. |
| + bool Initialize(pp::Instance* instance, |
| + const ClientContext& context, |
| + EventHandler* event_handler) override; |
| + void OnViewChanged(const pp::View& view) override; |
| + void OnSessionConfig(const protocol::SessionConfig& config) override; |
| + ChromotingStats* GetStats() override; |
| + void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, |
| + const base::Closure& done) override; |
| + |
| + private: |
| + class PendingPacket; |
| + |
| + struct FrameDecodeTimer { |
|
Wez
2014/12/24 17:11:15
nit: This isn't a timer in the base::Timer sense,
Sergey Ulanov
2015/01/06 01:16:34
Done.
|
| + FrameDecodeTimer(uint32_t frame_id, base::TimeTicks decode_started_time); |
| + uint32_t frame_id; |
| + base::TimeTicks decode_started_time; |
| + }; |
| + |
| + void OnInitialized(int32_t result); |
| + void DoDecode(); |
| + void OnDecodeDone(int32_t result); |
| + void DoGetPicture(); |
| + void OnPictureReady(int32_t result, PP_VideoPicture picture); |
| + void RecyclePictures(bool keep_first); |
| + void DoPaint(); |
| + void OnPaintDone(int32_t result); |
|
Wez
2014/12/24 17:11:16
nit: Break the members above into groups of logica
Sergey Ulanov
2015/01/06 01:16:34
Done.
|
| + |
| + void EnsureProgramForTexture(uint32_t texture_target); |
| + void CreateProgram(const char* vertex_shader, const char* fragment_shader); |
| + void CreateShaderProgram(int type, const char* source); |
| + void CheckGLError(); |
|
Wez
2014/12/24 17:11:16
nit: Suggest one-line comments be added for each o
Sergey Ulanov
2015/01/06 01:16:33
Done.
|
| + |
| + EventHandler* event_handler_; |
| + |
| + pp::Graphics3D graphics_; |
| + const PPB_OpenGLES2* gles2_if_; |
| + pp::VideoDecoder video_decoder_; |
| + |
| + webrtc::DesktopSize frame_size_; |
| + webrtc::DesktopVector frame_dpi_; |
| + webrtc::DesktopRegion desktop_shape_; |
| + |
| + int view_width_; |
| + int view_height_; |
|
Wez
2014/12/24 17:11:16
nit: Why not store these in a DesktopSize, for con
Sergey Ulanov
2015/01/06 01:16:33
Done.
|
| + |
| + ChromotingStats stats_; |
| + int64 latest_sequence_number_; |
| + |
| + bool initialized_; |
|
Wez
2014/12/24 17:11:15
nit: Could you derive |initialized_| from somethin
Sergey Ulanov
2015/01/06 01:16:34
No. VideoDecoder initialization is asynchronous an
|
| + bool decode_pending_; |
| + bool get_picture_pending_; |
| + bool paint_pending_; |
| + |
| + uint32_t last_frame_id_; |
|
Wez
2014/12/24 17:11:15
nit: Be consistent "last" here versus "latest" abo
Sergey Ulanov
2015/01/06 01:16:34
client_sequence_number is a misnomer - it's actual
Wez
2015/01/06 22:17:10
nit: Prefer "latest" to "last" since it's more obv
Sergey Ulanov
2015/01/07 19:37:30
Done.
|
| + |
| + // Queue of packets that that have been received, but haven't been decoded |
| + // yet. |
| + std::deque<PendingPacket*> pending_packets_; |
| + |
| + // List of per-frame structs that are used to time decoding time for each |
| + // frame. |
| + std::deque<FrameDecodeTimer> frames_decode_timers_; |
|
Wez
2014/12/24 17:11:16
nit: frame_decode_timers_
Or, since the things be
Sergey Ulanov
2015/01/06 01:16:34
Decoding a frame is a two-step process. First we c
Wez
2015/01/06 22:17:10
Right, I was thinking we could embed the timestamp
|
| + |
| + // Queue of video frames to be painted. May contain up to 2 frames. The last |
| + // frame is always to kept in this vector, in case it needs to be repainted. |
|
Wez
2014/12/24 17:11:15
Why might it contain two frames, rather than conta
Sergey Ulanov
2015/01/06 01:16:34
If a previous frame is still being rendered we wan
|
| + std::vector<PP_VideoPicture> pending_pictures_; |
| + |
| + // Set to true if the screen needs to be repainted. |
|
Wez
2014/12/24 17:11:15
nit: Clarify why that would be the case, e.g. due
Sergey Ulanov
2015/01/06 01:16:33
Done.
|
| + bool need_repaint_; |
| + |
| + // Time the last paint operation was started. |
| + base::TimeTicks last_paint_started_time_; |
|
Wez
2014/12/24 17:11:15
nit: See last/latest comment, above.
Sergey Ulanov
2015/01/06 01:16:33
Done.
|
| + |
| + uint32_t current_shader_program_texture_target_; |
| + GLuint shader_program_; |
| + GLint shader_texcoord_scale_location_; |
| + |
| + pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ |