OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppb_video_decoder_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { | 47 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { |
48 } | 48 } |
49 | 49 |
50 PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { | 50 PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { |
51 return this; | 51 return this; |
52 } | 52 } |
53 | 53 |
| 54 // Convert PP_VideoDecoder_Profile to media::VideoDecodeAccelerator::Profile. |
| 55 static media::VideoDecodeAccelerator::Profile PPToMediaProfile( |
| 56 const PP_VideoDecoder_Profile pp_profile) { |
| 57 // TODO(fischman,vrk): this assumes the enum values in the two Profile types |
| 58 // match up exactly. Add a COMPILE_ASSERT for this somewhere. |
| 59 return static_cast<media::VideoDecodeAccelerator::Profile>(pp_profile); |
| 60 } |
| 61 |
54 // static | 62 // static |
55 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, | 63 PP_Resource PPB_VideoDecoder_Impl::Create( |
56 PP_Resource graphics_context, | 64 PP_Instance instance, |
57 const PP_VideoConfigElement* config) { | 65 PP_Resource graphics_context, |
| 66 PP_VideoDecoder_Profile profile) { |
58 PluginDelegate::PlatformContext3D* platform_context = NULL; | 67 PluginDelegate::PlatformContext3D* platform_context = NULL; |
59 gpu::gles2::GLES2Implementation* gles2_impl = NULL; | 68 gpu::gles2::GLES2Implementation* gles2_impl = NULL; |
60 EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false); | 69 EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false); |
61 if (enter_context.succeeded()) { | 70 if (enter_context.succeeded()) { |
62 PPB_Context3D_Impl* context3d_impl = | 71 PPB_Context3D_Impl* context3d_impl = |
63 static_cast<PPB_Context3D_Impl*>(enter_context.object()); | 72 static_cast<PPB_Context3D_Impl*>(enter_context.object()); |
64 platform_context = context3d_impl->platform_context(); | 73 platform_context = context3d_impl->platform_context(); |
65 gles2_impl = context3d_impl->gles2_impl(); | 74 gles2_impl = context3d_impl->gles2_impl(); |
66 } else { | 75 } else { |
67 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, | 76 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, |
68 true); | 77 true); |
69 if (enter_context.failed()) | 78 if (enter_context.failed()) |
70 return 0; | 79 return 0; |
71 PPB_Graphics3D_Impl* graphics3d_impl = | 80 PPB_Graphics3D_Impl* graphics3d_impl = |
72 static_cast<PPB_Graphics3D_Impl*>(enter_context.object()); | 81 static_cast<PPB_Graphics3D_Impl*>(enter_context.object()); |
73 platform_context = graphics3d_impl->platform_context(); | 82 platform_context = graphics3d_impl->platform_context(); |
74 gles2_impl = graphics3d_impl->gles2_impl(); | 83 gles2_impl = graphics3d_impl->gles2_impl(); |
75 } | 84 } |
76 | 85 |
77 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 86 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
78 new PPB_VideoDecoder_Impl(instance)); | 87 new PPB_VideoDecoder_Impl(instance)); |
79 if (decoder->Init(graphics_context, platform_context, gles2_impl, config)) | 88 if (decoder->Init(graphics_context, platform_context, gles2_impl, profile)) |
80 return decoder->GetReference(); | 89 return decoder->GetReference(); |
81 return 0; | 90 return 0; |
82 } | 91 } |
83 | 92 |
84 bool PPB_VideoDecoder_Impl::Init( | 93 bool PPB_VideoDecoder_Impl::Init( |
85 PP_Resource graphics_context, | 94 PP_Resource graphics_context, |
86 PluginDelegate::PlatformContext3D* context, | 95 PluginDelegate::PlatformContext3D* context, |
87 gpu::gles2::GLES2Implementation* gles2_impl, | 96 gpu::gles2::GLES2Implementation* gles2_impl, |
88 const PP_VideoConfigElement* config) { | 97 PP_VideoDecoder_Profile profile) { |
89 InitCommon(graphics_context, gles2_impl); | 98 InitCommon(graphics_context, gles2_impl); |
90 | 99 |
91 int command_buffer_route_id = context->GetCommandBufferRouteId(); | 100 int command_buffer_route_id = context->GetCommandBufferRouteId(); |
92 if (command_buffer_route_id == 0) | 101 if (command_buffer_route_id == 0) |
93 return false; | 102 return false; |
94 | 103 |
95 std::vector<int32> copied; | |
96 if (!CopyConfigsToVector(config, &copied)) | |
97 return false; | |
98 | |
99 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 104 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
100 if (!plugin_delegate) | 105 if (!plugin_delegate) |
101 return false; | 106 return false; |
102 | 107 |
103 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( | 108 platform_video_decoder_ = plugin_delegate->CreateVideoDecoder( |
104 this, command_buffer_route_id); | 109 this, command_buffer_route_id); |
105 if (!platform_video_decoder_) | 110 if (!platform_video_decoder_) |
106 return false; | 111 return false; |
107 | 112 |
108 FlushCommandBuffer(); | 113 FlushCommandBuffer(); |
109 return platform_video_decoder_->Initialize(copied); | 114 return platform_video_decoder_->Initialize(PPToMediaProfile(profile)); |
110 } | 115 } |
111 | 116 |
112 int32_t PPB_VideoDecoder_Impl::Decode( | 117 int32_t PPB_VideoDecoder_Impl::Decode( |
113 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 118 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
114 PP_CompletionCallback callback) { | 119 PP_CompletionCallback callback) { |
115 if (!platform_video_decoder_) | 120 if (!platform_video_decoder_) |
116 return PP_ERROR_BADRESOURCE; | 121 return PP_ERROR_BADRESOURCE; |
117 | 122 |
118 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); | 123 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); |
119 if (enter.failed()) | 124 if (enter.failed()) |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 258 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
254 RunFlushCallback(PP_OK); | 259 RunFlushCallback(PP_OK); |
255 } | 260 } |
256 | 261 |
257 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { | 262 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
258 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; | 263 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!"; |
259 } | 264 } |
260 | 265 |
261 } // namespace ppapi | 266 } // namespace ppapi |
262 } // namespace webkit | 267 } // namespace webkit |
OLD | NEW |