Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Unified Diff: ppapi/thunk/ppb_audio_encoder_thunk.cc

Issue 1151973003: ppapi: implement PPB_AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Windows fixes in proxy code Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/thunk/ppb_audio_encoder_api.h ('k') | ppapi/thunk/resource_creation_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/thunk/ppb_audio_encoder_thunk.cc
diff --git a/ppapi/thunk/ppb_audio_encoder_thunk.cc b/ppapi/thunk/ppb_audio_encoder_thunk.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d935ffdaeb4ee5f25b82070c4f2ff90399a361bd
--- /dev/null
+++ b/ppapi/thunk/ppb_audio_encoder_thunk.cc
@@ -0,0 +1,153 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// 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 Mon Jun 1 10:58:40 2015.
+
+#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
« no previous file with comments | « ppapi/thunk/ppb_audio_encoder_api.h ('k') | ppapi/thunk/resource_creation_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698