OLD | NEW |
(Empty) | |
| 1 /* Copyright (c) 2011 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 |
| 6 #ifndef PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ |
| 7 #define PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ |
| 8 |
| 9 #include "ppapi/c/pp_bool.h" |
| 10 #include "ppapi/c/pp_instance.h" |
| 11 #include "ppapi/c/pp_macros.h" |
| 12 #include "ppapi/c/pp_resource.h" |
| 13 #include "ppapi/c/pp_stdint.h" |
| 14 |
| 15 /** |
| 16 * @file |
| 17 * This file defines the <code>PPB_Audio_Input</code> interface, which provides |
| 18 * realtime audio input capture. |
| 19 */ |
| 20 |
| 21 /** |
| 22 * @addtogroup Typedefs |
| 23 * @{ |
| 24 */ |
| 25 /** |
| 26 * <code>PPB_Audio_Input_Callback</code> defines the type of an audio callback |
| 27 * function used to provide the audio buffer with data. This callback will be |
| 28 * called on a separate thread to the creation thread. |
| 29 */ |
| 30 typedef void (*PPB_AudioInput_Callback)(void* sample_buffer, |
| 31 uint32_t buffer_size_in_bytes, |
| 32 void* user_data); |
| 33 |
| 34 /** |
| 35 * @addtogroup Interfaces |
| 36 * @{ |
| 37 */ |
| 38 /** |
| 39 * The <code>PPB_AudioInput_Dev</code> interface contains pointers to several |
| 40 * functions for handling audio input resources. |
| 41 */ |
| 42 |
| 43 #define PPB_AUDIO_INPUT_DEV_INTERFACE_0_1 "PPB_AudioInput(Dev);0.1" |
| 44 #define PPB_AUDIO_INPUT_DEV_INTERFACE PPB_AUDIO_INPUT_DEV_INTERFACE_0_1 |
| 45 |
| 46 struct PPB_AudioInput_Dev { |
| 47 /** |
| 48 * Create is a pointer to a function that creates an audio input resource. |
| 49 * No sound will be captured until StartCapture() is called. |
| 50 */ |
| 51 PP_Resource (*Create)(PP_Instance instance, |
| 52 PP_Resource config, |
| 53 PPB_AudioInput_Callback audio_input_callback, |
| 54 void* user_data); |
| 55 |
| 56 /** |
| 57 * IsAudioInput is a pointer to a function that determines if the given |
| 58 * resource is an audio input resource. |
| 59 * |
| 60 * @param[in] resource A PP_Resource containing a resource. |
| 61 * |
| 62 * @return A PP_BOOL containing containing PP_TRUE if the given resource is |
| 63 * an audio input resource, otherwise PP_FALSE. |
| 64 */ |
| 65 PP_Bool (*IsAudioInput)(PP_Resource audio_input); |
| 66 |
| 67 /** |
| 68 * GetCurrrentConfig() returns an audio config resource for the given audio |
| 69 * resource. |
| 70 * |
| 71 * @param[in] config A <code>PP_Resource</code> corresponding to an audio |
| 72 * resource. |
| 73 * |
| 74 * @return A <code>PP_Resource</code> containing the audio config resource if |
| 75 * successful. |
| 76 */ |
| 77 PP_Resource (*GetCurrentConfig)(PP_Resource audio); |
| 78 |
| 79 /** |
| 80 * StartCapture() starts the capture of the audio input resource and begins |
| 81 * periodically calling the callback. |
| 82 * |
| 83 * @param[in] config A <code>PP_Resource</code> corresponding to an audio |
| 84 * input resource. |
| 85 * |
| 86 * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if |
| 87 * successful, otherwise <code>PP_FALSE</code>. Also returns |
| 88 * <code>PP_TRUE</code> (and be a no-op) if called while callback is already |
| 89 * in progress. |
| 90 */ |
| 91 PP_Bool (*StartCapture)(PP_Resource audio_input); |
| 92 |
| 93 /** |
| 94 * StopCapture is a pointer to a function that stops the capture of |
| 95 * the audio input resource. |
| 96 * |
| 97 * @param[in] config A PP_Resource containing the audio input resource. |
| 98 * |
| 99 * @return A PP_BOOL containing PP_TRUE if successful, otherwise PP_FALSE. |
| 100 * Also returns PP_TRUE (and is a no-op) if called while capture is already |
| 101 * stopped. If a buffer is being captured, StopCapture will block until the |
| 102 * call completes. |
| 103 */ |
| 104 PP_Bool (*StopCapture)(PP_Resource audio_input); |
| 105 }; |
| 106 /** |
| 107 * @} |
| 108 */ |
| 109 |
| 110 #endif /* PPAPI_C_PPB_AUDIO_INPUT_DEV_H_ */ |
| 111 |
OLD | NEW |