pipewire/spa/include/spa/buffer.h
Wim Taymans dd1fbef28f work on memory references
Add a memory reference helper struct that we can use to track the memory
in buffers and formats.
Remove custom property get and set, the default ones will work fine.
Custom ones are problematic when we want to serialize properties in
formats etc.
Deserialized Formats are now tracked in the memory pool and can be freed
if needed.
2016-08-04 19:24:16 +02:00

148 lines
3.9 KiB
C

/* 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
typedef struct _SpaBuffer SpaBuffer;
typedef struct _SpaBufferGroup SpaBufferGroup;
#include <spa/defs.h>
#include <spa/memory.h>
/**
* SpaMetaType:
* @SPA_META_TYPE_INVALID: invalid metadata, should be ignored
* @SPA_META_TYPE_HEADER: header metadata
*/
typedef enum {
SPA_META_TYPE_INVALID = 0,
SPA_META_TYPE_HEADER,
SPA_META_TYPE_POINTER,
SPA_META_TYPE_VIDEO_CROP,
} SpaMetaType;
/**
* SpaBufferFlags:
* @SPA_BUFFER_FLAG_NONE: no flag
* @SPA_BUFFER_FLAG_DISCONT: the buffer marks a data discontinuity
* @SPA_BUFFER_FLAG_CORRUPTED: the buffer data might be corrupted
* @SPA_BUFFER_FLAG_MARKER: the buffer contains a media specific marker
* @SPA_BUFFER_FLAG_HEADER: the buffer contains a header
* @SPA_BUFFER_FLAG_GAP: the buffer has been constructed to fill a gap
* and contains media neutral data
* @SPA_BUFFER_FLAG_DELTA_UNIT: the media cannot be decoded independently
*/
typedef enum {
SPA_BUFFER_FLAG_NONE = 0,
SPA_BUFFER_FLAG_DISCONT = (1 << 0),
SPA_BUFFER_FLAG_CORRUPTED = (1 << 1),
SPA_BUFFER_FLAG_MARKER = (1 << 2),
SPA_BUFFER_FLAG_HEADER = (1 << 3),
SPA_BUFFER_FLAG_GAP = (1 << 4),
SPA_BUFFER_FLAG_DELTA_UNIT = (1 << 5),
} SpaBufferFlags;
typedef struct {
SpaBufferFlags flags;
uint32_t seq;
int64_t pts;
int64_t dts_offset;
} SpaMetaHeader;
typedef struct {
const char *ptr_type;
void *ptr;
} SpaMetaPointer;
/**
* SpaMetaVideoCrop:
* @x:
* @y:
* @width:
* @height
*/
typedef struct {
int x, y;
int width, height;
} SpaMetaVideoCrop;
/**
* SpaMeta:
* @type: metadata type
* @offset: offset of metadata in the buffer structure
* @size: size of metadata
*/
typedef struct {
SpaMetaType type;
off_t offset;
size_t size;
} SpaMeta;
/**
* SpaData:
* @mem: reference to the memory to use
* @offset: ofset in memory
* @size: size of memory
* @stride: stride of memory if applicable
*/
typedef struct {
SpaMemoryRef mem;
off_t offset;
size_t size;
size_t stride;
} SpaData;
/**
* SpaBuffer:
* @id: buffer id
* @mem: reference to the memory for this buffer
* @offset: offset inside memory
* @size: of of memory
* @n_metas: number of metadata
* @metas: offset of array of @n_metas metadata
* @n_datas: number of data pointers
* @datas: offset of array of @n_datas data pointers
*/
struct _SpaBuffer {
uint32_t id;
SpaMemoryRef mem;
off_t offset;
size_t size;
unsigned int n_metas;
off_t metas;
unsigned int n_datas;
off_t datas;
};
#define SPA_BUFFER_METAS(b) (SPA_MEMBER ((b), (b)->metas, SpaMeta))
#define SPA_BUFFER_DATAS(b) (SPA_MEMBER ((b), (b)->datas, SpaData))
#define spa_buffer_ref(b) spa_memory_ref (&(b)->mem)
#define spa_buffer_unref(b) spa_memory_unref (&(b)->mem)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_BUFFER_H__ */