OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ppapi/cpp/video_decoder.h" | 5 #include "ppapi/cpp/video_decoder.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/ppb_video_decoder.h" | 8 #include "ppapi/c/ppb_video_decoder.h" |
9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
10 #include "ppapi/cpp/instance_handle.h" | 10 #include "ppapi/cpp/instance_handle.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 template <> | 23 template <> |
24 const char* interface_name<PPB_VideoDecoder_0_2>() { | 24 const char* interface_name<PPB_VideoDecoder_0_2>() { |
25 return PPB_VIDEODECODER_INTERFACE_0_2; | 25 return PPB_VIDEODECODER_INTERFACE_0_2; |
26 } | 26 } |
27 | 27 |
28 template <> | 28 template <> |
29 const char* interface_name<PPB_VideoDecoder_1_0>() { | 29 const char* interface_name<PPB_VideoDecoder_1_0>() { |
30 return PPB_VIDEODECODER_INTERFACE_1_0; | 30 return PPB_VIDEODECODER_INTERFACE_1_0; |
31 } | 31 } |
32 | 32 |
| 33 template <> |
| 34 const char* interface_name<PPB_VideoDecoder_1_1>() { |
| 35 return PPB_VIDEODECODER_INTERFACE_1_1; |
| 36 } |
| 37 |
33 // This struct is used to adapt CompletionCallbackWithOutput<PP_VideoPicture> to | 38 // This struct is used to adapt CompletionCallbackWithOutput<PP_VideoPicture> to |
34 // the pre-1.0 APIs, which return PP_VideoPicture_0_1. This struct is allocated | 39 // the pre-1.0 APIs, which return PP_VideoPicture_0_1. This struct is allocated |
35 // on the heap, and deleted in CallbackConverter. | 40 // on the heap, and deleted in CallbackConverter. |
36 struct CallbackData_0_1 { | 41 struct CallbackData_0_1 { |
37 explicit CallbackData_0_1( | 42 explicit CallbackData_0_1( |
38 const CompletionCallbackWithOutput<PP_VideoPicture>& cc) | 43 const CompletionCallbackWithOutput<PP_VideoPicture>& cc) |
39 : original_picture(cc.output()), | 44 : original_picture(cc.output()), |
40 original_callback(cc.pp_completion_callback()) {} | 45 original_callback(cc.pp_completion_callback()) {} |
41 PP_VideoPicture_0_1 picture; | 46 PP_VideoPicture_0_1 picture; |
42 PP_VideoPicture* original_picture; | 47 PP_VideoPicture* original_picture; |
(...skipping 19 matching lines...) Expand all Loading... |
62 PP_RunCompletionCallback(&data->original_callback, result); | 67 PP_RunCompletionCallback(&data->original_callback, result); |
63 delete data; | 68 delete data; |
64 } | 69 } |
65 | 70 |
66 } // namespace | 71 } // namespace |
67 | 72 |
68 VideoDecoder::VideoDecoder() { | 73 VideoDecoder::VideoDecoder() { |
69 } | 74 } |
70 | 75 |
71 VideoDecoder::VideoDecoder(const InstanceHandle& instance) { | 76 VideoDecoder::VideoDecoder(const InstanceHandle& instance) { |
72 if (has_interface<PPB_VideoDecoder_1_0>()) { | 77 if (has_interface<PPB_VideoDecoder_1_1>()) { |
| 78 PassRefFromConstructor( |
| 79 get_interface<PPB_VideoDecoder_1_1>()->Create(instance.pp_instance())); |
| 80 } else if (has_interface<PPB_VideoDecoder_1_0>()) { |
73 PassRefFromConstructor( | 81 PassRefFromConstructor( |
74 get_interface<PPB_VideoDecoder_1_0>()->Create(instance.pp_instance())); | 82 get_interface<PPB_VideoDecoder_1_0>()->Create(instance.pp_instance())); |
75 } else if (has_interface<PPB_VideoDecoder_0_2>()) { | 83 } else if (has_interface<PPB_VideoDecoder_0_2>()) { |
76 PassRefFromConstructor( | 84 PassRefFromConstructor( |
77 get_interface<PPB_VideoDecoder_0_2>()->Create(instance.pp_instance())); | 85 get_interface<PPB_VideoDecoder_0_2>()->Create(instance.pp_instance())); |
78 } else if (has_interface<PPB_VideoDecoder_0_1>()) { | 86 } else if (has_interface<PPB_VideoDecoder_0_1>()) { |
79 PassRefFromConstructor( | 87 PassRefFromConstructor( |
80 get_interface<PPB_VideoDecoder_0_1>()->Create(instance.pp_instance())); | 88 get_interface<PPB_VideoDecoder_0_1>()->Create(instance.pp_instance())); |
81 } | 89 } |
82 } | 90 } |
(...skipping 23 matching lines...) Expand all Loading... |
106 context.pp_resource(), | 114 context.pp_resource(), |
107 profile, | 115 profile, |
108 acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK | 116 acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK |
109 ? PP_TRUE | 117 ? PP_TRUE |
110 : PP_FALSE, | 118 : PP_FALSE, |
111 cc.pp_completion_callback()); | 119 cc.pp_completion_callback()); |
112 } | 120 } |
113 return cc.MayForce(PP_ERROR_NOINTERFACE); | 121 return cc.MayForce(PP_ERROR_NOINTERFACE); |
114 } | 122 } |
115 | 123 |
| 124 int32_t VideoDecoder::Initialize(const Graphics3D& context, |
| 125 PP_VideoProfile profile, |
| 126 PP_HardwareAcceleration acceleration, |
| 127 uint32_t min_picture_count, |
| 128 const CompletionCallback& cc) { |
| 129 if (has_interface<PPB_VideoDecoder_1_1>()) { |
| 130 return get_interface<PPB_VideoDecoder_1_1>()->Initialize( |
| 131 pp_resource(), context.pp_resource(), profile, acceleration, |
| 132 min_picture_count, cc.pp_completion_callback()); |
| 133 } |
| 134 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 135 } |
| 136 |
116 int32_t VideoDecoder::Decode(uint32_t decode_id, | 137 int32_t VideoDecoder::Decode(uint32_t decode_id, |
117 uint32_t size, | 138 uint32_t size, |
118 const void* buffer, | 139 const void* buffer, |
119 const CompletionCallback& cc) { | 140 const CompletionCallback& cc) { |
120 if (has_interface<PPB_VideoDecoder_1_0>()) { | 141 if (has_interface<PPB_VideoDecoder_1_0>()) { |
121 return get_interface<PPB_VideoDecoder_1_0>()->Decode( | 142 return get_interface<PPB_VideoDecoder_1_0>()->Decode( |
122 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); | 143 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); |
123 } | 144 } |
124 if (has_interface<PPB_VideoDecoder_0_2>()) { | 145 if (has_interface<PPB_VideoDecoder_0_2>()) { |
125 return get_interface<PPB_VideoDecoder_0_2>()->Decode( | 146 return get_interface<PPB_VideoDecoder_0_2>()->Decode( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 pp_resource(), cc.pp_completion_callback()); | 215 pp_resource(), cc.pp_completion_callback()); |
195 } | 216 } |
196 if (has_interface<PPB_VideoDecoder_0_1>()) { | 217 if (has_interface<PPB_VideoDecoder_0_1>()) { |
197 return get_interface<PPB_VideoDecoder_0_1>()->Reset( | 218 return get_interface<PPB_VideoDecoder_0_1>()->Reset( |
198 pp_resource(), cc.pp_completion_callback()); | 219 pp_resource(), cc.pp_completion_callback()); |
199 } | 220 } |
200 return cc.MayForce(PP_ERROR_NOINTERFACE); | 221 return cc.MayForce(PP_ERROR_NOINTERFACE); |
201 } | 222 } |
202 | 223 |
203 } // namespace pp | 224 } // namespace pp |
OLD | NEW |