Roll Syzygy deps to 0.8.6.4.
[chromium-blink-merge.git] / ppapi / thunk / ppb_video_encoder_thunk.cc
blobb6981e55ecaf21172a12b32534078c8b8e11aa30
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 Thu Feb 5 10:33:32 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(PP_Resource video_encoder,
35 struct PP_ArrayOutput output,
36 struct PP_CompletionCallback callback) {
37 VLOG(4) << "PPB_VideoEncoder::GetSupportedProfiles()";
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()->GetSupportedProfiles(output, enter.callback()));
45 int32_t Initialize(PP_Resource video_encoder,
46 PP_VideoFrame_Format input_format,
47 const struct PP_Size* input_visible_size,
48 PP_VideoProfile output_profile,
49 uint32_t initial_bitrate,
50 PP_HardwareAcceleration acceleration,
51 struct PP_CompletionCallback callback) {
52 VLOG(4) << "PPB_VideoEncoder::Initialize()";
53 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
54 if (enter.failed())
55 return enter.retval();
56 return enter.SetResult(enter.object()->Initialize(
57 input_format, input_visible_size, output_profile, initial_bitrate,
58 acceleration, enter.callback()));
61 int32_t GetFramesRequired(PP_Resource video_encoder) {
62 VLOG(4) << "PPB_VideoEncoder::GetFramesRequired()";
63 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
64 if (enter.failed())
65 return enter.retval();
66 return enter.object()->GetFramesRequired();
69 int32_t GetFrameCodedSize(PP_Resource video_encoder,
70 struct PP_Size* coded_size) {
71 VLOG(4) << "PPB_VideoEncoder::GetFrameCodedSize()";
72 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
73 if (enter.failed())
74 return enter.retval();
75 return enter.object()->GetFrameCodedSize(coded_size);
78 int32_t GetVideoFrame(PP_Resource video_encoder,
79 PP_Resource* video_frame,
80 struct PP_CompletionCallback callback) {
81 VLOG(4) << "PPB_VideoEncoder::GetVideoFrame()";
82 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
83 if (enter.failed())
84 return enter.retval();
85 return enter.SetResult(
86 enter.object()->GetVideoFrame(video_frame, enter.callback()));
89 int32_t Encode(PP_Resource video_encoder,
90 PP_Resource video_frame,
91 PP_Bool force_keyframe,
92 struct PP_CompletionCallback callback) {
93 VLOG(4) << "PPB_VideoEncoder::Encode()";
94 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, callback, true);
95 if (enter.failed())
96 return enter.retval();
97 return enter.SetResult(
98 enter.object()->Encode(video_frame, force_keyframe, enter.callback()));
101 int32_t GetBitstreamBuffer(PP_Resource video_encoder,
102 struct PP_BitstreamBuffer* bitstream_buffer,
103 struct PP_CompletionCallback callback) {
104 VLOG(4) << "PPB_VideoEncoder::GetBitstreamBuffer()";
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()->GetBitstreamBuffer(bitstream_buffer, enter.callback()));
112 void RecycleBitstreamBuffer(PP_Resource video_encoder,
113 const struct PP_BitstreamBuffer* bitstream_buffer) {
114 VLOG(4) << "PPB_VideoEncoder::RecycleBitstreamBuffer()";
115 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
116 if (enter.failed())
117 return;
118 enter.object()->RecycleBitstreamBuffer(bitstream_buffer);
121 void RequestEncodingParametersChange(PP_Resource video_encoder,
122 uint32_t bitrate,
123 uint32_t framerate) {
124 VLOG(4) << "PPB_VideoEncoder::RequestEncodingParametersChange()";
125 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
126 if (enter.failed())
127 return;
128 enter.object()->RequestEncodingParametersChange(bitrate, framerate);
131 void Close(PP_Resource video_encoder) {
132 VLOG(4) << "PPB_VideoEncoder::Close()";
133 EnterResource<PPB_VideoEncoder_API> enter(video_encoder, true);
134 if (enter.failed())
135 return;
136 enter.object()->Close();
139 const PPB_VideoEncoder_0_1 g_ppb_videoencoder_thunk_0_1 = {
140 &Create,
141 &IsVideoEncoder,
142 &GetSupportedProfiles,
143 &Initialize,
144 &GetFramesRequired,
145 &GetFrameCodedSize,
146 &GetVideoFrame,
147 &Encode,
148 &GetBitstreamBuffer,
149 &RecycleBitstreamBuffer,
150 &RequestEncodingParametersChange,
151 &Close};
153 } // namespace
155 PPAPI_THUNK_EXPORT const PPB_VideoEncoder_0_1* GetPPB_VideoEncoder_0_1_Thunk() {
156 return &g_ppb_videoencoder_thunk_0_1;
159 } // namespace thunk
160 } // namespace ppapi