Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / thunk / ppb_video_encoder_thunk.cc
bloba53f2694d45f4f406331874b7f81d1ad11ae4f31
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // From ppb_video_encoder.idl modified Mon May 18 12:43:25 2015.
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_video_encoder.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppapi_thunk_export.h"
13 #include "ppapi/thunk/ppb_video_encoder_api.h"
15 namespace ppapi {
16 namespace thunk {
18 namespace {
20 PP_Resource Create(PP_Instance instance) {
21 VLOG(4) << "PPB_VideoEncoder::Create()";
22 EnterResourceCreation enter(instance);
23 if (enter.failed())
24 return 0;
25 return enter.functions()->CreateVideoEncoder(instance);
28 PP_Bool IsVideoEncoder(PP_Resource resource) {
29 VLOG(4) << "PPB_VideoEncoder::IsVideoEncoder()";
30 EnterResource<PPB_VideoEncoder_API> enter(resource, false);
31 return PP_FromBool(enter.succeeded());
34 int32_t GetSupportedProfiles_0_1(PP_Resource video_encoder,
35 struct PP_ArrayOutput output,
36 struct PP_CompletionCallback callback) {
37 VLOG(4) << "PPB_VideoEncoder::GetSupportedProfiles_0_1()";
38 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
39 if (enter.failed())
40 return enter.retval();
41 return enter.SetResult(
42 enter.object()->GetSupportedProfiles0_1(output, enter.callback()));
45 int32_t GetSupportedProfiles(PP_Resource video_encoder,
46 struct PP_ArrayOutput output,
47 struct PP_CompletionCallback callback) {
48 VLOG(4) << "PPB_VideoEncoder::GetSupportedProfiles()";
49 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
50 if (enter.failed())
51 return enter.retval();
52 return enter.SetResult(
53 enter.object()->GetSupportedProfiles(output, enter.callback()));
56 int32_t Initialize(PP_Resource video_encoder,
57 PP_VideoFrame_Format input_format,
58 const struct PP_Size* input_visible_size,
59 PP_VideoProfile output_profile,
60 uint32_t initial_bitrate,
61 PP_HardwareAcceleration acceleration,
62 struct PP_CompletionCallback callback) {
63 VLOG(4) << "PPB_VideoEncoder::Initialize()";
64 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
65 if (enter.failed())
66 return enter.retval();
67 return enter.SetResult(enter.object()->Initialize(
68 input_format, input_visible_size, output_profile, initial_bitrate,
69 acceleration, enter.callback()));
72 int32_t GetFramesRequired(PP_Resource video_encoder) {
73 VLOG(4) << "PPB_VideoEncoder::GetFramesRequired()";
74 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
75 if (enter.failed())
76 return enter.retval();
77 return enter.object()->GetFramesRequired();
80 int32_t GetFrameCodedSize(PP_Resource video_encoder,
81 struct PP_Size* coded_size) {
82 VLOG(4) << "PPB_VideoEncoder::GetFrameCodedSize()";
83 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
84 if (enter.failed())
85 return enter.retval();
86 return enter.object()->GetFrameCodedSize(coded_size);
89 int32_t GetVideoFrame(PP_Resource video_encoder,
90 PP_Resource* video_frame,
91 struct PP_CompletionCallback callback) {
92 VLOG(4) << "PPB_VideoEncoder::GetVideoFrame()";
93 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
94 if (enter.failed())
95 return enter.retval();
96 return enter.SetResult(
97 enter.object()->GetVideoFrame(video_frame, enter.callback()));
100 int32_t Encode(PP_Resource video_encoder,
101 PP_Resource video_frame,
102 PP_Bool force_keyframe,
103 struct PP_CompletionCallback callback) {
104 VLOG(4) << "PPB_VideoEncoder::Encode()";
105 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
106 if (enter.failed())
107 return enter.retval();
108 return enter.SetResult(
109 enter.object()->Encode(video_frame, force_keyframe, enter.callback()));
112 int32_t GetBitstreamBuffer(PP_Resource video_encoder,
113 struct PP_BitstreamBuffer* bitstream_buffer,
114 struct PP_CompletionCallback callback) {
115 VLOG(4) << "PPB_VideoEncoder::GetBitstreamBuffer()";
116 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
117 if (enter.failed())
118 return enter.retval();
119 return enter.SetResult(
120 enter.object()->GetBitstreamBuffer(bitstream_buffer, enter.callback()));
123 void RecycleBitstreamBuffer(PP_Resource video_encoder,
124 const struct PP_BitstreamBuffer* bitstream_buffer) {
125 VLOG(4) << "PPB_VideoEncoder::RecycleBitstreamBuffer()";
126 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
127 if (enter.failed())
128 return;
129 enter.object()->RecycleBitstreamBuffer(bitstream_buffer);
132 void RequestEncodingParametersChange(PP_Resource video_encoder,
133 uint32_t bitrate,
134 uint32_t framerate) {
135 VLOG(4) << "PPB_VideoEncoder::RequestEncodingParametersChange()";
136 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
137 if (enter.failed())
138 return;
139 enter.object()->RequestEncodingParametersChange(bitrate, framerate);
142 void Close(PP_Resource video_encoder) {
143 VLOG(4) << "PPB_VideoEncoder::Close()";
144 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
145 if (enter.failed())
146 return;
147 enter.object()->Close();
150 const PPB_VideoEncoder_0_1 g_ppb_videoencoder_thunk_0_1 = {
151 &Create,
152 &IsVideoEncoder,
153 &GetSupportedProfiles_0_1,
154 &Initialize,
155 &GetFramesRequired,
156 &GetFrameCodedSize,
157 &GetVideoFrame,
158 &Encode,
159 &GetBitstreamBuffer,
160 &RecycleBitstreamBuffer,
161 &RequestEncodingParametersChange,
162 &Close};
164 const PPB_VideoEncoder_0_2 g_ppb_videoencoder_thunk_0_2 = {
165 &Create,
166 &IsVideoEncoder,
167 &GetSupportedProfiles,
168 &Initialize,
169 &GetFramesRequired,
170 &GetFrameCodedSize,
171 &GetVideoFrame,
172 &Encode,
173 &GetBitstreamBuffer,
174 &RecycleBitstreamBuffer,
175 &RequestEncodingParametersChange,
176 &Close};
178 } // namespace
180 PPAPI_THUNK_EXPORT const PPB_VideoEncoder_0_1* GetPPB_VideoEncoder_0_1_Thunk() {
181 return &g_ppb_videoencoder_thunk_0_1;
184 PPAPI_THUNK_EXPORT const PPB_VideoEncoder_0_2* GetPPB_VideoEncoder_0_2_Thunk() {
185 return &g_ppb_videoencoder_thunk_0_2;
188 } // namespace thunk
189 } // namespace ppapi