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

Unified 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 6 years 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 side-by-side diff with in-line comments
Download patch
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..e4cd5b56a9afd23fecedcc1c37d29207eef80ca6
--- /dev/null
+++ b/remoting/client/plugin/pepper_video_renderer_3d.h
@@ -0,0 +1,115 @@
+// 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"
+#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
+// and Graphics3D for rendering.
+class PepperVideoRenderer3D : public PepperVideoRenderer {
+ public:
+ explicit PepperVideoRenderer3D();
+ ~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;
+
+ 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);
+
+ 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();
+
+ 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_;
+
+ ChromotingStats stats_;
+ int64 latest_sequence_number_;
+
+ bool initialized_;
+ bool decode_pending_;
+ bool get_picture_pending_;
+ bool paint_pending_;
+
+ uint32_t last_frame_id_;
+
+ // 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_;
+
+ // 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.
+ std::vector<PP_VideoPicture> pending_pictures_;
+
+ // Set to true if the screen needs to be repainted.
+ bool need_repaint_;
+
+ // Time the last paint operation was started.
+ base::TimeTicks last_paint_started_time_;
+
+ uint32_t current_shader_program_texture_target_;
+ GLuint shader_program_;
+ 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.
+
+ pp::CompletionCallbackFactory<PepperVideoRenderer3D> callback_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperVideoRenderer3D);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_CLIENT_PLUGIN_PEPPER_VIDEO_RENDERER_3D_H_

Powered by Google App Engine
This is Rietveld 408576698