+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* Simple Plugin API */ |
| 2 | /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ |
| 3 | /* SPDX-License-Identifier: MIT */ |
| 4 | |
| 5 | #ifndef SPA_META_H |
| 6 | #define SPA_META_H |
| 7 | |
| 8 | #include <spa/utils/defs.h> |
| 9 | #include <spa/pod/pod.h> |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | #ifndef SPA_API_META |
| 16 | #ifdef SPA_API_IMPL |
| 17 | #define SPA_API_META SPA_API_IMPL |
| 18 | #else |
| 19 | #define SPA_API_META static inline |
| 20 | #endif |
| 21 | #endif |
| 22 | |
| 23 | /** |
| 24 | * \addtogroup spa_buffer |
| 25 | * \{ |
| 26 | */ |
| 27 | |
| 28 | enum spa_meta_type { |
| 29 | SPA_META_Invalid, |
| 30 | SPA_META_Header, /**< struct spa_meta_header */ |
| 31 | SPA_META_VideoCrop, /**< struct spa_meta_region with cropping data */ |
| 32 | SPA_META_VideoDamage, /**< array of struct spa_meta_region with damage, where an invalid entry or end-of-array marks the end. */ |
| 33 | SPA_META_Bitmap, /**< struct spa_meta_bitmap */ |
| 34 | SPA_META_Cursor, /**< struct spa_meta_cursor */ |
| 35 | SPA_META_Control, /**< metadata contains a spa_meta_control |
| 36 | * associated with the data */ |
| 37 | SPA_META_Busy, /**< don't write to buffer when count > 0 */ |
| 38 | SPA_META_VideoTransform, /**< struct spa_meta_transform */ |
| 39 | SPA_META_SyncTimeline, /**< struct spa_meta_sync_timeline */ |
| 40 | _SPA_META_LAST, /**< not part of ABI/API */ |
| 41 | |
| 42 | SPA_META_START_custom = 0x200, |
| 43 | |
| 44 | SPA_META_START_features = 0x10000, /* features start, these have 0 size, the |
| 45 | * type in the upper 16 bits and a bitmask in |
| 46 | * the lower 16 bits with type specific features. */ |
| 47 | }; |
| 48 | |
| 49 | #define SPA_META_TYPE_FEATURES(type,features) (((type)<<16)|(features)) |
| 50 | |
| 51 | /** |
| 52 | * A metadata element. |
| 53 | * |
| 54 | * This structure is available on the buffer structure and contains |
| 55 | * the type of the metadata and a pointer/size to the actual metadata |
| 56 | * itself. |
| 57 | */ |
| 58 | struct spa_meta { |
| 59 | uint32_t type; /**< metadata type, one of enum spa_meta_type */ |
| 60 | uint32_t size; /**< size of metadata */ |
| 61 | void *data; /**< pointer to metadata */ |
| 62 | }; |
| 63 | |
| 64 | SPA_API_META void *spa_meta_first(const struct spa_meta *m) { |
| 65 | return m->data; |
| 66 | } |
| 67 | |
| 68 | SPA_API_META void *spa_meta_end(const struct spa_meta *m) { |
| 69 | return SPA_PTROFF(m->data,m->size,void); |
| 70 | } |
| 71 | #define spa_meta_check(p,m) (SPA_PTROFF(p,sizeof(*(p)),void) <= spa_meta_end(m)) |
| 72 | |
| 73 | /** |
| 74 | * Describes essential buffer header metadata such as flags and |
| 75 | * timestamps. |
| 76 | */ |
| 77 | struct spa_meta_header { |
| 78 | #define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /**< data is not continuous with previous buffer */ |
| 79 | #define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /**< data might be corrupted */ |
| 80 | #define SPA_META_HEADER_FLAG_MARKER (1 << 2) /**< media specific marker */ |
| 81 | #define SPA_META_HEADER_FLAG_HEADER (1 << 3) /**< data contains a codec specific header */ |
| 82 | #define SPA_META_HEADER_FLAG_GAP (1 << 4) /**< data contains media neutral data */ |
| 83 | #define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /**< cannot be decoded independently */ |
| 84 | uint32_t flags; /**< flags */ |
| 85 | uint32_t offset; /**< offset in current cycle */ |
| 86 | int64_t pts; /**< presentation timestamp in nanoseconds */ |
| 87 | int64_t dts_offset; /**< decoding timestamp as a difference with pts */ |
| 88 | uint64_t seq; /**< sequence number, increments with a |
| 89 | * media specific frequency */ |
| 90 | }; |
| 91 | |
| 92 | /** metadata structure for Region or an array of these for RegionArray */ |
| 93 | struct spa_meta_region { |
| 94 | struct spa_region region; |
| 95 | }; |
| 96 | |
| 97 | SPA_API_META bool spa_meta_region_is_valid(const struct spa_meta_region *m) { |
| 98 | return m->region.size.width != 0 && m->region.size.height != 0; |
| 99 | } |
| 100 | |
| 101 | /** iterate all the items in a metadata */ |
| 102 | #define spa_meta_for_each(pos,meta) \ |
| 103 | for ((pos) = (__typeof(pos))spa_meta_first(meta); \ |
| 104 | spa_meta_check(pos, meta); \ |
| 105 | (pos)++) |
| 106 | |
| 107 | /** |
| 108 | * Bitmap information |
| 109 | * |
| 110 | * This metadata contains a bitmap image in the given format and size. |
| 111 | * It is typically used for cursor images or other small images that are |
| 112 | * better transferred inline. |
| 113 | */ |
| 114 | struct spa_meta_bitmap { |
| 115 | uint32_t format; /**< bitmap video format, one of enum spa_video_format. 0 is |
| 116 | * and invalid format and should be handled as if there is |
| 117 | * no new bitmap information. */ |
| 118 | struct spa_rectangle size; /**< width and height of bitmap */ |
| 119 | int32_t stride; /**< stride of bitmap data */ |
| 120 | uint32_t offset; /**< offset of bitmap data in this structure. An offset of |
| 121 | * 0 means no image data (invisible), an offset >= |
| 122 | * sizeof(struct spa_meta_bitmap) contains valid bitmap |
| 123 | * info. */ |
| 124 | }; |
| 125 | |
| 126 | SPA_API_META bool spa_meta_bitmap_is_valid(const struct spa_meta_bitmap *m) { |
| 127 | return m->format != 0; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Cursor information |
| 132 | * |
| 133 | * Metadata to describe the position and appearance of a pointing device. |
| 134 | */ |
| 135 | struct spa_meta_cursor { |
| 136 | uint32_t id; /**< cursor id. an id of 0 is an invalid id and means that |
| 137 | * there is no new cursor data */ |
| 138 | uint32_t flags; /**< extra flags */ |
| 139 | struct spa_point position; /**< position on screen */ |
| 140 | struct spa_point hotspot; /**< offsets for hotspot in bitmap, this field has no meaning |
| 141 | * when there is no valid bitmap (see below) */ |
| 142 | uint32_t bitmap_offset; /**< offset of bitmap meta in this structure. When the offset |
| 143 | * is 0, there is no new bitmap information. When the offset is |
| 144 | * >= sizeof(struct spa_meta_cursor) there is a |
| 145 | * struct spa_meta_bitmap at the offset. */ |
| 146 | }; |
| 147 | |
| 148 | SPA_API_META bool spa_meta_cursor_is_valid(const struct spa_meta_cursor *m) { |
| 149 | return m->id != 0; |
| 150 | } |
| 151 | |
| 152 | /** a timed set of events associated with the buffer */ |
| 153 | struct spa_meta_control { |
| 154 | struct spa_pod_sequence sequence; |
| 155 | }; |
| 156 | |
| 157 | /** a busy counter for the buffer */ |
| 158 | struct spa_meta_busy { |
| 159 | uint32_t flags; |
| 160 | uint32_t count; /**< number of users busy with the buffer */ |
| 161 | }; |
| 162 | |
| 163 | enum spa_meta_videotransform_value { |
| 164 | SPA_META_TRANSFORMATION_None = 0, /**< no transform */ |
| 165 | SPA_META_TRANSFORMATION_90, /**< 90 degree counter-clockwise */ |
| 166 | SPA_META_TRANSFORMATION_180, /**< 180 degree counter-clockwise */ |
| 167 | SPA_META_TRANSFORMATION_270, /**< 270 degree counter-clockwise */ |
| 168 | SPA_META_TRANSFORMATION_Flipped, /**< 180 degree flipped around the vertical axis. Equivalent |
| 169 | * to a reflexion through the vertical line splitting the |
| 170 | * buffer in two equal sized parts */ |
| 171 | SPA_META_TRANSFORMATION_Flipped90, /**< flip then rotate around 90 degree counter-clockwise */ |
| 172 | SPA_META_TRANSFORMATION_Flipped180, /**< flip then rotate around 180 degree counter-clockwise */ |
| 173 | SPA_META_TRANSFORMATION_Flipped270, /**< flip then rotate around 270 degree counter-clockwise */ |
| 174 | }; |
| 175 | |
| 176 | /** a transformation of the buffer */ |
| 177 | struct spa_meta_videotransform { |
| 178 | uint32_t transform; /**< orientation transformation that was applied to the buffer, |
| 179 | * one of enum spa_meta_videotransform_value */ |
| 180 | }; |
| 181 | |
| 182 | /** |
| 183 | * A timeline point for explicit sync |
| 184 | * |
| 185 | * Metadata to describe the time on the timeline when the buffer |
| 186 | * can be acquired and when it can be reused. |
| 187 | * |
| 188 | * This metadata will require negotiation of 2 extra fds for the acquire |
| 189 | * and release timelines respectively. One way to achieve this is to place |
| 190 | * this metadata as SPA_PARAM_BUFFERS_metaType when negotiating a buffer |
| 191 | * layout with 2 extra fds. |
| 192 | */ |
| 193 | #define SPA_META_FEATURE_SYNC_TIMELINE_RELEASE (1<<0) /**< metadata supports RELEASE */ |
| 194 | |
| 195 | struct spa_meta_sync_timeline { |
| 196 | #define SPA_META_SYNC_TIMELINE_UNSCHEDULED_RELEASE (1<<0) /**< this flag is set by the producer and cleared |
| 197 | * by the consumer when it promises to signal |
| 198 | * the release point */ |
| 199 | uint32_t flags; |
| 200 | uint32_t padding; |
| 201 | uint64_t acquire_point; /**< the timeline acquire point, this is when the data |
| 202 | * can be accessed. */ |
| 203 | uint64_t release_point; /**< the timeline release point, this timeline point should |
| 204 | * be signaled when the data is no longer accessed. */ |
| 205 | }; |
| 206 | |
| 207 | /** |
| 208 | * \} |
| 209 | */ |
| 210 | |
| 211 | #ifdef __cplusplus |
| 212 | } /* extern "C" */ |
| 213 | #endif |
| 214 | |
| 215 | #endif /* SPA_META_H */ |