| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ | 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ |
| 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ | 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <list> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "ppapi/cpp/graphics_3d.h" | 16 #include "ppapi/cpp/graphics_3d.h" |
| 17 #include "ppapi/cpp/instance_handle.h" | 17 #include "ppapi/cpp/instance_handle.h" |
| 18 #include "ppapi/cpp/video_decoder.h" | 18 #include "ppapi/cpp/video_decoder.h" |
| 19 #include "ppapi/utility/completion_callback_factory.h" | 19 #include "ppapi/utility/completion_callback_factory.h" |
| 20 #include "remoting/client/plugin/pepper_video_renderer.h" | 20 #include "remoting/client/plugin/pepper_video_renderer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 // VideoRenderer interface. | 44 // VideoRenderer interface. |
| 45 void OnSessionConfig(const protocol::SessionConfig& config) override; | 45 void OnSessionConfig(const protocol::SessionConfig& config) override; |
| 46 protocol::VideoStub* GetVideoStub() override; | 46 protocol::VideoStub* GetVideoStub() override; |
| 47 protocol::FrameConsumer* GetFrameConsumer() override; | 47 protocol::FrameConsumer* GetFrameConsumer() override; |
| 48 | 48 |
| 49 // protocol::VideoStub interface. | 49 // protocol::VideoStub interface. |
| 50 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, | 50 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, |
| 51 const base::Closure& done) override; | 51 const base::Closure& done) override; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 class PendingPacket; | 54 // Class responsible for tracking state of a frame until it's rendered. |
| 55 class FrameTracker; |
| 56 |
| 55 class Picture; | 57 class Picture; |
| 56 | 58 |
| 57 // Callback for pp::VideoDecoder::Initialize(). | 59 // Callback for pp::VideoDecoder::Initialize(). |
| 58 void OnInitialized(int32_t result); | 60 void OnInitialized(int32_t result); |
| 59 | 61 |
| 60 // Passes one picture from |pending_packets_| to the |video_decoder_|. | 62 // Passes one picture from |pending_frames_| to the |video_decoder_|. |
| 61 void DecodeNextPacket(); | 63 void DecodeNextPacket(); |
| 62 | 64 |
| 63 // Callback for pp::VideoDecoder::Decode(). | 65 // Callback for pp::VideoDecoder::Decode(). |
| 64 void OnDecodeDone(int32_t result); | 66 void OnDecodeDone(int32_t result); |
| 65 | 67 |
| 66 // Fetches next picture from the |video_decoder_|. | 68 // Fetches next picture from the |video_decoder_|. |
| 67 void GetNextPicture(); | 69 void GetNextPicture(); |
| 68 | 70 |
| 69 // Callback for pp::VideoDecoder::GetPicture(). | 71 // Callback for pp::VideoDecoder::GetPicture(). |
| 70 void OnPictureReady(int32_t result, PP_VideoPicture picture); | 72 void OnPictureReady(int32_t result, PP_VideoPicture picture); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 98 | 100 |
| 99 webrtc::DesktopSize frame_size_; | 101 webrtc::DesktopSize frame_size_; |
| 100 | 102 |
| 101 webrtc::DesktopSize view_size_; | 103 webrtc::DesktopSize view_size_; |
| 102 | 104 |
| 103 bool initialization_finished_ = false; | 105 bool initialization_finished_ = false; |
| 104 bool decode_pending_ = false; | 106 bool decode_pending_ = false; |
| 105 bool get_picture_pending_ = false; | 107 bool get_picture_pending_ = false; |
| 106 bool paint_pending_ = false; | 108 bool paint_pending_ = false; |
| 107 | 109 |
| 108 // Queue of packets that that have been received, but haven't been passed to | 110 // Frames that have been received, but haven't been passed to the decoder yet. |
| 109 // the decoder yet. | 111 std::list<std::unique_ptr<FrameTracker>> pending_frames_; |
| 110 std::deque<PendingPacket*> pending_packets_; | |
| 111 | 112 |
| 112 // The current picture shown on the screen or being rendered. Must be deleted | 113 // Frames that have been decoded but for which we haven't received the |
| 113 // before |video_decoder_|. | 114 // pictures yet. |
| 114 std::unique_ptr<Picture> current_picture_; | 115 std::list<std::unique_ptr<FrameTracker>> decoded_frames_; |
| 115 | 116 |
| 116 // The next picture to be rendered. PaintIfNeeded() will copy it to | 117 // The next picture to be rendered. PaintIfNeeded() will copy it to |
| 117 // |current_picture_| and render it after that. Must be deleted | 118 // |current_picture_| and render it after that. Must be deleted |
| 118 // before |video_decoder_|. | 119 // before |video_decoder_|. |
| 119 std::unique_ptr<Picture> next_picture_; | 120 std::unique_ptr<Picture> next_picture_; |
| 120 | 121 |
| 122 // FrameTracker instances in |next_picture_|. |
| 123 std::list<std::unique_ptr<FrameTracker>> next_picture_frames_; |
| 124 |
| 125 // The current picture shown on the screen or being rendered. Must be deleted |
| 126 // before |video_decoder_|. |
| 127 std::unique_ptr<Picture> current_picture_; |
| 128 |
| 129 // FrameTrackers for frames in |current_picture_|. The queue is emptied once |
| 130 // the |current_picture_| is rendered. |
| 131 std::list<std::unique_ptr<FrameTracker>> current_picture_frames_; |
| 132 |
| 121 // Set to true if the screen has been resized and needs to be repainted. | 133 // Set to true if the screen has been resized and needs to be repainted. |
| 122 bool force_repaint_ = false; | 134 bool force_repaint_ = false; |
| 123 | 135 |
| 124 // The texture type for which |shader_program| was initialized. Can be either | 136 // The texture type for which |shader_program| was initialized. Can be either |
| 125 // 0, GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB or GL_TEXTURE_EXTERNAL_OES. 0 | 137 // 0, GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB or GL_TEXTURE_EXTERNAL_OES. 0 |
| 126 // indicates that |shader_program_| hasn't been intialized. | 138 // indicates that |shader_program_| hasn't been intialized. |
| 127 uint32_t current_shader_program_texture_target_ = 0; | 139 uint32_t current_shader_program_texture_target_ = 0; |
| 128 | 140 |
| 129 // Shader program ID. | 141 // Shader program ID. |
| 130 unsigned int shader_program_ = 0; | 142 unsigned int shader_program_ = 0; |
| 131 | 143 |
| 132 // Location of the scale value to be passed to the |shader_program_|. | 144 // Location of the scale value to be passed to the |shader_program_|. |
| 133 int shader_texcoord_scale_location_ = 0; | 145 int shader_texcoord_scale_location_ = 0; |
| 134 | 146 |
| 135 // True if the renderer has received frame from the host. | 147 // True if the renderer has received frame from the host. |
| 136 bool frame_received_ = false; | 148 bool frame_received_ = false; |
| 137 | 149 |
| 138 // True if dirty regions are to be sent to |event_handler_| for debugging. | 150 // True if dirty regions are to be sent to |event_handler_| for debugging. |
| 139 bool debug_dirty_region_ = false; | 151 bool debug_dirty_region_ = false; |
| 140 | 152 |
| 141 pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_; | 153 pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_; |
| 142 | 154 |
| 143 DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D); | 155 DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D); |
| 144 }; | 156 }; |
| 145 | 157 |
| 146 } // namespace remoting | 158 } // namespace remoting |
| 147 | 159 |
| 148 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ | 160 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_ |
| OLD | NEW |