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

Side by Side 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: Created 5 years, 7 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 // From ppb_audio_encoder.idl modified Thu May 21 15:56:53 2015.
6
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"
14
15 namespace ppapi {
16 namespace thunk {
17
18 namespace {
19
20 PP_Resource Create(PP_Instance instance) {
21 VLOG(4) << "PPB_AudioEncoder::Create()";
22 EnterResourceCreation enter(instance);
23 if (enter.failed())
24 return 0;
25 return enter.functions()->CreateAudioEncoder(instance);
26 }
27
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());
32 }
33
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);
39 if (enter.failed())
40 return enter.retval();
41 return enter.SetResult(
42 enter.object()->GetSupportedProfiles(output, enter.callback()));
43 }
44
45 int32_t Initialize(PP_Resource audio_encoder,
46 uint32_t channels,
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);
55 if (enter.failed())
56 return enter.retval();
57 return enter.SetResult(enter.object()->Initialize(
58 channels, input_sample_rate, input_sample_size, output_profile,
59 initial_bitrate, acceleration, enter.callback()));
60 }
61
62 int32_t GetNumberOfSamples(PP_Resource audio_encoder) {
63 VLOG(4) << "PPB_AudioEncoder::GetNumberOfSamples()";
64 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
65 if (enter.failed())
66 return enter.retval();
67 return enter.object()->GetNumberOfSamples();
68 }
69
70 int32_t GetBuffer(PP_Resource audio_encoder,
71 PP_Resource* audio_buffer,
72 struct PP_CompletionCallback callback) {
73 VLOG(4) << "PPB_AudioEncoder::GetBuffer()";
74 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
75 if (enter.failed())
76 return enter.retval();
77 return enter.SetResult(
78 enter.object()->GetBuffer(audio_buffer, enter.callback()));
79 }
80
81 int32_t Encode(PP_Resource audio_encoder,
82 PP_Resource audio_buffer,
83 struct PP_CompletionCallback callback) {
84 VLOG(4) << "PPB_AudioEncoder::Encode()";
85 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
86 if (enter.failed())
87 return enter.retval();
88 return enter.SetResult(
89 enter.object()->Encode(audio_buffer, enter.callback()));
90 }
91
92 int32_t GetBitstreamBuffer(PP_Resource audio_encoder,
93 struct PP_AudioBitstreamBuffer* bitstream_buffer,
94 struct PP_CompletionCallback callback) {
95 VLOG(4) << "PPB_AudioEncoder::GetBitstreamBuffer()";
96 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, callback, true);
97 if (enter.failed())
98 return enter.retval();
99 return enter.SetResult(
100 enter.object()->GetBitstreamBuffer(bitstream_buffer, enter.callback()));
101 }
102
103 void RecycleBitstreamBuffer(
104 PP_Resource audio_encoder,
105 const struct PP_AudioBitstreamBuffer* bitstream_buffer) {
106 VLOG(4) << "PPB_AudioEncoder::RecycleBitstreamBuffer()";
107 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
108 if (enter.failed())
109 return;
110 enter.object()->RecycleBitstreamBuffer(bitstream_buffer);
111 }
112
113 void RequestBitrateChange(PP_Resource audio_encoder, uint32_t bitrate) {
114 VLOG(4) << "PPB_AudioEncoder::RequestBitrateChange()";
115 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
116 if (enter.failed())
117 return;
118 enter.object()->RequestBitrateChange(bitrate);
119 }
120
121 void Close(PP_Resource audio_encoder) {
122 VLOG(4) << "PPB_AudioEncoder::Close()";
123 EnterResource<PPB_AudioEncoder_API> enter(audio_encoder, true);
124 if (enter.failed())
125 return;
126 enter.object()->Close();
127 }
128
129 const PPB_AudioEncoder_0_1 g_ppb_audioencoder_thunk_0_1 = {
130 &Create,
131 &IsAudioEncoder,
132 &GetSupportedProfiles,
133 &Initialize,
134 &GetNumberOfSamples,
135 &GetBuffer,
136 &Encode,
137 &GetBitstreamBuffer,
138 &RecycleBitstreamBuffer,
139 &RequestBitrateChange,
140 &Close};
141
142 } // namespace
143
144 PPAPI_THUNK_EXPORT const PPB_AudioEncoder_0_1* GetPPB_AudioEncoder_0_1_Thunk() {
145 return &g_ppb_audioencoder_thunk_0_1;
146 }
147
148 } // namespace thunk
149 } // namespace ppapi
OLDNEW
« 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