summaryrefslogtreecommitdiffstats
path: root/libvideoeditor/vss/common/inc/M4MDP_API.h
blob: 1000cd8412aa6f686d37684051ef2b759a099f38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
 * Copyright (C) 2004-2011 NXP Software
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
*************************************************************************
 * @file   M4MDP_API.h
 * @brief  Parser of metadata
 *
*************************************************************************
*/

#ifndef __M4MDP_API_H__
#define __M4MDP_API_H__

#ifdef __cplusplus
extern "C" {
#endif

#define MD4MDP_close M4MDP_close

#include "M4READER_Common.h"
#include "M4TOOL_VersionInfo.h"
#include "M4OSA_FileReader.h"
#include "M4OSA_FileWriter.h"

/*define the buffer size for content detection*/
#define M4MDP_INPUT_BUFFER_SIZE    8192

/**
 ************************************************************************
 * Public type of the M4MDP_osaFilePtrSt
 ************************************************************************
*/
typedef struct
{
    M4OSA_FileReadPointer*     m_pFileReaderFcts;
    M4OSA_FileWriterPointer* m_pFileWriterFcts;
} M4MDP_osaFilePtrSt;

/**
 ************************************************************************
 * Public type of the MDP execution context
 ************************************************************************
*/
typedef M4OSA_Void* M4MDP_Context;

/**
 ************************************************************************
 * Metadata Parser Errors & Warnings definition
 ************************************************************************
*/
#define M4WAR_MDP_MEDIATYPE_NOT_DETECTED        M4OSA_ERR_CREATE(M4_WAR, M4MDP, 0x000001)

#define    M4ERR_MDP_FATAL                            M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000000)
#define    M4ERR_MDP_UNSUPPORTED_TAG_VERSION        M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000001)
#define    M4ERR_MDP_UNSUPPORTED_ENCODING_TYPE        M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000002)
#define    M4ERR_MDP_INIT_FAILED                    M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000003)
#define    M4ERR_MDP_ASSET_PARSING_ERROR            M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000004)
#define M4ERR_MDP_FILE_NOT_FOUND                M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000005)
#define M4ERR_MDP_INVALID_PATH                    M4OSA_ERR_CREATE(M4_ERR, M4MDP, 0x000006)

/**
 ************************************************************************
 * Metadata parser FUNCTIONS
 ************************************************************************
*/

/**
 ************************************************************************
 * @brief    Getting the version of the metadata parser
 *            This function allows getting the version of the MDP library.
 *
 * @param    pVersionInfo    (OUT) Pointer on an allocated version info structure
 *                            After M4MDP_getVersion() successfully returns, this
 *                            structure is filled with the version numbers.
 *                            The structure must be allocated and further de-allocated
 *                            by the application.
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pVersionInfo is null (in DEBUG only)
 ************************************************************************
*/
M4OSA_ERR  M4MDP_getVersion(M4_VersionInfo* pVersionInfo);


/**
 ************************************************************************
 * @brief    Initializing the MDP
 *            This function initializes the MDP and allocates the MDP execution
 *            context and parses the metadata
 * @note    This function allocates the memory needed to store metadata in
 *            TAG ID3 V1&V2, ASF or 3gpp asset structure with the OSAL allocation
 *            function.
 *            This memory will be freed in M4MDP_cleanUp function
 *
 * @note    This function is synchronous.
 *
 * @param    pContext        (OUT)    Execution Context
 * @param    pFilePath        (IN)    Pointer to the multimedia file path
 * @param    pFileReaderFcts    (IN)    Pointer to a structure containing OSAL file reader
 *                                       functions pointers
 *
 * @return    M4NO_ERROR                        No error
 * @return    M4ERR_PARAMETER                    At least, one parameter is null (in DEBUG only)
 * @return    M4ERR_ALLOC                        There is no more memory available
 * @return    M4WAR_READER_NO_METADATA        The input file doesn't contain metadata
 * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE    The input file is not recognized
 ************************************************************************
*/
M4OSA_ERR M4MDP_init(M4MDP_Context* pContext, M4OSA_Char* pFilePath,
                      M4OSA_FileReadPointer*    pFileReaderFcts);

/**
 ************************************************************************
 * @brief    This function frees the MDP execution context and all metadata
 *            structures already allocated by M4MDP_init
 *
 * @note    This function is synchronous.
 *
 * @param    pContext                (IN) Execution Context
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext is NULL. (in DEBUG only)
************************************************************************
*/
M4OSA_ERR M4MDP_cleanUp(M4MDP_Context pContext);

/**
 ************************************************************************
 * @brief    This function Initializes the meta data parser only once to check several files one
 *            after another.
 *
 * @note    This function is synchronous.
 *
 * @param    pContext                (IN) Execution Context
  * @param    pFileReaderFcts    (IN)    Pointer to a structure containing OSAL file reader
  *                                          functions pointers
*
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext is NULL. (in DEBUG only)
************************************************************************
*/
M4OSA_ERR M4MDP_globalInit(M4MDP_Context* pContext, M4OSA_FileReadPointer*    pFileReaderFcts);

/**
 ************************************************************************
 * @brief    This function opens a file in the meta data parser
 *
 * @note    This function is synchronous.
 *
 * @param    pContext                (IN) Execution Context
 * @param    pFilePath        (IN)    Pointer to the multimedia file path
  *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext is NULL. (in DEBUG only)
************************************************************************
*/
M4OSA_ERR M4MDP_open(M4MDP_Context* pContext, M4OSA_Char* pFilePath);

/**
 ************************************************************************
 * @brief    This function closes a file in the meta data parser
 *
 * @note    This function is synchronous.
 *
 * @param    pContext                (IN) Execution Context
  *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext is NULL. (in DEBUG only)
************************************************************************
*/
M4OSA_ERR M4MDP_close(M4MDP_Context* pContext);


/**
 ************************************************************************
 * @brief    The function allows the retrieval of all fields of the
 *            M4_MetaDataFields structure
 *            It basically sets M4_MetaDataFields structure fields pointers to
 *            the corresponding already retrieved metadata
 *
 * @note    If metadata are retrieved from an MP3 or an AAC files, and both
 *            TAG ID3 V1 and V2 are present, then, priority is for metadata of TAG ID3 V2
 *
 * @note    This function is synchronous.
 * @note    This function is used specially by the music manager project
 *
 * @param    pContext        (IN) Execution Context
 * @param    pMetadata        (OUT) Pointer to M4_MetaDataFields structure
 *
 * @return    M4NO_ERROR                        No error
 * @return    M4ERR_PARAMETER                    pContext or pMetadata is NULL. (in DEBUG only)
 * @return    M4WAR_READER_NO_METADATA        The input file doesn't contain metadata
 ************************************************************************
*/
M4OSA_ERR M4MDP_getMetadata(M4MDP_Context pContext, M4_MetaDataFields* pMetadata);

/**
 ************************************************************************
 * @brief    This function returns the audio and video media type
 *
 * @note    This function is synchronous.
 * @note    This function is used specially by the music manager project
 *
 * @param    pContext        (IN)    Execution Context
 * @param    pAudio            (OUT)    Audio media type pointer
 * @param    pVideo            (OUT)    Video media type pointer
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        At least one parameter is NULL. (in DEBUG only)
 ************************************************************************
*/
M4OSA_ERR M4MDP_getStreamsType(M4MDP_Context pContext,M4_StreamType* pAudio,M4_StreamType* pVideo);


/**
 ************************************************************************
 * @brief    This function returns the mediaType
 *
 * @note    This function is synchronous.
 * @note    This function is used specially by the music manager project
 *
 * @param    pContext        (IN)    Execution Context
 * @param    pMediaType        (OUT)    MediaType pointer
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        At least one parameter is NULL. (in DEBUG only)
 ************************************************************************
*/
M4OSA_ERR M4MDP_getMediaType(M4MDP_Context pContext,M4READER_MediaType* pMediaType);

/******************************************************************************
* @brief        returns mediaType found in a file
* @note
* @param        pFileDescriptor (IN) : pointer to file descriptor
* @param        pFileFunction (IN)   : pointer to file function
* @param        pMediaType (OUT)     : mediaType if found
* @return       M4NO_ERROR / M4ERR_ALLOC
******************************************************************************/
M4OSA_ERR M4MDP_getMediaTypeFromFile(M4OSA_Void *pFileDescriptor,
                                       M4OSA_FileReadPointer *pFileFunction,
                                       M4READER_MediaType *pMediaType);

/******************************************************************************
* @brief        return media type by extension and content detections
* @note
* @param        pFileDescriptor (IN) : pointer to file descriptor
* @param        dataBuffer (IN)  : memory buffer
* @param        bufferSize (IN)  : buffer size
* @param        pMediaType (OUT) : mediaType if found
* @return       M4NO_ERROR / M4ERR_ALLOC
******************************************************************************/
M4OSA_ERR    M4MDP_getMediaTypeFromExtensionAndContent(M4OSA_Void *pFileDescriptor,
                                                        M4OSA_UInt8 *dataBuffer,
                                                        M4OSA_UInt32 bufferSize,
                                                        M4READER_MediaType *pMediaType);

/******************************************************************************
* @brief        return media type by content detection
* @note
* @param        dataBuffer (IN)  : memory buffer
* @param        bufferSize (IN)  : buffer size
* @param        pMediaType (OUT) : mediaType if found
* @return       M4NO_ERROR / M4ERR_ALLOC
******************************************************************************/
M4OSA_ERR    M4MDP_getMediaTypeFromContent(M4OSA_UInt8 *dataBuffer, M4OSA_UInt32 bufferSize,
                                             M4READER_MediaType *pMediaType);

/**
 ************************************************************************
 * @brief    The function parses the buffer pAsfBuffer, extracts metadata,
 *            allocates memory for pMetaData and fills in.
 *
 * @note    pAsfBuffer owns the application (caller).
 *            The application free pAsfBuffer and pMetaData
 *
 * @note    This function is synchronous.
 *
 * @param    pAsfBuffer            (IN)    input buffer
 * @param    pMetaData            (OUT)    Pointer to the metadata structure
 *
 * @return    M4NO_ERROR                        No error
 * @return    M4ERR_PARAMETER                    pContext or pAsfBuffer is NULL. (in DEBUG only)
 * @return    M4ERR_ALLOC                        There is no more memory available
 * @return    M4WAR_READER_NO_METADATA        The M4READER_Buffer doesn't contain metadata
 * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE    The input file is not recognized
 ************************************************************************
*/
M4OSA_ERR M4MDP_parseASFContentDesc(M4READER_Buffer* pAsfBuffer, M4_MetaDataFields *pMetaData);


/**
 ************************************************************************
 * @brief    The function allocates memory for pMetaData and copies its
 *            pAssetFields fields
 *
 * @note    The application which calls M4MDP_parse3GppAssetField MUST free pMetaData.
 *
 * @note    This function is synchronous.
 *
 * @param    pAssetFields    (IN)    Asset fields structure filled by the 3gpp reader
 * @param    pMetaData        (OUT)    Metadata structure to be filled in
 *
 * @return    M4NO_ERROR                        No error
 * @return    M4ERR_PARAMETER                    pContext or pAssetFields is NULL. (in DEBUG only)
 * @return    M4ERR_ALLOC                        There is no more memory available
 * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE    The input file is not recognized
 ************************************************************************
*/
M4OSA_ERR M4MDP_parse3GppAssetField(M4_MetaDataFields* pAssetFields, M4_MetaDataFields *pMetaData);


/**
 ************************************************************************
 * @brief    The function allocates memory for pMetaData and copies its
 *            pExifFields fields
 *
 * @note    The application which calls M4MDP_parseExifField MUST free pMetaData.
 *
 * @note    This function is synchronous.
 *
 * @param    pExifFields    (IN)    Exif fields structure filled by the exif reader
 * @param    pMetaData    (OUT)    Metadata structure to be filled in
 *
 * @return    M4NO_ERROR                        No error
 * @return    M4ERR_PARAMETER                    pContext or pAssetFields is NULL. (in DEBUG only)
 * @return    M4ERR_ALLOC                        There is no more memory available
 * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE    The input file is not recognized
 ************************************************************************
*/
M4OSA_ERR M4MDP_parseExifField(M4_MetaDataFields *pExifFields, M4_MetaDataFields *pMetaData);


/**
 ************************************************************************
 * @brief    The function allocates and fills the pMetaDataStruct by parsing
 *            a buffer
 *
 * @note    pMetaDataStruct owns the application (caller).
 *            It is the responsibility of the application (caller) to free it
 *
 * @note    This function is synchronous.
 *
 * @param        pBuffer            (IN)    input buffer
 * @param        mediaType        (IN)    media type of the buffer
 * @param        pMetaDataStruct    (OUT)    Pointer to an array of metadata
 * @param        pSize            (OUT)    pMetaDataStruct size
 *
 * @return    M4NO_ERROR                    No error
 * @return    M4ERR_PARAMETER                pContext or pBuffer or pMetaDataStruct is NULL.
 *                                          (in DEBUG only)
 * @return    M4ERR_ALLOC                    There is no more memory available
 * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE The media type is not supported
 * @return    M4WAR_READER_NO_METADATA    No metadata detected
 ************************************************************************
*/
M4OSA_ERR M4MDP_getMetaDataFromBuffer(M4_MetadataBuffer*    pBuffer,
                                      M4READER_MediaType    mediaType,
                                      M4_MetaDataFields**    pMetaDataStruct,
                                      M4OSA_UInt32*            pSize);

/**
 ************************************************************************
 * @brief    The function initializes the metadata  structure
 *
 * @param    pMetadata        (OUT) Pointer to M4_MetaDataFields structure
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext or pMetadata is NULL. (in DEBUG only)
 ************************************************************************
*/
M4OSA_ERR M4MDP_InitMetaDataFields(M4_MetaDataFields *pMetaDataTab);

/**
 ************************************************************************
 * @brief    The function frees the metadata  structure
 *
 * @param    pMetadata        (IN) Pointer to M4_MetaDataFields structure
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext or pMetadata is NULL. (in DEBUG only)
 ************************************************************************
*/
M4OSA_ERR M4MDP_FreeMetaDataFields(M4_MetaDataFields *pMetaDataTab);

/******************************************************************************
* @brief        returns mediaType found in a file
* @note
* @param        pContext (IN) : pointer to file descriptor
* @param        pFileDescriptor (IN) : pointer to file descriptor
* @param        pFileFunction (IN)   : pointer to file function
* @param        pMediaType (OUT)     : mediaType if found
* @return       M4NO_ERROR / M4ERR_ALLOC
******************************************************************************/
M4OSA_ERR M4MDP_getMediaTypeFromFileExtended(    M4MDP_Context pContext,
                                                M4OSA_Void *pFileDescriptor,
                                                M4OSA_FileReadPointer *pFileFunction,
                                                M4READER_MediaType *pMediaType);

/**
 ************************************************************************
 * @brief    The function to get file size
 *
 * @param    pContext        (IN) Pointer to M4MDP Context structure
 * @param    pSize            (OUT)Pointer to file size
 *
 * @return    M4NO_ERROR            No error
 * @return    M4ERR_PARAMETER        pContext or pMetadata is NULL. (in DEBUG only)
 ************************************************************************
*/
M4OSA_ERR M4MDP_getMetaDataFileSize(M4MDP_Context pContext, M4OSA_UInt32 *pSize);

#ifdef __cplusplus
}
#endif

#endif /* __M4MDP_API_H__ */