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    M4WRITER_common.h
     19  * @brief    VES writers shell interface.
     20  * @note    This file defines the types internally used by the VES to abstract writers
     21  ******************************************************************************
     22 */
     23 #ifndef __M4WRITER_COMMON_H__
     24 #define __M4WRITER_COMMON_H__
     25 
     26 #ifdef __cplusplus
     27 extern "C" {
     28 #endif /* __cplusplus */
     29 
     30 #include "M4OSA_Types.h"
     31 #include "M4OSA_FileWriter.h"   /* for M4OSA_FileWriterPointer */
     32 #include "M4OSA_FileReader.h"   /* for M4OSA_FileWriterPointer */
     33 #include "M4OSA_OptionID.h"     /* for M4OSA_OPTION_ID_CREATE() */
     34 #include "M4OSA_CoreID.h"       /* for M4WRITER_COMMON */
     35 
     36 #include "M4SYS_Stream.h"       /* for M4SYS_StreamID */
     37 #include "M4SYS_AccessUnit.h"   /* for M4SYS_AccessUnit */
     38 
     39 /**
     40  ******************************************************************************
     41  * MP4W Errors & Warnings definition
     42  ******************************************************************************
     43 */
     44 #define M4WAR_WRITER_STOP_REQ        M4OSA_ERR_CREATE(M4_WAR, M4WRITER_COMMON ,0x000001)
     45 
     46 /**
     47  ******************************************************************************
     48  * enum        M4WRITER_OutputFileType
     49  * @brief    This enum defines the avalaible output file format.
     50  ******************************************************************************
     51 */
     52 typedef enum
     53 {
     54     M4WRITER_kUnknown=-1,
     55     M4WRITER_k3GPP=0,            /**< 3GPP compliant file */
     56     M4WRITER_kAVI=1,            /**< AVI file */
     57     M4WRITER_kAMR=2,            /**< AMR file */
     58     M4WRITER_kNETWORK3GPP=3,    /**< 3GPP via TCP */
     59     M4WRITER_kPCM=4,            /**< PCM file */
     60     M4WRITER_kJPEG=5,            /**< JPEG EXIF writer */
     61     M4WRITER_kMP3=6,            /**< MP3 writer */
     62 
     63     M4WRITER_kType_NB  /* number of writers, keep it as last enum entry */
     64 
     65 } M4WRITER_OutputFileType;
     66 
     67 /**
     68  ******************************************************************************
     69  * enum    M4WRITER_OptionID
     70  * @brief    This enums defines all avalaible options. All the reuturned values are in
     71  *           M4OSA_UInt32 type.
     72  ******************************************************************************
     73 */
     74 typedef enum {
     75     M4WRITER_kMaxAUSize        = M4OSA_OPTION_ID_CREATE (M4_READ|M4_WRITE, M4WRITER_COMMON, 0x01),
     76     M4WRITER_kMaxChunckSize    = M4OSA_OPTION_ID_CREATE (M4_READ|M4_WRITE, M4WRITER_COMMON, 0x02),
     77     M4WRITER_kFileSize          = M4OSA_OPTION_ID_CREATE (M4_READ            , \
     78         M4WRITER_COMMON, 0x03),  /**< File size if the process was ended when we call the method */
     79     M4WRITER_kFileSizeAudioEstimated= M4OSA_OPTION_ID_CREATE (M4_READ    ,\
     80          M4WRITER_COMMON, 0x04),    /**< File size if the process was ended when we call the
     81                                      method, estimated size for audio */
     82     M4WRITER_kEmbeddedString  = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
     83          M4WRITER_COMMON, 0x05),    /**< String embedded at the end of the file(SW - VES) */
     84     M4WRITER_kEmbeddedVersion = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
     85          M4WRITER_COMMON, 0x06),    /**< Version embedded at the end of the file */
     86     M4WRITER_kIntegrationTag  = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
     87          M4WRITER_COMMON, 0x07),    /**< String embedded at the end of the file (char[60]
     88                                          for integration purpose) */
     89     M4WRITER_kMaxFileSize      = M4OSA_OPTION_ID_CREATE (M4_WRITE        , \
     90         M4WRITER_COMMON, 0x08),    /**< Maximum file size limitation */
     91     M4WRITER_kMaxFileDuration = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
     92          M4WRITER_COMMON, 0x09),    /**< Maximum file duration limitation */
     93     M4WRITER_kSetFtypBox      = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
     94          M4WRITER_COMMON, 0x0A),    /**< Set 'ftyp' atom */
     95     M4WRITER_kMetaData          = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
     96          M4WRITER_COMMON, 0x0B),    /**< Additionnal information to set in the file */
     97     M4WRITER_kDSI          = M4OSA_OPTION_ID_CREATE (M4_WRITE        , \
     98         M4WRITER_COMMON, 0x0C),    /**< To set DSI of the file (Decoder specifc info) */
     99     M4WRITER_kJpegReserveFPData     = M4OSA_OPTION_ID_CREATE (M4_WRITE        ,\
    100          M4WRITER_COMMON, 0x0D),    /**< Reserve some space in the file for JPEG fast
    101                                         processing data */
    102     M4WRITER_kJpegSetFPData     = M4OSA_OPTION_ID_CREATE (M4_WRITE        , \
    103         M4WRITER_COMMON, 0x0E),    /**< Write Fast Processing Data in the file*/
    104     /* + CRLV6775 -H.264 trimming */
    105     M4WRITER_kMUL_PPS_SPS       = M4OSA_OPTION_ID_CREATE (M4_WRITE        , M4WRITER_COMMON, 0x0F)
    106     /* - CRLV6775 -H.264 trimming */
    107 } M4WRITER_OptionID;
    108 
    109 
    110 /**
    111  ******************************************************************************
    112  * struct    M4WRITER_Header
    113  * @brief    This structure defines the buffer where an header is put.
    114  ******************************************************************************
    115 */
    116 typedef struct
    117 {
    118     M4OSA_MemAddr8    pBuf;        /**< Buffer for the header */
    119     M4OSA_UInt32    Size;        /**< Size of the data */
    120 } M4WRITER_Header;
    121 
    122 
    123 /**
    124  ******************************************************************************
    125  * struct    M4WRITER_StreamVideoInfos
    126  * @brief    This structure defines the specific video stream infos, extension to
    127  *           M4SYS_StreamDescription.
    128  ******************************************************************************
    129 */
    130 typedef struct {
    131     M4OSA_UInt32    height;                /**< Frame height */
    132     M4OSA_UInt32    width;                /**< Frame Width */
    133     M4OSA_Double    fps;                /**< Targetted framerate of the video */
    134     M4WRITER_Header    Header;                /**< Sequence header of the video stream,
    135                                         member set to NULL if no header present */
    136 } M4WRITER_StreamVideoInfos;
    137 
    138 
    139 /**
    140  ******************************************************************************
    141  * struct    M4WRITER_StreamAudioInfos
    142  * @brief    This structure defines the specific audio stream infos, extension to
    143              M4SYS_StreamDescription.
    144  ******************************************************************************
    145 */
    146 typedef struct {
    147     M4OSA_UInt32    nbSamplesPerSec;    /**< Number of Samples per second */
    148     M4OSA_UInt16    nbBitsPerSample;    /**< Number of Bits in 1 sample */
    149     M4OSA_UInt16    nbChannels;            /**< Number of channels */
    150     M4WRITER_Header    Header;                /**< Decoder Specific Info of the audiostream,
    151                                              member set to NULL if no DSI present */
    152 } M4WRITER_StreamAudioInfos;
    153 
    154 
    155 /**
    156  ******************************************************************************
    157  * enum        M4WRITER_Orientation
    158  * @brief    This enum defines the possible orientation of a frame as described
    159  *            in the EXIF standard.
    160  ******************************************************************************
    161 */
    162 typedef enum
    163 {
    164     M4WRITER_OrientationUnknown = 0,
    165     M4WRITER_OrientationTopLeft,
    166     M4WRITER_OrientationTopRight,
    167     M4WRITER_OrientationBottomRight,
    168     M4WRITER_OrientationBottomLeft,
    169     M4WRITER_OrientationLeftTop,
    170     M4WRITER_OrientationRightTop,
    171     M4WRITER_OrientationRightBottom,
    172     M4WRITER_OrientationLeftBottom
    173 }M4WRITER_Orientation ;
    174 
    175 /**
    176  ******************************************************************************
    177  * struct    M4WRITER_MetaData
    178  * @brief    This structure defines all the meta data to store in the encoded file.
    179  ******************************************************************************
    180 */
    181 typedef struct
    182 {
    183     M4OSA_Char*                Description ;
    184     M4OSA_Char*                PhoneManufacturer ;
    185     M4OSA_Char*                PhoneModel ;
    186     M4OSA_Char*                Artist ;
    187     M4OSA_Char*                Copyright ;
    188     M4OSA_Char*                Software ;
    189     M4OSA_Char*                CreationDate;
    190     M4WRITER_Orientation    Orientation ;
    191 
    192     M4OSA_UInt32            Width ;
    193     M4OSA_UInt32            Height ;
    194 
    195     M4OSA_UInt32            ThumbnailWidth ;
    196     M4OSA_UInt32            ThumbnailHeight ;
    197     M4OSA_Bool                ThumbnailPresence ;
    198 }M4WRITER_MetaData;
    199 
    200 
    201 typedef void* M4WRITER_Context;
    202 
    203 typedef M4OSA_ERR (M4WRITER_openWrite)        (M4WRITER_Context* hContext,\
    204                                              void* outputFileDescriptor,\
    205                                              M4OSA_FileWriterPointer* pFileWriterPointer,\
    206                                              void* tempFileDescriptor, \
    207                                              M4OSA_FileReadPointer* pFileReaderPointer);
    208 typedef M4OSA_ERR (M4WRITER_addStream)        (M4WRITER_Context  pContext,\
    209                                             M4SYS_StreamDescription*streamDescription);
    210 typedef M4OSA_ERR (M4WRITER_startWriting)    (M4WRITER_Context  pContext);
    211 typedef M4OSA_ERR (M4WRITER_closeWrite)        (M4WRITER_Context  pContext);
    212 typedef M4OSA_ERR (M4WRITER_setOption)        (M4WRITER_Context  pContext, \
    213                                             M4OSA_UInt32 optionID, \
    214                                             M4OSA_DataOption optionValue);
    215 typedef M4OSA_ERR (M4WRITER_getOption)        (M4WRITER_Context  pContext, \
    216                                             M4OSA_UInt32 optionID, \
    217                                             M4OSA_DataOption optionValue);
    218 
    219 
    220 /**
    221  ******************************************************************************
    222  * struct    M4WRITER_GlobalInterface
    223  * @brief    Defines all the functions required for a writer shell.
    224  ******************************************************************************
    225 */
    226 typedef struct _M4WRITER_GlobalInterface
    227 {
    228     M4WRITER_openWrite*             pFctOpen;
    229     M4WRITER_addStream*                pFctAddStream;
    230     M4WRITER_startWriting*          pFctStartWriting;
    231     M4WRITER_closeWrite*            pFctCloseWrite;
    232     M4WRITER_setOption*                pFctSetOption;
    233     M4WRITER_getOption*                pFctGetOption;
    234 } M4WRITER_GlobalInterface;
    235 
    236 typedef M4OSA_ERR  M4WRITER_startAU(M4WRITER_Context pContext, M4SYS_StreamID streamID,\
    237                                      M4SYS_AccessUnit* pAU);
    238 typedef M4OSA_ERR  M4WRITER_processAU(M4WRITER_Context pContext, M4SYS_StreamID streamID,\
    239                                      M4SYS_AccessUnit* pAU);
    240 
    241 /**
    242  ******************************************************************************
    243  * struct    M4WRITER_DataInterface
    244  * @brief    Defines all the functions required to write data with a writer shell.
    245  ******************************************************************************
    246 */
    247 typedef struct _M4WRITER_DataInterface
    248 {
    249     M4WRITER_startAU*    pStartAU;
    250     M4WRITER_processAU* pProcessAU;
    251 
    252     M4WRITER_Context    pWriterContext;
    253 
    254 } M4WRITER_DataInterface;
    255 
    256 #ifdef __cplusplus
    257 }
    258 #endif /* __cplusplus */
    259 
    260 #endif /*__M4WRITER_COMMON_H__*/
    261 
    262