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

Side by Side Diff: ppapi/cpp/video_decoder.cc

Issue 703753002: Pepper: Expose visible_rect to PPB_VideoDecoder.GetPicture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
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"
11 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h" 12 #include "ppapi/cpp/module_impl.h"
13 13
14 namespace pp { 14 namespace pp {
15 15
16 namespace { 16 namespace {
17 17
18 template <> 18 template <>
19 const char* interface_name<PPB_VideoDecoder_0_1>() { 19 const char* interface_name<PPB_VideoDecoder_0_1>() {
20 return PPB_VIDEODECODER_INTERFACE_0_1; 20 return PPB_VIDEODECODER_INTERFACE_0_1;
21 } 21 }
22 22
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 <>
29 const char* interface_name<PPB_VideoDecoder_0_3>() {
30 return PPB_VIDEODECODER_INTERFACE_0_3;
31 }
32
28 } // namespace 33 } // namespace
29 34
30 VideoDecoder::VideoDecoder() { 35 VideoDecoder::VideoDecoder() {
31 } 36 }
32 37
33 VideoDecoder::VideoDecoder(const InstanceHandle& instance) { 38 VideoDecoder::VideoDecoder(const InstanceHandle& instance) {
34 if (has_interface<PPB_VideoDecoder_0_1>()) { 39 if (has_interface<PPB_VideoDecoder_0_1>()) {
35 PassRefFromConstructor( 40 PassRefFromConstructor(
36 get_interface<PPB_VideoDecoder_0_1>()->Create(instance.pp_instance())); 41 get_interface<PPB_VideoDecoder_0_1>()->Create(instance.pp_instance()));
37 } 42 }
38 } 43 }
39 44
40 VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) { 45 VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) {
41 } 46 }
42 47
43 int32_t VideoDecoder::Initialize(const Graphics3D& context, 48 int32_t VideoDecoder::Initialize(const Graphics3D& context,
44 PP_VideoProfile profile, 49 PP_VideoProfile profile,
45 PP_HardwareAcceleration acceleration, 50 PP_HardwareAcceleration acceleration,
46 const CompletionCallback& cc) { 51 const CompletionCallback& cc) {
52 if (has_interface<PPB_VideoDecoder_0_3>()) {
53 return get_interface<PPB_VideoDecoder_0_3>()->Initialize(
54 pp_resource(), context.pp_resource(), profile, acceleration,
55 cc.pp_completion_callback());
56 }
47 if (has_interface<PPB_VideoDecoder_0_2>()) { 57 if (has_interface<PPB_VideoDecoder_0_2>()) {
48 return get_interface<PPB_VideoDecoder_0_2>()->Initialize( 58 return get_interface<PPB_VideoDecoder_0_2>()->Initialize(
49 pp_resource(), 59 pp_resource(), context.pp_resource(), profile, acceleration,
50 context.pp_resource(),
51 profile,
52 acceleration,
53 cc.pp_completion_callback()); 60 cc.pp_completion_callback());
54 } 61 }
55 if (has_interface<PPB_VideoDecoder_0_1>()) { 62 if (has_interface<PPB_VideoDecoder_0_1>()) {
56 if (acceleration == PP_HARDWAREACCELERATION_NONE) 63 if (acceleration == PP_HARDWAREACCELERATION_NONE)
57 return cc.MayForce(PP_ERROR_NOTSUPPORTED); 64 return cc.MayForce(PP_ERROR_NOTSUPPORTED);
58 return get_interface<PPB_VideoDecoder_0_1>()->Initialize( 65 return get_interface<PPB_VideoDecoder_0_1>()->Initialize(
59 pp_resource(), 66 pp_resource(),
60 context.pp_resource(), 67 context.pp_resource(),
61 profile, 68 profile,
62 acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK 69 acceleration == PP_HARDWAREACCELERATION_WITHFALLBACK
63 ? PP_TRUE 70 ? PP_TRUE
64 : PP_FALSE, 71 : PP_FALSE,
65 cc.pp_completion_callback()); 72 cc.pp_completion_callback());
66 } 73 }
67 return cc.MayForce(PP_ERROR_NOINTERFACE); 74 return cc.MayForce(PP_ERROR_NOINTERFACE);
68 } 75 }
69 76
70 int32_t VideoDecoder::Decode(uint32_t decode_id, 77 int32_t VideoDecoder::Decode(uint32_t decode_id,
71 uint32_t size, 78 uint32_t size,
72 const void* buffer, 79 const void* buffer,
73 const CompletionCallback& cc) { 80 const CompletionCallback& cc) {
81 if (has_interface<PPB_VideoDecoder_0_3>()) {
82 return get_interface<PPB_VideoDecoder_0_3>()->Decode(
83 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback());
84 }
74 if (has_interface<PPB_VideoDecoder_0_2>()) { 85 if (has_interface<PPB_VideoDecoder_0_2>()) {
75 return get_interface<PPB_VideoDecoder_0_2>()->Decode( 86 return get_interface<PPB_VideoDecoder_0_2>()->Decode(
76 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); 87 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback());
77 } 88 }
78 if (has_interface<PPB_VideoDecoder_0_1>()) { 89 if (has_interface<PPB_VideoDecoder_0_1>()) {
79 return get_interface<PPB_VideoDecoder_0_1>()->Decode( 90 return get_interface<PPB_VideoDecoder_0_1>()->Decode(
80 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); 91 pp_resource(), decode_id, size, buffer, cc.pp_completion_callback());
81 } 92 }
82 return cc.MayForce(PP_ERROR_NOINTERFACE); 93 return cc.MayForce(PP_ERROR_NOINTERFACE);
83 } 94 }
84 95
85 int32_t VideoDecoder::GetPicture( 96 int32_t VideoDecoder::GetPicture(
97 PP_Rect* visible_rect,
86 const CompletionCallbackWithOutput<PP_VideoPicture>& cc) { 98 const CompletionCallbackWithOutput<PP_VideoPicture>& cc) {
99 if (has_interface<PPB_VideoDecoder_0_3>()) {
100 return get_interface<PPB_VideoDecoder_0_3>()->GetPicture(
101 pp_resource(), cc.output(), visible_rect, cc.pp_completion_callback());
102 }
87 if (has_interface<PPB_VideoDecoder_0_2>()) { 103 if (has_interface<PPB_VideoDecoder_0_2>()) {
88 return get_interface<PPB_VideoDecoder_0_2>()->GetPicture( 104 return get_interface<PPB_VideoDecoder_0_2>()->GetPicture(
89 pp_resource(), cc.output(), cc.pp_completion_callback()); 105 pp_resource(), cc.output(), cc.pp_completion_callback());
dmichael (off chromium) 2014/11/05 19:28:08 Is there some reasonable default we can use for vi
bbudge 2014/11/05 22:41:48 Good idea. Done.
90 } 106 }
91 if (has_interface<PPB_VideoDecoder_0_1>()) { 107 if (has_interface<PPB_VideoDecoder_0_1>()) {
92 return get_interface<PPB_VideoDecoder_0_1>()->GetPicture( 108 return get_interface<PPB_VideoDecoder_0_1>()->GetPicture(
93 pp_resource(), cc.output(), cc.pp_completion_callback()); 109 pp_resource(), cc.output(), cc.pp_completion_callback());
94 } 110 }
95 return cc.MayForce(PP_ERROR_NOINTERFACE); 111 return cc.MayForce(PP_ERROR_NOINTERFACE);
96 } 112 }
97 113
98 void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) { 114 void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) {
99 if (has_interface<PPB_VideoDecoder_0_2>()) { 115 if (has_interface<PPB_VideoDecoder_0_3>()) {
116 get_interface<PPB_VideoDecoder_0_3>()->RecyclePicture(pp_resource(),
117 &picture);
118 } else if (has_interface<PPB_VideoDecoder_0_2>()) {
100 get_interface<PPB_VideoDecoder_0_2>()->RecyclePicture(pp_resource(), 119 get_interface<PPB_VideoDecoder_0_2>()->RecyclePicture(pp_resource(),
101 &picture); 120 &picture);
102 } else if (has_interface<PPB_VideoDecoder_0_1>()) { 121 } else if (has_interface<PPB_VideoDecoder_0_1>()) {
103 get_interface<PPB_VideoDecoder_0_1>()->RecyclePicture(pp_resource(), 122 get_interface<PPB_VideoDecoder_0_1>()->RecyclePicture(pp_resource(),
104 &picture); 123 &picture);
105 } 124 }
106 } 125 }
107 126
108 int32_t VideoDecoder::Flush(const CompletionCallback& cc) { 127 int32_t VideoDecoder::Flush(const CompletionCallback& cc) {
128 if (has_interface<PPB_VideoDecoder_0_3>()) {
129 return get_interface<PPB_VideoDecoder_0_3>()->Flush(
130 pp_resource(), cc.pp_completion_callback());
131 }
109 if (has_interface<PPB_VideoDecoder_0_2>()) { 132 if (has_interface<PPB_VideoDecoder_0_2>()) {
110 return get_interface<PPB_VideoDecoder_0_2>()->Flush( 133 return get_interface<PPB_VideoDecoder_0_2>()->Flush(
111 pp_resource(), cc.pp_completion_callback()); 134 pp_resource(), cc.pp_completion_callback());
112 } 135 }
113 if (has_interface<PPB_VideoDecoder_0_1>()) { 136 if (has_interface<PPB_VideoDecoder_0_1>()) {
114 return get_interface<PPB_VideoDecoder_0_1>()->Flush( 137 return get_interface<PPB_VideoDecoder_0_1>()->Flush(
115 pp_resource(), cc.pp_completion_callback()); 138 pp_resource(), cc.pp_completion_callback());
116 } 139 }
117 return cc.MayForce(PP_ERROR_NOINTERFACE); 140 return cc.MayForce(PP_ERROR_NOINTERFACE);
118 } 141 }
119 142
120 int32_t VideoDecoder::Reset(const CompletionCallback& cc) { 143 int32_t VideoDecoder::Reset(const CompletionCallback& cc) {
144 if (has_interface<PPB_VideoDecoder_0_3>()) {
145 return get_interface<PPB_VideoDecoder_0_3>()->Reset(
146 pp_resource(), cc.pp_completion_callback());
147 }
121 if (has_interface<PPB_VideoDecoder_0_2>()) { 148 if (has_interface<PPB_VideoDecoder_0_2>()) {
122 return get_interface<PPB_VideoDecoder_0_2>()->Reset( 149 return get_interface<PPB_VideoDecoder_0_2>()->Reset(
123 pp_resource(), cc.pp_completion_callback()); 150 pp_resource(), cc.pp_completion_callback());
124 } 151 }
125 if (has_interface<PPB_VideoDecoder_0_1>()) { 152 if (has_interface<PPB_VideoDecoder_0_1>()) {
126 return get_interface<PPB_VideoDecoder_0_1>()->Reset( 153 return get_interface<PPB_VideoDecoder_0_1>()->Reset(
127 pp_resource(), cc.pp_completion_callback()); 154 pp_resource(), cc.pp_completion_callback());
128 } 155 }
129 return cc.MayForce(PP_ERROR_NOINTERFACE); 156 return cc.MayForce(PP_ERROR_NOINTERFACE);
130 } 157 }
131 158
132 } // namespace pp 159 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698