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" | |
| 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 | |
| 29 // and Graphics3D for rendering. | |
| 30 class PepperVideoRenderer3D : public PepperVideoRenderer { | |
| 31 public: | |
| 32 explicit PepperVideoRenderer3D(); | |
| 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 struct FrameDecodeTimer; | |
| 48 | |
| 49 void OnInitialized(int32_t result); | |
| 50 void DoDecode(); | |
| 51 void OnDecodeDone(int32_t result); | |
| 52 void DoGetPicture(); | |
| 53 void OnPictureReady(int32_t result, PP_VideoPicture picture); | |
| 54 void RecyclePictures(bool keep_first); | |
| 55 void DoPaint(); | |
| 56 void OnPaintDone(int32_t result); | |
| 57 | |
| 58 void EnsureProgramForTexture(uint32_t texture_target); | |
| 59 void CreateProgram(const char* vertex_shader, const char* fragment_shader); | |
| 60 void CreateShaderProgram(int type, const char* source); | |
| 61 void CheckGLError(); | |
| 62 | |
| 63 EventHandler* event_handler_; | |
| 64 | |
| 65 pp::Graphics3D graphics_; | |
| 66 const PPB_OpenGLES2* gles2_if_; | |
| 67 pp::VideoDecoder video_decoder_; | |
| 68 | |
| 69 webrtc::DesktopSize frame_size_; | |
| 70 webrtc::DesktopVector frame_dpi_; | |
| 71 webrtc::DesktopRegion desktop_shape_; | |
| 72 | |
| 73 int view_width_; | |
| 74 int view_height_; | |
| 75 | |
| 76 ChromotingStats stats_; | |
| 77 int64 latest_sequence_number_; | |
| 78 | |
| 79 bool initialized_; | |
| 80 bool decode_pending_; | |
| 81 bool get_picture_pending_; | |
| 82 bool paint_pending_; | |
| 83 | |
| 84 uint32_t last_frame_id_; | |
| 85 | |
| 86 // Queue of packets that that have been received, but haven't been decoded | |
| 87 // yet. | |
| 88 std::deque<PendingPacket*> pending_packets_; | |
| 89 | |
| 90 // List of per-frame structs that are used to time decoding time for each | |
| 91 // frame. | |
| 92 std::deque<FrameDecodeTimer> frames_decode_timers_; | |
| 93 | |
| 94 // Queue of video frames to be painted. May contain up to 2 frames. The last | |
| 95 // frame is always to kept in this vector, in case it needs to be repainted. | |
| 96 std::vector<PP_VideoPicture> pending_pictures_; | |
| 97 | |
| 98 // Set to true if the screen needs to be repainted. | |
| 99 bool need_repaint_; | |
| 100 | |
| 101 // Time the last paint operation was started. | |
| 102 base::TimeTicks last_paint_started_time_; | |
| 103 | |
| 104 uint32_t current_shader_program_texture_target_; | |
| 105 GLuint shader_program_; | |
| 106 GLint shader_texcoord_scale_location_; | |
|
Wez
2014/12/24 17:11:13
nit: Please add a brief block comment to explain h
Sergey Ulanov
2015/01/06 01:16:31
Done.
| |
| 107 | |
| 108 pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_; | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D); | |
| 111 }; | |
| 112 | |
| 113 } // namespace remoting | |
| 114 | |
| 115 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ | |
| OLD | NEW |