Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * This file defines the <code>PPB_AudioInput_Dev</code> interface, which | 7 * This file defines the <code>PPB_AudioInput_Dev</code> interface, which |
| 8 * provides realtime audio input capture. | 8 * provides realtime audio input capture. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 label Chrome { | 11 label Chrome { |
| 12 M17 = 0.1 | 12 M17 = 0.1, |
| 13 M19 = 0.2 | |
| 13 }; | 14 }; |
| 14 | 15 |
| 15 /** | 16 /** |
| 16 * <code>PPB_AudioInput_Callback</code> defines the type of an audio callback | 17 * <code>PPB_AudioInput_Callback</code> defines the type of an audio callback |
| 17 * function used to provide the audio buffer with data. This callback will be | 18 * function used to provide the audio buffer with data. This callback will be |
| 18 * called on a separate thread from the creation thread. | 19 * called on a separate thread from the creation thread. |
| 19 */ | 20 */ |
| 20 typedef void PPB_AudioInput_Callback([in] mem_t sample_buffer, | 21 typedef void PPB_AudioInput_Callback([in] mem_t sample_buffer, |
| 21 [in] uint32_t buffer_size_in_bytes, | 22 [in] uint32_t buffer_size_in_bytes, |
| 22 [inout] mem_t user_data); | 23 [inout] mem_t user_data); |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * The <code>PPB_AudioInput_Dev</code> interface contains pointers to several | 26 * The <code>PPB_AudioInput_Dev</code> interface contains pointers to several |
| 26 * functions for handling audio input resources. | 27 * functions for handling audio input resources. |
| 27 */ | 28 */ |
| 28 [version=0.1, macro="PPB_AUDIO_INPUT_DEV_INTERFACE"] | 29 [macro="PPB_AUDIO_INPUT_DEV_INTERFACE"] |
| 29 interface PPB_AudioInput_Dev { | 30 interface PPB_AudioInput_Dev { |
| 30 /** | 31 [version=0.1] |
| 31 * Create is a pointer to a function that creates an audio input resource. | |
| 32 * No sound will be captured until StartCapture() is called. | |
| 33 */ | |
| 34 PP_Resource Create( | 32 PP_Resource Create( |
| 35 [in] PP_Instance instance, | 33 [in] PP_Instance instance, |
| 36 [in] PP_Resource config, | 34 [in] PP_Resource config, |
| 37 [in] PPB_AudioInput_Callback audio_input_callback, | 35 [in] PPB_AudioInput_Callback audio_input_callback, |
| 38 [inout] mem_t user_data); | 36 [inout] mem_t user_data); |
| 39 | 37 |
| 40 /** | 38 /** |
| 39 * Creates an audio input resource. | |
| 40 * | |
| 41 * @param[in] instance A <code>PP_Instance</code> identifying one instance of | |
| 42 * a module. | |
| 43 * | |
| 44 * @return A <code>PP_Resource</code> corresponding to an audio input resource | |
| 45 * if successful, 0 if failed. | |
| 46 */ | |
| 47 [version=0.2] | |
| 48 PP_Resource Create( | |
| 49 [in] PP_Instance instance); | |
| 50 | |
| 51 /** | |
| 41 * IsAudioInput is a pointer to a function that determines if the given | 52 * IsAudioInput is a pointer to a function that determines if the given |
| 42 * resource is an audio input resource. | 53 * resource is an audio input resource. |
| 43 * | 54 * |
| 44 * @param[in] resource A PP_Resource containing a resource. | 55 * @param[in] resource A <code>PP_Resource</code> containing a resource. |
| 45 * | 56 * |
| 46 * @return A PP_BOOL containing containing PP_TRUE if the given resource is | 57 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if the given |
| 47 * an audio input resource, otherwise PP_FALSE. | 58 * resource is an audio input resource, otherwise <code>PP_FALSE</code>. |
| 48 */ | 59 */ |
| 49 PP_Bool IsAudioInput( | 60 PP_Bool IsAudioInput( |
| 50 [in] PP_Resource audio_input); | 61 [in] PP_Resource resource); |
| 62 | |
| 63 /** | |
| 64 * Enumerates audio input devices. | |
| 65 * | |
| 66 * Please note that: | |
| 67 * - this method ignores the previous value pointed to by <code>devices</code> | |
| 68 * (won't release reference even if it is not 0); | |
| 69 * - <code>devices</code> must be valid until <code>callback</code> is called, | |
| 70 * if the method returns <code>PP_OK_COMPLETIONPENDING</code>; | |
| 71 * - the ref count of the returned <code>devices</code> has already been | |
| 72 * increased by 1 for the caller. | |
| 73 * | |
| 74 * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio | |
| 75 * input resource. | |
| 76 * @param[out] devices Once the operation is completed successfully, | |
| 77 * <code>devices</code> will be set to a <code>PPB_ResourceArray_Dev</code> | |
| 78 * resource, which holds a list of <code>PPB_DeviceRef_Dev</code> resources. | |
| 79 * @param[in] callback A <code>PP_CompletionCallback</code> to run on | |
| 80 * completion. | |
| 81 * | |
| 82 * @return An error code from <code>pp_errors.h</code>. | |
| 83 */ | |
| 84 [version=0.2] | |
| 85 int32_t EnumerateDevices( | |
| 86 [in] PP_Resource audio_input, | |
| 87 [out] PP_Resource devices, | |
| 88 [in] PP_CompletionCallback callback); | |
| 89 | |
| 90 /** | |
| 91 * Opens an audio input device. No sound will be captured until | |
| 92 * StartCapture() is called. | |
| 93 * | |
| 94 * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio | |
| 95 * input resource. | |
| 96 * @param[in] device_ref Identifies an audio input device. It could be one of | |
| 97 * the resource in the array returned by EnumerateDevices(), or 0 which means | |
| 98 * the default device. | |
| 99 * @param[in] config A <code>PPB_AudioConfig</code> audio configuration | |
| 100 * resource. | |
| 101 * @param[in] audio_input_callback A <code>PPB_AudioInput_Callback</code> | |
| 102 * function that will be called when data is available. | |
| 103 * @param[inout] user_data An opaque pointer that will be passed into | |
| 104 * <code>audio_input_callback</code>. | |
| 105 * @param[in] callback A <code>PP_CompletionCallback</code> to run when this | |
| 106 * open operation is completed. | |
| 107 * | |
| 108 * @return An error code from <code>pp_errors.h</code>. | |
| 109 */ | |
| 110 [version=0.2] | |
| 111 int32_t Open( | |
| 112 [in] PP_Resource audio_input, | |
| 113 [in] PP_Resource device_ref, | |
| 114 [in] PP_Resource config, | |
| 115 [in] PPB_AudioInput_Callback audio_input_callback, | |
| 116 [inout] mem_t user_data, | |
| 117 [in] PP_CompletionCallback callback); | |
| 51 | 118 |
| 52 /** | 119 /** |
| 53 * GetCurrrentConfig() returns an audio config resource for the given audio | 120 * GetCurrrentConfig() returns an audio config resource for the given audio |
| 54 * resource. | 121 * input resource. |
| 55 * | 122 * |
| 56 * @param[in] config A <code>PP_Resource</code> corresponding to an audio | 123 * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio |
| 57 * resource. | 124 * input resource. |
| 58 * | 125 * |
| 59 * @return A <code>PP_Resource</code> containing the audio config resource if | 126 * @return A <code>PP_Resource</code> containing the audio config resource if |
| 60 * successful. | 127 * successful. |
| 61 */ | 128 */ |
| 62 PP_Resource GetCurrentConfig( | 129 PP_Resource GetCurrentConfig( |
| 63 [in] PP_Resource audio_input); | 130 [in] PP_Resource audio_input); |
| 64 | 131 |
| 65 /** | 132 /** |
| 66 * StartCapture() starts the capture of the audio input resource and begins | 133 * StartCapture() starts the capture of the audio input resource and begins |
|
brettw
2012/03/02 19:13:41
Can both start & stop note that they return true i
yzshen1
2012/03/04 08:04:01
Done.
| |
| 67 * periodically calling the callback. | 134 * periodically calling the callback. |
| 68 * | 135 * |
| 69 * @param[in] config A <code>PP_Resource</code> corresponding to an audio | 136 * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio |
| 70 * input resource. | 137 * input resource. |
| 71 * | 138 * |
| 72 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if | 139 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if |
| 73 * successful, otherwise <code>PP_FALSE</code>. Also returns | 140 * successful, otherwise <code>PP_FALSE</code>. |
| 74 * <code>PP_TRUE</code> (and be a no-op) if called while callback is already | |
| 75 * in progress. | |
| 76 */ | 141 */ |
| 77 PP_Bool StartCapture( | 142 PP_Bool StartCapture( |
| 78 [in] PP_Resource audio_input); | 143 [in] PP_Resource audio_input); |
| 79 | 144 |
| 80 /** | 145 /** |
|
brettw
2012/03/02 19:13:41
Can you remove "pointer to a function" here?
yzshen1
2012/03/04 08:04:01
Done.
| |
| 81 * StopCapture is a pointer to a function that stops the capture of | 146 * StopCapture is a pointer to a function that stops the capture of |
| 82 * the audio input resource. | 147 * the audio input resource. |
| 83 * | 148 * |
| 84 * @param[in] config A PP_Resource containing the audio input resource. | 149 * @param[in] audio_input A PP_Resource containing the audio input resource. |
| 85 * | 150 * |
| 86 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. | 151 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if |
| 87 * Also returns PP_TRUE (and is a no-op) if called while capture is already | 152 * successful, otherwise <code>PP_FALSE</code>. |
| 88 * stopped. If a buffer is being captured, StopCapture will block until the | 153 * Also returns <code>PP_TRUE</code> (and is a no-op) if called while capture |
| 89 * call completes. | 154 * is already stopped. If a buffer is being captured, StopCapture will block |
| 155 * until the call completes. | |
| 90 */ | 156 */ |
| 91 PP_Bool StopCapture( | 157 PP_Bool StopCapture( |
| 92 [in] PP_Resource audio_input); | 158 [in] PP_Resource audio_input); |
| 159 | |
| 160 /** | |
| 161 * Closes the audio input device, and stops capturing if necessary. It is | |
| 162 * not valid to call Open() again after a call to this method. | |
| 163 * If an audio input resource is destroyed while a device is still open, then | |
| 164 * it will be implicitly closed, so you are not required to call this method. | |
| 165 * | |
| 166 * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio | |
| 167 * input resource. | |
| 168 */ | |
| 169 [version=0.2] | |
| 170 void Close( | |
| 171 [in] PP_Resource audio_input); | |
| 93 }; | 172 }; |
| 94 | |
| OLD | NEW |