Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      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  ************************************************************************
     18  * @file    M4WAV_WavReader.h
     19  * @brief   WAV Reader declarations
     20  * @note    This file implements functions of the WAV reader
     21  ************************************************************************
     22 */
     23 
     24 #include "M4OSA_CoreID.h"
     25 #include "M4OSA_Types.h"
     26 #include "M4OSA_Memory.h"
     27 #include "M4OSA_FileReader.h"
     28 #include "M4SYS_AccessUnit.h"
     29 #include "M4TOOL_VersionInfo.h"
     30 
     31 
     32 #define M4PCMC_ERR_PCM_NOT_COMPLIANT    M4OSA_ERR_CREATE(M4_ERR, M4WAV_COMMON,0x000001)
     33 #define M4PCMC_ERR_PCM_NO_SPACE_AVAIL   M4OSA_ERR_CREATE(M4_ERR, M4WAV_COMMON,0x000002)
     34 #define M4PCMC_ERR_PCM_NOT_SUPPORTED    M4OSA_ERR_CREATE(M4_ERR, M4WAV_COMMON,0x000003)
     35 
     36 #define M4PCMC_WAR_END_OF_STREAM        M4OSA_ERR_CREATE(M4_WAR, M4WAV_COMMON ,0x000001)
     37 
     38 /**
     39  ************************************************************************
     40  * structure    M4WAVC_DecoderSpecificInfo
     41  * @brief       This structure defines the decoder Specific informations
     42  * @note        This structure is used by the WAV reader to store all
     43  *              decoder specific informations:
     44  *              - Sample Frequency
     45  *              - Average Bytes per second
     46  *              - Number of channels (1 or 2)
     47  *              - Number of bits per sample (8 or 16)
     48  ************************************************************************
     49 */
     50 typedef struct {
     51     M4OSA_UInt32    SampleFrequency;
     52     M4OSA_UInt32    AvgBytesPerSec;
     53     M4OSA_UInt32    DataLength;
     54     M4OSA_UInt16    nbChannels;
     55     M4OSA_UInt16    BitsPerSample;
     56 } M4PCMC_DecoderSpecificInfo;
     57 
     58 /**
     59  ************************************************************************
     60  * enum     M4WAVR_State
     61  * @brief   This enum defines the WAV Reader States
     62  * @note    The state automaton is documented separately
     63  *          consult the design specification for details
     64  ************************************************************************
     65 */
     66 typedef enum {
     67     M4PCMR_kInit    = 0x0000,
     68     M4PCMR_kOpening = 0x0100,
     69     M4PCMR_kOpening_streamRetrieved = 0x0101,
     70     M4PCMR_kReading = 0x0200,
     71     M4PCMR_kReading_nextAU  = 0x0201,
     72     M4PCMR_kClosed  = 0x0300
     73 } M4PCMR_State;
     74 
     75 /**
     76  ************************************************************************
     77  * enum     M4WAVR_OptionID
     78  * @brief   This enum defines the WAV Reader options
     79  * @note    Only one option is available:
     80  *          - M4WAVR_kPCMblockSize: sets the size of the PCM block to read
     81  *            from WAV file
     82  ************************************************************************
     83 */
     84 typedef enum {
     85     M4PCMR_kPCMblockSize    = M4OSA_OPTION_ID_CREATE(M4_READ, M4WAV_READER, 0x01)
     86 } M4PCMR_OptionID;
     87 
     88 /**
     89  ************************************************************************
     90  * structure    M4WAVR_Context
     91  * @brief       This structure defines the WAV Reader context
     92  * @note        This structure is used for all WAV Reader calls to store
     93  *              the context
     94  ************************************************************************
     95 */
     96 typedef struct {
     97     M4OSA_MemAddr32             m_pDecoderSpecInfo;/**< Pointer to the decoder specific info
     98                                                         structure contained in pStreamDesc
     99                                                         (only used to free...) */
    100     M4OSA_FileReadPointer*      m_pFileReadFunc;/**< The OSAL set of pointer to function for
    101                                                          file management */
    102     M4OSA_Context               m_fileContext;  /**< The context needed by OSAL to manage File */
    103     M4PCMC_DecoderSpecificInfo  m_decoderConfig;/**< Specific configuration for decoder */
    104     M4PCMR_State                m_state;        /**< state of the wav reader */
    105     M4PCMR_State                m_microState;   /**< state of the read wav stream */
    106     M4OSA_UInt32                m_blockSize;    /**< Size of the read block */
    107     M4OSA_UInt32                m_offset;       /**< Offset of the PCM read (i.e m_offset of the
    108                                                         file without wav header) */
    109     M4OSA_MemAddr32             m_pAuBuffer;    /**< Re-used buffer for AU content storage */
    110     M4OSA_FilePosition          m_dataStartOffset;/**< offset of the pcm data beginning into
    111                                                          the file */
    112 } M4PCMR_Context;
    113 
    114 /*************************************************************************
    115  *
    116  *  Prototypes of all WAV reader functions
    117  *
    118  ************************************************************************/
    119 M4OSA_ERR M4PCMR_openRead(M4OSA_Context* pContext, M4OSA_Void* pUrl,
    120                              M4OSA_FileReadPointer* pFileFunction);
    121 M4OSA_ERR M4PCMR_getNextStream(M4OSA_Context context, M4SYS_StreamDescription* pStreamDesc);
    122 M4OSA_ERR M4PCMR_startReading(M4OSA_Context context, M4SYS_StreamID* pStreamIDs);
    123 M4OSA_ERR M4PCMR_nextAU(M4OSA_Context context, M4SYS_StreamID streamID, M4SYS_AccessUnit* pAU);
    124 M4OSA_ERR M4PCMR_freeAU(M4OSA_Context context, M4SYS_StreamID streamID, M4SYS_AccessUnit* pAU);
    125 M4OSA_ERR M4PCMR_seek(M4OSA_Context context, M4SYS_StreamID* pStreamID, M4OSA_Time time,
    126                          M4SYS_SeekAccessMode seekAccessMode, M4OSA_Time* pObtainCTS);
    127 M4OSA_ERR M4PCMR_closeRead(M4OSA_Context context);
    128 M4OSA_ERR M4PCMR_getOption(M4OSA_Context context, M4PCMR_OptionID optionID,
    129                               M4OSA_DataOption* pValue);
    130 M4OSA_ERR M4PCMR_setOption(M4OSA_Context context, M4PCMR_OptionID optionID,
    131                               M4OSA_DataOption Value);
    132 M4OSA_ERR M4PCMR_getVersion(M4_VersionInfo *pVersion);
    133