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