| 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 #include "remoting/client/plugin/pepper_video_renderer_3d.h" | 5 #include "remoting/client/plugin/pepper_video_renderer_3d.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "ppapi/c/pp_codecs.h" | 11 #include "ppapi/c/pp_codecs.h" |
| 12 #include "ppapi/c/ppb_opengles2.h" | 12 #include "ppapi/c/ppb_opengles2.h" |
| 13 #include "ppapi/c/ppb_video_decoder.h" |
| 13 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
| 14 #include "ppapi/lib/gl/include/GLES2/gl2.h" | 15 #include "ppapi/lib/gl/include/GLES2/gl2.h" |
| 15 #include "ppapi/lib/gl/include/GLES2/gl2ext.h" | 16 #include "ppapi/lib/gl/include/GLES2/gl2ext.h" |
| 16 #include "remoting/proto/video.pb.h" | 17 #include "remoting/proto/video.pb.h" |
| 17 #include "remoting/protocol/session_config.h" | 18 #include "remoting/protocol/session_config.h" |
| 18 | 19 |
| 19 namespace remoting { | 20 namespace remoting { |
| 20 | 21 |
| 22 // The implementation here requires this minimum number of pictures from the |
| 23 // video decoder interface to work. |
| 24 const uint32_t kMinimumPictureCount = 3; |
| 25 |
| 21 class PepperVideoRenderer3D::PendingPacket { | 26 class PepperVideoRenderer3D::PendingPacket { |
| 22 public: | 27 public: |
| 23 PendingPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) | 28 PendingPacket(scoped_ptr<VideoPacket> packet, const base::Closure& done) |
| 24 : packet_(packet.Pass()), | 29 : packet_(packet.Pass()), |
| 25 done_runner_(done) { | 30 done_runner_(done) { |
| 26 } | 31 } |
| 27 | 32 |
| 28 ~PendingPacket() {} | 33 ~PendingPacket() {} |
| 29 | 34 |
| 30 const VideoPacket* packet() const { return packet_.get(); } | 35 const VideoPacket* packet() const { return packet_.get(); } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 switch (config.video_config().codec) { | 168 switch (config.video_config().codec) { |
| 164 case protocol::ChannelConfig::CODEC_VP8: | 169 case protocol::ChannelConfig::CODEC_VP8: |
| 165 video_profile = PP_VIDEOPROFILE_VP8_ANY; | 170 video_profile = PP_VIDEOPROFILE_VP8_ANY; |
| 166 break; | 171 break; |
| 167 case protocol::ChannelConfig::CODEC_VP9: | 172 case protocol::ChannelConfig::CODEC_VP9: |
| 168 video_profile = PP_VIDEOPROFILE_VP9_ANY; | 173 video_profile = PP_VIDEOPROFILE_VP9_ANY; |
| 169 break; | 174 break; |
| 170 default: | 175 default: |
| 171 NOTREACHED(); | 176 NOTREACHED(); |
| 172 } | 177 } |
| 178 |
| 179 bool supports_video_decoder_1_1 = |
| 180 pp::Module::Get()->GetBrowserInterface( |
| 181 PPB_VIDEODECODER_INTERFACE_1_1) != NULL; |
| 173 int32_t result = video_decoder_.Initialize( | 182 int32_t result = video_decoder_.Initialize( |
| 174 graphics_, video_profile, PP_HARDWAREACCELERATION_WITHFALLBACK, | 183 graphics_, video_profile, PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 184 supports_video_decoder_1_1 ? kMinimumPictureCount : 0, |
| 175 callback_factory_.NewCallback(&PepperVideoRenderer3D::OnInitialized)); | 185 callback_factory_.NewCallback(&PepperVideoRenderer3D::OnInitialized)); |
| 176 CHECK_EQ(result, PP_OK_COMPLETIONPENDING) | 186 CHECK_EQ(result, PP_OK_COMPLETIONPENDING) |
| 177 << "video_decoder_.Initialize() returned " << result; | 187 << "video_decoder_.Initialize() returned " << result; |
| 178 } | 188 } |
| 179 | 189 |
| 180 ChromotingStats* PepperVideoRenderer3D::GetStats() { | 190 ChromotingStats* PepperVideoRenderer3D::GetStats() { |
| 181 return &stats_; | 191 return &stats_; |
| 182 } | 192 } |
| 183 | 193 |
| 184 protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { | 194 protocol::VideoStub* PepperVideoRenderer3D::GetVideoStub() { |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); | 555 gles2_if_->AttachShader(graphics_.pp_resource(), shader_program_, shader); |
| 546 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); | 556 gles2_if_->DeleteShader(graphics_.pp_resource(), shader); |
| 547 } | 557 } |
| 548 | 558 |
| 549 void PepperVideoRenderer3D::CheckGLError() { | 559 void PepperVideoRenderer3D::CheckGLError() { |
| 550 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); | 560 GLenum error = gles2_if_->GetError(graphics_.pp_resource()); |
| 551 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; | 561 CHECK_EQ(error, static_cast<GLenum>(GL_NO_ERROR)) << "GL error: " << error; |
| 552 } | 562 } |
| 553 | 563 |
| 554 } // namespace remoting | 564 } // namespace remoting |
| OLD | NEW |