Implement protocol extensions

Add hooks that contain protocol specific interfaces that can be used
to extend the protocol. This makes it possible to add new interfaces
to the protocol and implement the protocol specific data transport.
Move these protocol specific extension to the extensions directory.
This commit is contained in:
Wim Taymans 2017-07-12 18:04:00 +02:00
parent 267547c884
commit 465f12241e
43 changed files with 661 additions and 471 deletions

View file

@ -53,7 +53,7 @@ struct buffer {
};
struct impl {
struct pw_connection this;
struct pw_protocol_native_connection this;
struct buffer in, out;
@ -70,9 +70,9 @@ struct impl {
* \param index the index of the fd to get
* \return the fd at \a index or -1 when no such fd exists
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
int pw_connection_get_fd(struct pw_connection *conn, uint32_t index)
int pw_protocol_native_connection_get_fd(struct pw_protocol_native_connection *conn, uint32_t index)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
@ -88,9 +88,9 @@ int pw_connection_get_fd(struct pw_connection *conn, uint32_t index)
* \param fd the fd to add
* \return the index of the fd or -1 when an error occured
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
uint32_t pw_connection_add_fd(struct pw_connection *conn, int fd)
uint32_t pw_protocol_native_connection_add_fd(struct pw_protocol_native_connection *conn, int fd)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint32_t index, i;
@ -112,7 +112,7 @@ uint32_t pw_connection_add_fd(struct pw_connection *conn, int fd)
return index;
}
static void *connection_ensure_size(struct pw_connection *conn, struct buffer *buf, size_t size)
static void *connection_ensure_size(struct pw_protocol_native_connection *conn, struct buffer *buf, size_t size)
{
if (buf->buffer_size + size > buf->buffer_maxsize) {
buf->buffer_maxsize = SPA_ROUND_UP_N(buf->buffer_size + size, MAX_BUFFER_SIZE);
@ -124,7 +124,7 @@ static void *connection_ensure_size(struct pw_connection *conn, struct buffer *b
return (uint8_t *) buf->buffer_data + buf->buffer_size;
}
static bool refill_buffer(struct pw_connection *conn, struct buffer *buf)
static bool refill_buffer(struct pw_protocol_native_connection *conn, struct buffer *buf)
{
ssize_t len;
struct cmsghdr *cmsg;
@ -186,12 +186,12 @@ static void clear_buffer(struct buffer *buf)
* \param fd the socket
* \returns a newly allocated connection object
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
struct pw_connection *pw_connection_new(int fd)
struct pw_protocol_native_connection *pw_protocol_native_connection_new(int fd)
{
struct impl *impl;
struct pw_connection *this;
struct pw_protocol_native_connection *this;
impl = calloc(1, sizeof(struct impl));
if (impl == NULL)
@ -229,9 +229,9 @@ struct pw_connection *pw_connection_new(int fd)
*
* \param conn the connection to destroy
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
void pw_connection_destroy(struct pw_connection *conn)
void pw_protocol_native_connection_destroy(struct pw_protocol_native_connection *conn)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
@ -256,10 +256,10 @@ void pw_connection_destroy(struct pw_connection *conn)
* Get the next packet in \a conn and store the opcode and destination
* id as well as the packet data and size.
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
bool
pw_connection_get_next(struct pw_connection *conn,
pw_protocol_native_connection_get_next(struct pw_protocol_native_connection *conn,
uint8_t *opcode,
uint32_t *dest_id,
void **dt,
@ -330,7 +330,7 @@ pw_connection_get_next(struct pw_connection *conn,
return true;
}
static inline void *begin_write(struct pw_connection *conn, uint32_t size)
static inline void *begin_write(struct pw_protocol_native_connection *conn, uint32_t size)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint32_t *p;
@ -357,9 +357,9 @@ static uint32_t write_pod(struct spa_pod_builder *b, uint32_t ref, const void *d
}
struct spa_pod_builder *
pw_connection_begin_write_resource(struct pw_connection *conn,
struct pw_resource *resource,
uint8_t opcode)
pw_protocol_native_connection_begin_resource(struct pw_protocol_native_connection *conn,
struct pw_resource *resource,
uint8_t opcode)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint32_t diff, base, i, b;
@ -386,9 +386,9 @@ pw_connection_begin_write_resource(struct pw_connection *conn,
}
struct spa_pod_builder *
pw_connection_begin_write_proxy(struct pw_connection *conn,
struct pw_proxy *proxy,
uint8_t opcode)
pw_protocol_native_connection_begin_proxy(struct pw_protocol_native_connection *conn,
struct pw_proxy *proxy,
uint8_t opcode)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint32_t diff, base, i, b;
@ -415,8 +415,8 @@ pw_connection_begin_write_proxy(struct pw_connection *conn,
}
void
pw_connection_end_write(struct pw_connection *conn,
struct spa_pod_builder *builder)
pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
struct spa_pod_builder *builder)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
uint32_t *p, size = builder->offset;
@ -443,9 +443,9 @@ pw_connection_end_write(struct pw_connection *conn,
*
* Write the queued messages on the connection to the socket
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
bool pw_connection_flush(struct pw_connection *conn)
bool pw_protocol_native_connection_flush(struct pw_protocol_native_connection *conn)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);
ssize_t len;
@ -515,9 +515,9 @@ bool pw_connection_flush(struct pw_connection *conn)
*
* Remove all queued messages from \a conn
*
* \memberof pw_connection
* \memberof pw_protocol_native_connection
*/
bool pw_connection_clear(struct pw_connection *conn)
bool pw_protocol_native_connection_clear(struct pw_protocol_native_connection *conn)
{
struct impl *impl = SPA_CONTAINER_OF(conn, struct impl, this);

View file

@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_CONNECTION_H__
#define __PIPEWIRE_CONNECTION_H__
#ifndef __PIPEWIRE_PROTOCOL_NATIVE_CONNECTION_H__
#define __PIPEWIRE_PROTOCOL_NATIVE_CONNECTION_H__
#ifdef __cplusplus
extern "C" {
@ -27,63 +27,61 @@ extern "C" {
#include <spa/defs.h>
#include <pipewire/sig.h>
/** \class pw_connection
/** \class pw_protocol_native_connection
*
* \brief Manages the connection between client and server
*
* The \ref pw_connection handles the connection between client
* The \ref pw_protocol_native_connection handles the connection between client
* and server on a given socket.
*/
struct pw_connection {
struct pw_protocol_native_connection {
int fd; /**< the socket */
/** Emited when data has been written that needs to be flushed */
PW_SIGNAL(need_flush, (struct pw_listener *listener, struct pw_connection *conn));
PW_SIGNAL(need_flush, (struct pw_listener *listener,
struct pw_protocol_native_connection *conn));
/** Emited when the connection is destroyed */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_connection *conn));
PW_SIGNAL(destroy_signal, (struct pw_listener *listener,
struct pw_protocol_native_connection *conn));
};
struct pw_connection *
pw_connection_new(int fd);
struct pw_protocol_native_connection *
pw_protocol_native_connection_new(int fd);
void
pw_connection_destroy(struct pw_connection *conn);
uint32_t
pw_connection_add_fd(struct pw_connection *conn, int fd);
int
pw_connection_get_fd(struct pw_connection *conn, uint32_t index);
pw_protocol_native_connection_destroy(struct pw_protocol_native_connection *conn);
bool
pw_connection_get_next(struct pw_connection *conn,
uint8_t *opcode,
uint32_t *dest_id,
void **data, uint32_t *size);
pw_protocol_native_connection_get_next(struct pw_protocol_native_connection *conn,
uint8_t *opcode,
uint32_t *dest_id,
void **data, uint32_t *size);
uint32_t pw_protocol_native_connection_add_fd(struct pw_protocol_native_connection *conn, int fd);
int pw_protocol_native_connection_get_fd(struct pw_protocol_native_connection *conn, uint32_t index);
struct spa_pod_builder *
pw_connection_begin_write_resource(struct pw_connection *conn,
struct pw_resource *resource,
uint8_t opcode);
pw_protocol_native_connection_begin_resource(struct pw_protocol_native_connection *conn,
struct pw_resource *resource,
uint8_t opcode);
struct spa_pod_builder *
pw_connection_begin_write_proxy(struct pw_connection *conn,
struct pw_proxy *proxy,
uint8_t opcode);
pw_protocol_native_connection_begin_proxy(struct pw_protocol_native_connection *conn,
struct pw_proxy *proxy,
uint8_t opcode);
void
pw_connection_end_write(struct pw_connection *conn,
struct spa_pod_builder *builder);
pw_protocol_native_connection_end(struct pw_protocol_native_connection *conn,
struct spa_pod_builder *builder);
bool
pw_connection_flush(struct pw_connection *conn);
pw_protocol_native_connection_flush(struct pw_protocol_native_connection *conn);
bool
pw_connection_clear(struct pw_connection *conn);
pw_protocol_native_connection_clear(struct pw_protocol_native_connection *conn);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __PIPEWIRE_CONNECTION_H__ */
#endif /* __PIPEWIRE_PROTOCOL_NATIVE_CONNECTION_H__ */

View file

@ -17,6 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include <errno.h>
#include "spa/pod-iter.h"
@ -25,6 +26,7 @@
#include "pipewire/protocol.h"
#include "pipewire/interfaces.h"
#include "pipewire/resource.h"
#include "extensions/protocol-native.h"
#include "connection.h"
@ -37,12 +39,11 @@ typedef bool(*demarshal_func_t) (void *object, void *data, size_t size);
static void core_marshal_client_update(void *object, const struct spa_dict *props)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
int i, n_items;
b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_CLIENT_UPDATE);
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_METHOD_CLIENT_UPDATE);
n_items = props ? props->n_items : 0;
@ -55,37 +56,35 @@ static void core_marshal_client_update(void *object, const struct spa_dict *prop
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static void core_marshal_sync(void *object, uint32_t seq)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_SYNC);
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_METHOD_SYNC);
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, seq);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static void core_marshal_get_registry(void *object, uint32_t version, uint32_t new_id)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_GET_REGISTRY);
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_METHOD_GET_REGISTRY);
spa_pod_builder_struct(b, &f,
SPA_POD_TYPE_INT, version,
SPA_POD_TYPE_INT, new_id);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static void
@ -95,12 +94,11 @@ core_marshal_create_node(void *object,
uint32_t version, uint32_t new_id)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items;
b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_CREATE_NODE);
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_METHOD_CREATE_NODE);
n_items = props ? props->n_items : 0;
@ -119,7 +117,7 @@ core_marshal_create_node(void *object,
SPA_POD_TYPE_INT, new_id,
-SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static void
@ -133,12 +131,11 @@ core_marshal_create_link(void *object,
uint32_t new_id)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items;
b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_CREATE_LINK);
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_METHOD_CREATE_LINK);
n_items = props ? props->n_items : 0;
@ -160,19 +157,18 @@ core_marshal_create_link(void *object,
SPA_POD_TYPE_INT, new_id,
-SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static void
core_marshal_update_types_client(void *object, uint32_t first_id, uint32_t n_types, const char **types)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i;
b = pw_connection_begin_write_proxy(connection, proxy, PW_CORE_METHOD_UPDATE_TYPES);
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_METHOD_UPDATE_TYPES);
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
@ -183,7 +179,7 @@ core_marshal_update_types_client(void *object, uint32_t first_id, uint32_t n_typ
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static bool core_demarshal_info(void *object, void *data, size_t size)
@ -286,12 +282,11 @@ static bool core_demarshal_update_types_client(void *object, void *data, size_t
static void core_marshal_info(void *object, struct pw_core_info *info)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items;
b = pw_connection_begin_write_resource(connection, resource, PW_CORE_EVENT_INFO);
b = pw_protocol_native_begin_resource(resource, PW_CORE_EVENT_INFO);
n_items = info->props ? info->props->n_items : 0;
@ -312,33 +307,31 @@ static void core_marshal_info(void *object, struct pw_core_info *info)
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static void core_marshal_done(void *object, uint32_t seq)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_resource(connection, resource, PW_CORE_EVENT_DONE);
b = pw_protocol_native_begin_resource(resource, PW_CORE_EVENT_DONE);
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, seq);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static void core_marshal_error(void *object, uint32_t id, int res, const char *error, ...)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
char buffer[128];
struct spa_pod_builder *b;
struct spa_pod_frame f;
va_list ap;
b = pw_connection_begin_write_resource(connection, resource, PW_CORE_EVENT_ERROR);
b = pw_protocol_native_begin_resource(resource, PW_CORE_EVENT_ERROR);
va_start(ap, error);
vsnprintf(buffer, sizeof(buffer), error, ap);
@ -349,33 +342,31 @@ static void core_marshal_error(void *object, uint32_t id, int res, const char *e
SPA_POD_TYPE_INT, res,
SPA_POD_TYPE_STRING, buffer);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static void core_marshal_remove_id(void *object, uint32_t id)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_resource(connection, resource, PW_CORE_EVENT_REMOVE_ID);
b = pw_protocol_native_begin_resource(resource, PW_CORE_EVENT_REMOVE_ID);
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, id);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static void
core_marshal_update_types_server(void *object, uint32_t first_id, uint32_t n_types, const char **types)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i;
b = pw_connection_begin_write_resource(connection, resource, PW_CORE_EVENT_UPDATE_TYPES);
b = pw_protocol_native_begin_resource(resource, PW_CORE_EVENT_UPDATE_TYPES);
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
@ -386,7 +377,7 @@ core_marshal_update_types_server(void *object, uint32_t first_id, uint32_t n_typ
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static bool core_demarshal_client_update(void *object, void *data, size_t size)
@ -537,32 +528,30 @@ static bool core_demarshal_update_types_server(void *object, void *data, size_t
static void registry_marshal_global(void *object, uint32_t id, uint32_t type, uint32_t version)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_resource(connection, resource, PW_REGISTRY_EVENT_GLOBAL);
b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_EVENT_GLOBAL);
spa_pod_builder_struct(b, &f,
SPA_POD_TYPE_INT, id,
SPA_POD_TYPE_ID, type,
SPA_POD_TYPE_INT, version);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static void registry_marshal_global_remove(void *object, uint32_t id)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_resource(connection, resource, PW_REGISTRY_EVENT_GLOBAL_REMOVE);
b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_EVENT_GLOBAL_REMOVE);
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, id);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static bool registry_demarshal_bind(void *object, void *data, size_t size)
@ -585,12 +574,11 @@ static bool registry_demarshal_bind(void *object, void *data, size_t size)
static void module_marshal_info(void *object, struct pw_module_info *info)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items;
b = pw_connection_begin_write_resource(connection, resource, PW_MODULE_EVENT_INFO);
b = pw_protocol_native_begin_resource(resource, PW_MODULE_EVENT_INFO);
n_items = info->props ? info->props->n_items : 0;
@ -609,7 +597,7 @@ static void module_marshal_info(void *object, struct pw_module_info *info)
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static bool module_demarshal_info(void *object, void *data, size_t size)
@ -644,12 +632,11 @@ static bool module_demarshal_info(void *object, void *data, size_t size)
static void node_marshal_info(void *object, struct pw_node_info *info)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items;
b = pw_connection_begin_write_resource(connection, resource, PW_NODE_EVENT_INFO);
b = pw_protocol_native_begin_resource(resource, PW_NODE_EVENT_INFO);
spa_pod_builder_add(b,
SPA_POD_TYPE_STRUCT, &f,
@ -684,7 +671,7 @@ static void node_marshal_info(void *object, struct pw_node_info *info)
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static bool node_demarshal_info(void *object, void *data, size_t size)
@ -743,12 +730,11 @@ static bool node_demarshal_info(void *object, void *data, size_t size)
static void client_marshal_info(void *object, struct pw_client_info *info)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items;
b = pw_connection_begin_write_resource(connection, resource, PW_CLIENT_EVENT_INFO);
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_EVENT_INFO);
n_items = info->props ? info->props->n_items : 0;
@ -764,7 +750,7 @@ static void client_marshal_info(void *object, struct pw_client_info *info)
}
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static bool client_demarshal_info(void *object, void *data, size_t size)
@ -797,11 +783,10 @@ static bool client_demarshal_info(void *object, void *data, size_t size)
static void link_marshal_info(void *object, struct pw_link_info *info)
{
struct pw_resource *resource = object;
struct pw_connection *connection = resource->client->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_resource(connection, resource, PW_LINK_EVENT_INFO);
b = pw_protocol_native_begin_resource(resource, PW_LINK_EVENT_INFO);
spa_pod_builder_struct(b, &f,
SPA_POD_TYPE_INT, info->id,
@ -812,7 +797,7 @@ static void link_marshal_info(void *object, struct pw_link_info *info)
SPA_POD_TYPE_INT, info->input_port_id,
SPA_POD_TYPE_POD, info->format);
pw_connection_end_write(connection, b);
pw_protocol_native_end_resource(resource, b);
}
static bool link_demarshal_info(void *object, void *data, size_t size)
@ -872,18 +857,17 @@ static bool registry_demarshal_global_remove(void *object, void *data, size_t si
static void registry_marshal_bind(void *object, uint32_t id, uint32_t version, uint32_t new_id)
{
struct pw_proxy *proxy = object;
struct pw_connection *connection = proxy->remote->protocol_private;
struct spa_pod_builder *b;
struct spa_pod_frame f;
b = pw_connection_begin_write_proxy(connection, proxy, PW_REGISTRY_METHOD_BIND);
b = pw_protocol_native_begin_proxy(proxy, PW_REGISTRY_METHOD_BIND);
spa_pod_builder_struct(b, &f,
SPA_POD_TYPE_INT, id,
SPA_POD_TYPE_INT, version,
SPA_POD_TYPE_INT, new_id);
pw_connection_end_write(connection, b);
pw_protocol_native_end_proxy(proxy, b);
}
static const struct pw_core_methods pw_protocol_native_client_core_methods = {
@ -904,7 +888,7 @@ static const demarshal_func_t pw_protocol_native_client_core_demarshal[PW_CORE_E
};
static const struct pw_interface pw_protocol_native_client_core_interface = {
PIPEWIRE_TYPE__Core,
PW_TYPE__Core,
PW_VERSION_CORE,
PW_CORE_METHOD_NUM, &pw_protocol_native_client_core_methods,
PW_CORE_EVENT_NUM, pw_protocol_native_client_core_demarshal
@ -920,7 +904,7 @@ static const demarshal_func_t pw_protocol_native_client_registry_demarshal[] = {
};
static const struct pw_interface pw_protocol_native_client_registry_interface = {
PIPEWIRE_TYPE__Registry,
PW_TYPE__Registry,
PW_VERSION_REGISTRY,
PW_REGISTRY_METHOD_NUM, &pw_protocol_native_client_registry_methods,
PW_REGISTRY_EVENT_NUM, pw_protocol_native_client_registry_demarshal,
@ -931,7 +915,7 @@ static const demarshal_func_t pw_protocol_native_client_module_demarshal[] = {
};
static const struct pw_interface pw_protocol_native_client_module_interface = {
PIPEWIRE_TYPE__Module,
PW_TYPE__Module,
PW_VERSION_MODULE,
0, NULL,
PW_MODULE_EVENT_NUM, pw_protocol_native_client_module_demarshal,
@ -942,7 +926,7 @@ static const demarshal_func_t pw_protocol_native_client_node_demarshal[] = {
};
static const struct pw_interface pw_protocol_native_client_node_interface = {
PIPEWIRE_TYPE__Node,
PW_TYPE__Node,
PW_VERSION_NODE,
0, NULL,
PW_NODE_EVENT_NUM, pw_protocol_native_client_node_demarshal,
@ -953,7 +937,7 @@ static const demarshal_func_t pw_protocol_native_client_client_demarshal[] = {
};
static const struct pw_interface pw_protocol_native_client_client_interface = {
PIPEWIRE_TYPE__Client,
PW_TYPE__Client,
PW_VERSION_CLIENT,
0, NULL,
PW_CLIENT_EVENT_NUM, pw_protocol_native_client_client_demarshal,
@ -964,7 +948,7 @@ static const demarshal_func_t pw_protocol_native_client_link_demarshal[] = {
};
static const struct pw_interface pw_protocol_native_client_link_interface = {
PIPEWIRE_TYPE__Link,
PW_TYPE__Link,
PW_VERSION_LINK,
0, NULL,
PW_LINK_EVENT_NUM, pw_protocol_native_client_link_demarshal,
@ -988,7 +972,7 @@ static const struct pw_core_events pw_protocol_native_server_core_events = {
};
const struct pw_interface pw_protocol_native_server_core_interface = {
PIPEWIRE_TYPE__Core,
PW_TYPE__Core,
PW_VERSION_CORE,
PW_CORE_METHOD_NUM, pw_protocol_native_server_core_demarshal,
PW_CORE_EVENT_NUM, &pw_protocol_native_server_core_events,
@ -1004,7 +988,7 @@ static const struct pw_registry_events pw_protocol_native_server_registry_events
};
const struct pw_interface pw_protocol_native_server_registry_interface = {
PIPEWIRE_TYPE__Registry,
PW_TYPE__Registry,
PW_VERSION_REGISTRY,
PW_REGISTRY_METHOD_NUM, pw_protocol_native_server_registry_demarshal,
PW_REGISTRY_EVENT_NUM, &pw_protocol_native_server_registry_events,
@ -1015,7 +999,7 @@ static const struct pw_module_events pw_protocol_native_server_module_events = {
};
const struct pw_interface pw_protocol_native_server_module_interface = {
PIPEWIRE_TYPE__Module,
PW_TYPE__Module,
PW_VERSION_MODULE,
0, NULL,
PW_MODULE_EVENT_NUM, &pw_protocol_native_server_module_events,
@ -1026,7 +1010,7 @@ static const struct pw_node_events pw_protocol_native_server_node_events = {
};
const struct pw_interface pw_protocol_native_server_node_interface = {
PIPEWIRE_TYPE__Node,
PW_TYPE__Node,
PW_VERSION_NODE,
0, NULL,
PW_NODE_EVENT_NUM, &pw_protocol_native_server_node_events,
@ -1037,7 +1021,7 @@ static const struct pw_client_events pw_protocol_native_server_client_events = {
};
const struct pw_interface pw_protocol_native_server_client_interface = {
PIPEWIRE_TYPE__Client,
PW_TYPE__Client,
PW_VERSION_CLIENT,
0, NULL,
PW_CLIENT_EVENT_NUM, &pw_protocol_native_server_client_events,
@ -1048,22 +1032,14 @@ static const struct pw_link_events pw_protocol_native_server_link_events = {
};
const struct pw_interface pw_protocol_native_server_link_interface = {
PIPEWIRE_TYPE__Link,
PW_TYPE__Link,
PW_VERSION_LINK,
0, NULL,
PW_LINK_EVENT_NUM, &pw_protocol_native_server_link_events,
};
struct pw_protocol *pw_protocol_native_init(void)
void pw_protocol_native_init(struct pw_protocol *protocol)
{
static bool init = false;
struct pw_protocol *protocol;
protocol = pw_protocol_get(PW_TYPE_PROTOCOL__Native);
if (init)
return protocol;
pw_protocol_add_interfaces(protocol,
&pw_protocol_native_client_core_interface,
&pw_protocol_native_server_core_interface);
@ -1083,7 +1059,4 @@ struct pw_protocol *pw_protocol_native_init(void)
&pw_protocol_native_client_link_interface,
&pw_protocol_native_server_link_interface);
init = true;
return protocol;
}