/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* From dev/ppb_audio_input_dev.idl modified Sat Mar 3 23:06:35 2012. */
#ifndef PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_
#define PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_macros.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_stdint.h"
#define PPB_AUDIO_INPUT_DEV_INTERFACE_0_1 "PPB_AudioInput(Dev);0.1"
#define PPB_AUDIO_INPUT_DEV_INTERFACE_0_2 "PPB_AudioInput(Dev);0.2"
#define PPB_AUDIO_INPUT_DEV_INTERFACE PPB_AUDIO_INPUT_DEV_INTERFACE_0_2
/**
* @file
* This file defines the PPB_AudioInput_Dev
interface, which
* provides realtime audio input capture.
*/
/**
* @addtogroup Typedefs
* @{
*/
/**
* PPB_AudioInput_Callback
defines the type of an audio callback
* function used to provide the audio buffer with data. This callback will be
* called on a separate thread from the creation thread.
*/
typedef void (*PPB_AudioInput_Callback)(const void* sample_buffer,
uint32_t buffer_size_in_bytes,
void* user_data);
/**
* @}
*/
/**
* @addtogroup Interfaces
* @{
*/
/**
* The PPB_AudioInput_Dev
interface contains pointers to several
* functions for handling audio input resources.
*/
struct PPB_AudioInput_Dev_0_2 {
/**
* Creates an audio input resource.
*
* @param[in] instance A PP_Instance
identifying one instance of
* a module.
*
* @return A PP_Resource
corresponding to an audio input resource
* if successful, 0 if failed.
*/
PP_Resource (*Create)(PP_Instance instance);
/**
* Determines if the given resource is an audio input resource.
*
* @param[in] resource A PP_Resource
containing a resource.
*
* @return A PP_Bool
containing PP_TRUE
if the given
* resource is an audio input resource, otherwise PP_FALSE
.
*/
PP_Bool (*IsAudioInput)(PP_Resource resource);
/**
* Enumerates audio input devices.
*
* Please note that:
* - this method ignores the previous value pointed to by devices
* (won't release reference even if it is not 0);
* - devices
must be valid until callback
is called,
* if the method returns PP_OK_COMPLETIONPENDING
;
* - the ref count of the returned devices
has already been
* increased by 1 for the caller.
*
* @param[in] audio_input A PP_Resource
corresponding to an audio
* input resource.
* @param[out] devices Once the operation is completed successfully,
* devices
will be set to a PPB_ResourceArray_Dev
* resource, which holds a list of PPB_DeviceRef_Dev
resources.
* @param[in] callback A PP_CompletionCallback
to run on
* completion.
*
* @return An error code from pp_errors.h
.
*/
int32_t (*EnumerateDevices)(PP_Resource audio_input,
PP_Resource* devices,
struct PP_CompletionCallback callback);
/**
* Opens an audio input device. No sound will be captured until
* StartCapture() is called.
*
* @param[in] audio_input A PP_Resource
corresponding to an audio
* input resource.
* @param[in] device_ref Identifies an audio input device. It could be one of
* the resource in the array returned by EnumerateDevices(), or 0 which means
* the default device.
* @param[in] config A PPB_AudioConfig
audio configuration
* resource.
* @param[in] audio_input_callback A PPB_AudioInput_Callback
* function that will be called when data is available.
* @param[inout] user_data An opaque pointer that will be passed into
* audio_input_callback
.
* @param[in] callback A PP_CompletionCallback
to run when this
* open operation is completed.
*
* @return An error code from pp_errors.h
.
*/
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);
/**
* Returns an audio config resource for the given audio input resource.
*
* @param[in] audio_input A PP_Resource
corresponding to an audio
* input resource.
*
* @return A PP_Resource
containing the audio config resource if
* successful.
*/
PP_Resource (*GetCurrentConfig)(PP_Resource audio_input);
/**
* Starts the capture of the audio input resource and begins periodically
* calling the callback.
*
* @param[in] audio_input A PP_Resource
corresponding to an audio
* input resource.
*
* @return A PP_Bool
containing PP_TRUE
if
* successful, otherwise PP_FALSE
.
* Also returns PP_TRUE
(and is a no-op) if called while capture
* is already started.
*/
PP_Bool (*StartCapture)(PP_Resource audio_input);
/**
* Stops the capture of the audio input resource.
*
* @param[in] audio_input A PP_Resource containing the audio input resource.
*
* @return A PP_Bool
containing PP_TRUE
if
* successful, otherwise PP_FALSE
.
* Also returns PP_TRUE
(and is a no-op) if called while capture
* is already stopped. If a buffer is being captured, StopCapture will block
* until the call completes.
*/
PP_Bool (*StopCapture)(PP_Resource audio_input);
/**
* Closes the audio input device, and stops capturing if necessary. It is
* not valid to call Open() again after a call to this method.
* If an audio input resource is destroyed while a device is still open, then
* it will be implicitly closed, so you are not required to call this method.
*
* @param[in] audio_input A PP_Resource
corresponding to an audio
* input resource.
*/
void (*Close)(PP_Resource audio_input);
};
typedef struct PPB_AudioInput_Dev_0_2 PPB_AudioInput_Dev;
struct PPB_AudioInput_Dev_0_1 {
PP_Resource (*Create)(PP_Instance instance,
PP_Resource config,
PPB_AudioInput_Callback audio_input_callback,
void* user_data);
PP_Bool (*IsAudioInput)(PP_Resource resource);
PP_Resource (*GetCurrentConfig)(PP_Resource audio_input);
PP_Bool (*StartCapture)(PP_Resource audio_input);
PP_Bool (*StopCapture)(PP_Resource audio_input);
};
/**
* @}
*/
#endif /* PPAPI_C_DEV_PPB_AUDIO_INPUT_DEV_H_ */