1/* 2 ** Copyright 2003-2010, VisualOn, Inc. 3 ** 4 ** Licensed under the Apache License, Version 2.0 (the "License"); 5 ** you may not use this file except in compliance with the License. 6 ** You may obtain a copy of the License at 7 ** 8 ** http://www.apache.org/licenses/LICENSE-2.0 9 ** 10 ** Unless required by applicable law or agreed to in writing, software 11 ** distributed under the License is distributed on an "AS IS" BASIS, 12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 ** See the License for the specific language governing permissions and 14 ** limitations under the License. 15 */ 16/******************************************************************************* 17 File: voAudio.h 18 19 Content: Audio types and functions 20 21*******************************************************************************/ 22 23#ifndef __voAudio_H__ 24#define __voAudio_H__ 25 26#ifdef __cplusplus 27extern "C" { 28#endif /* __cplusplus */ 29 30#include "voIndex.h" 31#include "voMem.h" 32 33#define VO_PID_AUDIO_BASE 0x42000000 /*!< The base param ID for AUDIO codec */ 34#define VO_PID_AUDIO_FORMAT (VO_PID_AUDIO_BASE | 0X0001) /*!< The format data of audio in track */ 35#define VO_PID_AUDIO_SAMPLEREATE (VO_PID_AUDIO_BASE | 0X0002) /*!< The sample rate of audio */ 36#define VO_PID_AUDIO_CHANNELS (VO_PID_AUDIO_BASE | 0X0003) /*!< The channel of audio */ 37#define VO_PID_AUDIO_BITRATE (VO_PID_AUDIO_BASE | 0X0004) /*!< The bit rate of audio */ 38#define VO_PID_AUDIO_CHANNELMODE (VO_PID_AUDIO_BASE | 0X0005) /*!< The channel mode of audio */ 39 40#define VO_ERR_AUDIO_BASE 0x82000000 41#define VO_ERR_AUDIO_UNSCHANNEL (VO_ERR_AUDIO_BASE | 0x0001) 42#define VO_ERR_AUDIO_UNSSAMPLERATE (VO_ERR_AUDIO_BASE | 0x0002) 43#define VO_ERR_AUDIO_UNSFEATURE (VO_ERR_AUDIO_BASE | 0x0003) 44 45 46/** 47 *Enumeration used to define the possible audio coding formats. 48 */ 49typedef enum VO_AUDIO_CODINGTYPE { 50 VO_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */ 51 VO_AUDIO_CodingPCM, /**< Any variant of PCM coding */ 52 VO_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */ 53 VO_AUDIO_CodingAMRNB, /**< Any variant of AMR encoded data */ 54 VO_AUDIO_CodingAMRWB, /**< Any variant of AMR encoded data */ 55 VO_AUDIO_CodingAMRWBP, /**< Any variant of AMR encoded data */ 56 VO_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */ 57 VO_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */ 58 VO_AUDIO_CodingAAC, /**< Any variant of AAC encoded data, 0xA106 - ISO/MPEG-4 AAC, 0xFF - AAC */ 59 VO_AUDIO_CodingAC3, /**< Any variant of AC3 encoded data */ 60 VO_AUDIO_CodingFLAC, /**< Any variant of FLAC encoded data */ 61 VO_AUDIO_CodingMP1, /**< Any variant of MP1 encoded data */ 62 VO_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */ 63 VO_AUDIO_CodingOGG, /**< Any variant of OGG encoded data */ 64 VO_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */ 65 VO_AUDIO_CodingRA, /**< Any variant of RA encoded data */ 66 VO_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */ 67 VO_AUDIO_CodingDRA, /**< Any variant of dra encoded data */ 68 VO_AUDIO_CodingG729, /**< Any variant of dra encoded data */ 69 VO_AUDIO_Coding_MAX = VO_MAX_ENUM_VALUE 70} VO_AUDIO_CODINGTYPE; 71 72/*! 73* the channel type value 74*/ 75typedef enum { 76 VO_CHANNEL_CENTER = 1, /*!<center channel*/ 77 VO_CHANNEL_FRONT_LEFT = 1<<1, /*!<front left channel*/ 78 VO_CHANNEL_FRONT_RIGHT = 1<<2, /*!<front right channel*/ 79 VO_CHANNEL_SIDE_LEFT = 1<<3, /*!<side left channel*/ 80 VO_CHANNEL_SIDE_RIGHT = 1<<4, /*!<side right channel*/ 81 VO_CHANNEL_BACK_LEFT = 1<<5, /*!<back left channel*/ 82 VO_CHANNEL_BACK_RIGHT = 1<<6, /*!<back right channel*/ 83 VO_CHANNEL_BACK_CENTER = 1<<7, /*!<back center channel*/ 84 VO_CHANNEL_LFE_BASS = 1<<8, /*!<low-frequency effects bass channel*/ 85 VO_CHANNEL_ALL = 0xffff,/*!<[default] include all channels */ 86 VO_CHANNEL_MAX = VO_MAX_ENUM_VALUE 87} VO_AUDIO_CHANNELTYPE; 88 89/** 90 * General audio format info 91 */ 92typedef struct 93{ 94 VO_S32 SampleRate; /*!< Sample rate */ 95 VO_S32 Channels; /*!< Channel count */ 96 VO_S32 SampleBits; /*!< Bits per sample */ 97} VO_AUDIO_FORMAT; 98 99/** 100 * General audio output info 101 */ 102typedef struct 103{ 104 VO_AUDIO_FORMAT Format; /*!< Sample rate */ 105 VO_U32 InputUsed; /*!< Channel count */ 106 VO_U32 Resever; /*!< Resevered */ 107} VO_AUDIO_OUTPUTINFO; 108 109/** 110 * General audio codec function set 111 */ 112typedef struct VO_AUDIO_CODECAPI 113{ 114 /** 115 * Init the audio codec module and return codec handle 116 * \param phCodec [OUT] Return the video codec handle 117 * \param vType [IN] The codec type if the module support multi codec. 118 * \param pUserData [IN] The init param. It is either a memory operator or an allocated memory 119 * \retval VO_ERR_NONE Succeeded. 120 */ 121 VO_U32 (VO_API * Init) (VO_HANDLE * phCodec, VO_AUDIO_CODINGTYPE vType, VO_CODEC_INIT_USERDATA * pUserData ); 122 123 /** 124 * Set input audio data. 125 * \param hCodec [IN]] The codec handle which was created by Init function. 126 * \param pInput [IN] The input buffer param. 127 * \retval VO_ERR_NONE Succeeded. 128 */ 129 VO_U32 (VO_API * SetInputData) (VO_HANDLE hCodec, VO_CODECBUFFER * pInput); 130 131 /** 132 * Get the outut audio data 133 * \param hCodec [IN]] The codec handle which was created by Init function. 134 * \param pOutBuffer [OUT] The output audio data 135 * \param pOutInfo [OUT] The codec fills audio format and the input data size used in current call. 136 * pOutInfo->InputUsed is total used input data size in byte. 137 * \retval VO_ERR_NONE Succeeded. 138 * VO_ERR_INPUT_BUFFER_SMALL. The input was finished or the input data was not enought. Continue to input 139 * data before next call. 140 */ 141 VO_U32 (VO_API * GetOutputData) (VO_HANDLE hCodec, VO_CODECBUFFER * pOutBuffer, VO_AUDIO_OUTPUTINFO * pOutInfo); 142 143 /** 144 * Set the parameter for the specified param ID. 145 * \param hCodec [IN]] The codec handle which was created by Init function. 146 * \param uParamID [IN] The param ID. 147 * \param pData [IN] The param value. 148 * \retval VO_ERR_NONE Succeeded. 149 */ 150 VO_U32 (VO_API * SetParam) (VO_HANDLE hCodec, VO_S32 uParamID, VO_PTR pData); 151 152 /** 153 * Get the parameter for the specified param ID. 154 * \param hCodec [IN]] The codec handle which was created by Init function. 155 * \param uParamID [IN] The param ID. 156 * \param pData [IN] The param value. 157 * \retval VO_ERR_NONE Succeeded. 158 */ 159 VO_U32 (VO_API * GetParam) (VO_HANDLE hCodec, VO_S32 uParamID, VO_PTR pData); 160 161 /** 162 * Uninit the Codec. 163 * \param hCodec [IN]] The codec handle which was created by Init function. 164 * \retval VO_ERR_NONE Succeeded. 165 */ 166 VO_U32 (VO_API * Uninit) (VO_HANDLE hCodec); 167} VO_AUDIO_CODECAPI; 168 169#ifdef __cplusplus 170} 171#endif /* __cplusplus */ 172 173#endif // __voAudio_H__ 174