1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// From ppb_audio_encoder.idl modified Wed Jan 27 17:39:22 2016.
#include <stdint.h>
#include "base/logging.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_audio_encoder.h"
#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppapi_thunk_export.h"
#include "ppapi/thunk/ppb_audio_encoder_api.h"
namespace ppapi {
namespace thunk {
namespace {
PP_Resource Create(PP_Instance instance) {
VLOG(4) << "PPB_AudioEncoder::Create()";
EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
return enter.functions()->CreateAudioEncoder(instance);
}
PP_Bool IsAudioEncoder(PP_Resource resource) {
VLOG(4) << "PPB_AudioEncoder::IsAudioEncoder()";
EnterResource<PPB_AudioEncoder_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
}
int32_t GetSupportedProfiles(PP_Resource audio_encoder,
struct PP_ArrayOutput output,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_AudioEncoder::GetSupportedProfiles()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(
enter.object()->GetSupportedProfiles(output, enter.callback()));
}
int32_t Initialize(PP_Resource audio_encoder,
uint32_t channels,
PP_AudioBuffer_SampleRate input_sample_rate,
PP_AudioBuffer_SampleSize input_sample_size,
PP_AudioProfile output_profile,
uint32_t initial_bitrate,
PP_HardwareAcceleration acceleration,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_AudioEncoder::Initialize()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(enter.object()->Initialize(
channels, input_sample_rate, input_sample_size, output_profile,
initial_bitrate, acceleration, enter.callback()));
}
int32_t GetNumberOfSamples(PP_Resource audio_encoder) {
VLOG(4) << "PPB_AudioEncoder::GetNumberOfSamples()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
if (enter.failed())
return enter.retval();
return enter.object()->GetNumberOfSamples();
}
int32_t GetBuffer(PP_Resource audio_encoder,
PP_Resource* audio_buffer,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_AudioEncoder::GetBuffer()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(
enter.object()->GetBuffer(audio_buffer, enter.callback()));
}
int32_t Encode(PP_Resource audio_encoder,
PP_Resource audio_buffer,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_AudioEncoder::Encode()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(
enter.object()->Encode(audio_buffer, enter.callback()));
}
int32_t GetBitstreamBuffer(PP_Resource audio_encoder,
struct PP_AudioBitstreamBuffer* bitstream_buffer,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_AudioEncoder::GetBitstreamBuffer()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
if (enter.failed())
return enter.retval();
return enter.SetResult(
enter.object()->GetBitstreamBuffer(bitstream_buffer, enter.callback()));
}
void RecycleBitstreamBuffer(
PP_Resource audio_encoder,
const struct PP_AudioBitstreamBuffer* bitstream_buffer) {
VLOG(4) << "PPB_AudioEncoder::RecycleBitstreamBuffer()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
if (enter.failed())
return;
enter.object()->RecycleBitstreamBuffer(bitstream_buffer);
}
void RequestBitrateChange(PP_Resource audio_encoder, uint32_t bitrate) {
VLOG(4) << "PPB_AudioEncoder::RequestBitrateChange()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
if (enter.failed())
return;
enter.object()->RequestBitrateChange(bitrate);
}
void Close(PP_Resource audio_encoder) {
VLOG(4) << "PPB_AudioEncoder::Close()";
EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
if (enter.failed())
return;
enter.object()->Close();
}
const PPB_AudioEncoder_0_1 g_ppb_audioencoder_thunk_0_1 = {
&Create,
&IsAudioEncoder,
&GetSupportedProfiles,
&Initialize,
&GetNumberOfSamples,
&GetBuffer,
&Encode,
&GetBitstreamBuffer,
&RecycleBitstreamBuffer,
&RequestBitrateChange,
&Close};
} // namespace
PPAPI_THUNK_EXPORT const PPB_AudioEncoder_0_1* GetPPB_AudioEncoder_0_1_Thunk() {
return &g_ppb_audioencoder_thunk_0_1;
}
} // namespace thunk
} // namespace ppapi
|