mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
stream: add node_id in stream
Trigger initialized after we created the node global so that we can get its id. Add the server side node_id for the stream in the stream struct. Change the transport function to pass the node_id to the client. Small cleanups
This commit is contained in:
parent
58b97c8708
commit
5f5ef3de2c
6 changed files with 52 additions and 46 deletions
|
|
@ -833,13 +833,16 @@ client_node_port_command(void *object,
|
|||
pw_log_warn("port command not supported");
|
||||
}
|
||||
|
||||
static void client_node_transport(void *object, int readfd, int writefd, int memfd, uint32_t offset, uint32_t size)
|
||||
static void client_node_transport(void *object, uint32_t node_id,
|
||||
int readfd, int writefd, int memfd, uint32_t offset, uint32_t size)
|
||||
{
|
||||
struct pw_proxy *proxy = object;
|
||||
struct pw_stream *stream = proxy->object;
|
||||
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||
struct pw_transport_info info;
|
||||
|
||||
stream->node_id = node_id;
|
||||
|
||||
info.memfd = memfd;
|
||||
if (info.memfd == -1)
|
||||
return;
|
||||
|
|
@ -850,13 +853,15 @@ static void client_node_transport(void *object, int readfd, int writefd, int mem
|
|||
pw_transport_destroy(impl->trans);
|
||||
impl->trans = pw_transport_new_from_info(&info);
|
||||
|
||||
pw_log_info("stream %p: create client transport %p with fds %d %d", stream, impl->trans, readfd, writefd);
|
||||
pw_log_info("stream %p: create client transport %p with fds %d %d for node %u",
|
||||
stream, impl->trans, readfd, writefd, node_id);
|
||||
handle_socket(stream, readfd, writefd);
|
||||
|
||||
stream_set_state(stream, PW_STREAM_STATE_CONFIGURE, NULL);
|
||||
}
|
||||
|
||||
static const struct pw_client_node_events client_node_events = {
|
||||
&client_node_transport,
|
||||
&client_node_set_props,
|
||||
&client_node_event,
|
||||
&client_node_add_port,
|
||||
|
|
@ -867,7 +872,6 @@ static const struct pw_client_node_events client_node_events = {
|
|||
&client_node_use_buffers,
|
||||
&client_node_node_command,
|
||||
&client_node_port_command,
|
||||
&client_node_transport
|
||||
};
|
||||
|
||||
static void on_node_proxy_destroy(struct pw_listener *listener, struct pw_proxy *proxy)
|
||||
|
|
|
|||
|
|
@ -208,6 +208,8 @@ struct pw_stream {
|
|||
struct spa_list link; /**< link in the context */
|
||||
|
||||
char *name; /**< the name of the stream */
|
||||
uint32_t node_id; /**< node id for remote node, available from
|
||||
* CONFIGURE state and higher */
|
||||
struct pw_properties *properties; /**< properties of the stream */
|
||||
|
||||
/** Emited when the stream is destroyed */
|
||||
|
|
|
|||
|
|
@ -119,21 +119,41 @@ struct pw_client_node_methods {
|
|||
#define pw_client_node_do_event(r,...) ((struct pw_client_node_methods*)r->iface->methods)->event(r,__VA_ARGS__)
|
||||
#define pw_client_node_do_destroy(r) ((struct pw_client_node_methods*)r->iface->methods)->destroy(r)
|
||||
|
||||
#define PW_CLIENT_NODE_EVENT_SET_PROPS 0
|
||||
#define PW_CLIENT_NODE_EVENT_EVENT 1
|
||||
#define PW_CLIENT_NODE_EVENT_ADD_PORT 2
|
||||
#define PW_CLIENT_NODE_EVENT_REMOVE_PORT 3
|
||||
#define PW_CLIENT_NODE_EVENT_SET_FORMAT 4
|
||||
#define PW_CLIENT_NODE_EVENT_SET_PARAM 5
|
||||
#define PW_CLIENT_NODE_EVENT_ADD_MEM 6
|
||||
#define PW_CLIENT_NODE_EVENT_USE_BUFFERS 7
|
||||
#define PW_CLIENT_NODE_EVENT_NODE_COMMAND 8
|
||||
#define PW_CLIENT_NODE_EVENT_PORT_COMMAND 9
|
||||
#define PW_CLIENT_NODE_EVENT_TRANSPORT 10
|
||||
#define PW_CLIENT_NODE_EVENT_TRANSPORT 0
|
||||
#define PW_CLIENT_NODE_EVENT_SET_PROPS 1
|
||||
#define PW_CLIENT_NODE_EVENT_EVENT 2
|
||||
#define PW_CLIENT_NODE_EVENT_ADD_PORT 3
|
||||
#define PW_CLIENT_NODE_EVENT_REMOVE_PORT 4
|
||||
#define PW_CLIENT_NODE_EVENT_SET_FORMAT 5
|
||||
#define PW_CLIENT_NODE_EVENT_SET_PARAM 6
|
||||
#define PW_CLIENT_NODE_EVENT_ADD_MEM 7
|
||||
#define PW_CLIENT_NODE_EVENT_USE_BUFFERS 8
|
||||
#define PW_CLIENT_NODE_EVENT_NODE_COMMAND 9
|
||||
#define PW_CLIENT_NODE_EVENT_PORT_COMMAND 10
|
||||
#define PW_CLIENT_NODE_EVENT_NUM 11
|
||||
|
||||
/** \ref pw_client_node events */
|
||||
struct pw_client_node_events {
|
||||
/**
|
||||
* Notify of a new transport area
|
||||
*
|
||||
* The transport area is used to exchange real-time commands between
|
||||
* the client and the server.
|
||||
*
|
||||
* \param node_id the node id created for this client node
|
||||
* \param readfd fd for signal data can be read
|
||||
* \param writefd fd for signal data can be written
|
||||
* \param memfd the memory fd of the area
|
||||
* \param offset the offset to map
|
||||
* \param size the size to map
|
||||
*/
|
||||
void (*transport) (void *object,
|
||||
uint32_t node_id,
|
||||
int readfd,
|
||||
int writefd,
|
||||
int memfd,
|
||||
uint32_t offset,
|
||||
uint32_t size);
|
||||
/**
|
||||
* Notify of a property change
|
||||
*
|
||||
|
|
@ -258,26 +278,9 @@ struct pw_client_node_events {
|
|||
uint32_t port_id,
|
||||
const struct spa_command *command);
|
||||
|
||||
/**
|
||||
* Notify of a new transport area
|
||||
*
|
||||
* The transport area is used to exchange real-time commands between
|
||||
* the client and the server.
|
||||
*
|
||||
* \param readfd fd for signal data can be read
|
||||
* \param writefd fd for signal data can be written
|
||||
* \param memfd the memory fd of the area
|
||||
* \param offset the offset to map
|
||||
* \param size the size to map
|
||||
*/
|
||||
void (*transport) (void *object,
|
||||
int readfd,
|
||||
int writefd,
|
||||
int memfd,
|
||||
uint32_t offset,
|
||||
uint32_t size);
|
||||
};
|
||||
|
||||
#define pw_client_node_notify_transport(r,...) ((struct pw_client_node_events*)r->iface->events)->transport(r,__VA_ARGS__)
|
||||
#define pw_client_node_notify_set_props(r,...) ((struct pw_client_node_events*)r->iface->events)->props(r,__VA_ARGS__)
|
||||
#define pw_client_node_notify_event(r,...) ((struct pw_client_node_events*)r->iface->events)->event(r,__VA_ARGS__)
|
||||
#define pw_client_node_notify_add_port(r,...) ((struct pw_client_node_events*)r->iface->events)->add_port(r,__VA_ARGS__)
|
||||
|
|
@ -288,7 +291,6 @@ struct pw_client_node_events {
|
|||
#define pw_client_node_notify_use_buffers(r,...) ((struct pw_client_node_events*)r->iface->events)->use_buffers(r,__VA_ARGS__)
|
||||
#define pw_client_node_notify_node_command(r,...) ((struct pw_client_node_events*)r->iface->events)->node_command(r,__VA_ARGS__)
|
||||
#define pw_client_node_notify_port_command(r,...) ((struct pw_client_node_events*)r->iface->events)->port_command(r,__VA_ARGS__)
|
||||
#define pw_client_node_notify_transport(r,...) ((struct pw_client_node_events*)r->iface->events)->transport(r,__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -80,9 +80,6 @@ struct proxy_port {
|
|||
|
||||
uint32_t n_buffers;
|
||||
struct proxy_buffer buffers[MAX_BUFFERS];
|
||||
|
||||
uint32_t buffer_mem_id;
|
||||
struct pw_memblock buffer_mem;
|
||||
};
|
||||
|
||||
struct proxy {
|
||||
|
|
@ -139,9 +136,6 @@ static int clear_buffers(struct proxy *this, struct proxy_port *port)
|
|||
{
|
||||
if (port->n_buffers) {
|
||||
spa_log_info(this->log, "proxy %p: clear buffers", this);
|
||||
|
||||
pw_memblock_free(&port->buffer_mem);
|
||||
|
||||
port->n_buffers = 0;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -1057,7 +1051,8 @@ static void on_initialized(struct pw_listener *listener, struct pw_node *node)
|
|||
pw_client_node_get_fds(this, &readfd, &writefd);
|
||||
pw_transport_get_info(impl->transport, &info);
|
||||
|
||||
pw_client_node_notify_transport(this->resource, readfd, writefd, info.memfd, info.offset, info.size);
|
||||
pw_client_node_notify_transport(this->resource, node->global->id,
|
||||
readfd, writefd, info.memfd, info.offset, info.size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -468,11 +468,12 @@ static bool client_node_demarshal_transport(void *object, void *data, size_t siz
|
|||
struct pw_proxy *proxy = object;
|
||||
struct spa_pod_iter it;
|
||||
struct pw_connection *connection = proxy->context->protocol_private;
|
||||
uint32_t ridx, widx, memfd_idx, offset, sz;
|
||||
uint32_t node_id, ridx, widx, memfd_idx, offset, sz;
|
||||
int readfd, writefd, memfd;
|
||||
|
||||
if (!spa_pod_iter_struct(&it, data, size) ||
|
||||
!spa_pod_iter_get(&it,
|
||||
SPA_POD_TYPE_INT, &node_id,
|
||||
SPA_POD_TYPE_INT, &ridx,
|
||||
SPA_POD_TYPE_INT, &widx,
|
||||
SPA_POD_TYPE_INT, &memfd_idx,
|
||||
|
|
@ -486,7 +487,7 @@ static bool client_node_demarshal_transport(void *object, void *data, size_t siz
|
|||
if (readfd == -1 || writefd == -1 || memfd_idx == -1)
|
||||
return false;
|
||||
|
||||
((struct pw_client_node_events *) proxy->implementation)->transport(proxy,
|
||||
((struct pw_client_node_events *) proxy->implementation)->transport(proxy, node_id,
|
||||
readfd, writefd,
|
||||
memfd, offset, sz);
|
||||
return true;
|
||||
|
|
@ -729,7 +730,7 @@ client_node_marshal_port_command(void *object,
|
|||
b.b.offset);
|
||||
}
|
||||
|
||||
static void client_node_marshal_transport(void *object, int readfd, int writefd,
|
||||
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
|
||||
int memfd, uint32_t offset, uint32_t size)
|
||||
{
|
||||
struct pw_resource *resource = object;
|
||||
|
|
@ -740,6 +741,7 @@ static void client_node_marshal_transport(void *object, int readfd, int writefd,
|
|||
core_update_map_server(resource->client);
|
||||
|
||||
spa_pod_builder_struct(&b.b, &f,
|
||||
SPA_POD_TYPE_INT, node_id,
|
||||
SPA_POD_TYPE_INT, pw_connection_add_fd(connection, readfd),
|
||||
SPA_POD_TYPE_INT, pw_connection_add_fd(connection, writefd),
|
||||
SPA_POD_TYPE_INT, pw_connection_add_fd(connection, memfd),
|
||||
|
|
@ -882,6 +884,7 @@ static const struct pw_client_node_methods pw_protocol_native_client_client_node
|
|||
};
|
||||
|
||||
static const demarshal_func_t pw_protocol_native_client_client_node_demarshal[] = {
|
||||
&client_node_demarshal_transport,
|
||||
&client_node_demarshal_set_props,
|
||||
&client_node_demarshal_event_event,
|
||||
&client_node_demarshal_add_port,
|
||||
|
|
@ -892,7 +895,6 @@ static const demarshal_func_t pw_protocol_native_client_client_node_demarshal[]
|
|||
&client_node_demarshal_use_buffers,
|
||||
&client_node_demarshal_node_command,
|
||||
&client_node_demarshal_port_command,
|
||||
&client_node_demarshal_transport
|
||||
};
|
||||
|
||||
static const struct pw_interface pw_protocol_native_client_client_node_interface = {
|
||||
|
|
@ -911,6 +913,7 @@ static const demarshal_func_t pw_protocol_native_server_client_node_demarshal[]
|
|||
};
|
||||
|
||||
static const struct pw_client_node_events pw_protocol_native_server_client_node_events = {
|
||||
&client_node_marshal_transport,
|
||||
&client_node_marshal_set_props,
|
||||
&client_node_marshal_event_event,
|
||||
&client_node_marshal_add_port,
|
||||
|
|
@ -921,7 +924,6 @@ static const struct pw_client_node_events pw_protocol_native_server_client_node_
|
|||
&client_node_marshal_use_buffers,
|
||||
&client_node_marshal_node_command,
|
||||
&client_node_marshal_port_command,
|
||||
&client_node_marshal_transport,
|
||||
};
|
||||
|
||||
const struct pw_interface pw_protocol_native_server_client_node_interface = {
|
||||
|
|
|
|||
|
|
@ -157,7 +157,6 @@ static void update_port_ids(struct pw_node *node)
|
|||
break;
|
||||
}
|
||||
}
|
||||
pw_signal_emit(&node->initialized, node);
|
||||
}
|
||||
|
||||
static int pause_node(struct pw_node *this)
|
||||
|
|
@ -506,6 +505,8 @@ static void init_complete(struct pw_node *this)
|
|||
|
||||
update_info(this);
|
||||
|
||||
pw_signal_emit(&this->initialized, this);
|
||||
|
||||
pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue