Chromium Code Reviews| 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_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/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.
| |
| 18 #include "ppapi/utility/completion_callback_factory.h" | |
| 19 #include "remoting/client/chromoting_stats.h" | |
| 20 #include "remoting/client/plugin/pepper_video_renderer.h" | |
| 21 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | |
| 22 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | |
| 23 | |
| 24 struct PPB_OpenGLES2; | |
| 25 | |
| 26 namespace remoting { | |
| 27 | |
| 28 // 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.
| |
| 29 // and Graphics3D for rendering. | |
| 30 class PepperVideoRenderer3D : public PepperVideoRenderer { | |
| 31 public: | |
| 32 explicit PepperVideoRenderer3D(); | |
|
Wez
2014/12/24 17:11:15
nit: No need for explicit here.
Sergey Ulanov
2015/01/06 01:16:33
Done.
| |
| 33 ~PepperVideoRenderer3D() override; | |
| 34 | |
| 35 // PepperVideoRenderer interface. | |
| 36 bool Initialize(pp::Instance* instance, | |
| 37 const ClientContext& context, | |
| 38 EventHandler* event_handler) override; | |
| 39 void OnViewChanged(const pp::View& view) override; | |
| 40 void OnSessionConfig(const protocol::SessionConfig& config) override; | |
| 41 ChromotingStats* GetStats() override; | |
| 42 void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, | |
| 43 const base::Closure& done) override; | |
| 44 | |
| 45 private: | |
| 46 class PendingPacket; | |
| 47 | |
| 48 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.
| |
| 49 FrameDecodeTimer(uint32_t frame_id, base::TimeTicks decode_started_time); | |
| 50 uint32_t frame_id; | |
| 51 base::TimeTicks decode_started_time; | |
| 52 }; | |
| 53 | |
| 54 void OnInitialized(int32_t result); | |
| 55 void DoDecode(); | |
| 56 void OnDecodeDone(int32_t result); | |
| 57 void DoGetPicture(); | |
| 58 void OnPictureReady(int32_t result, PP_VideoPicture picture); | |
| 59 void RecyclePictures(bool keep_first); | |
| 60 void DoPaint(); | |
| 61 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.
| |
| 62 | |
| 63 void EnsureProgramForTexture(uint32_t texture_target); | |
| 64 void CreateProgram(const char* vertex_shader, const char* fragment_shader); | |
| 65 void CreateShaderProgram(int type, const char* source); | |
| 66 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.
| |
| 67 | |
| 68 EventHandler* event_handler_; | |
| 69 | |
| 70 pp::Graphics3D graphics_; | |
| 71 const PPB_OpenGLES2* gles2_if_; | |
| 72 pp::VideoDecoder video_decoder_; | |
| 73 | |
| 74 webrtc::DesktopSize frame_size_; | |
| 75 webrtc::DesktopVector frame_dpi_; | |
| 76 webrtc::DesktopRegion desktop_shape_; | |
| 77 | |
| 78 int view_width_; | |
| 79 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.
| |
| 80 | |
| 81 ChromotingStats stats_; | |
| 82 int64 latest_sequence_number_; | |
| 83 | |
| 84 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
| |
| 85 bool decode_pending_; | |
| 86 bool get_picture_pending_; | |
| 87 bool paint_pending_; | |
| 88 | |
| 89 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.
| |
| 90 | |
| 91 // Queue of packets that that have been received, but haven't been decoded | |
| 92 // yet. | |
| 93 std::deque<PendingPacket*> pending_packets_; | |
| 94 | |
| 95 // List of per-frame structs that are used to time decoding time for each | |
| 96 // frame. | |
| 97 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
| |
| 98 | |
| 99 // Queue of video frames to be painted. May contain up to 2 frames. The last | |
| 100 // 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
| |
| 101 std::vector<PP_VideoPicture> pending_pictures_; | |
| 102 | |
| 103 // 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.
| |
| 104 bool need_repaint_; | |
| 105 | |
| 106 // Time the last paint operation was started. | |
| 107 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.
| |
| 108 | |
| 109 uint32_t current_shader_program_texture_target_; | |
| 110 GLuint shader_program_; | |
| 111 GLint shader_texcoord_scale_location_; | |
| 112 | |
| 113 pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_; | |
| 114 | |
| 115 DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D); | |
| 116 }; | |
| 117 | |
| 118 } // namespace remoting | |
| 119 | |
| 120 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ | |
| OLD | NEW |