Pepper_42_C_interfaces
ppb_audio_input_dev.h
Go to the documentation of this file.
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
3  * found in the LICENSE file.
4  */
5 
6 /* From dev/ppb_audio_input_dev.idl modified Tue Dec 04 15:13:31 2012. */
7 
8 #ifndef PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_
9 #define PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_
10 
11 #include "ppapi/c/dev/ppb_device_ref_dev.h"
12 #include "ppapi/c/pp_array_output.h"
13 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_completion_callback.h"
15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_macros.h"
17 #include "ppapi/c/pp_resource.h"
18 #include "ppapi/c/pp_stdint.h"
19 
20 #define PPB_AUDIO_INPUT_DEV_INTERFACE_0_2 "PPB_AudioInput(Dev);0.2"
21 #define PPB_AUDIO_INPUT_DEV_INTERFACE_0_3 "PPB_AudioInput(Dev);0.3"
22 #define PPB_AUDIO_INPUT_DEV_INTERFACE PPB_AUDIO_INPUT_DEV_INTERFACE_0_3
23 
24 /**
25  * @file
26  * This file defines the <code>PPB_AudioInput_Dev</code> interface, which
27  * provides realtime audio input capture.
28  */
29 
30 
31 /**
32  * @addtogroup Typedefs
33  * @{
34  */
35 /**
36  * <code>PPB_AudioInput_Callback</code> defines the type of an audio callback
37  * function used to provide the audio buffer with data. This callback will be
38  * called on a separate thread from the creation thread.
39  */
40 typedef void (*PPB_AudioInput_Callback)(const void* sample_buffer,
41  uint32_t buffer_size_in_bytes,
42  void* user_data);
43 /**
44  * @}
45  */
46 
47 /**
48  * @addtogroup Interfaces
49  * @{
50  */
51 /**
52  * The <code>PPB_AudioInput_Dev</code> interface contains pointers to several
53  * functions for handling audio input resources.
54  *
55  * TODO(brettw) before moving out of dev, we need to resolve the issue of
56  * the mismatch between the current audio config interface and this one.
57  *
58  * In particular, the params for input assume stereo, but this class takes
59  * everything as mono. We either need to not use an audio config resource, or
60  * add mono support.
61  *
62  * In addition, RecommendSampleFrameCount is completely wrong for audio input.
63  * RecommendSampleFrameCount returns the frame count for the current
64  * low-latency output device, which is likely inappropriate for a random input
65  * device. We may want to move the "recommend" functions to the input or output
66  * classes rather than the config.
67  */
69  /**
70  * Creates an audio input resource.
71  *
72  * @param[in] instance A <code>PP_Instance</code> identifying one instance of
73  * a module.
74  *
75  * @return A <code>PP_Resource</code> corresponding to an audio input resource
76  * if successful, 0 if failed.
77  */
79  /**
80  * Determines if the given resource is an audio input resource.
81  *
82  * @param[in] resource A <code>PP_Resource</code> containing a resource.
83  *
84  * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if the given
85  * resource is an audio input resource, otherwise <code>PP_FALSE</code>.
86  */
88  /**
89  * Enumerates audio input devices.
90  *
91  * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio
92  * input resource.
93  * @param[in] output An output array which will receive
94  * <code>PPB_DeviceRef_Dev</code> resources on success. Please note that the
95  * ref count of those resources has already been increased by 1 for the
96  * caller.
97  * @param[in] callback A <code>PP_CompletionCallback</code> to run on
98  * completion.
99  *
100  * @return An error code from <code>pp_errors.h</code>.
101  */
102  int32_t (*EnumerateDevices)(PP_Resource audio_input,
103  struct PP_ArrayOutput output,
104  struct PP_CompletionCallback callback);
105  /**
106  * Requests device change notifications.
107  *
108  * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio
109  * input resource.
110  * @param[in] callback The callback to receive notifications. If not NULL, it
111  * will be called once for the currently available devices, and then every
112  * time the list of available devices changes. All calls will happen on the
113  * same thread as the one on which MonitorDeviceChange() is called. It will
114  * receive notifications until <code>audio_input</code> is destroyed or
115  * <code>MonitorDeviceChange()</code> is called to set a new callback for
116  * <code>audio_input</code>. You can pass NULL to cancel sending
117  * notifications.
118  * @param[inout] user_data An opaque pointer that will be passed to
119  * <code>callback</code>.
120  *
121  * @return An error code from <code>pp_errors.h</code>.
122  */
123  int32_t (*MonitorDeviceChange)(PP_Resource audio_input,
125  void* user_data);
126  /**
127  * Opens an audio input device. No sound will be captured until
128  * StartCapture() is called.
129  *
130  * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio
131  * input resource.
132  * @param[in] device_ref Identifies an audio input device. It could be one of
133  * the resource in the array returned by EnumerateDevices(), or 0 which means
134  * the default device.
135  * @param[in] config A <code>PPB_AudioConfig</code> audio configuration
136  * resource.
137  * @param[in] audio_input_callback A <code>PPB_AudioInput_Callback</code>
138  * function that will be called when data is available.
139  * @param[inout] user_data An opaque pointer that will be passed into
140  * <code>audio_input_callback</code>.
141  * @param[in] callback A <code>PP_CompletionCallback</code> to run when this
142  * open operation is completed.
143  *
144  * @return An error code from <code>pp_errors.h</code>.
145  */
146  int32_t (*Open)(PP_Resource audio_input,
147  PP_Resource device_ref,
148  PP_Resource config,
149  PPB_AudioInput_Callback audio_input_callback,
150  void* user_data,
151  struct PP_CompletionCallback callback);
152  /**
153  * Returns an audio config resource for the given audio input resource.
154  *
155  * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio
156  * input resource.
157  *
158  * @return A <code>PP_Resource</code> containing the audio config resource if
159  * successful.
160  */
162  /**
163  * Starts the capture of the audio input resource and begins periodically
164  * calling the callback.
165  *
166  * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio
167  * input resource.
168  *
169  * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if
170  * successful, otherwise <code>PP_FALSE</code>.
171  * Also returns <code>PP_TRUE</code> (and is a no-op) if called while capture
172  * is already started.
173  */
175  /**
176  * Stops the capture of the audio input resource.
177  *
178  * @param[in] audio_input A PP_Resource containing the audio input resource.
179  *
180  * @return A <code>PP_Bool</code> containing <code>PP_TRUE</code> if
181  * successful, otherwise <code>PP_FALSE</code>.
182  * Also returns <code>PP_TRUE</code> (and is a no-op) if called while capture
183  * is already stopped. If a buffer is being captured, StopCapture will block
184  * until the call completes.
185  */
186  PP_Bool (*StopCapture)(PP_Resource audio_input);
187  /**
188  * Closes the audio input device, and stops capturing if necessary. It is
189  * not valid to call Open() again after a call to this method.
190  * If an audio input resource is destroyed while a device is still open, then
191  * it will be implicitly closed, so you are not required to call this method.
192  *
193  * @param[in] audio_input A <code>PP_Resource</code> corresponding to an audio
194  * input resource.
195  */
196  void (*Close)(PP_Resource audio_input);
197 };
198 
200 
204  int32_t (*EnumerateDevices)(PP_Resource audio_input,
205  PP_Resource* devices,
206  struct PP_CompletionCallback callback);
207  int32_t (*Open)(PP_Resource audio_input,
208  PP_Resource device_ref,
209  PP_Resource config,
210  PPB_AudioInput_Callback audio_input_callback,
211  void* user_data,
212  struct PP_CompletionCallback callback);
215  PP_Bool (*StopCapture)(PP_Resource audio_input);
216  void (*Close)(PP_Resource audio_input);
217 };
218 /**
219  * @}
220  */
221 
222 #endif /* PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ */
223 
PP_Resource(* GetCurrentConfig)(PP_Resource audio_input)
PP_Resource(* GetCurrentConfig)(PP_Resource audio_input)
PP_Resource(* Create)(PP_Instance instance)
PP_Bool(* StartCapture)(PP_Resource audio_input)
int32_t(* EnumerateDevices)(PP_Resource audio_input, struct PP_ArrayOutput output, struct PP_CompletionCallback callback)
PP_Bool(* StopCapture)(PP_Resource audio_input)
void(* Close)(PP_Resource audio_input)
PP_Bool(* StartCapture)(PP_Resource audio_input)
PP_Bool(* StopCapture)(PP_Resource audio_input)
PP_Bool(* IsAudioInput)(PP_Resource resource)
int32_t(* Open)(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback audio_input_callback, void *user_data, struct PP_CompletionCallback callback)
int32_t PP_Resource
Definition: pp_resource.h:40
void(* Close)(PP_Resource audio_input)
int32_t(* Open)(PP_Resource audio_input, PP_Resource device_ref, PP_Resource config, PPB_AudioInput_Callback audio_input_callback, void *user_data, struct PP_CompletionCallback callback)
int32_t(* EnumerateDevices)(PP_Resource audio_input, PP_Resource *devices, struct PP_CompletionCallback callback)
void(* PPB_AudioInput_Callback)(const void *sample_buffer, uint32_t buffer_size_in_bytes, void *user_data)
PP_Resource(* Create)(PP_Instance instance)
int32_t PP_Instance
Definition: pp_instance.h:34
PP_Bool(* IsAudioInput)(PP_Resource resource)
PP_Bool
Definition: pp_bool.h:30
void(* PP_MonitorDeviceChangeCallback)(void *user_data, uint32_t device_count, const PP_Resource devices[])
int32_t(* MonitorDeviceChange)(PP_Resource audio_input, PP_MonitorDeviceChangeCallback callback, void *user_data)