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 } |
83 | 91 |
84 VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) { | 92 VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) { |
85 } | 93 } |
86 | 94 |
87 int32_t VideoDecoder::Initialize(const Graphics3D& context, | 95 int32_t VideoDecoder::Initialize(const Graphics3D& context, |
88 PP_VideoProfile profile, | 96 PP_VideoProfile profile, |
89 PP_HardwareAcceleration acceleration, | 97 PP_HardwareAcceleration acceleration, |
| 98 uint32_t min_picture_count, |
90 const CompletionCallback& cc) { | 99 const CompletionCallback& cc) { |
| 100 if (has_interface<PPB_VideoDecoder_1_1>()) { |
| 101 return get_interface<PPB_VideoDecoder_1_1>()->Initialize( |
| 102 pp_resource(), context.pp_resource(), profile, acceleration, |
| 103 min_picture_count, cc.pp_completion_callback()); |
| 104 } |
91 if (has_interface<PPB_VideoDecoder_1_0>()) { | 105 if (has_interface<PPB_VideoDecoder_1_0>()) { |
| 106 if (min_picture_count != 0) |
| 107 return cc.MayForce(PP_ERROR_NOTSUPPORTED); |
92 return get_interface<PPB_VideoDecoder_1_0>()->Initialize( | 108 return get_interface<PPB_VideoDecoder_1_0>()->Initialize( |
93 pp_resource(), context.pp_resource(), profile, acceleration, | 109 pp_resource(), context.pp_resource(), profile, acceleration, |
94 cc.pp_completion_callback()); | 110 cc.pp_completion_callback()); |
95 } | 111 } |
96 if (has_interface<PPB_VideoDecoder_0_2>()) { | 112 if (has_interface<PPB_VideoDecoder_0_2>()) { |
| 113 if (min_picture_count != 0) |
| 114 return cc.MayForce(PP_ERROR_NOTSUPPORTED); |
97 return get_interface<PPB_VideoDecoder_0_2>()->Initialize( | 115 return get_interface<PPB_VideoDecoder_0_2>()->Initialize( |
98 pp_resource(), context.pp_resource(), profile, acceleration, | 116 pp_resource(), context.pp_resource(), profile, acceleration, |
99 cc.pp_completion_callback()); | 117 cc.pp_completion_callback()); |
100 } | 118 } |
101 if (has_interface<PPB_VideoDecoder_0_1>()) { | 119 if (has_interface<PPB_VideoDecoder_0_1>()) { |
| 120 if (min_picture_count != 0) |
| 121 return cc.MayForce(PP_ERROR_NOTSUPPORTED); |
102 if (acceleration == PP_HARDWAREACCELERATION_NONE) | 122 if (acceleration == PP_HARDWAREACCELERATION_NONE) |
103 return cc.MayForce(PP_ERROR_NOTSUPPORTED); | 123 return cc.MayForce(PP_ERROR_NOTSUPPORTED); |
104 return get_interface<PPB_VideoDecoder_0_1>()->Initialize( | 124 return get_interface<PPB_VideoDecoder_0_1>()->Initialize( |
105 pp_resource(), | 125 pp_resource(), |
106 context.pp_resource(), | 126 context.pp_resource(), |
107 profile, | 127 profile, |
108 acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK | 128 acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK |
109 ? PP_TRUE | 129 ? PP_TRUE |
110 : PP_FALSE, | 130 : PP_FALSE, |
111 cc.pp_completion_callback()); | 131 cc.pp_completion_callback()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 pp_resource(), cc.pp_completion_callback()); | 214 pp_resource(), cc.pp_completion_callback()); |
195 } | 215 } |
196 if (has_interface<PPB_VideoDecoder_0_1>()) { | 216 if (has_interface<PPB_VideoDecoder_0_1>()) { |
197 return get_interface<PPB_VideoDecoder_0_1>()->Reset( | 217 return get_interface<PPB_VideoDecoder_0_1>()->Reset( |
198 pp_resource(), cc.pp_completion_callback()); | 218 pp_resource(), cc.pp_completion_callback()); |
199 } | 219 } |
200 return cc.MayForce(PP_ERROR_NOINTERFACE); | 220 return cc.MayForce(PP_ERROR_NOINTERFACE); |
201 } | 221 } |
202 | 222 |
203 } // namespace pp | 223 } // namespace pp |
OLD | NEW |