mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
link: don't allocate shared meta in shared mem
We can't allocate the shared meta in shared mem because then clients can damage it for other clients. Place it instead right after the buffer metadata array. Filter out the shared metadata for a client, we send it as part of the client_buffer structure. Remove pointer metadata, it's not so useful. Document the layout of the allocated buffers and the shared memory. Work on metadata to define control parameters
This commit is contained in:
parent
e774339ffe
commit
4d0bab799c
5 changed files with 158 additions and 69 deletions
|
|
@ -36,13 +36,68 @@ extern "C" {
|
|||
#define SPA_TYPE_META_BASE SPA_TYPE__Meta ":"
|
||||
|
||||
#define SPA_TYPE_META__Header SPA_TYPE_META_BASE "Header"
|
||||
#define SPA_TYPE_META__Pointer SPA_TYPE_META_BASE "Pointer"
|
||||
#define SPA_TYPE_META__VideoCrop SPA_TYPE_META_BASE "VideoCrop"
|
||||
#define SPA_TYPE_META__Shared SPA_TYPE_META_BASE "Shared"
|
||||
|
||||
/**
|
||||
* A metadata element.
|
||||
*
|
||||
* This structure is available on the buffer structure and contains
|
||||
* the type of the metadata and a pointer/size to the actual metadata
|
||||
* itself.
|
||||
*/
|
||||
struct spa_meta {
|
||||
uint32_t type; /**< metadata type */
|
||||
void *data; /**< pointer to metadata */
|
||||
uint32_t size; /**< size of metadata */
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes essential buffer header metadata such as flags and
|
||||
* timestamps.
|
||||
*/
|
||||
struct spa_meta_header {
|
||||
#define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /**< data is not continous with previous buffer */
|
||||
#define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /**< data might be corrupted */
|
||||
#define SPA_META_HEADER_FLAG_MARKER (1 << 2) /**< media specific marker */
|
||||
#define SPA_META_HEADER_FLAG_HEADER (1 << 3) /**< data contains a codec specific header */
|
||||
#define SPA_META_HEADER_FLAG_GAP (1 << 4) /**< data contains media neutral data */
|
||||
#define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /**< cannot be decoded independently */
|
||||
uint32_t flags; /**< flags */
|
||||
uint32_t seq; /**< sequence number, increments with a
|
||||
* media specific frequency */
|
||||
int64_t pts; /**< presentation timestamp */
|
||||
int64_t dts_offset; /**< decoding timestamp and a difference with pts */
|
||||
};
|
||||
|
||||
/**
|
||||
* Video cropping metadata
|
||||
* a */
|
||||
struct spa_meta_video_crop {
|
||||
int32_t x, y; /**< x and y offsets */
|
||||
int32_t width, height; /**< width and height */
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the shared memory that holds buffer meta/chunk/data
|
||||
*/
|
||||
struct spa_meta_shared {
|
||||
uint32_t flags; /**< flags */
|
||||
int fd; /**< file descriptor of memory */
|
||||
uint32_t offset; /**< offset in memory */
|
||||
uint32_t size; /**< size of memory */
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes a control location in the buffer.
|
||||
*/
|
||||
struct spa_meta_control {
|
||||
uint32_t id; /**< control id */
|
||||
uint32_t offset; /**< offset in buffer memory */
|
||||
};
|
||||
|
||||
struct spa_type_meta {
|
||||
uint32_t Header;
|
||||
uint32_t Pointer;
|
||||
uint32_t VideoCrop;
|
||||
uint32_t Shared;
|
||||
};
|
||||
|
|
@ -51,54 +106,11 @@ static inline void spa_type_meta_map(struct spa_type_map *map, struct spa_type_m
|
|||
{
|
||||
if (type->Header == 0) {
|
||||
type->Header = spa_type_map_get_id(map, SPA_TYPE_META__Header);
|
||||
type->Pointer = spa_type_map_get_id(map, SPA_TYPE_META__Pointer);
|
||||
type->VideoCrop = spa_type_map_get_id(map, SPA_TYPE_META__VideoCrop);
|
||||
type->Shared = spa_type_map_get_id(map, SPA_TYPE_META__Shared);
|
||||
}
|
||||
}
|
||||
|
||||
/** Describes essential buffer header metadata */
|
||||
struct spa_meta_header {
|
||||
#define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /**< data is not continous with previous buffer */
|
||||
#define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /**< data might be corrupted */
|
||||
#define SPA_META_HEADER_FLAG_MARKER (1 << 2) /**< media specific marker */
|
||||
#define SPA_META_HEADER_FLAG_HEADER (1 << 3) /**< data contains a codec specific header */
|
||||
#define SPA_META_HEADER_FLAG_GAP (1 << 4) /**< data contains media neutral data */
|
||||
#define SPA_META_HEADER_FLAG_DELTA_UNIT (1 << 5) /**< cannot be decoded independently */
|
||||
uint32_t flags; /**< flags */
|
||||
uint32_t seq; /**< sequence number, increments with a
|
||||
* media specific frequency */
|
||||
int64_t pts; /**< presentation timestamp */
|
||||
int64_t dts_offset; /**< decoding timestamp and a difference with pts */
|
||||
};
|
||||
|
||||
/** Pointer metadata */
|
||||
struct spa_meta_pointer {
|
||||
uint32_t type; /**< the pointer type */
|
||||
void *ptr; /**< the pointer */
|
||||
};
|
||||
|
||||
/** Video cropping metadata */
|
||||
struct spa_meta_video_crop {
|
||||
int32_t x, y; /**< x and y offsets */
|
||||
int32_t width, height; /**< width and height */
|
||||
};
|
||||
|
||||
/** Describes the shared memory of a buffer is stored */
|
||||
struct spa_meta_shared {
|
||||
int32_t flags; /**< flags */
|
||||
int fd; /**< file descriptor of memory */
|
||||
int32_t offset; /**< offset in memory */
|
||||
uint32_t size; /**< size of memory */
|
||||
};
|
||||
|
||||
/** A metadata element */
|
||||
struct spa_meta {
|
||||
uint32_t type; /**< metadata type */
|
||||
void *data; /**< pointer to metadata */
|
||||
uint32_t size; /**< size of metadata */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -405,8 +405,8 @@ struct spa_node {
|
|||
* Tell the port to allocate memory for \a buffers.
|
||||
*
|
||||
* \a buffers should contain an array of pointers to buffers. The data
|
||||
* in the buffers should point to an array of at least 1 SPA_DATA_TYPE_INVALID
|
||||
* data pointers that will be filled by this function.
|
||||
* in the buffers should point to an array of at least 1 data entry
|
||||
* with a 0 type that will be filled by this function.
|
||||
*
|
||||
* For input ports, the buffers will be dequeued and ready to be filled
|
||||
* and pushed into the port. A notify should be configured so that you can
|
||||
|
|
|
|||
|
|
@ -72,12 +72,6 @@ int spa_debug_buffer(const struct spa_buffer *buffer)
|
|||
fprintf(stderr, " seq: %u\n", h->seq);
|
||||
fprintf(stderr, " pts: %" PRIi64 "\n", h->pts);
|
||||
fprintf(stderr, " dts_offset: %" PRIi64 "\n", h->dts_offset);
|
||||
} else if (!strcmp(type_name, SPA_TYPE_META__Pointer)) {
|
||||
struct spa_meta_pointer *h = m->data;
|
||||
fprintf(stderr, " struct spa_meta_pointer:\n");
|
||||
fprintf(stderr, " type: %s\n",
|
||||
spa_type_map_get_type(map, h->type));
|
||||
fprintf(stderr, " ptr: %p\n", h->ptr);
|
||||
} else if (!strcmp(type_name, SPA_TYPE_META__VideoCrop)) {
|
||||
struct spa_meta_video_crop *h = m->data;
|
||||
fprintf(stderr, " struct spa_meta_video_crop:\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue