Work on sink

Remove _remove from properties, we can do the same with set of a NULL
value.
Add signals to the stream API to manage the buffers. Wrap those buffers
in a GstBuffer in the pinossrc and pinossink elements and pool them in a
bufferpool.
Remove SPA_EVENT_TYPE_PULL_INPUT, we can do the same with NEED_INPUT and
by using a ringbuffer.
Do more complete allocation of buffers in the link. Use the buffer
allocator if none of the nodes can allocate.
Follow the node state to trigger negotiation and allocation.
Remove offset and size when refering to buffers, we want to always deal
with the complete buffer and use a ringbuffer for ranges or change the
offset/size in the buffer data when needed.
Serialize port_info structures as part of the port_update
Print both the enum number and the name when debuging properties or
formats.
This commit is contained in:
Wim Taymans 2016-08-24 16:26:58 +02:00
parent a03352353f
commit ca7d08c406
45 changed files with 1614 additions and 570 deletions

View file

@ -27,9 +27,6 @@ extern "C" {
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
@ -40,8 +37,13 @@ typedef enum {
SPA_META_TYPE_HEADER,
SPA_META_TYPE_POINTER,
SPA_META_TYPE_VIDEO_CROP,
SPA_META_TYPE_RINGBUFFER,
} SpaMetaType;
#include <spa/defs.h>
#include <spa/memory.h>
#include <spa/port.h>
/**
* SpaBufferFlags:
* @SPA_BUFFER_FLAG_NONE: no flag
@ -87,6 +89,20 @@ typedef struct {
int width, height;
} SpaMetaVideoCrop;
/**
* SpaMetaRingbuffer:
* @readindex:
* @writeindex:
* @size:
* @size_mask:
*/
typedef struct {
volatile int readindex;
volatile int writeindex;
int size;
int size_mask;
} SpaMetaRingbuffer;
/**
* SpaMeta:
* @type: metadata type
@ -133,6 +149,11 @@ struct _SpaBuffer {
#define spa_buffer_ref(b) spa_memory_ref (&(b)->mem)
#define spa_buffer_unref(b) spa_memory_unref (&(b)->mem)
SpaResult spa_buffer_alloc (SpaAllocParam **params,
unsigned int n_params,
SpaBuffer **buffers,
unsigned int *n_buffers);
#ifdef __cplusplus
} /* extern "C" */
#endif

View file

@ -201,16 +201,12 @@ typedef struct {
typedef struct {
uint32_t port_id;
uint32_t buffer_id;
off_t offset;
size_t size;
} SpaControlCmdProcessBuffer;
/* SPA_CONTROL_CMD_REUSE_BUFFER */
typedef struct {
uint32_t port_id;
uint32_t buffer_id;
off_t offset;
size_t size;
} SpaControlCmdReuseBuffer;

View file

@ -33,11 +33,11 @@ typedef struct _SpaEvent SpaEvent;
/**
* SpaEventType:
* @SPA_EVENT_TYPE_INVALID: invalid event, should be ignored
* @SPA_EVENT_TYPE_PORT_ADDED: a new port is added
* @SPA_EVENT_TYPE_PORT_REMOVED: a port is removed
* @SPA_EVENT_TYPE_STATE_CHANGE: emited when the state changes
* @SPA_EVENT_TYPE_CAN_PULL_OUTPUT: emited when an async node has output that can be pulled
* @SPA_EVENT_TYPE_CAN_PUSH_INPUT: emited when more data can be pushed to an async node
* @SPA_EVENT_TYPE_PULL_INPUT: emited when data needs to be provided on an input. data points to
* SpaEventPullInput
* @SPA_EVENT_TYPE_HAVE_OUTPUT: emited when an async node has output that can be pulled
* @SPA_EVENT_TYPE_NEED_INPUT: emited when more data can be pushed to an async node
* @SPA_EVENT_TYPE_REUSE_BUFFER: emited when a buffer can be reused
* @SPA_EVENT_TYPE_ADD_POLL: emited when a pollfd should be added. data points to #SpaPollItem
* @SPA_EVENT_TYPE_REMOVE_POLL: emited when a pollfd should be removed. data points to #SpaPollItem
@ -52,9 +52,8 @@ typedef enum {
SPA_EVENT_TYPE_PORT_ADDED,
SPA_EVENT_TYPE_PORT_REMOVED,
SPA_EVENT_TYPE_STATE_CHANGE,
SPA_EVENT_TYPE_CAN_PULL_OUTPUT,
SPA_EVENT_TYPE_CAN_PUSH_INPUT,
SPA_EVENT_TYPE_PULL_INPUT,
SPA_EVENT_TYPE_HAVE_OUTPUT,
SPA_EVENT_TYPE_NEED_INPUT,
SPA_EVENT_TYPE_REUSE_BUFFER,
SPA_EVENT_TYPE_ADD_POLL,
SPA_EVENT_TYPE_REMOVE_POLL,
@ -76,20 +75,12 @@ typedef struct {
SpaDirection direction;
} SpaEventPortAdded;
typedef struct {
uint32_t buffer_id;
off_t offset;
size_t size;
} SpaEventPullInput;
typedef struct {
SpaNodeState state;
} SpaEventStateChange;
typedef struct {
uint32_t buffer_id;
off_t offset;
size_t size;
uint32_t buffer_id;
} SpaEventReuseBuffer;
#ifdef __cplusplus

View file

@ -31,6 +31,7 @@ typedef struct _SpaNode SpaNode;
* @SPA_NODE_STATE_INIT: the node is initializing
* @SPA_NODE_STATE_CONFIGURE: the node needs at least one port format
* @SPA_NODE_STATE_READY: the node is ready for memory allocation
* @SPA_NODE_STATE_PAUSED: the node is paused
* @SPA_NODE_STATE_STREAMING: the node is streaming
* @SPA_NODE_STATE_ERROR: the node is in error
*/
@ -81,8 +82,6 @@ typedef enum {
* @port_id: the port id
* @flags: extra flags
* @buffer_id: a buffer id
* @offset: offset of data in @id
* @size: size of data in @id
* @status: status
*
* Input information for a node.
@ -91,8 +90,6 @@ typedef struct {
uint32_t port_id;
SpaInputFlags flags;
uint32_t buffer_id;
off_t offset;
size_t size;
SpaResult status;
} SpaInputInfo;
@ -116,8 +113,6 @@ typedef enum {
* @port_id: the port id
* @flags: extra flags
* @buffer_id: a buffer id will be set
* @offset: offset to get
* @size: size to get
* @event: output event
* @status: a status
*
@ -127,8 +122,6 @@ typedef struct {
uint32_t port_id;
SpaOutputFlags flags;
uint32_t buffer_id;
off_t offset;
size_t size;
SpaEvent *event;
SpaResult status;
} SpaOutputInfo;
@ -416,9 +409,7 @@ struct _SpaNode {
SpaResult (*port_reuse_buffer) (SpaNode *node,
uint32_t port_id,
uint32_t buffer_id,
off_t offset,
size_t size);
uint32_t buffer_id);
SpaResult (*port_get_status) (SpaNode *node,
uint32_t port_id,

View file

@ -24,6 +24,8 @@
extern "C" {
#endif
typedef struct _SpaAllocParam SpaAllocParam;
#include <spa/defs.h>
#include <spa/buffer.h>
@ -41,10 +43,10 @@ typedef enum {
SPA_ALLOC_PARAM_TYPE_VIDEO_PADDING,
} SpaAllocParamType;
typedef struct {
struct _SpaAllocParam {
uint32_t type;
size_t size;
} SpaAllocParam;
};
typedef struct {
SpaAllocParam param;