protocol: add v0 compatibility

For flatpaks we need to be able to support older v0 protocol clients.
To handle this we have:

- the connection detects an old client when it receives the first
  message. It can do this by checking the sequence number, on old
  versions it contains the message size and is never 0, on new
  clients the sequence number is 0.

- We add a new signal at the start of the connection with the detected
  version number. This installs the right version of the core proxy.
  We also move the binding of the client until the hello message is
  received. This way we can have a new client connect (portal),
  hand over the connection to an old client, which then removes the
  client binding again in the hello request with a v0 version.
  There are some changes to the passing of fds in v0 vs v3 which need
  to investigated some more.

- bump version of our interfaces to 3. This makes it possible to
  have v0 and v3 protocol marshal functions.

- Add version number in the proxy. This is mostly automatically done
  internally based on the version numbers the library is compiled
  with. Where the version number was in the API before, it is now
  actually used to look up the right protocol marshal functions. For
  Proxies there is usually just 1 version, the current one. It is the
  server that will support different versions.

- Add v0 compat marshal functions to convert from and to v0 format.
  This has some complications. v0 has a type map it keeps in sync
  with the server. For this we have a static type map with mappings
  to our own v3 types. Pods are mostly the same except for objects
  that used to have arbitrary pods in v0 vs spa_pod_prop in v3. Also
  convert between v0 spa_pod_prop and v3 spa_pod_choice.
  Formats and commands are also slightly different so handle those
  mappings as well.
  We only have marshal functions for the server side (resource)
  v0 functions.

- Add v0 compatible client-node again. It's a bit tricky to map, v0
  client-node basically lets the server to the mixing and teeing
  and just does the processing of the internal node.
This commit is contained in:
Wim Taymans 2019-10-08 22:52:25 +02:00
parent d99350635a
commit 082463efd0
26 changed files with 4814 additions and 77 deletions

View file

@ -34,7 +34,7 @@ extern "C" {
struct pw_client_node_proxy { struct spa_interface iface; }; struct pw_client_node_proxy { struct spa_interface iface; };
#define PW_VERSION_CLIENT_NODE 0 #define PW_VERSION_CLIENT_NODE 3
#define PW_EXTENSION_MODULE_CLIENT_NODE PIPEWIRE_MODULE_PREFIX "module-client-node" #define PW_EXTENSION_MODULE_CLIENT_NODE PIPEWIRE_MODULE_PREFIX "module-client-node"

View file

@ -23,19 +23,6 @@ pipewire_module_rtkit = shared_library('pipewire-module-rtkit', [ 'module-rtkit.
) )
endif endif
pipewire_module_client_node = shared_library('pipewire-module-client-node',
[ 'module-client-node.c',
'module-client-node/remote-node.c',
'module-client-node/client-node.c',
'module-client-node/protocol-native.c',
'spa/spa-node.c', ],
c_args : pipewire_module_c_args,
include_directories : [configinc, spa_inc],
install : true,
install_dir : modules_install_dir,
dependencies : [mathlib, dl_lib, pipewire_dep],
)
pipewire_module_client_node = shared_library('pipewire-module-client-device', pipewire_module_client_node = shared_library('pipewire-module-client-device',
[ 'module-client-device.c', [ 'module-client-device.c',
'module-client-device/resource-device.c', 'module-client-device/resource-device.c',
@ -68,6 +55,7 @@ pipewire_module_protocol_native = shared_library('pipewire-module-protocol-nativ
'module-protocol-native/local-socket.c', 'module-protocol-native/local-socket.c',
'module-protocol-native/portal-screencast.c', 'module-protocol-native/portal-screencast.c',
'module-protocol-native/protocol-native.c', 'module-protocol-native/protocol-native.c',
'module-protocol-native/v0/protocol-native.c',
'module-protocol-native/connection.c' ], 'module-protocol-native/connection.c' ],
c_args : pipewire_module_c_args, c_args : pipewire_module_c_args,
include_directories : [configinc, spa_inc], include_directories : [configinc, spa_inc],
@ -76,6 +64,23 @@ pipewire_module_protocol_native = shared_library('pipewire-module-protocol-nativ
dependencies : pipewire_module_protocol_native_deps, dependencies : pipewire_module_protocol_native_deps,
) )
pipewire_module_client_node = shared_library('pipewire-module-client-node',
[ 'module-client-node.c',
'module-client-node/remote-node.c',
'module-client-node/client-node.c',
'module-client-node/protocol-native.c',
'module-client-node/v0/client-node.c',
'module-client-node/v0/transport.c',
'module-client-node/v0/protocol-native.c',
'spa/spa-node.c', ],
c_args : pipewire_module_c_args,
include_directories : [configinc, spa_inc],
link_with : pipewire_module_protocol_native,
install : true,
install_dir : modules_install_dir,
dependencies : [mathlib, dl_lib, pipewire_dep],
)
test('pw-test-protocol-native', test('pw-test-protocol-native',
executable('pw-test-protocol-native', executable('pw-test-protocol-native',
[ 'module-protocol-native/test-connection.c', [ 'module-protocol-native/test-connection.c',

View file

@ -31,6 +31,7 @@
#include <pipewire/pipewire.h> #include <pipewire/pipewire.h>
#include "module-client-node/v0/client-node.h"
#include "module-client-node/client-node.h" #include "module-client-node/client-node.h"
#define NAME "client-node" #define NAME "client-node"
@ -47,6 +48,7 @@ struct pw_proxy *pw_remote_spa_node_export(struct pw_remote *remote,
uint32_t type, struct pw_properties *props, void *object, size_t user_data_size); uint32_t type, struct pw_properties *props, void *object, size_t user_data_size);
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core); struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core);
struct pw_protocol *pw_protocol_native_ext_client_node0_init(struct pw_core *core);
struct factory_data { struct factory_data {
struct pw_factory *this; struct pw_factory *this;
@ -76,7 +78,11 @@ static void *create_object(void *_data,
goto error_resource; goto error_resource;
} }
result = pw_client_node_new(node_resource, properties, true); if (version == 0) {
result = pw_client_node0_new(node_resource, properties);
} else {
result = pw_client_node_new(node_resource, properties, true);
}
if (result == NULL) { if (result == NULL) {
res = -errno; res = -errno;
goto error_node; goto error_node;
@ -167,6 +173,7 @@ int pipewire__module_init(struct pw_module *module, const char *args)
data); data);
pw_protocol_native_ext_client_node_init(core); pw_protocol_native_ext_client_node_init(core);
pw_protocol_native_ext_client_node0_init(core);
data->export_node.type = PW_TYPE_INTERFACE_Node; data->export_node.type = PW_TYPE_INTERFACE_Node;
data->export_node.func = pw_remote_node_export; data->export_node.func = pw_remote_node_export;

View file

@ -97,7 +97,7 @@ client_node_marshal_get_node(void *object, uint32_t version, size_t user_data_si
struct pw_proxy *res; struct pw_proxy *res;
uint32_t new_id; uint32_t new_id;
res = pw_proxy_new(object, PW_TYPE_INTERFACE_Node, user_data_size); res = pw_proxy_new(object, PW_TYPE_INTERFACE_Node, version, user_data_size);
if (res == NULL) if (res == NULL)
return NULL; return NULL;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
/* PipeWire
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PIPEWIRE_CLIENT_NODE0_H
#define PIPEWIRE_CLIENT_NODE0_H
#include <pipewire/node.h>
#include "ext-client-node.h"
#ifdef __cplusplus
extern "C" {
#endif
/** \class pw_client_node0
*
* PipeWire client node interface
*/
struct pw_client_node0 {
struct pw_node *node;
struct pw_resource *resource;
};
struct pw_client_node0 *
pw_client_node0_new(struct pw_resource *resource,
struct pw_properties *properties);
void
pw_client_node0_destroy(struct pw_client_node0 *node);
#ifdef __cplusplus
}
#endif
#endif /* PIPEWIRE_CLIENT_NODE0_H */

View file

@ -0,0 +1,407 @@
/* PipeWire
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_EXT_CLIENT_NODE0_H__
#define __PIPEWIRE_EXT_CLIENT_NODE0_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/param/param.h>
#include <spa/node/node.h>
#include <pipewire/proxy.h>
#define PW_VERSION_CLIENT_NODE0 0
struct pw_client_node0_message;
/** Shared structure between client and server \memberof pw_client_node */
struct pw_client_node0_area {
uint32_t max_input_ports; /**< max input ports of the node */
uint32_t n_input_ports; /**< number of input ports of the node */
uint32_t max_output_ports; /**< max output ports of the node */
uint32_t n_output_ports; /**< number of output ports of the node */
};
/** \class pw_client_node0_transport
*
* \brief Transport object
*
* The transport object contains shared data and ringbuffers to exchange
* events and data between the server and the client in a low-latency and
* lockfree way.
*/
struct pw_client_node0_transport {
struct pw_client_node0_area *area; /**< the transport area */
struct spa_io_buffers *inputs; /**< array of buffer input io */
struct spa_io_buffers *outputs; /**< array of buffer output io */
void *input_data; /**< input memory for ringbuffer */
struct spa_ringbuffer *input_buffer; /**< ringbuffer for input memory */
void *output_data; /**< output memory for ringbuffer */
struct spa_ringbuffer *output_buffer; /**< ringbuffer for output memory */
/** Destroy a transport
* \param trans a transport to destroy
* \memberof pw_client_node0_transport
*/
void (*destroy) (struct pw_client_node0_transport *trans);
/** Add a message to the transport
* \param trans the transport to send the message on
* \param message the message to add
* \return 0 on success, < 0 on error
*
* Write \a message to the shared ringbuffer.
*/
int (*add_message) (struct pw_client_node0_transport *trans, struct pw_client_node0_message *message);
/** Get next message from a transport
* \param trans the transport to get the message of
* \param[out] message the message to read
* \return < 0 on error, 1 when a message is available,
* 0 when no more messages are available.
*
* Get the skeleton next message from \a trans into \a message. This function will
* only read the head and object body of the message.
*
* After the complete size of the message has been calculated, you should call
* \ref parse_message() to read the complete message contents.
*/
int (*next_message) (struct pw_client_node0_transport *trans, struct pw_client_node0_message *message);
/** Parse the complete message on transport
* \param trans the transport to read from
* \param[out] message memory that can hold the complete message
* \return 0 on success, < 0 on error
*
* Use this function after \ref next_message().
*/
int (*parse_message) (struct pw_client_node0_transport *trans, void *message);
};
#define pw_client_node0_transport_destroy(t) ((t)->destroy((t)))
#define pw_client_node0_transport_add_message(t,m) ((t)->add_message((t), (m)))
#define pw_client_node0_transport_next_message(t,m) ((t)->next_message((t), (m)))
#define pw_client_node0_transport_parse_message(t,m) ((t)->parse_message((t), (m)))
enum pw_client_node0_message_type {
PW_CLIENT_NODE0_MESSAGE_HAVE_OUTPUT, /*< signal that the node has output */
PW_CLIENT_NODE0_MESSAGE_NEED_INPUT, /*< signal that the node needs input */
PW_CLIENT_NODE0_MESSAGE_PROCESS_INPUT, /*< instruct the node to process input */
PW_CLIENT_NODE0_MESSAGE_PROCESS_OUTPUT, /*< instruct the node output is processed */
PW_CLIENT_NODE0_MESSAGE_PORT_REUSE_BUFFER, /*< reuse a buffer */
};
struct pw_client_node0_message_body {
struct spa_pod_int type SPA_ALIGNED(8); /*< one of enum pw_client_node0_message_type */
};
struct pw_client_node0_message {
struct spa_pod_struct pod;
struct pw_client_node0_message_body body;
};
struct pw_client_node0_message_port_reuse_buffer_body {
struct spa_pod_int type SPA_ALIGNED(8); /*< PW_CLIENT_NODE0_MESSAGE_PORT_REUSE_BUFFER */
struct spa_pod_int port_id SPA_ALIGNED(8); /*< port id */
struct spa_pod_int buffer_id SPA_ALIGNED(8); /*< buffer id to reuse */
};
struct pw_client_node0_message_port_reuse_buffer {
struct spa_pod_struct pod;
struct pw_client_node0_message_port_reuse_buffer_body body;
};
#define PW_CLIENT_NODE0_MESSAGE_TYPE(message) (((struct pw_client_node0_message*)(message))->body.type.value)
#define PW_CLIENT_NODE0_MESSAGE_INIT(message) (struct pw_client_node0_message) \
{ { { sizeof(struct pw_client_node0_message_body), SPA_TYPE_Struct } }, \
{ SPA_POD_INIT_Int(message) } }
#define PW_CLIENT_NODE0_MESSAGE_INIT_FULL(type,size,message,...) (type) \
{ { { size, SPA_TYPE_Struct } }, \
{ SPA_POD_INIT_Int(message), ##__VA_ARGS__ } } \
#define PW_CLIENT_NODE0_MESSAGE_PORT_REUSE_BUFFER_INIT(port_id,buffer_id) \
PW_CLIENT_NODE0_MESSAGE_INIT_FULL(struct pw_client_node0_message_port_reuse_buffer, \
sizeof(struct pw_client_node0_message_port_reuse_buffer_body), \
PW_CLIENT_NODE0_MESSAGE_PORT_REUSE_BUFFER, \
SPA_POD_INIT_Int(port_id), \
SPA_POD_INIT_Int(buffer_id))
/** information about a buffer */
struct pw_client_node0_buffer {
uint32_t mem_id; /**< the memory id for the metadata */
uint32_t offset; /**< offset in memory */
uint32_t size; /**< size in memory */
struct spa_buffer *buffer; /**< buffer describing metadata and buffer memory */
};
#define PW_CLIENT_NODE0_PROXY_METHOD_DONE 0
#define PW_CLIENT_NODE0_PROXY_METHOD_UPDATE 1
#define PW_CLIENT_NODE0_PROXY_METHOD_PORT_UPDATE 2
#define PW_CLIENT_NODE0_PROXY_METHOD_SET_ACTIVE 3
#define PW_CLIENT_NODE0_PROXY_METHOD_EVENT 4
#define PW_CLIENT_NODE0_PROXY_METHOD_DESTROY 5
#define PW_CLIENT_NODE0_PROXY_METHOD_NUM 6
/** \ref pw_client_node methods */
struct pw_client_node0_proxy_methods {
#define PW_VERSION_CLIENT_NODE0_PROXY_METHODS 0
uint32_t version;
/** Complete an async operation */
void (*done) (void *object, int seq, int res);
/**
* Update the node ports and properties
*
* Update the maximum number of ports and the params of the
* client node.
* \param change_mask bitfield with changed parameters
* \param max_input_ports new max input ports
* \param max_output_ports new max output ports
* \param params new params
*/
void (*update) (void *object,
#define PW_CLIENT_NODE0_UPDATE_MAX_INPUTS (1 << 0)
#define PW_CLIENT_NODE0_UPDATE_MAX_OUTPUTS (1 << 1)
#define PW_CLIENT_NODE0_UPDATE_PARAMS (1 << 2)
uint32_t change_mask,
uint32_t max_input_ports,
uint32_t max_output_ports,
uint32_t n_params,
const struct spa_pod **params);
/**
* Update a node port
*
* Update the information of one port of a node.
* \param direction the direction of the port
* \param port_id the port id to update
* \param change_mask a bitfield of changed items
* \param n_params number of port parameters
* \param params array of port parameters
* \param info port information
*/
void (*port_update) (void *object,
enum spa_direction direction,
uint32_t port_id,
#define PW_CLIENT_NODE0_PORT_UPDATE_PARAMS (1 << 0)
#define PW_CLIENT_NODE0_PORT_UPDATE_INFO (1 << 1)
uint32_t change_mask,
uint32_t n_params,
const struct spa_pod **params,
const struct spa_port_info *info);
/**
* Activate or deactivate the node
*/
void (*set_active) (void *object, bool active);
/**
* Send an event to the node
* \param event the event to send
*/
void (*event) (void *object, struct spa_event *event);
/**
* Destroy the client_node
*/
void (*destroy) (void *object);
};
#define PW_CLIENT_NODE0_PROXY_EVENT_ADD_MEM 0
#define PW_CLIENT_NODE0_PROXY_EVENT_TRANSPORT 1
#define PW_CLIENT_NODE0_PROXY_EVENT_SET_PARAM 2
#define PW_CLIENT_NODE0_PROXY_EVENT_EVENT 3
#define PW_CLIENT_NODE0_PROXY_EVENT_COMMAND 4
#define PW_CLIENT_NODE0_PROXY_EVENT_ADD_PORT 5
#define PW_CLIENT_NODE0_PROXY_EVENT_REMOVE_PORT 6
#define PW_CLIENT_NODE0_PROXY_EVENT_PORT_SET_PARAM 7
#define PW_CLIENT_NODE0_PROXY_EVENT_PORT_USE_BUFFERS 8
#define PW_CLIENT_NODE0_PROXY_EVENT_PORT_COMMAND 9
#define PW_CLIENT_NODE0_PROXY_EVENT_PORT_SET_IO 10
#define PW_CLIENT_NODE0_PROXY_EVENT_NUM 11
/** \ref pw_client_node events */
struct pw_client_node0_proxy_events {
#define PW_VERSION_CLIENT_NODE0_PROXY_EVENTS 0
uint32_t version;
/**
* Memory was added to a node
*
* \param mem_id the id of the memory
* \param type the memory type
* \param memfd the fd of the memory
* \param flags flags for the \a memfd
*/
void (*add_mem) (void *object,
uint32_t mem_id,
uint32_t type,
int memfd,
uint32_t flags);
/**
* 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 transport the shared transport area
*/
void (*transport) (void *object,
uint32_t node_id,
int readfd,
int writefd,
struct pw_client_node0_transport *transport);
/**
* Notify of a property change
*
* When the server configures the properties on the node
* this event is sent
*
* \param seq a sequence number
* \param id the id of the parameter
* \param flags parameter flags
* \param param the param to set
*/
void (*set_param) (void *object, uint32_t seq,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
/**
* Receive an event from the client node
* \param event the received event */
void (*event) (void *object, const struct spa_event *event);
/**
* Notify of a new node command
*
* \param seq a sequence number
* \param command the command
*/
void (*command) (void *object, uint32_t seq, const struct spa_command *command);
/**
* A new port was added to the node
*
* The server can at any time add a port to the node when there
* are free ports available.
*
* \param seq a sequence number
* \param direction the direction of the port
* \param port_id the new port id
*/
void (*add_port) (void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id);
/**
* A port was removed from the node
*
* \param seq a sequence number
* \param direction a port direction
* \param port_id the remove port id
*/
void (*remove_port) (void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id);
/**
* A parameter was configured on the port
*
* \param seq a sequence number
* \param direction a port direction
* \param port_id the port id
* \param id the id of the parameter
* \param flags flags used when setting the param
* \param param the new param
*/
void (*port_set_param) (void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod *param);
/**
* Notify the port of buffers
*
* \param seq a sequence number
* \param direction a port direction
* \param port_id the port id
* \param n_buffer the number of buffers
* \param buffers and array of buffer descriptions
*/
void (*port_use_buffers) (void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t n_buffers,
struct pw_client_node0_buffer *buffers);
/**
* Notify of a new port command
*
* \param direction a port direction
* \param port_id the port id
* \param command the command
*/
void (*port_command) (void *object,
enum spa_direction direction,
uint32_t port_id,
const struct spa_command *command);
/**
* Configure the io area with \a id of \a port_id.
*
* \param seq a sequence number
* \param direction the direction of the port
* \param port_id the port id
* \param id the id of the io area to set
* \param mem_id the id of the memory to use
* \param offset offset of io area in memory
* \param size size of the io area
*/
void (*port_set_io) (void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
uint32_t mem_id,
uint32_t offset,
uint32_t size);
};
#define pw_client_node0_resource(r,m,v,...) pw_resource_call(r, struct pw_client_node0_proxy_events, m, v, ##__VA_ARGS__)
#define pw_client_node0_resource_add_mem(r,...) pw_client_node0_resource(r,add_mem,0,__VA_ARGS__)
#define pw_client_node0_resource_transport(r,...) pw_client_node0_resource(r,transport,0,__VA_ARGS__)
#define pw_client_node0_resource_set_param(r,...) pw_client_node0_resource(r,set_param,0,__VA_ARGS__)
#define pw_client_node0_resource_event(r,...) pw_client_node0_resource(r,event,0,__VA_ARGS__)
#define pw_client_node0_resource_command(r,...) pw_client_node0_resource(r,command,0,__VA_ARGS__)
#define pw_client_node0_resource_add_port(r,...) pw_client_node0_resource(r,add_port,0,__VA_ARGS__)
#define pw_client_node0_resource_remove_port(r,...) pw_client_node0_resource(r,remove_port,0,__VA_ARGS__)
#define pw_client_node0_resource_port_set_param(r,...) pw_client_node0_resource(r,port_set_param,0,__VA_ARGS__)
#define pw_client_node0_resource_port_use_buffers(r,...) pw_client_node0_resource(r,port_use_buffers,0,__VA_ARGS__)
#define pw_client_node0_resource_port_command(r,...) pw_client_node0_resource(r,port_command,0,__VA_ARGS__)
#define pw_client_node0_resource_port_set_io(r,...) pw_client_node0_resource(r,port_set_io,0,__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __PIPEWIRE_EXT_CLIENT_NODE0_H__ */

View file

@ -0,0 +1,517 @@
/* PipeWire
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <errno.h>
#include <spa/pod/parser.h>
#include "pipewire/pipewire.h"
#include "pipewire/interfaces.h"
#include "pipewire/protocol.h"
#include "pipewire/client.h"
#include "pipewire/private.h"
#include "extensions/protocol-native.h"
#include "ext-client-node.h"
#include "transport.h"
#define PW_PROTOCOL_NATIVE_FLAG_REMAP (1<<0)
extern uint32_t pw_protocol_native0_find_type(struct pw_client *client, const char *type);
extern int pw_protocol_native0_pod_to_v2(struct pw_client *client, const struct spa_pod *pod,
struct spa_pod_builder *b);
extern uint32_t pw_protocol_native0_type_to_v2(struct pw_client *client,
const struct spa_type_info *info, uint32_t type);
static void
client_node_marshal_add_mem(void *object,
uint32_t mem_id,
uint32_t type,
int memfd, uint32_t flags)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
const char *typename;
switch (type) {
case SPA_DATA_MemFd:
typename = "Spa:Enum:DataType:Fd:MemFd";
break;
case SPA_DATA_DmaBuf:
typename = "Spa:Enum:DataType:Fd:DmaBuf";
break;
default:
case SPA_DATA_MemPtr:
return;
}
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_ADD_MEM, NULL);
spa_pod_builder_add_struct(b,
"i", mem_id,
"I", pw_protocol_native0_find_type(resource->client, typename),
"i", pw_protocol_native_add_resource_fd(resource, memfd),
"i", flags);
pw_protocol_native_end_resource(resource, b);
}
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
struct pw_client_node0_transport *transport)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
struct pw_client_node0_transport_info info;
pw_client_node0_transport_get_info(transport, &info);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_TRANSPORT, NULL);
spa_pod_builder_add_struct(b,
"i", node_id,
"i", pw_protocol_native_add_resource_fd(resource, readfd),
"i", pw_protocol_native_add_resource_fd(resource, writefd),
"i", pw_protocol_native_add_resource_fd(resource, info.memfd),
"i", info.offset,
"i", info.size);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t flags,
const struct spa_pod *param)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_SET_PARAM, NULL);
spa_pod_builder_add_struct(b,
"i", seq,
"I", id,
"i", flags,
"P", param);
pw_protocol_native_end_resource(resource, b);
}
static void client_node_marshal_event_event(void *object, const struct spa_event *event)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_EVENT, NULL);
spa_pod_builder_add_struct(b, "P", event);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_command(void *object, uint32_t seq, const struct spa_command *command)
{
struct pw_resource *resource = object;
struct pw_client *client = resource->client;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_COMMAND, NULL);
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b, "i", seq, NULL);
pw_protocol_native0_pod_to_v2(client, (struct spa_pod *)command, b);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_add_port(void *object,
uint32_t seq, enum spa_direction direction, uint32_t port_id)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_ADD_PORT, NULL);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_remove_port(void *object,
uint32_t seq, enum spa_direction direction, uint32_t port_id)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_REMOVE_PORT, NULL);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_port_set_param(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t id,
uint32_t flags,
const struct spa_pod *param)
{
struct pw_resource *resource = object;
struct pw_client *client = resource->client;
struct spa_pod_builder *b;
struct spa_pod_frame f;
const char *typename;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_PORT_SET_PARAM, NULL);
switch (id) {
case SPA_PARAM_Props:
typename = "Spa:Enum:ParamId:Props";
break;
case SPA_PARAM_Format:
typename = "Spa:Enum:ParamId:Format";
break;
default:
return;
}
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b,
"i", seq,
"i", direction,
"i", port_id,
"I", pw_protocol_native0_find_type(client, typename),
"i", flags, NULL);
pw_protocol_native0_pod_to_v2(client, param, b);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_port_use_buffers(void *object,
uint32_t seq,
enum spa_direction direction,
uint32_t port_id,
uint32_t n_buffers, struct pw_client_node0_buffer *buffers)
{
struct pw_resource *resource = object;
struct pw_client *client = resource->client;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, j;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_PORT_USE_BUFFERS, NULL);
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b,
"i", seq,
"i", direction,
"i", port_id,
"i", n_buffers, NULL);
for (i = 0; i < n_buffers; i++) {
struct spa_buffer *buf = buffers[i].buffer;
spa_pod_builder_add(b,
"i", buffers[i].mem_id,
"i", buffers[i].offset,
"i", buffers[i].size,
"i", i,
"i", buf->n_metas, NULL);
for (j = 0; j < buf->n_metas; j++) {
struct spa_meta *m = &buf->metas[j];
spa_pod_builder_add(b,
"I", pw_protocol_native0_type_to_v2(client, spa_type_meta_type, m->type),
"i", m->size, NULL);
}
spa_pod_builder_add(b, "i", buf->n_datas, NULL);
for (j = 0; j < buf->n_datas; j++) {
struct spa_data *d = &buf->datas[j];
spa_pod_builder_add(b,
"I", pw_protocol_native0_type_to_v2(client, spa_type_data_type, d->type),
"i", SPA_PTR_TO_UINT32(d->data),
"i", d->flags,
"i", d->mapoffset,
"i", d->maxsize, NULL);
}
}
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_port_command(void *object,
uint32_t direction,
uint32_t port_id,
const struct spa_command *command)
{
struct pw_resource *resource = object;
struct pw_client *client = resource->client;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_PORT_COMMAND, NULL);
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b,
"i", direction,
"i", port_id, NULL);
pw_protocol_native0_pod_to_v2(client, (struct spa_pod *)command, b);
spa_pod_builder_pop(b, &f);
pw_protocol_native_end_resource(resource, b);
}
static void
client_node_marshal_port_set_io(void *object,
uint32_t seq,
uint32_t direction,
uint32_t port_id,
uint32_t id,
uint32_t memid,
uint32_t offset,
uint32_t size)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE0_PROXY_EVENT_PORT_SET_IO, NULL);
spa_pod_builder_add_struct(b,
"i", seq,
"i", direction,
"i", port_id,
"I", id,
"i", memid,
"i", offset,
"i", size);
pw_protocol_native_end_resource(resource, b);
}
static int client_node_demarshal_done(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t seq, res;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
"i", &seq,
"i", &res) < 0)
return -EINVAL;
return pw_resource_notify(resource, struct pw_client_node0_proxy_methods, done, 0, seq, res);
}
static int client_node_demarshal_update(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
struct spa_pod_frame f;
uint32_t change_mask, max_input_ports, max_output_ports, n_params;
const struct spa_pod **params;
uint32_t i;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_push_struct(&prs, &f) < 0 ||
spa_pod_parser_get(&prs,
"i", &change_mask,
"i", &max_input_ports,
"i", &max_output_ports,
"i", &n_params, NULL) < 0)
return -EINVAL;
params = alloca(n_params * sizeof(struct spa_pod *));
for (i = 0; i < n_params; i++)
if (spa_pod_parser_get(&prs, "O", &params[i], NULL) < 0)
return -EINVAL;
return pw_resource_notify(resource, struct pw_client_node0_proxy_methods, update, 0, change_mask,
max_input_ports,
max_output_ports,
n_params,
params);
}
static int client_node_demarshal_port_update(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
struct spa_pod_frame f[2];
uint32_t i, direction, port_id, change_mask, n_params;
const struct spa_pod **params = NULL;
struct spa_port_info info = { 0 }, *infop = NULL;
struct spa_dict props;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_push_struct(&prs, &f[0]) < 0 ||
spa_pod_parser_get(&prs,
"i", &direction,
"i", &port_id,
"i", &change_mask,
"i", &n_params, NULL) < 0)
return -EINVAL;
params = alloca(n_params * sizeof(struct spa_pod *));
for (i = 0; i < n_params; i++)
if (spa_pod_parser_get(&prs, "O", &params[i], NULL) < 0)
return -EINVAL;
if (spa_pod_parser_push_struct(&prs, &f[1]) >= 0) {
infop = &info;
if (spa_pod_parser_get(&prs,
"i", &info.flags,
"i", &info.rate,
"i", &props.n_items, NULL) < 0)
return -EINVAL;
if (props.n_items > 0) {
info.props = &props;
props.items = alloca(props.n_items * sizeof(struct spa_dict_item));
for (i = 0; i < props.n_items; i++) {
if (spa_pod_parser_get(&prs,
"s", &props.items[i].key,
"s", &props.items[i].value,
NULL) < 0)
return -EINVAL;
}
}
}
return pw_resource_notify(resource, struct pw_client_node0_proxy_methods, port_update, 0, direction,
port_id,
change_mask,
n_params,
params, infop);
}
static int client_node_demarshal_set_active(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
int active;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
"b", &active) < 0)
return -EINVAL;
return pw_resource_notify(resource, struct pw_client_node0_proxy_methods, set_active, 0, active);
}
static int client_node_demarshal_event_method(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
struct spa_event *event;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
"O", &event) < 0)
return -EINVAL;
return pw_resource_notify(resource, struct pw_client_node0_proxy_methods, event, 0, event);
}
static int client_node_demarshal_destroy(void *object, const struct pw_protocol_native_message *msg)
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
int res;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs, NULL) < 0)
return -EINVAL;
res = pw_resource_notify(resource, struct pw_client_node0_proxy_methods, destroy, 0);
pw_resource_destroy(resource);
return res;
}
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_method_demarshal[] = {
{ &client_node_demarshal_done, 0, 0 },
{ &client_node_demarshal_update, 0, PW_PROTOCOL_NATIVE_FLAG_REMAP },
{ &client_node_demarshal_port_update, 0, PW_PROTOCOL_NATIVE_FLAG_REMAP },
{ &client_node_demarshal_set_active, 0, 0 },
{ &client_node_demarshal_event_method, 0, PW_PROTOCOL_NATIVE_FLAG_REMAP },
{ &client_node_demarshal_destroy, 0, 0 },
};
static const struct pw_client_node0_proxy_events pw_protocol_native_client_node_event_marshal = {
PW_VERSION_CLIENT_NODE0_PROXY_EVENTS,
&client_node_marshal_add_mem,
&client_node_marshal_transport,
&client_node_marshal_set_param,
&client_node_marshal_event_event,
&client_node_marshal_command,
&client_node_marshal_add_port,
&client_node_marshal_remove_port,
&client_node_marshal_port_set_param,
&client_node_marshal_port_use_buffers,
&client_node_marshal_port_command,
&client_node_marshal_port_set_io,
};
static const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
PW_TYPE_INTERFACE_ClientNode,
PW_VERSION_CLIENT_NODE0,
PW_CLIENT_NODE0_PROXY_METHOD_NUM,
PW_CLIENT_NODE0_PROXY_EVENT_NUM,
NULL,
&pw_protocol_native_client_node_method_demarshal,
&pw_protocol_native_client_node_event_marshal,
NULL,
};
struct pw_protocol *pw_protocol_native_ext_client_node0_init(struct pw_core *core)
{
struct pw_protocol *protocol;
protocol = pw_core_find_protocol(core, PW_TYPE_INFO_PROTOCOL_Native);
if (protocol == NULL)
return NULL;
pw_protocol_add_marshal(protocol, &pw_protocol_native_client_node_marshal);
return protocol;
}

View file

@ -0,0 +1,257 @@
/* PipeWire
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
#include <spa/utils/ringbuffer.h>
#include <spa/node/io.h>
#include <pipewire/log.h>
#include <pipewire/private.h>
#include "ext-client-node.h"
#include "transport.h"
/** \cond */
#define INPUT_BUFFER_SIZE (1<<12)
#define OUTPUT_BUFFER_SIZE (1<<12)
struct transport {
struct pw_client_node0_transport trans;
struct pw_memblock *mem;
size_t offset;
struct pw_client_node0_message current;
uint32_t current_index;
};
/** \endcond */
static size_t area_get_size(struct pw_client_node0_area *area)
{
size_t size;
size = sizeof(struct pw_client_node0_area);
size += area->max_input_ports * sizeof(struct spa_io_buffers);
size += area->max_output_ports * sizeof(struct spa_io_buffers);
size += sizeof(struct spa_ringbuffer);
size += INPUT_BUFFER_SIZE;
size += sizeof(struct spa_ringbuffer);
size += OUTPUT_BUFFER_SIZE;
return size;
}
static void transport_setup_area(void *p, struct pw_client_node0_transport *trans)
{
struct pw_client_node0_area *a;
trans->area = a = p;
p = SPA_MEMBER(p, sizeof(struct pw_client_node0_area), struct spa_io_buffers);
trans->inputs = p;
p = SPA_MEMBER(p, a->max_input_ports * sizeof(struct spa_io_buffers), void);
trans->outputs = p;
p = SPA_MEMBER(p, a->max_output_ports * sizeof(struct spa_io_buffers), void);
trans->input_buffer = p;
p = SPA_MEMBER(p, sizeof(struct spa_ringbuffer), void);
trans->input_data = p;
p = SPA_MEMBER(p, INPUT_BUFFER_SIZE, void);
trans->output_buffer = p;
p = SPA_MEMBER(p, sizeof(struct spa_ringbuffer), void);
trans->output_data = p;
p = SPA_MEMBER(p, OUTPUT_BUFFER_SIZE, void);
}
static void transport_reset_area(struct pw_client_node0_transport *trans)
{
uint32_t i;
struct pw_client_node0_area *a = trans->area;
for (i = 0; i < a->max_input_ports; i++) {
trans->inputs[i].status = SPA_STATUS_OK;
trans->inputs[i].buffer_id = SPA_ID_INVALID;
}
for (i = 0; i < a->max_output_ports; i++) {
trans->outputs[i].status = SPA_STATUS_OK;
trans->outputs[i].buffer_id = SPA_ID_INVALID;
}
spa_ringbuffer_init(trans->input_buffer);
spa_ringbuffer_init(trans->output_buffer);
}
static void destroy(struct pw_client_node0_transport *trans)
{
struct transport *impl = (struct transport *) trans;
pw_log_debug("transport %p: destroy", trans);
pw_memblock_free(impl->mem);
free(impl);
}
static int add_message(struct pw_client_node0_transport *trans, struct pw_client_node0_message *message)
{
struct transport *impl = (struct transport *) trans;
int32_t filled, avail;
uint32_t size, index;
if (impl == NULL || message == NULL)
return -EINVAL;
filled = spa_ringbuffer_get_write_index(trans->output_buffer, &index);
avail = OUTPUT_BUFFER_SIZE - filled;
size = SPA_POD_SIZE(message);
if (avail < (int)size)
return -ENOSPC;
spa_ringbuffer_write_data(trans->output_buffer,
trans->output_data, OUTPUT_BUFFER_SIZE,
index & (OUTPUT_BUFFER_SIZE - 1), message, size);
spa_ringbuffer_write_update(trans->output_buffer, index + size);
return 0;
}
static int next_message(struct pw_client_node0_transport *trans, struct pw_client_node0_message *message)
{
struct transport *impl = (struct transport *) trans;
int32_t avail;
if (impl == NULL || message == NULL)
return -EINVAL;
avail = spa_ringbuffer_get_read_index(trans->input_buffer, &impl->current_index);
if (avail < (int) sizeof(struct pw_client_node0_message))
return 0;
spa_ringbuffer_read_data(trans->input_buffer,
trans->input_data, INPUT_BUFFER_SIZE,
impl->current_index & (INPUT_BUFFER_SIZE - 1),
&impl->current, sizeof(struct pw_client_node0_message));
if (avail < (int) SPA_POD_SIZE(&impl->current))
return 0;
*message = impl->current;
return 1;
}
static int parse_message(struct pw_client_node0_transport *trans, void *message)
{
struct transport *impl = (struct transport *) trans;
uint32_t size;
if (impl == NULL || message == NULL)
return -EINVAL;
size = SPA_POD_SIZE(&impl->current);
spa_ringbuffer_read_data(trans->input_buffer,
trans->input_data, INPUT_BUFFER_SIZE,
impl->current_index & (INPUT_BUFFER_SIZE - 1), message, size);
spa_ringbuffer_read_update(trans->input_buffer, impl->current_index + size);
return 0;
}
/** Create a new transport
* \param max_input_ports maximum number of input_ports
* \param max_output_ports maximum number of output_ports
* \return a newly allocated \ref pw_client_node0_transport
* \memberof pw_client_node0_transport
*/
struct pw_client_node0_transport *
pw_client_node0_transport_new(struct pw_core *core,
uint32_t max_input_ports, uint32_t max_output_ports)
{
struct transport *impl;
struct pw_client_node0_transport *trans;
struct pw_client_node0_area area = { 0 };
area.max_input_ports = max_input_ports;
area.n_input_ports = 0;
area.max_output_ports = max_output_ports;
area.n_output_ports = 0;
impl = calloc(1, sizeof(struct transport));
if (impl == NULL)
return NULL;
pw_log_debug("transport %p: new %d %d", impl, max_input_ports, max_output_ports);
trans = &impl->trans;
impl->offset = 0;
impl->mem = pw_mempool_alloc(core->pool,
PW_MEMBLOCK_FLAG_READWRITE |
PW_MEMBLOCK_FLAG_MAP |
PW_MEMBLOCK_FLAG_SEAL,
SPA_DATA_MemFd, area_get_size(&area));
if (impl->mem == NULL)
return NULL;
memcpy(impl->mem->map->ptr, &area, sizeof(struct pw_client_node0_area));
transport_setup_area(impl->mem->map->ptr, trans);
transport_reset_area(trans);
trans->destroy = destroy;
trans->add_message = add_message;
trans->next_message = next_message;
trans->parse_message = parse_message;
return trans;
}
struct pw_client_node0_transport *
pw_client_node0_transport_new_from_info(struct pw_client_node0_transport_info *info)
{
errno = ENOTSUP;
return NULL;
}
/** Get transport info
* \param trans the transport to get info of
* \param[out] info transport info
* \return 0 on success
*
* Fill \a info with the transport info of \a trans. This information can be
* passed to the client to set up the shared transport.
*
* \memberof pw_client_node0_transport
*/
int pw_client_node0_transport_get_info(struct pw_client_node0_transport *trans,
struct pw_client_node0_transport_info *info)
{
struct transport *impl = (struct transport *) trans;
info->memfd = impl->mem->fd;
info->offset = impl->offset;
info->size = impl->mem->size;
return 0;
}

View file

@ -0,0 +1,54 @@
/* PipeWire
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_CLIENT_NODE0_TRANSPORT_H__
#define __PIPEWIRE_CLIENT_NODE0_TRANSPORT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#include <spa/utils/defs.h>
#include <pipewire/mem.h>
/** information about the transport region \memberof pw_client_node */
struct pw_client_node0_transport_info {
int memfd; /**< the memfd of the transport area */
uint32_t offset; /**< offset to map \a memfd at */
uint32_t size; /**< size of memfd mapping */
};
struct pw_client_node0_transport *
pw_client_node0_transport_new(struct pw_core *core, uint32_t max_input_ports, uint32_t max_output_ports);
struct pw_client_node0_transport *
pw_client_node0_transport_new_from_info(struct pw_client_node0_transport_info *info);
int
pw_client_node0_transport_get_info(struct pw_client_node0_transport *trans,
struct pw_client_node0_transport_info *info);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __PIPEWIRE_CLIENT_NODE0_TRANSPORT_H__ */

View file

@ -44,6 +44,8 @@
#include <pipewire/pipewire.h> #include <pipewire/pipewire.h>
#include <extensions/protocol-native.h> #include <extensions/protocol-native.h>
#include "pipewire/map.h"
#include "pipewire/private.h" #include "pipewire/private.h"
#include "modules/module-protocol-native/connection.h" #include "modules/module-protocol-native/connection.h"
@ -67,6 +69,7 @@ static bool debug_messages = 0;
#define LOCK_SUFFIXLEN 5 #define LOCK_SUFFIXLEN 5
void pw_protocol_native_init(struct pw_protocol *protocol); void pw_protocol_native_init(struct pw_protocol *protocol);
void pw_protocol_native0_init(struct pw_protocol *protocol);
struct protocol_data { struct protocol_data {
struct pw_module *module; struct pw_module *module;
@ -102,10 +105,15 @@ struct server {
struct client_data { struct client_data {
struct pw_client *client; struct pw_client *client;
struct spa_hook client_listener; struct spa_hook client_listener;
struct spa_source *source; struct spa_source *source;
struct pw_protocol_native_connection *connection; struct pw_protocol_native_connection *connection;
struct spa_hook conn_listener;
unsigned int busy:1; unsigned int busy:1;
unsigned int need_flush:1; unsigned int need_flush:1;
struct protocol_compat_v2 compat_v2;
}; };
static void static void
@ -127,9 +135,20 @@ process_messages(struct client_data *data)
const struct pw_protocol_marshal *marshal; const struct pw_protocol_marshal *marshal;
uint32_t permissions, required; uint32_t permissions, required;
if (pw_protocol_native_connection_get_next(conn, &msg) != 1) res = pw_protocol_native_connection_get_next(conn, &msg);
if (res < 0) {
if (res == -EAGAIN)
break;
goto error;
}
if (res == 0)
break; break;
if (client->core_resource == NULL) {
res = -EPROTO;
goto error;
}
client->recv_seq = msg->seq; client->recv_seq = msg->seq;
pw_log_trace(NAME" %p: got message %d from %u", client->protocol, pw_log_trace(NAME" %p: got message %d from %u", client->protocol,
@ -193,6 +212,10 @@ invalid_message:
spa_debug_pod(0, NULL, (struct spa_pod *)msg->data); spa_debug_pod(0, NULL, (struct spa_pod *)msg->data);
pw_client_destroy(client); pw_client_destroy(client);
goto done; goto done;
error:
pw_log_error(NAME" %p: client error (%s)", client->protocol, spa_strerror(res));
pw_client_destroy(client);
goto done;
} }
static void static void
@ -260,6 +283,8 @@ static void client_free(void *data)
pw_loop_destroy_source(client->protocol->core->main_loop, this->source); pw_loop_destroy_source(client->protocol->core->main_loop, this->source);
if (this->connection) if (this->connection)
pw_protocol_native_connection_destroy(this->connection); pw_protocol_native_connection_destroy(this->connection);
pw_map_clear(&this->compat_v2.types);
} }
static const struct pw_client_events client_events = { static const struct pw_client_events client_events = {
@ -268,6 +293,32 @@ static const struct pw_client_events client_events = {
.busy_changed = client_busy_changed, .busy_changed = client_busy_changed,
}; };
static void on_start(void *data, uint32_t version)
{
struct client_data *this = data;
struct pw_client *client = this->client;
struct pw_core *core = client->core;
pw_log_debug("version %d", version);
if (pw_global_bind(pw_core_get_global(core), client,
PW_PERM_RWX, version, 0) < 0)
return;
if (version == 0)
client->compat_v2 = &this->compat_v2;
if (pw_client_register(client, NULL) < 0)
return;
return;
}
static const struct pw_protocol_native_connection_events server_conn_events = {
PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS,
.start = on_start,
};
static struct pw_client *client_new(struct server *s, int fd) static struct pw_client *client_new(struct server *s, int fd)
{ {
struct client_data *this; struct client_data *this;
@ -323,18 +374,15 @@ static struct pw_client *client_new(struct server *s, int fd)
if (this->connection == NULL) if (this->connection == NULL)
goto cleanup_client; goto cleanup_client;
pw_map_init(&this->compat_v2.types, 0, 32);
pw_protocol_native_connection_add_listener(this->connection,
&this->conn_listener,
&server_conn_events,
this);
pw_client_add_listener(client, &this->client_listener, &client_events, this); pw_client_add_listener(client, &this->client_listener, &client_events, this);
if (pw_global_bind(pw_core_get_global(core), client,
PW_PERM_RWX, PW_VERSION_CORE_PROXY, 0) < 0)
goto cleanup_client;
if (pw_client_register(client, NULL) < 0)
goto cleanup_client;
if (pw_global_bind(pw_client_get_global(client), client,
PW_PERM_RWX, PW_VERSION_CLIENT_PROXY, 1) < 0)
goto cleanup_client;
return client; return client;
@ -632,7 +680,7 @@ static void on_need_flush(void *data)
} }
} }
static const struct pw_protocol_native_connection_events conn_events = { static const struct pw_protocol_native_connection_events client_conn_events = {
PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS, PW_VERSION_PROTOCOL_NATIVE_CONNECTION_EVENTS,
.need_flush = on_need_flush, .need_flush = on_need_flush,
}; };
@ -662,7 +710,7 @@ static int impl_connect_fd(struct pw_protocol_client *client, int fd, bool do_cl
pw_protocol_native_connection_add_listener(impl->connection, pw_protocol_native_connection_add_listener(impl->connection,
&impl->conn_listener, &impl->conn_listener,
&conn_events, &client_conn_events,
impl); impl);
return 0; return 0;
@ -957,6 +1005,7 @@ int pipewire__module_init(struct pw_module *module, const char *args)
this->extension = &protocol_ext_impl; this->extension = &protocol_ext_impl;
pw_protocol_native_init(this); pw_protocol_native_init(this);
pw_protocol_native0_init(this);
pw_log_debug(NAME" %p: new %d", this, debug_messages); pw_log_debug(NAME" %p: new %d", this, debug_messages);

View file

@ -58,6 +58,7 @@ struct buffer {
struct pw_protocol_native_message msg; struct pw_protocol_native_message msg;
bool update; bool update;
bool first;
}; };
struct impl { struct impl {
@ -66,6 +67,9 @@ struct impl {
struct buffer in, out; struct buffer in, out;
struct spa_pod_builder builder; struct spa_pod_builder builder;
uint32_t version;
size_t hdr_size;
}; };
/** \endcond */ /** \endcond */
@ -240,11 +244,15 @@ struct pw_protocol_native_connection *pw_protocol_native_connection_new(struct p
this->fd = fd; this->fd = fd;
spa_hook_list_init(&this->listener_list); spa_hook_list_init(&this->listener_list);
impl->hdr_size = HDR_SIZE;
impl->version = 3;
impl->out.buffer_data = calloc(1, MAX_BUFFER_SIZE); impl->out.buffer_data = calloc(1, MAX_BUFFER_SIZE);
impl->out.buffer_maxsize = MAX_BUFFER_SIZE; impl->out.buffer_maxsize = MAX_BUFFER_SIZE;
impl->in.buffer_data = calloc(1, MAX_BUFFER_SIZE); impl->in.buffer_data = calloc(1, MAX_BUFFER_SIZE);
impl->in.buffer_maxsize = MAX_BUFFER_SIZE; impl->in.buffer_maxsize = MAX_BUFFER_SIZE;
impl->in.update = true; impl->in.update = true;
impl->in.first = true;
if (impl->out.buffer_data == NULL || impl->in.buffer_data == NULL) if (impl->out.buffer_data == NULL || impl->in.buffer_data == NULL)
goto no_mem; goto no_mem;
@ -279,6 +287,7 @@ void pw_protocol_native_connection_destroy(struct pw_protocol_native_connection
static int prepare_packet(struct pw_protocol_native_connection *conn, struct buffer *buf) static int prepare_packet(struct pw_protocol_native_connection *conn, struct buffer *buf)
{ {
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint8_t *data; uint8_t *data;
size_t size, len; size_t size, len;
uint32_t *p; uint32_t *p;
@ -286,18 +295,39 @@ static int prepare_packet(struct pw_protocol_native_connection *conn, struct buf
data = buf->buffer_data + buf->offset; data = buf->buffer_data + buf->offset;
size = buf->buffer_size - buf->offset; size = buf->buffer_size - buf->offset;
if (size < HDR_SIZE) if (size < impl->hdr_size)
return HDR_SIZE; return impl->hdr_size;
p = (uint32_t *) data; p = (uint32_t *) data;
data += HDR_SIZE;
size -= HDR_SIZE;
buf->msg.id = p[0]; buf->msg.id = p[0];
buf->msg.opcode = p[1] >> 24; buf->msg.opcode = p[1] >> 24;
len = p[1] & 0xffffff; len = p[1] & 0xffffff;
buf->msg.seq = p[2];
buf->msg.n_fds = p[3]; if (buf->first) {
buf->first = false;
if (p[2] != 0) {
pw_log_warn("old version detected");
impl->version = 0;
impl->hdr_size = 8;
} else {
impl->version = 3;
impl->hdr_size = 16;
}
spa_hook_list_call(&conn->listener_list,
struct pw_protocol_native_connection_events,
start, 0, impl->version);
}
if (impl->version >= 3) {
buf->msg.seq = p[2];
buf->msg.n_fds = p[3];
} else {
buf->msg.seq = 0;
buf->msg.n_fds = 0;
}
data += impl->hdr_size;
size -= impl->hdr_size;
buf->msg.fds = &buf->fds[buf->fds_offset]; buf->msg.fds = &buf->fds[buf->fds_offset];
if (size < len) if (size < len)
@ -306,7 +336,7 @@ static int prepare_packet(struct pw_protocol_native_connection *conn, struct buf
buf->msg.size = len; buf->msg.size = len;
buf->msg.data = data; buf->msg.data = data;
buf->offset += HDR_SIZE + len; buf->offset += impl->hdr_size + len;
buf->fds_offset += buf->msg.n_fds; buf->fds_offset += buf->msg.n_fds;
if (buf->offset >= buf->buffer_size) if (buf->offset >= buf->buffer_size)
@ -334,14 +364,16 @@ pw_protocol_native_connection_get_next(struct pw_protocol_native_connection *con
const struct pw_protocol_native_message **msg) const struct pw_protocol_native_message **msg)
{ {
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
size_t len; int len, res;
int res;
struct buffer *buf; struct buffer *buf;
buf = &impl->in; buf = &impl->in;
while (1) { while (1) {
if ((len = prepare_packet(conn, buf)) == 0) len = prepare_packet(conn, buf);
if (len < 0)
return len;
if (len == 0)
break; break;
if (connection_ensure_size(conn, buf, len) == NULL) if (connection_ensure_size(conn, buf, len) == NULL)
@ -359,10 +391,10 @@ static inline void *begin_write(struct pw_protocol_native_connection *conn, uint
uint32_t *p; uint32_t *p;
struct buffer *buf = &impl->out; struct buffer *buf = &impl->out;
/* header and size for payload */ /* header and size for payload */
if ((p = connection_ensure_size(conn, buf, HDR_SIZE + size)) == NULL) if ((p = connection_ensure_size(conn, buf, impl->hdr_size + size)) == NULL)
return NULL; return NULL;
return SPA_MEMBER(p, HDR_SIZE, void); return SPA_MEMBER(p, impl->hdr_size, void);
} }
static int builder_overflow(void *data, uint32_t size) static int builder_overflow(void *data, uint32_t size)
@ -393,8 +425,14 @@ pw_protocol_native_connection_begin(struct pw_protocol_native_connection *conn,
buf->msg.opcode = opcode; buf->msg.opcode = opcode;
impl->builder = SPA_POD_BUILDER_INIT(NULL, 0); impl->builder = SPA_POD_BUILDER_INIT(NULL, 0);
spa_pod_builder_set_callbacks(&impl->builder, &builder_callbacks, impl); spa_pod_builder_set_callbacks(&impl->builder, &builder_callbacks, impl);
buf->msg.n_fds = 0; if (impl->version >= 3) {
buf->msg.fds = &buf->fds[buf->n_fds]; buf->msg.n_fds = 0;
buf->msg.fds = &buf->fds[buf->n_fds];
} else {
buf->msg.n_fds = buf->n_fds;
buf->msg.fds = &buf->fds[0];
}
buf->msg.seq = buf->seq; buf->msg.seq = buf->seq;
if (msg) if (msg)
*msg = &buf->msg; *msg = &buf->msg;
@ -410,21 +448,26 @@ pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
struct buffer *buf = &impl->out; struct buffer *buf = &impl->out;
int res; int res;
if ((p = connection_ensure_size(conn, buf, HDR_SIZE + size)) == NULL) if ((p = connection_ensure_size(conn, buf, impl->hdr_size + size)) == NULL)
return -errno; return -errno;
p[0] = buf->msg.id; p[0] = buf->msg.id;
p[1] = (buf->msg.opcode << 24) | (size & 0xffffff); p[1] = (buf->msg.opcode << 24) | (size & 0xffffff);
p[2] = buf->msg.seq; if (impl->version >= 3) {
p[3] = buf->msg.n_fds; p[2] = buf->msg.seq;
p[3] = buf->msg.n_fds;
}
buf->buffer_size += HDR_SIZE + size; buf->buffer_size += impl->hdr_size + size;
buf->n_fds += buf->msg.n_fds; if (impl->version >= 3)
buf->n_fds += buf->msg.n_fds;
else
buf->n_fds = buf->msg.n_fds;
if (debug_messages) { if (debug_messages) {
fprintf(stderr, ">>>>>>>>> out: id:%d op:%d size:%d seq:%d\n", fprintf(stderr, ">>>>>>>>> out: id:%d op:%d size:%d seq:%d\n",
buf->msg.id, buf->msg.opcode, size, buf->msg.seq); buf->msg.id, buf->msg.opcode, size, buf->msg.seq);
spa_debug_pod(0, NULL, SPA_MEMBER(p, HDR_SIZE, struct spa_pod)); spa_debug_pod(0, NULL, SPA_MEMBER(p, impl->hdr_size, struct spa_pod));
} }
buf->seq = (buf->seq + 1) & SPA_ASYNC_SEQ_MASK; buf->seq = (buf->seq + 1) & SPA_ASYNC_SEQ_MASK;

View file

@ -43,6 +43,8 @@ struct pw_protocol_native_connection_events {
void (*error) (void *data, int error); void (*error) (void *data, int error);
void (*need_flush) (void *data); void (*need_flush) (void *data);
void (*start) (void *data, uint32_t version);
}; };
/** \class pw_protocol_native_connection /** \class pw_protocol_native_connection

View file

@ -108,7 +108,7 @@ static struct pw_registry_proxy * core_method_marshal_get_registry(void *object,
struct pw_proxy *res; struct pw_proxy *res;
uint32_t new_id; uint32_t new_id;
res = pw_proxy_new(object, PW_TYPE_INTERFACE_Registry, user_data_size); res = pw_proxy_new(object, PW_TYPE_INTERFACE_Registry, version, user_data_size);
if (res == NULL) if (res == NULL)
return NULL; return NULL;
@ -200,7 +200,7 @@ core_method_marshal_create_object(void *object,
struct pw_proxy *res; struct pw_proxy *res;
uint32_t new_id; uint32_t new_id;
res = pw_proxy_new(object, type, user_data_size); res = pw_proxy_new(object, type, version, user_data_size);
if (res == NULL) if (res == NULL)
return NULL; return NULL;
@ -1833,7 +1833,7 @@ static void * registry_marshal_bind(void *object, uint32_t id,
struct pw_proxy *res; struct pw_proxy *res;
uint32_t new_id; uint32_t new_id;
res = pw_proxy_new(object, type, user_data_size); res = pw_proxy_new(object, type, version, user_data_size);
if (res == NULL) if (res == NULL)
return NULL; return NULL;

View file

@ -0,0 +1,532 @@
/* PipeWire
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef PIPEWIRE_INTERFACES_V0_H
#define PIPEWIRE_INTERFACES_V0_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/param/param.h>
#include <spa/node/node.h>
#include <pipewire/introspect.h>
#include <pipewire/proxy.h>
/** Core */
#define PW_VERSION_CORE_V0 0
#define PW_CORE_PROXY_V0_METHOD_HELLO 0
#define PW_CORE_PROXY_V0_METHOD_UPDATE_TYPES 1
#define PW_CORE_PROXY_V0_METHOD_SYNC 2
#define PW_CORE_PROXY_V0_METHOD_GET_REGISTRY 3
#define PW_CORE_PROXY_V0_METHOD_CLIENT_UPDATE 4
#define PW_CORE_PROXY_V0_METHOD_PERMISSIONS 5
#define PW_CORE_PROXY_V0_METHOD_CREATE_OBJECT 6
#define PW_CORE_PROXY_V0_METHOD_DESTROY 7
#define PW_CORE_PROXY_V0_METHOD_NUM 8
#if 0
/**
* Key to update default permissions of globals without specific
* permissions. value is "[r][w][x]" */
#define PW_CORE_PROXY_PERMISSIONS_DEFAULT "permissions.default"
/**
* Key to update specific permissions of a global. If the global
* did not have specific permissions, it will first be assigned
* the default permissions before it is updated.
* Value is "<global-id>:[r][w][x]"*/
#define PW_CORE_PROXY_PERMISSIONS_GLOBAL "permissions.global"
/**
* Key to update specific permissions of all existing globals.
* This is equivalent to using \ref PW_CORE_PROXY_PERMISSIONS_GLOBAL
* on each global id individually that did not have specific
* permissions.
* Value is "[r][w][x]" */
#define PW_CORE_PROXY_PERMISSIONS_EXISTING "permissions.existing"
#define PW_LINK_OUTPUT_NODE_ID "link.output_node.id"
#define PW_LINK_OUTPUT_PORT_ID "link.output_port.id"
#define PW_LINK_INPUT_NODE_ID "link.input_node.id"
#define PW_LINK_INPUT_PORT_ID "link.input_port.id"
#endif
/**
* \struct pw_core_proxy_v0_methods
* \brief Core methods
*
* The core global object. This is a singleton object used for
* creating new objects in the remote PipeWire intance. It is
* also used for internal features.
*/
struct pw_core_proxy_v0_methods {
#define PW_VERSION_CORE_PROXY_V0_METHODS 0
uint32_t version;
/**
* Start a conversation with the server. This will send
* the core info and server types.
*
* All the existing resources for the client (except the core
* resource) will be destroyed.
*/
void (*hello) (void *object);
/**
* Update the type map
*
* Send a type map update to the PipeWire server. The server uses this
* information to keep a mapping between client types and the server types.
* \param first_id the id of the first type
* \param types the types as a string
* \param n_types the number of types
*/
void (*update_types) (void *object,
uint32_t first_id,
const char **types,
uint32_t n_types);
/**
* Do server roundtrip
*
* Ask the server to emit the 'done' event with \a id.
* Since methods are handled in-order and events are delivered
* in-order, this can be used as a barrier to ensure all previous
* methods and the resulting events have been handled.
* \param seq the sequence number passed to the done event
*/
void (*sync) (void *object, uint32_t seq);
/**
* Get the registry object
*
* Create a registry object that allows the client to list and bind
* the global objects available from the PipeWire server
* \param version the client proxy id
* \param id the client proxy id
*/
void (*get_registry) (void *object, uint32_t version, uint32_t new_id);
/**
* Update the client properties
* \param props the new client properties
*/
void (*client_update) (void *object, const struct spa_dict *props);
/**
* Manage the permissions of the global objects
*
* Update the permissions of the global objects using the
* dictionary with properties.
*
* Globals can use the default permissions or can have specific
* permissions assigned to them.
*
* \param id the global id to change
* \param props dictionary with permission properties
*/
void (*permissions) (void *object, const struct spa_dict *props);
/**
* Create a new object on the PipeWire server from a factory.
* Use a \a factory_name of "client-node" to create a
* \ref pw_client_node.
*
* \param factory_name the factory name to use
* \param type the interface to bind to
* \param version the version of the interface
* \param props extra properties
* \param new_id the client proxy id
*/
void (*create_object) (void *object,
const char *factory_name,
uint32_t type,
uint32_t version,
const struct spa_dict *props,
uint32_t new_id);
/**
* Destroy an object id
*
* \param id the object id to destroy
*/
void (*destroy) (void *object, uint32_t id);
};
#define PW_CORE_PROXY_V0_EVENT_UPDATE_TYPES 0
#define PW_CORE_PROXY_V0_EVENT_DONE 1
#define PW_CORE_PROXY_V0_EVENT_ERROR 2
#define PW_CORE_PROXY_V0_EVENT_REMOVE_ID 3
#define PW_CORE_PROXY_V0_EVENT_INFO 4
#define PW_CORE_PROXY_V0_EVENT_NUM 5
/** \struct pw_core_proxy_v0_events
* \brief Core events
* \ingroup pw_core_interface The pw_core interface
*/
struct pw_core_proxy_v0_events {
#define PW_VERSION_CORE_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Update the type map
*
* Send a type map update to the client. The client uses this
* information to keep a mapping between server types and the client types.
* \param first_id the id of the first type
* \param types the types as a string
* \param n_types the number of \a types
*/
void (*update_types) (void *object,
uint32_t first_id,
const char **types,
uint32_t n_types);
/**
* Emit a done event
*
* The done event is emited as a result of a sync method with the
* same sequence number.
* \param seq the sequence number passed to the sync method call
*/
void (*done) (void *object, uint32_t seq);
/**
* Fatal error event
*
* The error event is sent out when a fatal (non-recoverable)
* error has occurred. The id argument is the object where
* the error occurred, most often in response to a request to that
* object. The message is a brief description of the error,
* for (debugging) convenience.
* \param id object where the error occurred
* \param res error code
* \param error error description
*/
void (*error) (void *object, uint32_t id, int res, const char *error, ...);
/**
* Remove an object ID
*
* This event is used internally by the object ID management
* logic. When a client deletes an object, the server will send
* this event to acknowledge that it has seen the delete request.
* When the client receives this event, it will know that it can
* safely reuse the object ID.
* \param id deleted object ID
*/
void (*remove_id) (void *object, uint32_t id);
/**
* Notify new core info
*
* \param info new core info
*/
void (*info) (void *object, struct pw_core_info *info);
};
#define pw_core_resource_v0_update_types(r,...) pw_resource_notify(r,struct pw_core_proxy_v0_events,update_types,__VA_ARGS__)
#define pw_core_resource_v0_done(r,...) pw_resource_notify(r,struct pw_core_proxy_v0_events,done,__VA_ARGS__)
#define pw_core_resource_v0_error(r,...) pw_resource_notify(r,struct pw_core_proxy_v0_events,error,__VA_ARGS__)
#define pw_core_resource_v0_remove_id(r,...) pw_resource_notify(r,struct pw_core_proxy_v0_events,remove_id,__VA_ARGS__)
#define pw_core_resource_v0_info(r,...) pw_resource_notify(r,struct pw_core_proxy_v0_events,info,__VA_ARGS__)
#define PW_VERSION_REGISTRY_V0 0
/** \page page_registry Registry
*
* \section page_registry_overview Overview
*
* The registry object is a singleton object that keeps track of
* global objects on the PipeWire instance. See also \ref page_global.
*
* Global objects typically represent an actual object in PipeWire
* (for example, a module or node) or they are singleton
* objects such as the core.
*
* When a client creates a registry object, the registry object
* will emit a global event for each global currently in the
* registry. Globals come and go as a result of device hotplugs or
* reconfiguration or other events, and the registry will send out
* global and global_remove events to keep the client up to date
* with the changes. To mark the end of the initial burst of
* events, the client can use the pw_core.sync methosd immediately
* after calling pw_core.get_registry.
*
* A client can bind to a global object by using the bind
* request. This creates a client-side proxy that lets the object
* emit events to the client and lets the client invoke methods on
* the object. See \ref page_proxy
*
* Clients can also change the permissions of the global objects that
* it can see. This is interesting when you want to configure a
* pipewire session before handing it to another application. You
* can, for example, hide certain existing or new objects or limit
* the access permissions on an object.
*/
#define PW_REGISTRY_PROXY_V0_METHOD_BIND 0
#define PW_REGISTRY_PROXY_V0_METHOD_NUM 1
/** Registry methods */
struct pw_registry_proxy_v0_methods {
#define PW_VERSION_REGISTRY_PROXY_V0_METHODS 0
uint32_t version;
/**
* Bind to a global object
*
* Bind to the global object with \a id and use the client proxy
* with new_id as the proxy. After this call, methods can be
* send to the remote global object and events can be received
*
* \param id the global id to bind to
* \param type the interface type to bind to
* \param version the interface version to use
* \param new_id the client proxy to use
*/
void (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version, uint32_t new_id);
};
#define PW_REGISTRY_PROXY_V0_EVENT_GLOBAL 0
#define PW_REGISTRY_PROXY_V0_EVENT_GLOBAL_REMOVE 1
#define PW_REGISTRY_PROXY_V0_EVENT_NUM 2
/** Registry events */
struct pw_registry_proxy_v0_events {
#define PW_VERSION_REGISTRY_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify of a new global object
*
* The registry emits this event when a new global object is
* available.
*
* \param id the global object id
* \param parent_id the parent global id
* \param permissions the permissions of the object
* \param type the type of the interface
* \param version the version of the interface
* \param props extra properties of the global
*/
void (*global) (void *object, uint32_t id, uint32_t parent_id,
uint32_t permissions, uint32_t type, uint32_t version,
const struct spa_dict *props);
/**
* Notify of a global object removal
*
* Emited when a global object was removed from the registry.
* If the client has any bindings to the global, it should destroy
* those.
*
* \param id the id of the global that was removed
*/
void (*global_remove) (void *object, uint32_t id);
};
#define pw_registry_resource_v0_global(r,...) pw_resource_notify(r,struct pw_registry_proxy_v0_events,global,__VA_ARGS__)
#define pw_registry_resource_v0_global_remove(r,...) pw_resource_notify(r,struct pw_registry_proxy_v0_events,global_remove,__VA_ARGS__)
#define PW_VERSION_MODULE_V0 0
#define PW_MODULE_PROXY_V0_EVENT_INFO 0
#define PW_MODULE_PROXY_V0_EVENT_NUM 1
/** Module events */
struct pw_module_proxy_v0_events {
#define PW_VERSION_MODULE_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify module info
*
* \param info info about the module
*/
void (*info) (void *object, struct pw_module_info *info);
};
#define pw_module_resource_v0_info(r,...) pw_resource_notify(r,struct pw_module_proxy_v0_events,info,__VA_ARGS__)
#define PW_VERSION_NODE_V0 0
#define PW_NODE_PROXY_V0_EVENT_INFO 0
#define PW_NODE_PROXY_V0_EVENT_PARAM 1
#define PW_NODE_PROXY_V0_EVENT_NUM 2
/** Node events */
struct pw_node_proxy_v0_events {
#define PW_VERSION_NODE_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify node info
*
* \param info info about the node
*/
void (*info) (void *object, struct pw_node_info *info);
/**
* Notify a node param
*
* Event emited as a result of the enum_params method.
*
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *object,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define pw_node_resource_v0_info(r,...) pw_resource_notify(r,struct pw_node_proxy_v0_events,info,__VA_ARGS__)
#define pw_node_resource_v0_param(r,...) pw_resource_notify(r,struct pw_node_proxy_v0_events,param,__VA_ARGS__)
#define PW_NODE_PROXY_V0_METHOD_ENUM_PARAMS 0
#define PW_NODE_PROXY_V0_METHOD_NUM 1
/** Node methods */
struct pw_node_proxy_v0_methods {
#define PW_VERSION_NODE_PROXY_V0_METHODS 0
uint32_t version;
/**
* Enumerate node parameters
*
* Start enumeration of node parameters. For each param, a
* param event will be emited.
*
* \param id the parameter id to enum or SPA_ID_INVALID for all
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*/
void (*enum_params) (void *object, uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
};
#define PW_VERSION_PORT_V0 0
#define PW_PORT_PROXY_V0_EVENT_INFO 0
#define PW_PORT_PROXY_V0_EVENT_PARAM 1
#define PW_PORT_PROXY_V0_EVENT_NUM 2
/** Port events */
struct pw_port_proxy_v0_events {
#define PW_VERSION_PORT_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify port info
*
* \param info info about the port
*/
void (*info) (void *object, struct pw_port_info *info);
/**
* Notify a port param
*
* Event emited as a result of the enum_params method.
*
* \param id the param id
* \param index the param index
* \param next the param index of the next param
* \param param the parameter
*/
void (*param) (void *object,
uint32_t id, uint32_t index, uint32_t next,
const struct spa_pod *param);
};
#define pw_port_resource_v0_info(r,...) pw_resource_notify(r,struct pw_port_proxy_v0_events,info,__VA_ARGS__)
#define pw_port_resource_v0_param(r,...) pw_resource_notify(r,struct pw_port_proxy_v0_events,param,__VA_ARGS__)
#define PW_PORT_PROXY_V0_METHOD_ENUM_PARAMS 0
#define PW_PORT_PROXY_V0_METHOD_NUM 1
/** Port methods */
struct pw_port_proxy_v0_methods {
#define PW_VERSION_PORT_PROXY_V0_METHODS 0
uint32_t version;
/**
* Enumerate port parameters
*
* Start enumeration of port parameters. For each param, a
* param event will be emited.
*
* \param id the parameter id to enumerate
* \param start the start index or 0 for the first param
* \param num the maximum number of params to retrieve
* \param filter a param filter or NULL
*/
void (*enum_params) (void *object, uint32_t id, uint32_t start, uint32_t num,
const struct spa_pod *filter);
};
#define PW_VERSION_FACTORY_V0 0
#define PW_FACTORY_PROXY_V0_EVENT_INFO 0
#define PW_FACTORY_PROXY_V0_EVENT_NUM 1
/** Factory events */
struct pw_factory_proxy_v0_events {
#define PW_VERSION_FACTORY_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify factory info
*
* \param info info about the factory
*/
void (*info) (void *object, struct pw_factory_info *info);
};
#define pw_factory_resource_v0_info(r,...) pw_resource_notify(r,struct pw_factory_proxy_v0_events,info,__VA_ARGS__)
#define PW_VERSION_CLIENT_V0 0
#define PW_CLIENT_PROXY_V0_EVENT_INFO 0
#define PW_CLIENT_PROXY_V0_EVENT_NUM 1
/** Client events */
struct pw_client_proxy_v0_events {
#define PW_VERSION_CLIENT_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify client info
*
* \param info info about the client
*/
void (*info) (void *object, struct pw_client_info *info);
};
#define pw_client_resource_v0_info(r,...) pw_resource_notify(r,struct pw_client_proxy_v0_events,info,__VA_ARGS__)
#define PW_VERSION_LINK_V0 0
#define PW_LINK_PROXY_V0_EVENT_INFO 0
#define PW_LINK_PROXY_V0_EVENT_NUM 1
/** Link events */
struct pw_link_proxy_v0_events {
#define PW_VERSION_LINK_PROXY_V0_EVENTS 0
uint32_t version;
/**
* Notify link info
*
* \param info info about the link
*/
void (*info) (void *object, struct pw_link_info *info);
};
#define pw_link_resource_v0_info(r,...) pw_resource_notify(r,struct pw_link_proxy_v0_events,info,__VA_ARGS__)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* PIPEWIRE_INTERFACES_V0_H */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,261 @@
const struct type_info {
const char *type;
const char *name;
uint32_t id;
} type_map[] = {
{ "Spa:Interface:TypeMap", SPA_TYPE_INFO_INTERFACE_BASE, 0, },
{ "Spa:Interface:Log", SPA_TYPE_INFO_INTERFACE_BASE "Log", SPA_TYPE_INTERFACE_Log, },
{ "Spa:Interface:Loop", SPA_TYPE_INFO_INTERFACE_BASE "Loop", SPA_TYPE_INTERFACE_Loop, },
{ "Spa:Interface:LoopControl", SPA_TYPE_INFO_INTERFACE_BASE "LoopControl", SPA_TYPE_INTERFACE_LoopControl, },
{ "Spa:Interface:LoopUtils", SPA_TYPE_INFO_INTERFACE_BASE "LoopUtils", SPA_TYPE_INTERFACE_LoopUtils, },
{ "PipeWire:Interface:Core", PW_TYPE_INFO_INTERFACE_BASE "Core", PW_TYPE_INTERFACE_Core, },
{ "PipeWire:Interface:Registry", PW_TYPE_INFO_INTERFACE_BASE "Registry", PW_TYPE_INTERFACE_Registry, },
{ "PipeWire:Interface:Node", PW_TYPE_INFO_INTERFACE_BASE "Node", PW_TYPE_INTERFACE_Node, },
{ "PipeWire:Interface:Port", PW_TYPE_INFO_INTERFACE_BASE "Port", PW_TYPE_INTERFACE_Port,},
{ "PipeWire:Interface:Factory", PW_TYPE_INFO_INTERFACE_BASE "Factory", PW_TYPE_INTERFACE_Factory, },
{ "PipeWire:Interface:Link", PW_TYPE_INFO_INTERFACE_BASE "Link", PW_TYPE_INTERFACE_Link, },
{ "PipeWire:Interface:Client", PW_TYPE_INFO_INTERFACE_BASE "Client", PW_TYPE_INTERFACE_Client, },
{ "PipeWire:Interface:Module", PW_TYPE_INFO_INTERFACE_BASE "Module", PW_TYPE_INTERFACE_Module, },
{ "PipeWire:Interface:ClientNode", PW_TYPE_INFO_INTERFACE_BASE "ClientNode", PW_TYPE_INTERFACE_ClientNode, },
{ "PipeWire:Interface:Device", PW_TYPE_INFO_INTERFACE_BASE "Device", PW_TYPE_INTERFACE_Device, },
{ "Spa:Interface:Node", SPA_TYPE_INFO_INTERFACE_BASE "Node", SPA_TYPE_INTERFACE_Node, },
{ "Spa:Interface:Clock", },
{ "Spa:Interface:Monitor", },
{ "Spa:Interface:Device", SPA_TYPE_INFO_INTERFACE_BASE "Device", SPA_TYPE_INTERFACE_Device, },
{ "Spa:POD:Object:Param:Format", SPA_TYPE_INFO_Format, SPA_TYPE_OBJECT_Format, },
{ "Spa:POD:Object:Param:Props", SPA_TYPE_INFO_Props, SPA_TYPE_OBJECT_Props, },
{ "Spa:Pointer:IO:Buffers", },
{ "Spa:Pointer:IO:Control:Range", },
{ "Spa:Pointer:IO:Prop", },
{ "Spa:Enum:ParamId:List", },
{ "Spa:POD:Object:Param:List", },
{ "Spa:POD:Object:Param:List:id", },
{ "Spa:Enum:ParamId:PropInfo", SPA_TYPE_INFO_PARAM_ID_BASE "PropInfo", SPA_PARAM_PropInfo, },
{ "Spa:POD:Object:Param:PropInfo", SPA_TYPE_INFO_PROP_INFO_BASE, SPA_PROP_INFO_START, },
{ "Spa:POD:Object:Param:PropInfo:id", SPA_TYPE_INFO_PROP_INFO_BASE "id", SPA_PROP_INFO_id, },
{ "Spa:POD:Object:Param:PropInfo:name", SPA_TYPE_INFO_PROP_INFO_BASE "name", SPA_PROP_INFO_name, },
{ "Spa:POD:Object:Param:PropInfo:type", SPA_TYPE_INFO_PROP_INFO_BASE "typ", SPA_PROP_INFO_type, },
{ "Spa:POD:Object:Param:PropInfo:labels", SPA_TYPE_INFO_PROP_INFO_BASE "labels", SPA_PROP_INFO_labels, },
{ "Spa:Enum:ParamId:Props", SPA_TYPE_INFO_PARAM_ID_BASE "Props", SPA_PARAM_Props, },
{ "Spa:Enum:ParamId:EnumFormat", SPA_TYPE_INFO_PARAM_ID_BASE "EnumFormat", SPA_PARAM_EnumFormat,},
{ "Spa:Enum:ParamId:Format", SPA_TYPE_INFO_PARAM_ID_BASE "Format", SPA_PARAM_Format, },
{ "Spa:Enum:ParamId:Buffers", SPA_TYPE_INFO_PARAM_ID_BASE "Buffers", SPA_PARAM_Buffers },
{ "Spa:Enum:ParamId:Meta", SPA_TYPE_INFO_PARAM_ID_BASE "Meta", SPA_PARAM_Meta, },
{ "Spa:Pointer:Meta:Header", SPA_TYPE_INFO_META_BASE "Header", SPA_META_Header, },
{ "Spa:Pointer:Meta:VideoCrop", SPA_TYPE_INFO_META_REGION_BASE "VideoCrop", SPA_META_VideoCrop, },
{ "Spa:Pointer:Meta:VideoDamage", SPA_TYPE_INFO_META_REGION_ARRAY_BASE "VideoDamage", SPA_META_VideoDamage, },
{ "Spa:Pointer:Meta:Bitmap", SPA_TYPE_INFO_META_BASE "Bitmap", SPA_META_Bitmap, },
{ "Spa:Pointer:Meta:Cursor", SPA_TYPE_INFO_META_BASE "Cursor", SPA_META_Cursor, },
{ "Spa:Enum:DataType:MemPtr", SPA_TYPE_INFO_DATA_BASE "MemPtr", SPA_DATA_MemPtr, },
{ "Spa:Enum:DataType:Fd:MemFd", SPA_TYPE_INFO_DATA_FD_BASE "MemFd", SPA_DATA_MemFd, },
{ "Spa:Enum:DataType:Fd:DmaBuf", SPA_TYPE_INFO_DATA_FD_BASE "DmaBuf", SPA_DATA_DmaBuf, },
{ "Spa:POD:Object:Event:Node:Error", },
{ "Spa:POD:Object:Event:Node:Buffering", },
{ "Spa:POD:Object:Event:Node:RequestRefresh", },
{ "Spa:POD:Object:Event:Node:RequestClockUpdate", },
{ "Spa:POD:Object:Command:Node", SPA_TYPE_INFO_COMMAND_BASE "Node", SPA_TYPE_COMMAND_Node,},
{ "Spa:POD:Object:Command:Node:Suspend", SPA_TYPE_INFO_NODE_COMMAND_BASE "Suspend", SPA_NODE_COMMAND_Suspend,},
{ "Spa:POD:Object:Command:Node:Pause", SPA_TYPE_INFO_NODE_COMMAND_BASE "Pause", SPA_NODE_COMMAND_Pause, },
{ "Spa:POD:Object:Command:Node:Start", SPA_TYPE_INFO_NODE_COMMAND_BASE "Start", SPA_NODE_COMMAND_Start, },
{ "Spa:POD:Object:Command:Node:Enable", SPA_TYPE_INFO_NODE_COMMAND_BASE "Enable", SPA_NODE_COMMAND_Enable, },
{ "Spa:POD:Object:Command:Node:Disable", SPA_TYPE_INFO_NODE_COMMAND_BASE "Disable", SPA_NODE_COMMAND_Disable, },
{ "Spa:POD:Object:Command:Node:Flush", SPA_TYPE_INFO_NODE_COMMAND_BASE "Flush", SPA_NODE_COMMAND_Flush, },
{ "Spa:POD:Object:Command:Node:Drain", SPA_TYPE_INFO_NODE_COMMAND_BASE "Drain", SPA_NODE_COMMAND_Drain, },
{ "Spa:POD:Object:Command:Node:Marker", SPA_TYPE_INFO_NODE_COMMAND_BASE "Marker", SPA_NODE_COMMAND_Marker, },
{ "Spa:POD:Object:Command:Node:ClockUpdate", },
{ "Spa:POD:Object:Event:Monitor:Added", },
{ "Spa:POD:Object:Event:Monitor:Removed", },
{ "Spa:POD:Object:Event:Monitor:Changed", },
{ "Spa:POD:Object:MonitorItem", },
{ "Spa:POD:Object:MonitorItem:id", },
{ "Spa:POD:Object:MonitorItem:flags", },
{ "Spa:POD:Object:MonitorItem:state", },
{ "Spa:POD:Object:MonitorItem:name", },
{ "Spa:POD:Object:MonitorItem:class", },
{ "Spa:POD:Object:MonitorItem:info", },
{ "Spa:POD:Object:MonitorItem:factory", },
{ "Spa:POD:Object:Param:Buffers", SPA_TYPE_INFO_PARAM_Buffers, SPA_TYPE_OBJECT_ParamBuffers, },
{ "Spa:POD:Object:Param:Buffers:size", SPA_TYPE_INFO_PARAM_BLOCK_INFO_BASE "size", SPA_PARAM_BUFFERS_size, },
{ "Spa:POD:Object:Param:Buffers:stride", SPA_TYPE_INFO_PARAM_BLOCK_INFO_BASE "stride", SPA_PARAM_BUFFERS_stride, },
{ "Spa:POD:Object:Param:Buffers:buffers", SPA_TYPE_INFO_PARAM_BUFFERS_BASE "buffers", SPA_PARAM_BUFFERS_buffers, },
{ "Spa:POD:Object:Param:Buffers:align",SPA_TYPE_INFO_PARAM_BLOCK_INFO_BASE "align", SPA_PARAM_BUFFERS_align, },
{ "Spa:POD:Object:Param:Meta", SPA_TYPE_INFO_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, },
{ "Spa:POD:Object:Param:Meta:type", SPA_TYPE_INFO_PARAM_META_BASE "type", SPA_PARAM_META_type, },
{ "Spa:POD:Object:Param:Meta:size", SPA_TYPE_INFO_PARAM_META_BASE "size", SPA_PARAM_META_size, },
{ "Spa:POD:Object:Param:IO:id", },
{ "Spa:POD:Object:Param:IO:size", },
{ "Spa:Enum:ParamId:IO:Buffers", },
{ "Spa:POD:Object:Param:IO:Buffers", },
{ "Spa:Enum:ParamId:IO:Control", },
{ "Spa:POD:Object:Param:IO:Control", },
{ "Spa:Enum:ParamId:IO:Props:In", },
{ "Spa:Enum:ParamId:IO:Props:Out", },
{ "Spa:POD:Object:Param:IO:Prop", },
{ "Spa:Interface:DBus", SPA_TYPE_INFO_INTERFACE_BASE "DBus", SPA_TYPE_INTERFACE_DBus, },
{ "Spa:Enum:MediaType:audio", SPA_TYPE_INFO_MEDIA_TYPE_BASE "audio", SPA_MEDIA_TYPE_audio, },
{ "Spa:Enum:MediaType:video", SPA_TYPE_INFO_MEDIA_TYPE_BASE "video", SPA_MEDIA_TYPE_video, },
{ "Spa:Enum:MediaType:image", SPA_TYPE_INFO_MEDIA_TYPE_BASE "image", SPA_MEDIA_TYPE_image, },
{ "Spa:Enum:MediaType:binary", SPA_TYPE_INFO_MEDIA_TYPE_BASE "binary", SPA_MEDIA_TYPE_binary, },
{ "Spa:Enum:MediaType:stream", SPA_TYPE_INFO_MEDIA_TYPE_BASE "stream", SPA_MEDIA_TYPE_stream, },
{ "Spa:Enum:MediaSubtype:raw", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:h264", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "h264", SPA_MEDIA_SUBTYPE_h264, },
{ "Spa:Enum:MediaSubtype:mjpg", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "mjpg", SPA_MEDIA_SUBTYPE_mjpg, },
{ "Spa:Enum:MediaSubtype:dv", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "dv", SPA_MEDIA_SUBTYPE_dv, },
{ "Spa:Enum:MediaSubtype:mpegts", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "mpegts", SPA_MEDIA_SUBTYPE_mpegts, },
{ "Spa:Enum:MediaSubtype:h263", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "h263", SPA_MEDIA_SUBTYPE_h263, },
{ "Spa:Enum:MediaSubtype:mpeg1", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "mpeg1", SPA_MEDIA_SUBTYPE_mpeg1, },
{ "Spa:Enum:MediaSubtype:mpeg2", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "mpeg2", SPA_MEDIA_SUBTYPE_mpeg2, },
{ "Spa:Enum:MediaSubtype:mpeg4", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "mpeg4", SPA_MEDIA_SUBTYPE_mpeg4, },
{ "Spa:Enum:MediaSubtype:xvid", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:vc1", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:vp8", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:vp9", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:jpeg", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:bayer", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:mp3", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:aac", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:vorbis", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:wma", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:ra", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:sbc", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:adpcm", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:g723", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:g726", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:g729", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:amr", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:gsm", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:Enum:MediaSubtype:midi", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
{ "Spa:POD:Object:Param:Format:Video:format", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "format", SPA_FORMAT_VIDEO_format,},
{ "Spa:POD:Object:Param:Format:Video:size", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "size", SPA_FORMAT_VIDEO_size,},
{ "Spa:POD:Object:Param:Format:Video:framerate", SPA_TYPE_INFO_FORMAT_VIDEO_BASE "framerate", SPA_FORMAT_VIDEO_framerate},
{ "Spa:POD:Object:Param:Format:Video:max-framerate", },
{ "Spa:POD:Object:Param:Format:Video:views", },
{ "Spa:POD:Object:Param:Format:Video:interlace-mode", },
{ "Spa:POD:Object:Param:Format:Video:pixel-aspect-ratio", },
{ "Spa:POD:Object:Param:Format:Video:multiview-mode", },
{ "Spa:POD:Object:Param:Format:Video:multiview-flags", },
{ "Spa:POD:Object:Param:Format:Video:chroma-site", },
{ "Spa:POD:Object:Param:Format:Video:color-range", },
{ "Spa:POD:Object:Param:Format:Video:color-matrix", },
{ "Spa:POD:Object:Param:Format:Video:transfer-function", },
{ "Spa:POD:Object:Param:Format:Video:color-primaries", },
{ "Spa:POD:Object:Param:Format:Video:profile", },
{ "Spa:POD:Object:Param:Format:Video:level", },
{ "Spa:POD:Object:Param:Format:Video:stream-format", },
{ "Spa:POD:Object:Param:Format:Video:alignment", },
{ "Spa:POD:Object:Param:Format:Audio:format", SPA_TYPE_INFO_FORMAT_AUDIO_BASE "format", SPA_FORMAT_AUDIO_format,},
{ "Spa:POD:Object:Param:Format:Audio:flags", },
{ "Spa:POD:Object:Param:Format:Audio:layout", },
{ "Spa:POD:Object:Param:Format:Audio:rate", },
{ "Spa:POD:Object:Param:Format:Audio:channels", },
{ "Spa:POD:Object:Param:Format:Audio:channel-mask", },
{ "Spa:Enum:VideoFormat:encoded", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "encoded", SPA_VIDEO_FORMAT_ENCODED,},
{ "Spa:Enum:VideoFormat:I420", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:YV12", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "YV12", SPA_VIDEO_FORMAT_YV12,},
{ "Spa:Enum:VideoFormat:YUY2", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "YUY2", SPA_VIDEO_FORMAT_YUY2,},
{ "Spa:Enum:VideoFormat:UYVY", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "UYVY", SPA_VIDEO_FORMAT_UYVY,},
{ "Spa:Enum:VideoFormat:AYUV", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "AYUV", SPA_VIDEO_FORMAT_AYUV,},
{ "Spa:Enum:VideoFormat:RGBx", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "RGBx", SPA_VIDEO_FORMAT_RGBx,},
{ "Spa:Enum:VideoFormat:BGRx", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "BGRx", SPA_VIDEO_FORMAT_BGRx,},
{ "Spa:Enum:VideoFormat:xRGB", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:xBGR", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:RGBA", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:BGRA", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:ARGB", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:ABGR", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:RGB", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:BGR", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y41B", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y42B", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:YVYU", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y444", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:v210", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:v216", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:NV12", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:NV21", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GRAY8", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GRAY16_BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GRAY16_LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:v308", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:RGB16", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:BGR16", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:RGB15", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:BGR15", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:UYVP", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A420", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:RGB8P", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:YUV9", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:YVU9", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:IYU1", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:ARGB64", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:AYUV64", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:r210", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I420_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I420_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I422_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I422_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y444_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y444_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBR", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBR_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBR_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:NV16", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:NV24", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:NV12_64Z32", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A420_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A420_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A422_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A422_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A444_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:A444_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:NV61", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:P010_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:P010_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:IYU2", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:VYUY", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBRA", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBRA_10BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBRA_10LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBR_12BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBR_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBRA_12BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:GBRA_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I420_12BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I420_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I422_12BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:I422_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y444_12BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:VideoFormat:Y444_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", SPA_VIDEO_FORMAT_I420,},
{ "Spa:Enum:AudioFormat:ENCODED", },
{ "Spa:Enum:AudioFormat:S8", },
{ "Spa:Enum:AudioFormat:U8", },
{ "Spa:Enum:AudioFormat:S16LE", },
{ "Spa:Enum:AudioFormat:U16LE", },
{ "Spa:Enum:AudioFormat:S24_32LE", },
{ "Spa:Enum:AudioFormat:U24_32LE", },
{ "Spa:Enum:AudioFormat:S32LE", },
{ "Spa:Enum:AudioFormat:U32LE", },
{ "Spa:Enum:AudioFormat:S24LE", },
{ "Spa:Enum:AudioFormat:U24LE", },
{ "Spa:Enum:AudioFormat:S20LE", },
{ "Spa:Enum:AudioFormat:U20LE", },
{ "Spa:Enum:AudioFormat:S18LE", },
{ "Spa:Enum:AudioFormat:U18LE", },
{ "Spa:Enum:AudioFormat:F32LE", },
{ "Spa:Enum:AudioFormat:F64LE", },
{ "Spa:Enum:AudioFormat:S16BE", },
{ "Spa:Enum:AudioFormat:U16BE", },
{ "Spa:Enum:AudioFormat:S24_32BE", },
{ "Spa:Enum:AudioFormat:U24_32BE", },
{ "Spa:Enum:AudioFormat:S32BE", },
{ "Spa:Enum:AudioFormat:U32BE", },
{ "Spa:Enum:AudioFormat:S24BE", },
{ "Spa:Enum:AudioFormat:U24BE", },
{ "Spa:Enum:AudioFormat:S20BE", },
{ "Spa:Enum:AudioFormat:U20BE", },
{ "Spa:Enum:AudioFormat:S18BE", },
{ "Spa:Enum:AudioFormat:U18BE", },
{ "Spa:Enum:AudioFormat:F32BE", },
{ "Spa:Enum:AudioFormat:F64BE", },
};

View file

@ -172,8 +172,7 @@ static int destroy_resource(void *object, void *data)
struct pw_client *client = resource->client; struct pw_client *client = resource->client;
if (resource && if (resource &&
resource != client->core_resource && resource != client->core_resource) {
resource != client->client_resource) {
resource->removed = true; resource->removed = true;
pw_resource_destroy(resource); pw_resource_destroy(resource);
} }
@ -185,11 +184,20 @@ static int core_hello(void *object, uint32_t version)
struct pw_resource *resource = object; struct pw_resource *resource = object;
struct pw_client *client = resource->client; struct pw_client *client = resource->client;
struct pw_core *this = resource->core; struct pw_core *this = resource->core;
int res;
pw_log_debug(NAME" %p: hello %d from resource %p", this, version, resource); pw_log_debug(NAME" %p: hello %d from resource %p", this, version, resource);
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
pw_map_for_each(&client->objects, destroy_resource, client); pw_map_for_each(&client->objects, destroy_resource, client);
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
pw_core_resource_info(resource, &this->info); pw_core_resource_info(resource, &this->info);
if (version >= 3) {
if ((res = pw_global_bind(client->global, client,
PW_PERM_RWX, PW_VERSION_CLIENT_PROXY, 1)) < 0)
return res;
}
return 0; return 0;
} }

View file

@ -41,23 +41,23 @@ extern "C" {
#include <pipewire/proxy.h> #include <pipewire/proxy.h>
#include <pipewire/permission.h> #include <pipewire/permission.h>
#define PW_VERSION_CORE_PROXY 0 #define PW_VERSION_CORE_PROXY 3
struct pw_core_proxy { struct spa_interface iface; }; struct pw_core_proxy { struct spa_interface iface; };
#define PW_VERSION_REGISTRY_PROXY 0 #define PW_VERSION_REGISTRY_PROXY 3
struct pw_registry_proxy { struct spa_interface iface; }; struct pw_registry_proxy { struct spa_interface iface; };
#define PW_VERSION_MODULE_PROXY 0 #define PW_VERSION_MODULE_PROXY 3
struct pw_module_proxy { struct spa_interface iface; }; struct pw_module_proxy { struct spa_interface iface; };
#define PW_VERSION_DEVICE_PROXY 0 #define PW_VERSION_DEVICE_PROXY 3
struct pw_device_proxy { struct spa_interface iface; }; struct pw_device_proxy { struct spa_interface iface; };
#define PW_VERSION_NODE_PROXY 0 #define PW_VERSION_NODE_PROXY 3
struct pw_node_proxy { struct spa_interface iface; }; struct pw_node_proxy { struct spa_interface iface; };
#define PW_VERSION_PORT_PROXY 0 #define PW_VERSION_PORT_PROXY 3
struct pw_port_proxy { struct spa_interface iface; }; struct pw_port_proxy { struct spa_interface iface; };
#define PW_VERSION_FACTORY_PROXY 0 #define PW_VERSION_FACTORY_PROXY 3
struct pw_factory_proxy { struct spa_interface iface; }; struct pw_factory_proxy { struct spa_interface iface; };
#define PW_VERSION_CLIENT_PROXY 0 #define PW_VERSION_CLIENT_PROXY 3
struct pw_client_proxy { struct spa_interface iface; }; struct pw_client_proxy { struct spa_interface iface; };
#define PW_VERSION_LINK_PROXY 0 #define PW_VERSION_LINK_PROXY 3
struct pw_link_proxy { struct spa_interface iface; }; struct pw_link_proxy { struct spa_interface iface; };
/** /**

View file

@ -87,6 +87,11 @@ typedef uint32_t (*pw_permission_func_t) (struct pw_global *global,
#define pw_client_emit_resource_removed(o,r) pw_client_emit(o, resource_removed, 0, r) #define pw_client_emit_resource_removed(o,r) pw_client_emit(o, resource_removed, 0, r)
#define pw_client_emit_busy_changed(o,b) pw_client_emit(o, busy_changed, 0, b) #define pw_client_emit_busy_changed(o,b) pw_client_emit(o, busy_changed, 0, b)
struct protocol_compat_v2 {
/* v2 typemap */
struct pw_map types;
};
struct pw_client { struct pw_client {
struct pw_core *core; /**< core object */ struct pw_core *core; /**< core object */
struct spa_list link; /**< link in core object client list */ struct spa_list link; /**< link in core object client list */
@ -119,6 +124,9 @@ struct pw_client {
unsigned int registered:1; unsigned int registered:1;
unsigned int ucred_valid:1; /**< if the ucred member is valid */ unsigned int ucred_valid:1; /**< if the ucred member is valid */
unsigned int busy:1; unsigned int busy:1;
/* v2 compatibility data */
void *compat_v2;
}; };
#define pw_global_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_global_events, m, v, ##__VA_ARGS__) #define pw_global_emit(o,m,v,...) spa_hook_list_call(&o->listener_list, struct pw_global_events, m, v, ##__VA_ARGS__)
@ -689,6 +697,7 @@ struct pw_proxy {
struct pw_remote *remote; /**< the owner remote of this proxy */ struct pw_remote *remote; /**< the owner remote of this proxy */
uint32_t id; /**< client side id */ uint32_t id; /**< client side id */
uint32_t version; /**< client side version */
int refcount; int refcount;
unsigned int zombie:1; /**< proxy is removed locally and waiting to unsigned int zombie:1; /**< proxy is removed locally and waiting to
* be removed from server */ * be removed from server */

View file

@ -152,12 +152,12 @@ pw_protocol_add_marshal(struct pw_protocol *protocol,
SPA_EXPORT SPA_EXPORT
const struct pw_protocol_marshal * const struct pw_protocol_marshal *
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type) pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version)
{ {
struct marshal *impl; struct marshal *impl;
spa_list_for_each(impl, &protocol->marshal_list, link) { spa_list_for_each(impl, &protocol->marshal_list, link) {
if (impl->marshal->type == type) if (impl->marshal->type == type && impl->marshal->version == version)
return impl->marshal; return impl->marshal;
} }
return NULL; return NULL;

View file

@ -132,7 +132,7 @@ int pw_protocol_add_marshal(struct pw_protocol *protocol,
const struct pw_protocol_marshal *marshal); const struct pw_protocol_marshal *marshal);
const struct pw_protocol_marshal * const struct pw_protocol_marshal *
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type); pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version);
struct pw_protocol * pw_core_find_protocol(struct pw_core *core, const char *name); struct pw_protocol * pw_core_find_protocol(struct pw_core *core, const char *name);

View file

@ -56,7 +56,7 @@ struct proxy {
*/ */
SPA_EXPORT SPA_EXPORT
struct pw_proxy *pw_proxy_new(struct pw_proxy *factory, struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
uint32_t type, uint32_t type, uint32_t version,
size_t user_data_size) size_t user_data_size)
{ {
struct proxy *impl; struct proxy *impl;
@ -71,10 +71,13 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
this = &impl->this; this = &impl->this;
this->remote = remote; this->remote = remote;
this->refcount = 1; this->refcount = 1;
this->version = version;
this->marshal = pw_protocol_get_marshal(remote->conn->protocol, type); this->marshal = pw_protocol_get_marshal(remote->conn->protocol, type, version);
if (this->marshal == NULL) { if (this->marshal == NULL) {
pw_log_error(NAME" %p: no marshal for type %d", this, type); pw_log_error(NAME" %p: no marshal for type %s/%d", this,
spa_debug_type_find_name(pw_type_info(), type),
version);
res = -EPROTO; res = -EPROTO;
goto error_clean; goto error_clean;
} }
@ -97,9 +100,9 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
this->marshal->version, this->marshal->version,
this->marshal->method_marshal, this); this->marshal->method_marshal, this);
pw_log_debug(NAME" %p: new %u %s remote %p, marshal %p", pw_log_debug(NAME" %p: new %u type %s/%d remote:%p, marshal:%p",
this, this->id, this, this->id,
spa_debug_type_find_name(pw_type_info(), type), spa_debug_type_find_name(pw_type_info(), type), version,
remote, this->marshal); remote, this->marshal);
return this; return this;

View file

@ -123,6 +123,7 @@ struct pw_proxy_events {
struct pw_proxy * struct pw_proxy *
pw_proxy_new(struct pw_proxy *factory, /**< factory */ pw_proxy_new(struct pw_proxy *factory, /**< factory */
uint32_t type, /**< interface type */ uint32_t type, /**< interface type */
uint32_t version, /**< interface version */
size_t user_data_size /**< size of user data */); size_t user_data_size /**< size of user data */);
/** Add an event listener to proxy */ /** Add an event listener to proxy */

View file

@ -377,9 +377,10 @@ do_connect(struct spa_loop *loop,
struct pw_proxy dummy, *core_proxy; struct pw_proxy dummy, *core_proxy;
int res; int res;
spa_zero(dummy);
dummy.remote = remote; dummy.remote = remote;
core_proxy = pw_proxy_new(&dummy, PW_TYPE_INTERFACE_Core, 0); core_proxy = pw_proxy_new(&dummy, PW_TYPE_INTERFACE_Core, PW_VERSION_CORE_PROXY, 0);
if (core_proxy == NULL) { if (core_proxy == NULL) {
res = -errno; res = -errno;
goto error_disconnect; goto error_disconnect;
@ -387,7 +388,7 @@ do_connect(struct spa_loop *loop,
remote->core_proxy = (struct pw_core_proxy*)core_proxy; remote->core_proxy = (struct pw_core_proxy*)core_proxy;
remote->client_proxy = (struct pw_client_proxy*)pw_proxy_new(&dummy, remote->client_proxy = (struct pw_client_proxy*)pw_proxy_new(&dummy,
PW_TYPE_INTERFACE_Client, 0); PW_TYPE_INTERFACE_Client, PW_VERSION_CLIENT_PROXY, 0);
if (remote->client_proxy == NULL) { if (remote->client_proxy == NULL) {
res = -errno; res = -errno;
goto error_clean_core_proxy; goto error_clean_core_proxy;
@ -396,8 +397,8 @@ do_connect(struct spa_loop *loop,
pw_core_proxy_add_listener(remote->core_proxy, &impl->core_listener, &core_events, remote); pw_core_proxy_add_listener(remote->core_proxy, &impl->core_listener, &core_events, remote);
pw_proxy_add_listener(core_proxy, &impl->core_proxy_listener, &core_proxy_events, remote); pw_proxy_add_listener(core_proxy, &impl->core_proxy_listener, &core_proxy_events, remote);
pw_client_proxy_update_properties(remote->client_proxy, &remote->properties->dict);
pw_core_proxy_hello(remote->core_proxy, PW_VERSION_CORE_PROXY); pw_core_proxy_hello(remote->core_proxy, PW_VERSION_CORE_PROXY);
pw_client_proxy_update_properties(remote->client_proxy, &remote->properties->dict);
pw_remote_update_state(remote, PW_REMOTE_STATE_CONNECTED, NULL); pw_remote_update_state(remote, PW_REMOTE_STATE_CONNECTED, NULL);
return 0; return 0;

View file

@ -66,7 +66,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
spa_hook_list_init(&this->listener_list); spa_hook_list_init(&this->listener_list);
spa_hook_list_init(&this->object_listener_list); spa_hook_list_init(&this->object_listener_list);
this->marshal = pw_protocol_get_marshal(client->protocol, type); this->marshal = pw_protocol_get_marshal(client->protocol, type, version);
if (this->marshal == NULL) { if (this->marshal == NULL) {
pw_log_error(NAME" %p: no marshal for type %s/%d", this, pw_log_error(NAME" %p: no marshal for type %s/%d", this,
spa_debug_type_find_name(pw_type_info(), type), spa_debug_type_find_name(pw_type_info(), type),
@ -97,7 +97,7 @@ struct pw_resource *pw_resource_new(struct pw_client *client,
this->marshal->version, this->marshal->version,
this->marshal->event_marshal, this); this->marshal->event_marshal, this);
pw_log_debug(NAME" %p: new %u %s/%d client %p marshal %p", pw_log_debug(NAME" %p: new %u type %s/%d client:%p marshal:%p",
this, id, this, id,
spa_debug_type_find_name(pw_type_info(), type), version, spa_debug_type_find_name(pw_type_info(), type), version,
client, this->marshal); client, this->marshal);