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_audio_encoder.idl modified Mon Sep 7 10:17:53 2015.
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_audio_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_audio_encoder_api.h"
20 PP_Resource
Create(PP_Instance instance
) {
21 VLOG(4) << "PPB_AudioEncoder::Create()";
22 EnterResourceCreation
enter(instance
);
25 return enter
.functions()->CreateAudioEncoder(instance
);
28 PP_Bool
IsAudioEncoder(PP_Resource resource
) {
29 VLOG(4) << "PPB_AudioEncoder::IsAudioEncoder()";
30 EnterResource
<PPB_AudioEncoder_API
> enter(resource
, false);
31 return PP_FromBool(enter
.succeeded());
34 int32_t GetSupportedProfiles(PP_Resource audio_encoder
,
35 struct PP_ArrayOutput output
,
36 struct PP_CompletionCallback callback
) {
37 VLOG(4) << "PPB_AudioEncoder::GetSupportedProfiles()";
38 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, callback
, true);
40 return enter
.retval();
41 return enter
.SetResult(
42 enter
.object()->GetSupportedProfiles(output
, enter
.callback()));
45 int32_t Initialize(PP_Resource audio_encoder
,
47 PP_AudioBuffer_SampleRate input_sample_rate
,
48 PP_AudioBuffer_SampleSize input_sample_size
,
49 PP_AudioProfile output_profile
,
50 uint32_t initial_bitrate
,
51 PP_HardwareAcceleration acceleration
,
52 struct PP_CompletionCallback callback
) {
53 VLOG(4) << "PPB_AudioEncoder::Initialize()";
54 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, callback
, true);
56 return enter
.retval();
57 return enter
.SetResult(enter
.object()->Initialize(channels
,
66 int32_t GetNumberOfSamples(PP_Resource audio_encoder
) {
67 VLOG(4) << "PPB_AudioEncoder::GetNumberOfSamples()";
68 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, true);
70 return enter
.retval();
71 return enter
.object()->GetNumberOfSamples();
74 int32_t GetBuffer(PP_Resource audio_encoder
,
75 PP_Resource
* audio_buffer
,
76 struct PP_CompletionCallback callback
) {
77 VLOG(4) << "PPB_AudioEncoder::GetBuffer()";
78 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, callback
, true);
80 return enter
.retval();
81 return enter
.SetResult(
82 enter
.object()->GetBuffer(audio_buffer
, enter
.callback()));
85 int32_t Encode(PP_Resource audio_encoder
,
86 PP_Resource audio_buffer
,
87 struct PP_CompletionCallback callback
) {
88 VLOG(4) << "PPB_AudioEncoder::Encode()";
89 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, callback
, true);
91 return enter
.retval();
92 return enter
.SetResult(
93 enter
.object()->Encode(audio_buffer
, enter
.callback()));
96 int32_t GetBitstreamBuffer(PP_Resource audio_encoder
,
97 struct PP_AudioBitstreamBuffer
* bitstream_buffer
,
98 struct PP_CompletionCallback callback
) {
99 VLOG(4) << "PPB_AudioEncoder::GetBitstreamBuffer()";
100 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, callback
, true);
102 return enter
.retval();
103 return enter
.SetResult(
104 enter
.object()->GetBitstreamBuffer(bitstream_buffer
, enter
.callback()));
107 void RecycleBitstreamBuffer(
108 PP_Resource audio_encoder
,
109 const struct PP_AudioBitstreamBuffer
* bitstream_buffer
) {
110 VLOG(4) << "PPB_AudioEncoder::RecycleBitstreamBuffer()";
111 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, true);
114 enter
.object()->RecycleBitstreamBuffer(bitstream_buffer
);
117 void RequestBitrateChange(PP_Resource audio_encoder
, uint32_t bitrate
) {
118 VLOG(4) << "PPB_AudioEncoder::RequestBitrateChange()";
119 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, true);
122 enter
.object()->RequestBitrateChange(bitrate
);
125 void Close(PP_Resource audio_encoder
) {
126 VLOG(4) << "PPB_AudioEncoder::Close()";
127 EnterResource
<PPB_AudioEncoder_API
> enter(audio_encoder
, true);
130 enter
.object()->Close();
133 const PPB_AudioEncoder_0_1 g_ppb_audioencoder_thunk_0_1
= {
136 &GetSupportedProfiles
,
142 &RecycleBitstreamBuffer
,
143 &RequestBitrateChange
,
148 PPAPI_THUNK_EXPORT
const PPB_AudioEncoder_0_1
* GetPPB_AudioEncoder_0_1_Thunk() {
149 return &g_ppb_audioencoder_thunk_0_1
;