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    M4READER_3gpCom.h
     19  * @brief    Generic encapsulation of the core 3gp reader
     20  * @note    This file declares the generic shell interface retrieving function
     21  *            of the 3GP reader
     22  ************************************************************************
     23 */
     24 
     25 #ifndef __M4READER_3GPCOM_H__
     26 #define __M4READER_3GPCOM_H__
     27 
     28 #include "NXPSW_CompilerSwitches.h"
     29 
     30 #include "M4OSA_Types.h"
     31 #include "M4OSA_Error.h"
     32 #include "M4READER_Common.h"
     33 
     34 #ifdef __cplusplus
     35 extern "C" {
     36 #endif
     37 
     38 /**
     39  * Error: Function M4READER_Com3GP_getNextStreamHandler must be called before.
     40  */
     41 #define M4ERR_NO_VIDEO_STREAM_RETRIEVED_YET        M4OSA_ERR_CREATE(M4_ERR, M4READER_3GP, 0x000001)
     42 
     43 /**
     44  * Error: No video stream H263 in file.
     45  */
     46 #define M4ERR_VIDEO_NOT_H263                    M4OSA_ERR_CREATE(M4_ERR, M4READER_3GP, 0x000002)
     47 
     48 /**
     49  * There has been a problem with the decoder configuration information, seems to be invalid */
     50 #define M4ERR_READER3GP_DECODER_CONFIG_ERROR    M4OSA_ERR_CREATE(M4_ERR, M4READER_3GP, 0x000003)
     51 
     52 #define M4READER_COM3GP_MAXVIDEOSTREAM  5
     53 #define M4READER_COM3GP_MAXAUDIOSTREAM  5
     54 #define M4READER_COM3GP_MAXTEXTSTREAM   5
     55 
     56 typedef struct
     57 {
     58     M4OSA_Context                m_pFFContext;    /**< core file format context */
     59 
     60     M4_StreamHandler*            m_AudioStreams[M4READER_COM3GP_MAXAUDIOSTREAM];
     61     M4_StreamHandler*            m_pAudioStream;    /**< pointer to the current allocated audio
     62                                                             stream handler */
     63 
     64     M4_StreamHandler*            m_VideoStreams[M4READER_COM3GP_MAXVIDEOSTREAM];
     65     M4_StreamHandler*            m_pVideoStream;    /**< pointer to the current allocated video
     66                                                             stream handler */
     67 
     68 #ifdef M4VPS_SUPPORT_TTEXT
     69     M4_StreamHandler*            m_TextStreams[M4READER_COM3GP_MAXTEXTSTREAM];
     70     M4_StreamHandler*            m_pTextStream;    /**< pointer to the current allocated text
     71                                                             stream handler */
     72 #endif /*M4VPS_SUPPORT_TTEXT*/
     73 
     74 } M4READER_Com3GP_Context;
     75 
     76 /**
     77  ************************************************************************
     78  * structure M4READER_3GP_Buffer (but nothing specific to 3GP, nor to a reader !)
     79  * @brief     This structure defines a buffer that can be used to exchange data (should be in OSAL)
     80  ************************************************************************
     81 */
     82 typedef struct
     83 {
     84     M4OSA_UInt32    size;            /**< the size in bytes of the buffer */
     85     M4OSA_MemAddr8    dataAddress;    /**< the pointer to the buffer */
     86 } M4READER_3GP_Buffer;
     87 
     88 /**
     89  ************************************************************************
     90  * enum     M4READER_3GP_OptionID
     91  * @brief    This enum defines the reader options specific to the 3GP format.
     92  * @note    These options can be read from or written to a 3GP reader via M4READER_3GP_getOption.
     93  ************************************************************************
     94 */
     95 typedef enum
     96 {
     97     /**
     98      * Get the DecoderConfigInfo for H263,
     99      * option value must be a pointer to M4READER_3GP_H263Properties allocated by caller */
    100     M4READER_3GP_kOptionID_H263Properties = M4OSA_OPTION_ID_CREATE(M4_READ, M4READER_3GP, 0x01),
    101 
    102     /**
    103      * Get the Purple Labs drm information */
    104     M4READER_3GP_kOptionID_PurpleLabsDrm = M4OSA_OPTION_ID_CREATE(M4_READ, M4READER_3GP, 0x02),
    105 
    106     /**
    107      * Set the Fast open mode (Only the first AU of each stream will be parsed -> less CPU,
    108                                  less RAM). */
    109     M4READER_3GP_kOptionID_FastOpenMode = M4OSA_OPTION_ID_CREATE(M4_WRITE, M4READER_3GP, 0x03),
    110 
    111     /**
    112      * Set the Audio only mode (the video stream won't be opened) */
    113     M4READER_3GP_kOptionID_AudioOnly = M4OSA_OPTION_ID_CREATE(M4_WRITE, M4READER_3GP, 0x04),
    114 
    115     /**
    116      * Set the Video only mode (the audio stream won't be opened) */
    117     M4READER_3GP_kOptionID_VideoOnly = M4OSA_OPTION_ID_CREATE(M4_WRITE, M4READER_3GP, 0x05),
    118 
    119     /**
    120      * Get the next video CTS */
    121     M4READER_3GP_kOptionID_getNextVideoCTS = M4OSA_OPTION_ID_CREATE(M4_READ, M4READER_3GP, 0x06)
    122 
    123 } M4READER_3GP_OptionID;
    124 
    125 
    126 /**
    127  ************************************************************************
    128  * struct    M4READER_3GP_H263Properties
    129  * @brief    Contains info about H263 stream read from the 3GP file.
    130  ************************************************************************
    131 */
    132 typedef struct
    133 {
    134     /**< the profile as defined in the Visual Object Sequence header, if present */
    135     M4OSA_UInt8        uiProfile;
    136     /**< the level as defined in the Visual Object Sequence header, if present */
    137     M4OSA_UInt8        uiLevel;
    138 
    139 } M4READER_3GP_H263Properties;
    140 
    141 /**
    142  ************************************************************************
    143  * @brief    Get the next stream found in the 3gp file
    144  * @note
    145  * @param    pContext:        (IN)    Context of the reader
    146  * @param    pMediaFamily:    (OUT)    Pointer to a user allocated M4READER_MediaFamily that will
    147  *                                      be filled with the media family of the found stream
    148  * @param    pStreamHandler:    (OUT)    Pointer to a stream handler that will be allocated and
    149  *                                          filled with the found stream description
    150  * @return    M4NO_ERROR                 There is no error
    151  * @return    M4ERR_PARAMETER            At least one parameter is not properly set
    152  * @return    M4WAR_NO_MORE_STREAM    No more available stream in the media (all streams found)
    153  ************************************************************************
    154 */
    155 M4OSA_ERR M4READER_Com3GP_getNextStreamHandler(M4OSA_Context context,
    156                                                  M4READER_MediaFamily *pMediaFamily,
    157                                                  M4_StreamHandler **pStreamHandler);
    158 
    159 /**
    160  ************************************************************************
    161  * @brief    Prepare the  access unit (AU)
    162  * @note    An AU is the smallest possible amount of data to be decoded by a decoder.
    163  * @param    pContext:        (IN)        Context of the reader
    164  * @param    pStreamHandler    (IN)        The stream handler of the stream to make jump
    165  * @param    pAccessUnit        (IN/OUT)    Pointer to an access unit to fill with read data
    166  *                                          (the au structure is allocated by the user, and must
    167  *                                          be initialized by calling M4READER_fillAuStruct_fct
    168  *                                          after creation)
    169  * @return    M4NO_ERROR                     There is no error
    170  * @return    M4ERR_PARAMETER                At least one parameter is not properly set
    171  * @returns    M4ERR_ALLOC                    Memory allocation failed
    172  ************************************************************************
    173 */
    174 M4OSA_ERR M4READER_Com3GP_fillAuStruct(M4OSA_Context context, M4_StreamHandler *pStreamHandler,
    175                                          M4_AccessUnit *pAccessUnit);
    176 
    177 /**
    178  ************************************************************************
    179  * @brief    Cleans up the stream handler
    180  * @param    pContext: (IN/OUT) Context of the reader shell
    181  * @param    pStreamHandler: (IN/OUT) Stream handler
    182  * @return    M4ERR_PARAMETER:    The context is null
    183  * @return    M4NO_ERROR:            No error
    184  ************************************************************************
    185 */
    186 M4OSA_ERR M4READER_Com3GP_cleanUpHandler(M4_StreamHandler* pStreamHandler);
    187 
    188 #ifdef __cplusplus
    189 }
    190 #endif /* __cplusplus */
    191 
    192 #endif /* __M4READER_3GPCOM_H__ */
    193 
    194