Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 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. |
| 4 | */ |
| 5 | |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 6 | /* From ppb_audio_buffer.idl modified Tue Mar 25 18:29:27 2014. */ |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 7 | |
| 8 | #ifndef PPAPI_C_PPB_AUDIO_BUFFER_H_ |
| 9 | #define PPAPI_C_PPB_AUDIO_BUFFER_H_ |
| 10 | |
| 11 | #include "ppapi/c/pp_bool.h" |
| 12 | #include "ppapi/c/pp_macros.h" |
| 13 | #include "ppapi/c/pp_resource.h" |
| 14 | #include "ppapi/c/pp_stdint.h" |
| 15 | #include "ppapi/c/pp_time.h" |
| 16 | |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 17 | #define PPB_AUDIOBUFFER_INTERFACE_0_1 "PPB_AudioBuffer;0.1" |
| 18 | #define PPB_AUDIOBUFFER_INTERFACE PPB_AUDIOBUFFER_INTERFACE_0_1 |
| 19 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 20 | /** |
| 21 | * @file |
| 22 | * Defines the <code>PPB_AudioBuffer</code> interface. |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | /** |
| 27 | * @addtogroup Enums |
| 28 | * @{ |
| 29 | */ |
| 30 | /** |
| 31 | * PP_AudioBuffer_SampleRate is an enumeration of the different audio sample |
| 32 | * rates. |
| 33 | */ |
| 34 | typedef enum { |
| 35 | PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN = 0, |
| 36 | PP_AUDIOBUFFER_SAMPLERATE_8000 = 8000, |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 37 | PP_AUDIOBUFFER_SAMPLERATE_16000 = 16000, |
| 38 | PP_AUDIOBUFFER_SAMPLERATE_22050 = 22050, |
| 39 | PP_AUDIOBUFFER_SAMPLERATE_32000 = 32000, |
| 40 | PP_AUDIOBUFFER_SAMPLERATE_44100 = 44100, |
| 41 | PP_AUDIOBUFFER_SAMPLERATE_48000 = 48000, |
| 42 | PP_AUDIOBUFFER_SAMPLERATE_96000 = 96000, |
| 43 | PP_AUDIOBUFFER_SAMPLERATE_192000 = 192000 |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 44 | } PP_AudioBuffer_SampleRate; |
| 45 | |
| 46 | /** |
| 47 | * PP_AudioBuffer_SampleSize is an enumeration of the different audio sample |
| 48 | * sizes. |
| 49 | */ |
| 50 | typedef enum { |
| 51 | PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN = 0, |
| 52 | PP_AUDIOBUFFER_SAMPLESIZE_16_BITS = 2 |
| 53 | } PP_AudioBuffer_SampleSize; |
| 54 | /** |
| 55 | * @} |
| 56 | */ |
| 57 | |
| 58 | /** |
| 59 | * @addtogroup Interfaces |
| 60 | * @{ |
| 61 | */ |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 62 | struct PPB_AudioBuffer_0_1 { |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 63 | /** |
| 64 | * Determines if a resource is an AudioBuffer resource. |
| 65 | * |
| 66 | * @param[in] resource The <code>PP_Resource</code> to test. |
| 67 | * |
| 68 | * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
| 69 | * resource is an AudioBuffer resource or <code>PP_FALSE</code> otherwise. |
| 70 | */ |
| 71 | PP_Bool (*IsAudioBuffer)(PP_Resource resource); |
| 72 | /** |
| 73 | * Gets the timestamp of the audio buffer. |
| 74 | * |
| 75 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 76 | * buffer resource. |
| 77 | * |
| 78 | * @return A <code>PP_TimeDelta</code> containing the timestamp of the audio |
| 79 | * buffer. Given in seconds since the start of the containing audio stream. |
| 80 | */ |
| 81 | PP_TimeDelta (*GetTimestamp)(PP_Resource buffer); |
| 82 | /** |
| 83 | * Sets the timestamp of the audio buffer. |
| 84 | * |
| 85 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 86 | * buffer resource. |
| 87 | * @param[in] timestamp A <code>PP_TimeDelta</code> containing the timestamp |
| 88 | * of the audio buffer. Given in seconds since the start of the containing |
| 89 | * audio stream. |
| 90 | */ |
| 91 | void (*SetTimestamp)(PP_Resource buffer, PP_TimeDelta timestamp); |
| 92 | /** |
| 93 | * Gets the sample rate of the audio buffer. |
| 94 | * |
| 95 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 96 | * buffer resource. |
| 97 | * |
| 98 | * @return The sample rate of the audio buffer. |
| 99 | */ |
| 100 | PP_AudioBuffer_SampleRate (*GetSampleRate)(PP_Resource buffer); |
| 101 | /** |
| 102 | * Gets the sample size of the audio buffer. |
| 103 | * |
| 104 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 105 | * buffer resource. |
| 106 | * |
| 107 | * @return The sample size of the audio buffer. |
| 108 | */ |
| 109 | PP_AudioBuffer_SampleSize (*GetSampleSize)(PP_Resource buffer); |
| 110 | /** |
| 111 | * Gets the number of channels in the audio buffer. |
| 112 | * |
| 113 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 114 | * buffer resource. |
| 115 | * |
| 116 | * @return The number of channels in the audio buffer. |
| 117 | */ |
| 118 | uint32_t (*GetNumberOfChannels)(PP_Resource buffer); |
| 119 | /** |
| 120 | * Gets the number of samples in the audio buffer. |
| 121 | * |
| 122 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 123 | * buffer resource. |
| 124 | * |
| 125 | * @return The number of samples in the audio buffer. |
| 126 | * For example, at a sampling rate of 44,100 Hz in stereo audio, a buffer |
| 127 | * containing 4410 * 2 samples would have a duration of 100 milliseconds. |
| 128 | */ |
| 129 | uint32_t (*GetNumberOfSamples)(PP_Resource buffer); |
| 130 | /** |
| 131 | * Gets the data buffer containing the audio samples. |
| 132 | * |
| 133 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 134 | * buffer resource. |
| 135 | * |
| 136 | * @return A pointer to the beginning of the data buffer. |
| 137 | */ |
| 138 | void* (*GetDataBuffer)(PP_Resource buffer); |
| 139 | /** |
| 140 | * Gets the size of the data buffer in bytes. |
| 141 | * |
| 142 | * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio |
| 143 | * buffer resource. |
| 144 | * |
| 145 | * @return The size of the data buffer in bytes. |
| 146 | */ |
| 147 | uint32_t (*GetDataBufferSize)(PP_Resource buffer); |
| 148 | }; |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 149 | |
| 150 | typedef struct PPB_AudioBuffer_0_1 PPB_AudioBuffer; |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 151 | /** |
| 152 | * @} |
| 153 | */ |
| 154 | |
| 155 | #endif /* PPAPI_C_PPB_AUDIO_BUFFER_H_ */ |
| 156 | |