mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
Reorganise SPA tree
Reorganise the SPA includes to make it more extensible later Simplify the naming of the buffer and meta params
This commit is contained in:
parent
58451d626c
commit
caaeaff223
151 changed files with 1353 additions and 964 deletions
108
spa/include/spa/buffer/buffer.h
Normal file
108
spa/include/spa/buffer/buffer.h
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_BUFFER_H__
|
||||
#define __SPA_BUFFER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/buffer/meta.h>
|
||||
#include <spa/support/type-map.h>
|
||||
|
||||
/** \page page_buffer Buffers
|
||||
*
|
||||
* Buffers describe the data and metadata that is exchanged between
|
||||
* ports of a node.
|
||||
*
|
||||
*/
|
||||
#define SPA_TYPE__Buffer SPA_TYPE_POINTER_BASE "Buffer"
|
||||
#define SPA_TYPE_BUFFER_BASE SPA_TYPE__Buffer ":"
|
||||
|
||||
#define SPA_TYPE__Data SPA_TYPE_ENUM_BASE "DataType"
|
||||
#define SPA_TYPE_DATA_BASE SPA_TYPE__Data ":"
|
||||
|
||||
#define SPA_TYPE_DATA__MemPtr SPA_TYPE_DATA_BASE "MemPtr"
|
||||
#define SPA_TYPE_DATA__MemFd SPA_TYPE_DATA_BASE "MemFd"
|
||||
#define SPA_TYPE_DATA__DmaBuf SPA_TYPE_DATA_BASE "DmaBuf"
|
||||
#define SPA_TYPE_DATA__Id SPA_TYPE_DATA_BASE "Id"
|
||||
|
||||
struct spa_type_data {
|
||||
uint32_t MemPtr;
|
||||
uint32_t MemFd;
|
||||
uint32_t DmaBuf;
|
||||
uint32_t Id;
|
||||
};
|
||||
|
||||
static inline void spa_type_data_map(struct spa_type_map *map, struct spa_type_data *type)
|
||||
{
|
||||
if (type->MemPtr == 0) {
|
||||
type->MemPtr = spa_type_map_get_id(map, SPA_TYPE_DATA__MemPtr);
|
||||
type->MemFd = spa_type_map_get_id(map, SPA_TYPE_DATA__MemFd);
|
||||
type->DmaBuf = spa_type_map_get_id(map, SPA_TYPE_DATA__DmaBuf);
|
||||
type->Id = spa_type_map_get_id(map, SPA_TYPE_DATA__Id);
|
||||
}
|
||||
}
|
||||
|
||||
/** Chunk of memory */
|
||||
struct spa_chunk {
|
||||
uint32_t offset; /**< offset of valid data */
|
||||
uint32_t size; /**< size of valid data */
|
||||
int32_t stride; /**< stride of valid data */
|
||||
};
|
||||
|
||||
/** Data for a buffer */
|
||||
struct spa_data {
|
||||
uint32_t type; /**< memory type */
|
||||
uint32_t flags; /**< data flags */
|
||||
int fd; /**< optional fd for data */
|
||||
uint32_t mapoffset; /**< offset to map fd at */
|
||||
uint32_t maxsize; /**< max size of data */
|
||||
void *data; /**< optional data pointer */
|
||||
struct spa_chunk *chunk; /**< valid chunk of memory */
|
||||
};
|
||||
|
||||
/** A Buffer */
|
||||
struct spa_buffer {
|
||||
uint32_t id; /**< the id of this buffer */
|
||||
uint32_t n_metas; /**< number of metadata elements */
|
||||
struct spa_meta *metas; /**< array of metadata */
|
||||
uint32_t n_datas; /**< number of data members */
|
||||
struct spa_data *datas; /**< array of data members */
|
||||
};
|
||||
|
||||
/** Find metadata in a buffer */
|
||||
static inline void *spa_buffer_find_meta(struct spa_buffer *b, uint32_t type)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < b->n_metas; i++)
|
||||
if (b->metas[i].type == type)
|
||||
return b->metas[i].data;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_BUFFER_H__ */
|
||||
114
spa/include/spa/buffer/meta.h
Normal file
114
spa/include/spa/buffer/meta.h
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_META_H__
|
||||
#define __SPA_META_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/ringbuffer.h>
|
||||
#include <spa/support/type-map.h>
|
||||
|
||||
/** \page page_meta Metadata
|
||||
*
|
||||
* Metadata contains extra information on a buffer.
|
||||
*/
|
||||
#define SPA_TYPE__Meta SPA_TYPE_POINTER_BASE "Meta"
|
||||
#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__Ringbuffer SPA_TYPE_META_BASE "Ringbuffer"
|
||||
#define SPA_TYPE_META__Shared SPA_TYPE_META_BASE "Shared"
|
||||
|
||||
struct spa_type_meta {
|
||||
uint32_t Header;
|
||||
uint32_t Pointer;
|
||||
uint32_t VideoCrop;
|
||||
uint32_t Ringbuffer;
|
||||
uint32_t Shared;
|
||||
};
|
||||
|
||||
static inline void spa_type_meta_map(struct spa_type_map *map, struct spa_type_meta *type)
|
||||
{
|
||||
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->Ringbuffer = spa_type_map_get_id(map, SPA_TYPE_META__Ringbuffer);
|
||||
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 */
|
||||
};
|
||||
|
||||
/** Ringbuffer metadata */
|
||||
struct spa_meta_ringbuffer {
|
||||
struct spa_ringbuffer ringbuffer; /**< the ringbuffer */
|
||||
};
|
||||
|
||||
/** 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
|
||||
|
||||
#endif /* __SPA_META_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue