Correct license information
[platform/adaptation/broadcom/libomxil-vc4.git] / interface / mmal / mmal_metadata.h
1 /*
2 Copyright (c) 2012, Broadcom Europe Ltd
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7     * Redistributions of source code must retain the above copyright
8       notice, this list of conditions and the following disclaimer.
9     * Redistributions in binary form must reproduce the above copyright
10       notice, this list of conditions and the following disclaimer in the
11       documentation and/or other materials provided with the distribution.
12     * Neither the name of the copyright holder nor the
13       names of its contributors may be used to endorse or promote products
14       derived from this software without specific prior written permission.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef MMAL_METADATA_H
29 #define MMAL_METADATA_H
30
31 #include "mmal_common.h"
32
33 /** \defgroup MmalMetadata List of pre-defined metadata types
34  * This defines a list of standard metadata types. Components can still define proprietary
35  * metadata types by using their own FourCC and defining their own metadata structures. */
36 /* @{ */
37
38 /** \name Pre-defined metadata FourCCs */
39 /* @{ */
40 #define MMAL_METADATA_HELLO_WORLD             MMAL_FOURCC('H','E','L','O')
41 /* @} */
42
43 /** Generic metadata type. All metadata structures need to begin with these fields. */
44 typedef struct MMAL_METATDATA_T
45 {
46    uint32_t id;    /**< Metadata id. This is a FourCC */
47    uint32_t size;  /**< Size in bytes of the following metadata (not including id and size) */
48 } MMAL_METADATA_T;
49
50 /** Hello World metadata. */
51 typedef struct MMAL_METATDATA_HELLO_WORLD_T
52 {
53    uint32_t id;    /**< Metadata id. This is a FourCC */
54    uint32_t size;  /**< Size in bytes of the following metadata (not including id and size) */
55
56    uint32_t myvalue; /**< Metadata value */
57 } MMAL_METADATA_HELLO_WORLD_T;
58
59 /** Get metadata item from buffer header.
60  * This will search through all the metadata in the buffer header and return a pointer to the
61  * first instance of the requested metadata id.
62  *
63  * @param header buffer header containing the metadata
64  * @param id     requested metadata id
65  *
66  * @return Pointer to metadata requested or NULL if not found.
67  */
68 MMAL_METADATA_T *mmal_metadata_get(MMAL_BUFFER_HEADER_T *header, uint32_t id);
69
70 /** Set metadata item in buffer header.
71  * This will store the metadata item into the buffer header. This operation can fail if not
72  * enough memory is available in the data section of the buffer header.
73  *
74  * @param header   buffer header to store the metadata into
75  * @param metadata metadata item to store in buffer header
76  *
77  * @return MMAL_SUCCESS on success or MMAL_ENOMEM if not enough memory is available for storing
78  * the metadata
79  */
80 MMAL_STATUS_T mmal_metadata_set(MMAL_BUFFER_HEADER_T *header, MMAL_METADATA_T *metadata);
81
82 /* @} */
83
84 #endif /* MMAL_METADATA_H */