2017-05-23 19:15:33 +02:00
|
|
|
/* PipeWire
|
2017-03-03 19:06:54 +01:00
|
|
|
* 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>
|
|
|
|
|
|
2017-03-07 11:56:43 +01:00
|
|
|
#include "spa/pod-iter.h"
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-11 15:57:20 +02:00
|
|
|
#include "pipewire/pipewire.h"
|
|
|
|
|
#include "pipewire/interfaces.h"
|
|
|
|
|
#include "pipewire/protocol.h"
|
|
|
|
|
#include "pipewire/client.h"
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
#include "extensions/protocol-native.h"
|
|
|
|
|
#include "extensions/client-node.h"
|
2017-07-11 12:24:03 +02:00
|
|
|
|
2017-05-30 19:46:51 +02:00
|
|
|
/** \cond */
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
typedef bool(*demarshal_func_t) (void *object, void *data, size_t size);
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-05-30 19:46:51 +02:00
|
|
|
/** \endcond */
|
|
|
|
|
|
2017-06-09 17:24:18 +02:00
|
|
|
static void
|
|
|
|
|
client_node_marshal_done(void *object, int seq, int res)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-09 17:24:18 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_METHOD_DONE);
|
2017-06-09 17:24:18 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-09 17:24:18 +02:00
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_INT, res);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
2017-06-09 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-03-06 15:48:04 +01:00
|
|
|
static void
|
2017-05-26 08:05:01 +02:00
|
|
|
client_node_marshal_update(void *object,
|
|
|
|
|
uint32_t change_mask,
|
|
|
|
|
uint32_t max_input_ports,
|
|
|
|
|
uint32_t max_output_ports, const struct spa_props *props)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_frame f;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_METHOD_UPDATE);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-05-26 08:05:01 +02:00
|
|
|
SPA_POD_TYPE_INT, change_mask,
|
|
|
|
|
SPA_POD_TYPE_INT, max_input_ports,
|
|
|
|
|
SPA_POD_TYPE_INT, max_output_ports, SPA_POD_TYPE_POD, props);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-05-26 08:05:01 +02:00
|
|
|
client_node_marshal_port_update(void *object,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
uint32_t change_mask,
|
|
|
|
|
uint32_t n_possible_formats,
|
|
|
|
|
const struct spa_format **possible_formats,
|
|
|
|
|
const struct spa_format *format,
|
|
|
|
|
uint32_t n_params,
|
|
|
|
|
const struct spa_param **params, const struct spa_port_info *info)
|
2017-03-06 15:48:04 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_frame f[2];
|
|
|
|
|
int i;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_METHOD_PORT_UPDATE);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-05-26 08:05:01 +02:00
|
|
|
SPA_POD_TYPE_STRUCT, &f[0],
|
|
|
|
|
SPA_POD_TYPE_INT, direction,
|
|
|
|
|
SPA_POD_TYPE_INT, port_id,
|
|
|
|
|
SPA_POD_TYPE_INT, change_mask, SPA_POD_TYPE_INT, n_possible_formats, 0);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
for (i = 0; i < n_possible_formats; i++)
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, SPA_POD_TYPE_POD, possible_formats[i], 0);
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, SPA_POD_TYPE_POD, format, SPA_POD_TYPE_INT, n_params, 0);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < n_params; i++) {
|
|
|
|
|
const struct spa_param *p = params[i];
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, SPA_POD_TYPE_POD, p, 0);
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info) {
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-05-26 08:05:01 +02:00
|
|
|
SPA_POD_TYPE_STRUCT, &f[1],
|
|
|
|
|
SPA_POD_TYPE_INT, info->flags, SPA_POD_TYPE_INT, info->rate, 0);
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f[1], 0);
|
2017-05-26 08:05:01 +02:00
|
|
|
} else {
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, SPA_POD_TYPE_POD, NULL, 0);
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f[0], 0);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static void client_node_marshal_event_method(void *object, struct spa_event *event)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_frame f;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_METHOD_EVENT);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_POD, event);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
static void client_node_marshal_destroy(void *object)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_frame f;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_METHOD_DESTROY);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f, 0);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-30 19:46:51 +02:00
|
|
|
static bool client_node_demarshal_set_props(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
uint32_t seq;
|
|
|
|
|
const struct spa_props *props = NULL;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
|
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &seq,
|
|
|
|
|
-SPA_POD_TYPE_OBJECT, &props, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->set_props(proxy, seq, props);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static bool client_node_demarshal_event_event(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
const struct spa_event *event;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-26 08:05:01 +02:00
|
|
|
!spa_pod_iter_get(&it, SPA_POD_TYPE_OBJECT, &event, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->event(proxy, event);
|
|
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
static bool client_node_demarshal_add_port(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
int32_t seq, direction, port_id;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
|
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &seq,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction, SPA_POD_TYPE_INT, &port_id, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->add_port(proxy, seq, direction,
|
|
|
|
|
port_id);
|
|
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
static bool client_node_demarshal_remove_port(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
int32_t seq, direction, port_id;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
|
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &seq,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction, SPA_POD_TYPE_INT, &port_id, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->remove_port(proxy, seq, direction,
|
|
|
|
|
port_id);
|
|
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-26 08:05:01 +02:00
|
|
|
static bool client_node_demarshal_set_format(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
uint32_t seq, direction, port_id, flags;
|
|
|
|
|
const struct spa_format *format = NULL;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-26 08:05:01 +02:00
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &seq,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction,
|
|
|
|
|
SPA_POD_TYPE_INT, &port_id,
|
2017-05-30 19:46:51 +02:00
|
|
|
SPA_POD_TYPE_INT, &flags,
|
|
|
|
|
-SPA_POD_TYPE_OBJECT, &format, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->set_format(proxy, seq, direction,
|
|
|
|
|
port_id, flags,
|
|
|
|
|
format);
|
|
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-30 19:46:51 +02:00
|
|
|
static bool client_node_demarshal_set_param(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
2017-05-30 19:46:51 +02:00
|
|
|
uint32_t seq, direction, port_id;
|
|
|
|
|
const struct spa_param *param = NULL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-26 08:05:01 +02:00
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &seq,
|
2017-05-30 19:46:51 +02:00
|
|
|
SPA_POD_TYPE_INT, &direction,
|
|
|
|
|
SPA_POD_TYPE_INT, &port_id,
|
|
|
|
|
-SPA_POD_TYPE_OBJECT, ¶m, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-05-30 19:46:51 +02:00
|
|
|
((struct pw_client_node_events *) proxy->implementation)->set_param(proxy, seq, direction,
|
|
|
|
|
port_id, param);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
uint32_t direction, port_id, mem_id, type, memfd_idx, flags, offset, sz;
|
|
|
|
|
int memfd;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-26 08:05:01 +02:00
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction,
|
|
|
|
|
SPA_POD_TYPE_INT, &port_id,
|
|
|
|
|
SPA_POD_TYPE_INT, &mem_id,
|
|
|
|
|
SPA_POD_TYPE_ID, &type,
|
|
|
|
|
SPA_POD_TYPE_INT, &memfd_idx,
|
|
|
|
|
SPA_POD_TYPE_INT, &flags,
|
|
|
|
|
SPA_POD_TYPE_INT, &offset, SPA_POD_TYPE_INT, &sz, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->add_mem(proxy,
|
|
|
|
|
direction,
|
|
|
|
|
port_id,
|
|
|
|
|
mem_id,
|
|
|
|
|
type,
|
|
|
|
|
memfd, flags, offset, sz);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_use_buffers(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
uint32_t seq, direction, port_id, n_buffers, data_id;
|
|
|
|
|
struct pw_client_node_buffer *buffers;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-26 08:05:01 +02:00
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &seq,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction,
|
|
|
|
|
SPA_POD_TYPE_INT, &port_id, SPA_POD_TYPE_INT, &n_buffers, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
buffers = alloca(sizeof(struct pw_client_node_buffer) * n_buffers);
|
|
|
|
|
for (i = 0; i < n_buffers; i++) {
|
|
|
|
|
struct spa_buffer *buf = buffers[i].buffer = alloca(sizeof(struct spa_buffer));
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &buffers[i].mem_id,
|
|
|
|
|
SPA_POD_TYPE_INT, &buffers[i].offset,
|
|
|
|
|
SPA_POD_TYPE_INT, &buffers[i].size,
|
|
|
|
|
SPA_POD_TYPE_INT, &buf->id,
|
|
|
|
|
SPA_POD_TYPE_INT, &buf->n_metas, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
buf->metas = alloca(sizeof(struct spa_meta) * buf->n_metas);
|
|
|
|
|
for (j = 0; j < buf->n_metas; j++) {
|
|
|
|
|
struct spa_meta *m = &buf->metas[j];
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_ID, &m->type,
|
|
|
|
|
SPA_POD_TYPE_INT, &m->size, 0))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!spa_pod_iter_get(&it, SPA_POD_TYPE_INT, &buf->n_datas, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
buf->datas = alloca(sizeof(struct spa_data) * buf->n_datas);
|
|
|
|
|
for (j = 0; j < buf->n_datas; j++) {
|
|
|
|
|
struct spa_data *d = &buf->datas[j];
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_ID, &d->type,
|
|
|
|
|
SPA_POD_TYPE_INT, &data_id,
|
|
|
|
|
SPA_POD_TYPE_INT, &d->flags,
|
|
|
|
|
SPA_POD_TYPE_INT, &d->mapoffset,
|
|
|
|
|
SPA_POD_TYPE_INT, &d->maxsize, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
d->data = SPA_UINT32_TO_PTR(data_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->use_buffers(proxy,
|
|
|
|
|
seq,
|
|
|
|
|
direction,
|
|
|
|
|
port_id,
|
|
|
|
|
n_buffers, buffers);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_node_command(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
const struct spa_command *command;
|
|
|
|
|
uint32_t seq;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-26 08:05:01 +02:00
|
|
|
!spa_pod_iter_get(&it, SPA_POD_TYPE_INT, &seq, SPA_POD_TYPE_OBJECT, &command, 0))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
((struct pw_client_node_events *) proxy->implementation)->node_command(proxy, seq, command);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_port_command(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
const struct spa_command *command;
|
2017-05-30 19:46:51 +02:00
|
|
|
uint32_t direction, port_id;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-07-11 12:24:03 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
|
2017-05-30 19:46:51 +02:00
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction,
|
|
|
|
|
SPA_POD_TYPE_INT, &port_id,
|
|
|
|
|
SPA_POD_TYPE_OBJECT, &command, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-05-30 19:46:51 +02:00
|
|
|
((struct pw_client_node_events *) proxy->implementation)->port_command(proxy,
|
|
|
|
|
direction,
|
|
|
|
|
port_id,
|
2017-05-26 08:05:01 +02:00
|
|
|
command);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_transport(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_iter it;
|
2017-06-27 13:24:37 +02:00
|
|
|
uint32_t node_id, ridx, widx, memfd_idx, offset, sz;
|
2017-06-09 17:24:18 +02:00
|
|
|
int readfd, writefd, memfd;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
|
|
|
|
!spa_pod_iter_get(&it,
|
2017-06-27 13:24:37 +02:00
|
|
|
SPA_POD_TYPE_INT, &node_id,
|
2017-06-09 17:24:18 +02:00
|
|
|
SPA_POD_TYPE_INT, &ridx,
|
|
|
|
|
SPA_POD_TYPE_INT, &widx,
|
2017-05-26 08:05:01 +02:00
|
|
|
SPA_POD_TYPE_INT, &memfd_idx,
|
2017-05-30 19:46:51 +02:00
|
|
|
SPA_POD_TYPE_INT, &offset,
|
|
|
|
|
SPA_POD_TYPE_INT, &sz, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
|
|
|
|
|
writefd = pw_protocol_native_get_proxy_fd(proxy, widx);
|
|
|
|
|
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
2017-06-09 17:24:18 +02:00
|
|
|
if (readfd == -1 || writefd == -1 || memfd_idx == -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-06-27 13:24:37 +02:00
|
|
|
((struct pw_client_node_events *) proxy->implementation)->transport(proxy, node_id,
|
2017-06-09 17:24:18 +02:00
|
|
|
readfd, writefd,
|
|
|
|
|
memfd, offset, sz);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static void
|
|
|
|
|
client_node_marshal_set_props(void *object, uint32_t seq, const struct spa_props *props)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_SET_PROPS);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_POD, props);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void client_node_marshal_event_event(void *object, const struct spa_event *event)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_EVENT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_POD, event);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_ADD_PORT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_INT, direction, SPA_POD_TYPE_INT, port_id);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_REMOVE_PORT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_INT, direction, SPA_POD_TYPE_INT, port_id);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
client_node_marshal_set_format(void *object,
|
|
|
|
|
uint32_t seq,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
uint32_t flags,
|
|
|
|
|
const struct spa_format *format)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_SET_FORMAT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_INT, direction,
|
|
|
|
|
SPA_POD_TYPE_INT, port_id,
|
|
|
|
|
SPA_POD_TYPE_INT, flags,
|
|
|
|
|
SPA_POD_TYPE_POD, format);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
client_node_marshal_set_param(void *object,
|
|
|
|
|
uint32_t seq,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
const struct spa_param *param)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_SET_PARAM);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_INT, direction,
|
|
|
|
|
SPA_POD_TYPE_INT, port_id,
|
|
|
|
|
SPA_POD_TYPE_POD, param);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
client_node_marshal_add_mem(void *object,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
uint32_t mem_id,
|
|
|
|
|
uint32_t type,
|
|
|
|
|
int memfd, uint32_t flags, uint32_t offset, uint32_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_ADD_MEM);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, direction,
|
|
|
|
|
SPA_POD_TYPE_INT, port_id,
|
|
|
|
|
SPA_POD_TYPE_INT, mem_id,
|
|
|
|
|
SPA_POD_TYPE_ID, type,
|
2017-07-12 18:04:00 +02:00
|
|
|
SPA_POD_TYPE_INT, pw_protocol_native_add_resource_fd(resource, memfd),
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, flags,
|
|
|
|
|
SPA_POD_TYPE_INT, offset, SPA_POD_TYPE_INT, size);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
client_node_marshal_use_buffers(void *object,
|
|
|
|
|
uint32_t seq,
|
|
|
|
|
enum spa_direction direction,
|
|
|
|
|
uint32_t port_id,
|
|
|
|
|
uint32_t n_buffers, struct pw_client_node_buffer *buffers)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
uint32_t i, j;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_USE_BUFFERS);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_STRUCT, &f,
|
|
|
|
|
SPA_POD_TYPE_INT, seq,
|
|
|
|
|
SPA_POD_TYPE_INT, direction,
|
|
|
|
|
SPA_POD_TYPE_INT, port_id, SPA_POD_TYPE_INT, n_buffers, 0);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_buffers; i++) {
|
|
|
|
|
struct spa_buffer *buf = buffers[i].buffer;
|
|
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, buffers[i].mem_id,
|
|
|
|
|
SPA_POD_TYPE_INT, buffers[i].offset,
|
|
|
|
|
SPA_POD_TYPE_INT, buffers[i].size,
|
|
|
|
|
SPA_POD_TYPE_INT, buf->id, SPA_POD_TYPE_INT, buf->n_metas, 0);
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < buf->n_metas; j++) {
|
|
|
|
|
struct spa_meta *m = &buf->metas[j];
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_ID, m->type, SPA_POD_TYPE_INT, m->size, 0);
|
|
|
|
|
}
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, SPA_POD_TYPE_INT, buf->n_datas, 0);
|
2017-06-21 12:11:54 +02:00
|
|
|
for (j = 0; j < buf->n_datas; j++) {
|
|
|
|
|
struct spa_data *d = &buf->datas[j];
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_ID, d->type,
|
|
|
|
|
SPA_POD_TYPE_INT, SPA_PTR_TO_UINT32(d->data),
|
|
|
|
|
SPA_POD_TYPE_INT, d->flags,
|
|
|
|
|
SPA_POD_TYPE_INT, d->mapoffset,
|
|
|
|
|
SPA_POD_TYPE_INT, d->maxsize, 0);
|
|
|
|
|
}
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b, -SPA_POD_TYPE_STRUCT, &f, 0);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static void
|
|
|
|
|
client_node_marshal_node_command(void *object, uint32_t seq, const struct spa_command *command)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_NODE_COMMAND);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f, SPA_POD_TYPE_INT, seq, SPA_POD_TYPE_POD, command);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_PORT_COMMAND);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, direction,
|
|
|
|
|
SPA_POD_TYPE_INT, port_id,
|
|
|
|
|
SPA_POD_TYPE_POD, command);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-27 13:24:37 +02:00
|
|
|
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
|
2017-06-21 12:11:54 +02:00
|
|
|
int memfd, uint32_t offset, uint32_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-07-11 12:24:03 +02:00
|
|
|
struct spa_pod_builder *b;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod_frame f;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_EVENT_TRANSPORT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_struct(b, &f,
|
2017-06-27 13:24:37 +02:00
|
|
|
SPA_POD_TYPE_INT, node_id,
|
2017-07-12 18:04:00 +02:00
|
|
|
SPA_POD_TYPE_INT, pw_protocol_native_add_resource_fd(resource, readfd),
|
|
|
|
|
SPA_POD_TYPE_INT, pw_protocol_native_add_resource_fd(resource, writefd),
|
|
|
|
|
SPA_POD_TYPE_INT, pw_protocol_native_add_resource_fd(resource, memfd),
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, offset, SPA_POD_TYPE_INT, size);
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
pw_protocol_native_end_resource(resource, b);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_done(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_iter it;
|
2017-06-21 12:11:54 +02:00
|
|
|
uint32_t seq, res;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
|
|
|
|
!spa_pod_iter_get(&it,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, &seq,
|
|
|
|
|
SPA_POD_TYPE_INT, &res, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
((struct pw_client_node_methods *) resource->implementation)->done(resource, seq, res);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static bool client_node_demarshal_update(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_iter it;
|
2017-06-21 12:11:54 +02:00
|
|
|
uint32_t change_mask, max_input_ports, max_output_ports;
|
|
|
|
|
const struct spa_props *props;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-06-21 12:11:54 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &resource->client->types) ||
|
2017-05-30 19:46:51 +02:00
|
|
|
!spa_pod_iter_get(&it,
|
2017-06-21 12:11:54 +02:00
|
|
|
SPA_POD_TYPE_INT, &change_mask,
|
|
|
|
|
SPA_POD_TYPE_INT, &max_input_ports,
|
|
|
|
|
SPA_POD_TYPE_INT, &max_output_ports, -SPA_POD_TYPE_OBJECT, &props, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
((struct pw_client_node_methods *) resource->implementation)->update(resource, change_mask,
|
|
|
|
|
max_input_ports,
|
|
|
|
|
max_output_ports,
|
|
|
|
|
props);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static bool client_node_demarshal_port_update(void *object, void *data, size_t size)
|
2017-03-03 19:06:54 +01:00
|
|
|
{
|
2017-06-21 12:11:54 +02:00
|
|
|
struct pw_resource *resource = object;
|
2017-05-26 08:05:01 +02:00
|
|
|
struct spa_pod_iter it;
|
2017-06-21 12:11:54 +02:00
|
|
|
uint32_t i, direction, port_id, change_mask, n_possible_formats, n_params;
|
|
|
|
|
const struct spa_param **params = NULL;
|
|
|
|
|
const struct spa_format **possible_formats = NULL, *format = NULL;
|
|
|
|
|
struct spa_port_info info, *infop = NULL;
|
|
|
|
|
struct spa_pod *ipod;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
2017-06-21 12:11:54 +02:00
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &resource->client->types) ||
|
|
|
|
|
!spa_pod_iter_get(&it,
|
|
|
|
|
SPA_POD_TYPE_INT, &direction,
|
|
|
|
|
SPA_POD_TYPE_INT, &port_id,
|
|
|
|
|
SPA_POD_TYPE_INT, &change_mask,
|
|
|
|
|
SPA_POD_TYPE_INT, &n_possible_formats, 0))
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
possible_formats = alloca(n_possible_formats * sizeof(struct spa_format *));
|
|
|
|
|
for (i = 0; i < n_possible_formats; i++)
|
|
|
|
|
if (!spa_pod_iter_get(&it, SPA_POD_TYPE_OBJECT, &possible_formats[i], 0))
|
|
|
|
|
return false;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (!spa_pod_iter_get(&it, -SPA_POD_TYPE_OBJECT, &format, SPA_POD_TYPE_INT, &n_params, 0))
|
|
|
|
|
return false;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
params = alloca(n_params * sizeof(struct spa_param *));
|
|
|
|
|
for (i = 0; i < n_params; i++)
|
|
|
|
|
if (!spa_pod_iter_get(&it, SPA_POD_TYPE_OBJECT, ¶ms[i], 0))
|
|
|
|
|
return false;
|
2017-04-27 17:17:47 +02:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (!spa_pod_iter_get(&it, -SPA_POD_TYPE_STRUCT, &ipod, 0))
|
|
|
|
|
return false;
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (ipod) {
|
|
|
|
|
struct spa_pod_iter it2;
|
|
|
|
|
infop = &info;
|
|
|
|
|
|
|
|
|
|
if (!spa_pod_iter_pod(&it2, ipod) ||
|
|
|
|
|
!spa_pod_iter_get(&it2,
|
|
|
|
|
SPA_POD_TYPE_INT, &info.flags,
|
|
|
|
|
SPA_POD_TYPE_INT, &info.rate, 0))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
((struct pw_client_node_methods *) resource->implementation)->port_update(resource,
|
|
|
|
|
direction,
|
|
|
|
|
port_id,
|
|
|
|
|
change_mask,
|
|
|
|
|
n_possible_formats,
|
|
|
|
|
possible_formats,
|
|
|
|
|
format,
|
|
|
|
|
n_params,
|
|
|
|
|
params, infop);
|
|
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static bool client_node_demarshal_event_method(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_iter it;
|
|
|
|
|
struct spa_event *event;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (!spa_pod_iter_struct(&it, data, size) ||
|
|
|
|
|
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &resource->client->types) ||
|
|
|
|
|
!spa_pod_iter_get(&it, SPA_POD_TYPE_OBJECT, &event, 0))
|
|
|
|
|
return false;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
((struct pw_client_node_methods *) resource->implementation)->event(resource, event);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static bool client_node_demarshal_destroy(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_iter it;
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (!spa_pod_iter_struct(&it, data, size))
|
|
|
|
|
return false;
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
((struct pw_client_node_methods *) resource->implementation)->destroy(resource);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
static const struct pw_client_node_methods pw_protocol_native_client_client_node_methods = {
|
2017-06-09 17:24:18 +02:00
|
|
|
&client_node_marshal_done,
|
2017-05-26 08:05:01 +02:00
|
|
|
&client_node_marshal_update,
|
|
|
|
|
&client_node_marshal_port_update,
|
2017-06-21 12:11:54 +02:00
|
|
|
&client_node_marshal_event_method,
|
2017-05-26 08:05:01 +02:00
|
|
|
&client_node_marshal_destroy
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
|
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
static const demarshal_func_t pw_protocol_native_client_client_node_demarshal[] = {
|
2017-06-27 13:24:37 +02:00
|
|
|
&client_node_demarshal_transport,
|
2017-05-30 19:46:51 +02:00
|
|
|
&client_node_demarshal_set_props,
|
2017-06-21 12:11:54 +02:00
|
|
|
&client_node_demarshal_event_event,
|
2017-05-26 08:05:01 +02:00
|
|
|
&client_node_demarshal_add_port,
|
|
|
|
|
&client_node_demarshal_remove_port,
|
|
|
|
|
&client_node_demarshal_set_format,
|
2017-05-30 19:46:51 +02:00
|
|
|
&client_node_demarshal_set_param,
|
2017-05-26 08:05:01 +02:00
|
|
|
&client_node_demarshal_add_mem,
|
|
|
|
|
&client_node_demarshal_use_buffers,
|
|
|
|
|
&client_node_demarshal_node_command,
|
|
|
|
|
&client_node_demarshal_port_command,
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
|
|
|
|
|
2017-05-23 19:15:33 +02:00
|
|
|
static const struct pw_interface pw_protocol_native_client_client_node_interface = {
|
2017-07-12 18:04:00 +02:00
|
|
|
PW_TYPE__ClientNode,
|
2017-06-15 17:54:55 +02:00
|
|
|
PW_VERSION_CLIENT_NODE,
|
2017-05-26 08:05:01 +02:00
|
|
|
PW_CLIENT_NODE_METHOD_NUM, &pw_protocol_native_client_client_node_methods,
|
|
|
|
|
PW_CLIENT_NODE_EVENT_NUM, pw_protocol_native_client_client_node_demarshal,
|
2017-03-09 13:00:56 +01:00
|
|
|
};
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static const demarshal_func_t pw_protocol_native_server_client_node_demarshal[] = {
|
|
|
|
|
&client_node_demarshal_done,
|
|
|
|
|
&client_node_demarshal_update,
|
|
|
|
|
&client_node_demarshal_port_update,
|
|
|
|
|
&client_node_demarshal_event_method,
|
|
|
|
|
&client_node_demarshal_destroy,
|
2017-03-09 13:00:56 +01:00
|
|
|
};
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
static const struct pw_client_node_events pw_protocol_native_server_client_node_events = {
|
2017-06-27 13:24:37 +02:00
|
|
|
&client_node_marshal_transport,
|
2017-06-21 12:11:54 +02:00
|
|
|
&client_node_marshal_set_props,
|
|
|
|
|
&client_node_marshal_event_event,
|
|
|
|
|
&client_node_marshal_add_port,
|
|
|
|
|
&client_node_marshal_remove_port,
|
|
|
|
|
&client_node_marshal_set_format,
|
|
|
|
|
&client_node_marshal_set_param,
|
|
|
|
|
&client_node_marshal_add_mem,
|
|
|
|
|
&client_node_marshal_use_buffers,
|
|
|
|
|
&client_node_marshal_node_command,
|
|
|
|
|
&client_node_marshal_port_command,
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
|
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
const struct pw_interface pw_protocol_native_server_client_node_interface = {
|
2017-07-12 18:04:00 +02:00
|
|
|
PW_TYPE__ClientNode,
|
2017-06-21 12:11:54 +02:00
|
|
|
PW_VERSION_CLIENT_NODE,
|
|
|
|
|
PW_CLIENT_NODE_METHOD_NUM, &pw_protocol_native_server_client_node_demarshal,
|
|
|
|
|
PW_CLIENT_NODE_EVENT_NUM, &pw_protocol_native_server_client_node_events,
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core)
|
2017-05-26 08:05:01 +02:00
|
|
|
{
|
2017-06-15 17:54:55 +02:00
|
|
|
struct pw_protocol *protocol;
|
|
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
protocol = pw_core_find_protocol(core, PW_TYPE_PROTOCOL__Native);
|
2017-06-15 17:54:55 +02:00
|
|
|
|
2017-07-12 18:04:00 +02:00
|
|
|
if (protocol == NULL)
|
|
|
|
|
return NULL;
|
2017-06-16 10:06:50 +02:00
|
|
|
|
2017-06-15 17:54:55 +02:00
|
|
|
pw_protocol_add_interfaces(protocol,
|
|
|
|
|
&pw_protocol_native_client_client_node_interface,
|
2017-06-21 12:11:54 +02:00
|
|
|
&pw_protocol_native_server_client_node_interface);
|
2017-06-15 17:54:55 +02:00
|
|
|
|
2017-06-16 10:06:50 +02:00
|
|
|
return protocol;
|
2017-03-09 13:00:56 +01:00
|
|
|
}
|