examples: add video upload example

Add an example of a node that makes a video available.
Improve buffer reuse in stream.
Add more video formats
This commit is contained in:
Wim Taymans 2017-04-18 17:57:04 +02:00
parent c7333c46cc
commit db16de85bb
16 changed files with 466 additions and 93 deletions

View file

@ -159,26 +159,31 @@ spa_proxy_node_set_props (SpaNode *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static void
static inline void
do_flush (SpaProxy *this)
{
uint64_t cmd = 1;
write (this->data_source.fd, &cmd, 8);
}
static inline void
send_need_input (SpaProxy *this)
{
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, proxy);
SpaEvent event = SPA_EVENT_INIT (impl->core->type.event_node.NeedInput);
uint64_t cmd = 1;
pinos_transport_add_event (impl->transport, &event);
write (this->data_source.fd, &cmd, 8);
do_flush (this);
}
static void
static inline void
send_have_output (SpaProxy *this)
{
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, proxy);
SpaEvent event = SPA_EVENT_INIT (impl->core->type.event_node.HaveOutput);
uint64_t cmd = 1;
pinos_transport_add_event (impl->transport, &event);
write (this->data_source.fd, &cmd, 8);
do_flush (this);
}
static SpaResult
@ -808,6 +813,8 @@ spa_proxy_node_process_input (SpaNode *node)
if (!io)
continue;
pinos_log_trace ("%d %d", io->status, io->buffer_id);
impl->transport->inputs[i] = *io;
io->status = SPA_RESULT_OK;
}
@ -822,7 +829,7 @@ spa_proxy_node_process_output (SpaNode *node)
SpaProxy *this;
PinosClientNodeImpl *impl;
int i;
bool send_need = false;
bool send_need = false, flush = false;
if (node == NULL)
return SPA_RESULT_INVALID_ARGUMENTS;
@ -844,6 +851,7 @@ spa_proxy_node_process_output (SpaNode *node)
pinos_transport_add_event (impl->transport, (SpaEvent *)&rb);
io->buffer_id = SPA_ID_INVALID;
flush = true;
}
tmp = impl->transport->outputs[i];
@ -858,6 +866,8 @@ spa_proxy_node_process_output (SpaNode *node)
}
if (send_need)
send_need_input (this);
else if (flush)
do_flush (this);
return SPA_RESULT_HAVE_OUTPUT;
}
@ -866,6 +876,20 @@ static SpaResult
handle_node_event (SpaProxy *this,
SpaEvent *event)
{
PinosClientNodeImpl *impl = SPA_CONTAINER_OF (this, PinosClientNodeImpl, proxy);
int i;
if (SPA_EVENT_TYPE (event) == impl->core->type.event_node.HaveOutput) {
for (i = 0; i < MAX_OUTPUTS; i++) {
SpaPortIO *io = this->out_ports[i].io;
if (!io)
continue;
*io = impl->transport->outputs[i];
pinos_log_trace ("%d %d", io->status, io->buffer_id);
}
}
this->event_cb (&this->node, event, this->user_data);
return SPA_RESULT_OK;
}

View file

@ -333,7 +333,6 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
spa_list_for_each (outport, &this->output_ports, link) {
PinosLink *link;
PinosPort *inport;
SpaPortIO *po;
po = &outport->io;
@ -343,17 +342,22 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data)
pinos_log_trace ("node %p: have output %d", this, po->buffer_id);
spa_list_for_each (link, &outport->rt.links, rt.output_link) {
PinosPort *inport;
if (link->rt.input == NULL || link->rt.output == NULL)
continue;
inport = link->rt.input;
inport->io = *po;
pinos_log_trace ("node %p: do process input %d", this, po->buffer_id);
if ((res = spa_node_process_input (inport->node->node)) < 0)
pinos_log_warn ("node %p: got process input %d", inport->node, res);
}
}
if ((res = spa_node_process_output (this->node)) < 0)
res = spa_node_process_output (this->node);
if (res < 0 && res != SPA_RESULT_HAVE_OUTPUT)
pinos_log_warn ("node %p: got process output %d", this, res);
}