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"
20 PP_Resource
Create(PP_Instance instance
) {
21 VLOG(4) << "PPB_VideoEncoder::Create()";
22 EnterResourceCreation
enter(instance
);
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);
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);
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);
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);
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);
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);
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);
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);
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);
129 enter
.object()->RecycleBitstreamBuffer(bitstream_buffer
);
132 void RequestEncodingParametersChange(PP_Resource video_encoder
,
134 uint32_t framerate
) {
135 VLOG(4) << "PPB_VideoEncoder::RequestEncodingParametersChange()";
136 EnterResource
<PPB_VideoEncoder_API
> enter(video_encoder
, true);
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);
147 enter
.object()->Close();
150 const PPB_VideoEncoder_0_1 g_ppb_videoencoder_thunk_0_1
= {
153 &GetSupportedProfiles_0_1
,
160 &RecycleBitstreamBuffer
,
161 &RequestEncodingParametersChange
,
164 const PPB_VideoEncoder_0_2 g_ppb_videoencoder_thunk_0_2
= {
167 &GetSupportedProfiles
,
174 &RecycleBitstreamBuffer
,
175 &RequestEncodingParametersChange
,
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
;