Work on unifying client and server

Remove context and extensions, make client API also use the core.
Make a new pw_remote object that keeps connections with remote
instances.
Remove introspection API, it's just as easy to connect to the registry
and get updates like that.
Expand the protocol a little to make it useful for making listeners
and connections.
Move protocol specific connection to the module. Make some new
convenience methods.
Make a factory to create nodes from spa objects
Add an example of a local pipeline displaying a v4l2 source.
This commit is contained in:
Wim Taymans 2017-07-11 12:24:03 +02:00
parent 2ece95ea48
commit 847cef83b6
65 changed files with 2634 additions and 2713 deletions

View file

@ -96,8 +96,8 @@ static inline bool spa_graph_scheduler_iterate(struct spa_graph_scheduler *sched
switch (n->action) {
case SPA_GRAPH_ACTION_IN:
n->state = n->methods->schedule_input(n, n->user_data);
debug("node %p scheduled input state %d\n", n, n->state);
n->state = n->methods->process_input(n, n->user_data);
debug("node %p processed input state %d\n", n, n->state);
if (n == sched->node)
break;
n->action = SPA_GRAPH_ACTION_CHECK;
@ -105,8 +105,8 @@ static inline bool spa_graph_scheduler_iterate(struct spa_graph_scheduler *sched
break;
case SPA_GRAPH_ACTION_OUT:
n->state = n->methods->schedule_output(n, n->user_data);
debug("node %p scheduled output state %d\n", n, n->state);
n->state = n->methods->process_output(n, n->user_data);
debug("node %p processed output state %d\n", n, n->state);
n->action = SPA_GRAPH_ACTION_CHECK;
spa_list_insert(sched->ready.prev, &n->ready_link);
break;

View file

@ -38,32 +38,36 @@ static inline void spa_graph_scheduler_init(struct spa_graph_scheduler *sched,
sched->node = NULL;
}
static inline int spa_graph_scheduler_input(struct spa_graph_node *node, void *user_data)
static inline int spa_graph_node_scheduler_input(struct spa_graph_node *node, void *user_data)
{
struct spa_node *n = node->user_data;
return spa_node_process_input(n);
}
static inline int spa_graph_scheduler_output(struct spa_graph_node *node, void *user_data)
static inline int spa_graph_node_scheduler_output(struct spa_graph_node *node, void *user_data)
{
struct spa_node *n = node->user_data;
return spa_node_process_output(n);
}
static inline int spa_graph_scheduler_reuse_buffer(struct spa_graph_port *port,
uint32_t buffer_id, void *user_data)
static const struct spa_graph_node_methods spa_graph_node_scheduler_default = {
SPA_VERSION_GRAPH_NODE_METHODS,
spa_graph_node_scheduler_input,
spa_graph_node_scheduler_output,
};
static inline int spa_graph_port_scheduler_reuse_buffer(struct spa_graph_port *port,
uint32_t buffer_id, void *user_data)
{
printf("port %p reuse buffer %d\n", port, buffer_id);
struct spa_graph_node *node = port->node;
struct spa_node *n = node->user_data;
return spa_node_port_reuse_buffer(n, port->port_id, buffer_id);
struct spa_node *node = port->node->user_data;
return spa_node_port_reuse_buffer(node, port->port_id, buffer_id);
}
static const struct spa_graph_node_methods spa_graph_scheduler_default = {
SPA_VERSION_GRAPH_NODE_METHODS,
spa_graph_scheduler_input,
spa_graph_scheduler_output,
spa_graph_scheduler_reuse_buffer,
static const struct spa_graph_port_methods spa_graph_port_scheduler_default = {
SPA_VERSION_GRAPH_PORT_METHODS,
spa_graph_port_scheduler_reuse_buffer,
};
static inline void spa_graph_scheduler_pull(struct spa_graph_scheduler *sched, struct spa_graph_node *node)
@ -92,8 +96,8 @@ static inline void spa_graph_scheduler_pull(struct spa_graph_scheduler *sched, s
}
spa_list_for_each_safe(n, t, &ready, ready_link) {
n->state = n->methods->schedule_output(n, n->user_data);
debug("peer %p scheduled out %d\n", n, n->state);
n->state = n->methods->process_output(n, n->user_data);
debug("peer %p processed out %d\n", n, n->state);
if (n->state == SPA_RESULT_NEED_BUFFER)
spa_graph_scheduler_pull(sched, n);
else {
@ -109,8 +113,8 @@ static inline void spa_graph_scheduler_pull(struct spa_graph_scheduler *sched, s
debug("node %p %d %d\n", node, node->ready_in, node->required_in);
if (node->required_in > 0 && node->ready_in == node->required_in) {
node->state = node->methods->schedule_input(node, node->user_data);
debug("node %p scheduled in %d\n", node, node->state);
node->state = node->methods->process_input(node, node->user_data);
debug("node %p processed in %d\n", node, node->state);
if (node->state == SPA_RESULT_HAVE_BUFFER) {
spa_list_for_each(p, &node->ports[SPA_DIRECTION_OUTPUT], link) {
if (p->io->status == SPA_RESULT_HAVE_BUFFER)
@ -154,8 +158,8 @@ static inline void spa_graph_scheduler_push(struct spa_graph_scheduler *sched, s
}
spa_list_for_each_safe(n, t, &ready, ready_link) {
n->state = n->methods->schedule_input(n, n->user_data);
debug("peer %p scheduled in %d\n", n, n->state);
n->state = n->methods->process_input(n, n->user_data);
debug("peer %p processed in %d\n", n, n->state);
if (n->state == SPA_RESULT_HAVE_BUFFER)
spa_graph_scheduler_push(sched, n);
else {
@ -169,8 +173,8 @@ static inline void spa_graph_scheduler_push(struct spa_graph_scheduler *sched, s
n->ready_link.next = NULL;
}
node->state = node->methods->schedule_output(node, node->user_data);
debug("node %p scheduled out %d\n", node, node->state);
node->state = node->methods->process_output(node, node->user_data);
debug("node %p processed out %d\n", node, node->state);
if (node->state == SPA_RESULT_NEED_BUFFER) {
node->ready_in = 0;
spa_list_for_each(p, &node->ports[SPA_DIRECTION_INPUT], link) {

View file

@ -46,8 +46,14 @@ struct spa_graph {
struct spa_graph_node_methods {
uint32_t version;
int (*schedule_input) (struct spa_graph_node *node, void *user_data);
int (*schedule_output) (struct spa_graph_node *node, void *user_data);
int (*process_input) (struct spa_graph_node *node, void *user_data);
int (*process_output) (struct spa_graph_node *node, void *user_data);
};
#define SPA_VERSION_GRAPH_PORT_METHODS 0
struct spa_graph_port_methods {
uint32_t version;
int (*reuse_buffer) (struct spa_graph_port *port, uint32_t buffer_id, void *user_data);
};
@ -62,11 +68,11 @@ struct spa_graph_node {
#define SPA_GRAPH_ACTION_IN 1
#define SPA_GRAPH_ACTION_OUT 2
uint32_t action;
const struct spa_graph_node_methods *methods;
void *user_data;
uint32_t max_in;
uint32_t required_in;
uint32_t ready_in;
const struct spa_graph_node_methods *methods;
void *user_data;
};
struct spa_graph_port {
@ -77,6 +83,8 @@ struct spa_graph_port {
uint32_t flags;
struct spa_port_io *io;
struct spa_graph_port *peer;
const struct spa_graph_port_methods *methods;
void *user_data;
};
static inline void spa_graph_init(struct spa_graph *graph)
@ -85,19 +93,24 @@ static inline void spa_graph_init(struct spa_graph *graph)
}
static inline void
spa_graph_node_init(struct spa_graph_node *node,
const struct spa_graph_node_methods *methods,
void *user_data)
spa_graph_node_init(struct spa_graph_node *node)
{
spa_list_init(&node->ports[SPA_DIRECTION_INPUT]);
spa_list_init(&node->ports[SPA_DIRECTION_OUTPUT]);
node->flags = 0;
node->methods = methods;
node->user_data = user_data;
node->max_in = node->required_in = node->ready_in = 0;
debug("node %p init\n", node);
}
static inline void
spa_graph_node_set_methods(struct spa_graph_node *node,
const struct spa_graph_node_methods *methods,
void *user_data)
{
node->methods = methods;
node->user_data = user_data;
}
static inline void
spa_graph_node_add(struct spa_graph *graph,
struct spa_graph_node *node)
@ -123,6 +136,15 @@ spa_graph_port_init(struct spa_graph_port *port,
port->io = io;
}
static inline void
spa_graph_port_set_methods(struct spa_graph_port *port,
const struct spa_graph_port_methods *methods,
void *user_data)
{
port->methods = methods;
port->user_data = user_data;
}
static inline void
spa_graph_port_add(struct spa_graph_node *node,
struct spa_graph_port *port)