1 /* Copyright 2014 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.
7 * Defines the <code>PPB_AudioBuffer</code> interface.
13 [channel=dev] M34 = 0.1
17 * PP_AudioBuffer_SampleRate is an enumeration of the different audio sample
20 enum PP_AudioBuffer_SampleRate {
21 PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN = 0,
22 PP_AUDIOBUFFER_SAMPLERATE_8000 = 8000,
23 PP_AUDIOBUFFER_SAMPLERATE_44100 = 44100
27 * PP_AudioBuffer_SampleSize is an enumeration of the different audio sample
30 enum PP_AudioBuffer_SampleSize {
31 PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN = 0,
32 PP_AUDIOBUFFER_SAMPLESIZE_16_BITS = 2
35 interface PPB_AudioBuffer {
37 * Determines if a resource is an AudioBuffer resource.
39 * @param[in] resource The <code>PP_Resource</code> to test.
41 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
42 * resource is an AudioBuffer resource or <code>PP_FALSE</code> otherwise.
44 PP_Bool IsAudioBuffer([in] PP_Resource resource);
47 * Gets the timestamp of the audio buffer.
49 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
52 * @return A <code>PP_TimeDelta</code> containing the timestamp of the audio
53 * buffer. Given in seconds since the start of the containing audio stream.
56 PP_TimeDelta GetTimestamp([in] PP_Resource buffer);
59 * Sets the timestamp of the audio buffer.
61 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
63 * @param[in] timestamp A <code>PP_TimeDelta</code> containing the timestamp
64 * of the audio buffer. Given in seconds since the start of the containing
67 void SetTimestamp([in] PP_Resource buffer, [in] PP_TimeDelta timestamp);
70 * Gets the sample rate of the audio buffer.
72 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
75 * @return The sample rate of the audio buffer.
77 [on_failure=PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN]
78 PP_AudioBuffer_SampleRate GetSampleRate([in] PP_Resource buffer);
81 * Gets the sample size of the audio buffer.
83 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
86 * @return The sample size of the audio buffer.
88 [on_failure=PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN]
89 PP_AudioBuffer_SampleSize GetSampleSize([in] PP_Resource buffer);
92 * Gets the number of channels in the audio buffer.
94 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
97 * @return The number of channels in the audio buffer.
99 uint32_t GetNumberOfChannels([in] PP_Resource buffer);
102 * Gets the number of samples in the audio buffer.
104 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
107 * @return The number of samples in the audio buffer.
108 * For example, at a sampling rate of 44,100 Hz in stereo audio, a buffer
109 * containing 4410 * 2 samples would have a duration of 100 milliseconds.
111 uint32_t GetNumberOfSamples([in] PP_Resource buffer);
114 * Gets the data buffer containing the audio samples.
116 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
119 * @return A pointer to the beginning of the data buffer.
121 mem_t GetDataBuffer([in] PP_Resource buffer);
124 * Gets the size of the data buffer in bytes.
126 * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
129 * @return The size of the data buffer in bytes.
131 uint32_t GetDataBufferSize([in] PP_Resource buffer);