Add port direction again

simplify port numbering again by using 0->max_ports for bot input ports
and output ports. This means we need to tall what direction the port is.
Add port_info serialize functions
Copy metadata and data when we are not sharing buffers.
Make pinossink work again.
This commit is contained in:
Wim Taymans 2016-10-03 19:43:42 +02:00
parent b208e8b690
commit d828073bb8
26 changed files with 1104 additions and 648 deletions

View file

@ -96,6 +96,8 @@ struct _SpaVideoTestSrc {
SpaQueue ready;
};
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
#define DEFAULT_LIVE true
enum {
@ -418,6 +420,7 @@ spa_videotestsrc_node_get_port_ids (SpaNode *node,
static SpaResult
spa_videotestsrc_node_add_port (SpaNode *node,
SpaDirection direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
@ -425,6 +428,7 @@ spa_videotestsrc_node_add_port (SpaNode *node,
static SpaResult
spa_videotestsrc_node_remove_port (SpaNode *node,
SpaDirection direction,
uint32_t port_id)
{
return SPA_RESULT_NOT_IMPLEMENTED;
@ -432,6 +436,7 @@ spa_videotestsrc_node_remove_port (SpaNode *node,
static SpaResult
spa_videotestsrc_node_port_enum_formats (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaFormat **format,
const SpaFormat *filter,
@ -445,7 +450,7 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
index = (*state == NULL ? 0 : *(int*)state);
@ -483,6 +488,7 @@ clear_buffers (SpaVideoTestSrc *this)
static SpaResult
spa_videotestsrc_node_port_set_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaPortFormatFlags flags,
const SpaFormat *format)
@ -495,7 +501,7 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (format == NULL) {
@ -539,6 +545,7 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
static SpaResult
spa_videotestsrc_node_port_get_format (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaFormat **format)
{
@ -549,7 +556,7 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -562,6 +569,7 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
static SpaResult
spa_videotestsrc_node_port_get_info (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaPortInfo **info)
{
@ -572,7 +580,7 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
*info = &this->info;
@ -581,15 +589,17 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_videotestsrc_node_port_get_props (SpaNode *node,
uint32_t port_id,
SpaProps **props)
spa_videotestsrc_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_videotestsrc_node_port_set_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
{
@ -598,6 +608,7 @@ spa_videotestsrc_node_port_set_props (SpaNode *node,
static SpaResult
spa_videotestsrc_node_port_use_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaBuffer **buffers,
uint32_t n_buffers)
@ -609,7 +620,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -667,6 +678,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node,
static SpaResult
spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
uint32_t n_params,
@ -681,7 +693,7 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -698,44 +710,9 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id,
uint32_t buffer_id)
{
SpaVideoTestSrc *this;
VTSBuffer *b;
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
if (!this->have_buffers)
return SPA_RESULT_NO_BUFFERS;
if (buffer_id >= this->n_buffers)
return SPA_RESULT_INVALID_BUFFER_ID;
b = &this->buffers[buffer_id];
if (!b->outstanding)
return SPA_RESULT_OK;
b->outstanding = false;
b->next = NULL;
SPA_QUEUE_PUSH_TAIL (&this->empty, VTSBuffer, next, b);
if (this->empty.length == 1 && !this->props[1].live)
update_poll_enabled (this, true);
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_get_status (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaPortStatus **status)
{
@ -746,7 +723,7 @@ spa_videotestsrc_node_port_get_status (SpaNode *node,
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
if (!CHECK_PORT (this, direction, port_id))
return SPA_RESULT_INVALID_PORT;
if (!this->have_format)
@ -811,8 +788,45 @@ spa_videotestsrc_node_port_pull_output (SpaNode *node,
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_reuse_buffer (SpaNode *node,
uint32_t port_id,
uint32_t buffer_id)
{
SpaVideoTestSrc *this;
VTSBuffer *b;
if (node == NULL || node->handle == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
this = (SpaVideoTestSrc *) node->handle;
if (port_id != 0)
return SPA_RESULT_INVALID_PORT;
if (!this->have_buffers)
return SPA_RESULT_NO_BUFFERS;
if (buffer_id >= this->n_buffers)
return SPA_RESULT_INVALID_BUFFER_ID;
b = &this->buffers[buffer_id];
if (!b->outstanding)
return SPA_RESULT_OK;
b->outstanding = false;
b->next = NULL;
SPA_QUEUE_PUSH_TAIL (&this->empty, VTSBuffer, next, b);
if (this->empty.length == 1 && !this->props[1].live)
update_poll_enabled (this, true);
return SPA_RESULT_OK;
}
static SpaResult
spa_videotestsrc_node_port_push_event (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaNodeEvent *event)
{
@ -840,10 +854,10 @@ static const SpaNode videotestsrc_node = {
spa_videotestsrc_node_port_set_props,
spa_videotestsrc_node_port_use_buffers,
spa_videotestsrc_node_port_alloc_buffers,
spa_videotestsrc_node_port_reuse_buffer,
spa_videotestsrc_node_port_get_status,
spa_videotestsrc_node_port_push_input,
spa_videotestsrc_node_port_pull_output,
spa_videotestsrc_node_port_reuse_buffer,
spa_videotestsrc_node_port_push_event,
};