| 1 |
/* Simple Plugin API |
| 2 |
* |
| 3 |
* Copyright © 2018 Wim Taymans |
| 4 |
* |
| 5 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 6 |
* copy of this software and associated documentation files (the "Software"), |
| 7 |
* to deal in the Software without restriction, including without limitation |
| 8 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following conditions: |
| 11 |
* |
| 12 |
* The above copyright notice and this permission notice (including the next |
| 13 |
* paragraph) shall be included in all copies or substantial portions of the |
| 14 |
* Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 |
* DEALINGS IN THE SOFTWARE. |
| 23 |
*/ |
| 24 |
|
| 25 |
#ifndef SPA_META_H |
| 26 |
#define SPA_META_H |
| 27 |
|
| 28 |
#ifdef __cplusplus |
| 29 |
extern "C" { |
| 30 |
#endif |
| 31 |
|
| 32 |
#include <spa/utils/defs.h> |
| 33 |
#include <spa/pod/pod.h> |
| 34 |
|
| 35 |
/** \page page_meta Metadata |
| 36 |
* |
| 37 |
* Metadata contains extra information on a buffer. |
| 38 |
*/ |
| 39 |
enum spa_meta_type { |
| 40 |
SPA_META_Invalid, |
| 41 |
SPA_META_Header, /**< struct spa_meta_header */ |
| 42 |
SPA_META_VideoCrop, /**< struct spa_meta_region with cropping data */ |
| 43 |
SPA_META_VideoDamage, /**< array of struct spa_meta_region with damage */ |
| 44 |
SPA_META_Bitmap, /**< struct spa_meta_bitmap */ |
| 45 |
SPA_META_Cursor, /**< struct spa_meta_cursor */ |
| 46 |
SPA_META_Control, /**< metadata contains a spa_meta_control |
| 47 |
* associated with the data */ |
| 48 |
SPA_META_Busy, /**< don't write to buffer when count > 0 */ |
| 49 |
|
| 50 |
SPA_META_LAST, /**< not part of ABI/API */ |
| 51 |
}; |
| 52 |
|
| 53 |
/** |
| 54 |
* A metadata element. |
| 55 |
* |
| 56 |
* This structure is available on the buffer structure and contains |
| 57 |
* the type of the metadata and a pointer/size to the actual metadata |
| 58 |
* itself. |
| 59 |
*/ |
| 60 |
struct spa_meta { |
| 61 |
uint32_t type; /**< metadata type, one of enum spa_meta_type */ |
| 62 |
uint32_t size; /**< size of metadata */ |
| 63 |
void *data; /**< pointer to metadata */ |
| 64 |
}; |
| 65 |
|
| 66 |
#define spa_meta_first(m) ((m)->data) |
| 67 |
#define spa_meta_end(m) SPA_PTROFF((m)->data,(m)->size,void) |
| 68 |
#define spa_meta_check(p,m) (SPA_PTROFF(p,sizeof(*p),void) <= spa_meta_end(m)) |
| 69 |
|
| 70 |
/** |
| 71 |
* Describes essential buffer header metadata such as flags and |
| 72 |
* timestamps. |
| 73 |
*/ |
| 74 |
struct spa_meta_header { |
| 75 |
#define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /**< data is not continuous with previous buffer */ |
| 76 |
#define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /**< data might be corrupted */ |
| 77 |
#define SPA_META_HEADER_FLAG_MARKER (1 << 2) /**< media specific marker */ |
| 78 |
#define SPA_META_HEADER_FLAG_HEADER (1 << 3) /**< data contains a codec specific header */ |
| 79 |
#define SPA_META_HEADER_FLAG_GAP (1 << 4) /**< data contains media neutral data */ |
| 80 |
#define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /**< cannot be decoded independently */ |
| 81 |
uint32_t flags; /**< flags */ |
| 82 |
uint32_t offset; /**< offset in current cycle */ |
| 83 |
int64_t pts; /**< presentation timestamp */ |
| 84 |
int64_t dts_offset; /**< decoding timestamp as a difference with pts */ |
| 85 |
uint64_t seq; /**< sequence number, increments with a |
| 86 |
* media specific frequency */ |
| 87 |
}; |
| 88 |
|
| 89 |
/** metadata structure for Region or an array of these for RegionArray */ |
| 90 |
struct spa_meta_region { |
| 91 |
struct spa_region region; |
| 92 |
}; |
| 93 |
|
| 94 |
#define spa_meta_region_is_valid(m) ((m)->region.size.width != 0 && (m)->region.size.height != 0) |
| 95 |
|
| 96 |
/** iterate all the items in a metadata */ |
| 97 |
#define spa_meta_for_each(pos,meta) \ |
| 98 |
for (pos = (__typeof(pos))spa_meta_first(meta); \ |
| 99 |
spa_meta_check(pos, meta); \ |
| 100 |
(pos)++) |
| 101 |
|
| 102 |
#define spa_meta_bitmap_is_valid(m) ((m)->format != 0) |
| 103 |
|
| 104 |
/** |
| 105 |
* Bitmap information |
| 106 |
* |
| 107 |
* This metadata contains a bitmap image in the given format and size. |
| 108 |
* It is typically used for cursor images or other small images that are |
| 109 |
* better transferred inline. |
| 110 |
*/ |
| 111 |
struct spa_meta_bitmap { |
| 112 |
uint32_t format; /**< bitmap video format, one of enum spa_video_format. 0 is |
| 113 |
* and invalid format and should be handled as if there is |
| 114 |
* no new bitmap information. */ |
| 115 |
struct spa_rectangle size; /**< width and height of bitmap */ |
| 116 |
int32_t stride; /**< stride of bitmap data */ |
| 117 |
uint32_t offset; /**< offset of bitmap data in this structure. An offset of |
| 118 |
* 0 means no image data (invisible), an offset >= |
| 119 |
* sizeof(struct spa_meta_bitmap) contains valid bitmap |
| 120 |
* info. */ |
| 121 |
}; |
| 122 |
|
| 123 |
#define spa_meta_cursor_is_valid(m) ((m)->id != 0) |
| 124 |
|
| 125 |
/** |
| 126 |
* Cursor information |
| 127 |
* |
| 128 |
* Metadata to describe the position and appearance of a pointing device. |
| 129 |
*/ |
| 130 |
struct spa_meta_cursor { |
| 131 |
uint32_t id; /**< cursor id. an id of 0 is an invalid id and means that |
| 132 |
* there is no new cursor data */ |
| 133 |
uint32_t flags; /**< extra flags */ |
| 134 |
struct spa_point position; /**< position on screen */ |
| 135 |
struct spa_point hotspot; /**< offsets for hotspot in bitmap, this field has no meaning |
| 136 |
* when there is no valid bitmap (see below) */ |
| 137 |
uint32_t bitmap_offset; /**< offset of bitmap meta in this structure. When the offset |
| 138 |
* is 0, there is no new bitmap information. When the offset is |
| 139 |
* >= sizeof(struct spa_meta_cursor) there is a |
| 140 |
* struct spa_meta_bitmap at the offset. */ |
| 141 |
}; |
| 142 |
|
| 143 |
/** a timed set of events associated with the buffer */ |
| 144 |
struct spa_meta_control { |
| 145 |
struct spa_pod_sequence sequence; |
| 146 |
}; |
| 147 |
|
| 148 |
/** a busy counter for the buffer */ |
| 149 |
struct spa_meta_busy { |
| 150 |
uint32_t flags; |
| 151 |
uint32_t count; /**< number of users busy with the buffer */ |
| 152 |
}; |
| 153 |
|
| 154 |
#ifdef __cplusplus |
| 155 |
} /* extern "C" */ |
| 156 |
#endif |
| 157 |
|
| 158 |
#endif /* SPA_META_H */ |