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-11-10 13:36:14 +01:00
|
|
|
#include <spa/pod/parser.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-08-07 10:25:02 +02:00
|
|
|
#include "transport.h"
|
|
|
|
|
|
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
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DONE);
|
2017-06-09 17:24:18 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", seq,
|
|
|
|
|
"i", res);
|
2017-06-09 17:24:18 +02:00
|
|
|
|
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,
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t max_output_ports,
|
|
|
|
|
uint32_t n_params,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params)
|
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-11-07 17:39:31 +01:00
|
|
|
int i;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_UPDATE);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_builder_add(b,
|
|
|
|
|
"[",
|
|
|
|
|
"i", change_mask,
|
|
|
|
|
"i", max_input_ports,
|
|
|
|
|
"i", max_output_ports,
|
|
|
|
|
"i", n_params, NULL);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_params; i++)
|
|
|
|
|
spa_pod_builder_add(b, "P", params[i], NULL);
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_add(b, "]", NULL);
|
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_params,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params,
|
2017-11-07 17:39:31 +01:00
|
|
|
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
|
|
|
int i;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_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-09-21 18:57:41 +02:00
|
|
|
"[",
|
|
|
|
|
"i", direction,
|
|
|
|
|
"i", port_id,
|
|
|
|
|
"i", change_mask,
|
|
|
|
|
"i", n_params, NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
for (i = 0; i < n_params; i++)
|
|
|
|
|
spa_pod_builder_add(b, "P", params[i], NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
if (info) {
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", info->flags,
|
|
|
|
|
"i", info->rate);
|
2017-05-26 08:05:01 +02:00
|
|
|
} else {
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_add(b, "P", NULL, NULL);
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_add(b, "]", NULL);
|
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-10-13 16:18:42 +02:00
|
|
|
static void client_node_marshal_set_active(void *object, bool active)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
|
|
|
|
|
|
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE);
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_struct(b, "b", active);
|
|
|
|
|
|
|
|
|
|
pw_protocol_native_end_proxy(proxy, b);
|
|
|
|
|
}
|
|
|
|
|
|
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-03-06 15:48:04 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_EVENT);
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b, "P", 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-03-03 19:06:54 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DESTROY);
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b);
|
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-12-01 17:24:03 +01:00
|
|
|
static bool client_node_demarshal_add_mem(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
|
|
|
|
uint32_t mem_id, type, memfd_idx, flags;
|
|
|
|
|
int memfd;
|
|
|
|
|
|
|
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &mem_id,
|
|
|
|
|
"I", &type,
|
|
|
|
|
"i", &memfd_idx,
|
|
|
|
|
"i", &flags, NULL) < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
|
|
|
|
|
|
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_mem,
|
|
|
|
|
mem_id,
|
|
|
|
|
type,
|
|
|
|
|
memfd, flags);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
static bool client_node_demarshal_transport(void *object, void *data, size_t size)
|
2017-05-30 19:46:51 +02:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t node_id, ridx, widx, memfd_idx;
|
|
|
|
|
int readfd, writefd;
|
|
|
|
|
struct pw_client_node_transport_info info;
|
|
|
|
|
struct pw_client_node_transport *transport;
|
|
|
|
|
|
|
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &node_id,
|
|
|
|
|
"i", &ridx,
|
|
|
|
|
"i", &widx,
|
|
|
|
|
"i", &memfd_idx,
|
|
|
|
|
"i", &info.offset,
|
|
|
|
|
"i", &info.size, NULL) < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
readfd = pw_protocol_native_get_proxy_fd(proxy, ridx);
|
|
|
|
|
writefd = pw_protocol_native_get_proxy_fd(proxy, widx);
|
|
|
|
|
info.memfd = pw_protocol_native_get_proxy_fd(proxy, memfd_idx);
|
|
|
|
|
|
|
|
|
|
if (readfd == -1 || writefd == -1 || info.memfd == -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
transport = pw_client_node_transport_new_from_info(&info);
|
|
|
|
|
|
|
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, transport, node_id,
|
|
|
|
|
readfd, writefd, transport);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_set_param(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
|
|
|
|
uint32_t seq, id, flags;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param = NULL;
|
2017-05-30 19:46:51 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
2017-11-07 17:39:31 +01:00
|
|
|
"I", &id,
|
|
|
|
|
"i", &flags,
|
|
|
|
|
"O", ¶m, NULL) < 0)
|
2017-05-30 19:46:51 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, set_param, seq, id, flags, param);
|
2017-05-30 19:46:51 +02:00
|
|
|
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;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-05-26 08:05:01 +02:00
|
|
|
const struct spa_event *event;
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs, "[ O", &event, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, event, event);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
static bool client_node_demarshal_command(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;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
const struct spa_command *command;
|
|
|
|
|
uint32_t seq;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
2017-11-07 17:39:31 +01:00
|
|
|
"O", &command, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, command, seq, command);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01: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;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-05-26 08:05:01 +02:00
|
|
|
int32_t seq, direction, port_id;
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
|
|
|
|
"i", &direction,
|
|
|
|
|
"i", &port_id, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, add_port, seq, direction, port_id);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01: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;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
int32_t seq, direction, port_id;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
|
|
|
|
"i", &direction,
|
2017-11-07 17:39:31 +01:00
|
|
|
"i", &port_id, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, remove_port, seq, direction, port_id);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
static bool client_node_demarshal_port_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;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t seq, direction, port_id, id, flags;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param = NULL;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
|
|
|
|
"i", &direction,
|
|
|
|
|
"i", &port_id,
|
2017-11-07 17:39:31 +01:00
|
|
|
"I", &id,
|
|
|
|
|
"i", &flags,
|
2017-09-21 18:57:41 +02:00
|
|
|
"O", ¶m, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_param,
|
|
|
|
|
seq, direction, port_id, id, flags, param);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
static bool client_node_demarshal_port_use_buffers(void *object, void *data, size_t size)
|
2017-05-26 08:05:01 +02:00
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-05-26 08:05:01 +02:00
|
|
|
uint32_t seq, direction, port_id, n_buffers, data_id;
|
|
|
|
|
struct pw_client_node_buffer *buffers;
|
|
|
|
|
int i, j;
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
|
|
|
|
"i", &direction,
|
|
|
|
|
"i", &port_id,
|
|
|
|
|
"i", &n_buffers, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
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));
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"i", &buffers[i].mem_id,
|
|
|
|
|
"i", &buffers[i].offset,
|
|
|
|
|
"i", &buffers[i].size,
|
|
|
|
|
"i", &buf->id,
|
|
|
|
|
"i", &buf->n_metas, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
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];
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"I", &m->type,
|
|
|
|
|
"i", &m->size, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs, "i", &buf->n_datas, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
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];
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"I", &d->type,
|
|
|
|
|
"i", &data_id,
|
|
|
|
|
"i", &d->flags,
|
|
|
|
|
"i", &d->mapoffset,
|
|
|
|
|
"i", &d->maxsize, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
d->data = SPA_UINT32_TO_PTR(data_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_use_buffers, seq,
|
2017-07-13 15:21:52 +02:00
|
|
|
direction,
|
|
|
|
|
port_id,
|
|
|
|
|
n_buffers, buffers);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool client_node_demarshal_port_command(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-05-26 08:05:01 +02:00
|
|
|
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
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &direction,
|
|
|
|
|
"i", &port_id,
|
|
|
|
|
"O", &command, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_command, direction,
|
2017-07-13 15:21:52 +02:00
|
|
|
port_id,
|
|
|
|
|
command);
|
2017-05-26 08:05:01 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-30 16:36:29 +01:00
|
|
|
static bool client_node_demarshal_port_set_io(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_proxy *proxy = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
|
|
|
|
uint32_t seq, direction, port_id, id, memid, off, sz;
|
|
|
|
|
|
|
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
|
|
|
|
"i", &direction,
|
|
|
|
|
"i", &port_id,
|
|
|
|
|
"I", &id,
|
|
|
|
|
"i", &memid,
|
|
|
|
|
"i", &off,
|
|
|
|
|
"i", &sz, NULL) < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
pw_proxy_notify(proxy, struct pw_client_node_proxy_events, port_set_io,
|
|
|
|
|
seq,
|
|
|
|
|
direction, port_id,
|
|
|
|
|
id, memid,
|
|
|
|
|
off, sz);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-01 17:24:03 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_MEM);
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", mem_id,
|
|
|
|
|
"I", type,
|
|
|
|
|
"i", pw_protocol_native_add_resource_fd(resource, memfd),
|
|
|
|
|
"i", flags);
|
|
|
|
|
|
|
|
|
|
pw_protocol_native_end_resource(resource, b);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
static void client_node_marshal_transport(void *object, uint32_t node_id, int readfd, int writefd,
|
|
|
|
|
struct pw_client_node_transport *transport)
|
2017-05-26 08:05:01 +02:00
|
|
|
{
|
2017-11-07 17:39:31 +01:00
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_builder *b;
|
2017-08-07 10:25:02 +02:00
|
|
|
struct pw_client_node_transport_info info;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
pw_client_node_transport_get_info(transport, &info);
|
2017-08-07 10:25:02 +02:00
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT);
|
2017-06-09 17:24:18 +02:00
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_builder_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);
|
2017-08-07 10:25:02 +02:00
|
|
|
|
2017-11-07 17:39:31 +01: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
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t flags,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param)
|
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-05-26 08:05:01 +02:00
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", seq,
|
2017-11-07 17:39:31 +01:00
|
|
|
"I", id,
|
|
|
|
|
"i", flags,
|
|
|
|
|
"P", param);
|
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_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
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_EVENT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b, "P", 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
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_command(void *object, uint32_t seq, const struct spa_command *command)
|
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
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_builder_struct(b, "i", seq, "P", 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
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_add_port(void *object,
|
|
|
|
|
uint32_t seq, enum spa_direction direction, uint32_t port_id)
|
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
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", seq,
|
|
|
|
|
"i", direction,
|
|
|
|
|
"i", port_id);
|
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
|
2017-11-07 17:39:31 +01:00
|
|
|
client_node_marshal_remove_port(void *object,
|
|
|
|
|
uint32_t seq, enum spa_direction direction, uint32_t port_id)
|
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
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", seq,
|
|
|
|
|
"i", direction,
|
2017-11-07 17:39:31 +01:00
|
|
|
"i", port_id);
|
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
|
2017-11-07 17:39:31 +01:00
|
|
|
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,
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod *param)
|
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
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", seq,
|
|
|
|
|
"i", direction,
|
|
|
|
|
"i", port_id,
|
2017-11-07 17:39:31 +01:00
|
|
|
"I", id,
|
|
|
|
|
"i", flags,
|
2017-09-21 18:57:41 +02:00
|
|
|
"P", param);
|
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
|
2017-11-07 17:39:31 +01:00
|
|
|
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_node_buffer *buffers)
|
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
|
|
|
uint32_t i, j;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_USE_BUFFERS);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-07-11 12:24:03 +02:00
|
|
|
spa_pod_builder_add(b,
|
2017-09-21 18:57:41 +02:00
|
|
|
"[",
|
|
|
|
|
"i", seq,
|
|
|
|
|
"i", direction,
|
|
|
|
|
"i", port_id,
|
|
|
|
|
"i", n_buffers, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
|
|
|
|
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-09-21 18:57:41 +02:00
|
|
|
"i", buffers[i].mem_id,
|
|
|
|
|
"i", buffers[i].offset,
|
|
|
|
|
"i", buffers[i].size,
|
|
|
|
|
"i", buf->id,
|
|
|
|
|
"i", buf->n_metas, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
|
|
|
|
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-09-21 18:57:41 +02:00
|
|
|
"I", m->type,
|
|
|
|
|
"i", m->size, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_add(b, "i", buf->n_datas, NULL);
|
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-09-21 18:57:41 +02:00
|
|
|
"I", d->type,
|
|
|
|
|
"i", SPA_PTR_TO_UINT32(d->data),
|
|
|
|
|
"i", d->flags,
|
|
|
|
|
"i", d->mapoffset,
|
|
|
|
|
"i", d->maxsize, NULL);
|
2017-06-21 12:11:54 +02:00
|
|
|
}
|
2017-05-26 08:05:01 +02:00
|
|
|
}
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_add(b, "]", NULL);
|
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_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
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_COMMAND);
|
2017-06-21 12:11:54 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", direction,
|
|
|
|
|
"i", port_id,
|
|
|
|
|
"P", 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
|
|
|
}
|
|
|
|
|
|
2017-11-30 16:36:29 +01:00
|
|
|
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_NODE_PROXY_EVENT_PORT_SET_IO);
|
|
|
|
|
|
|
|
|
|
spa_pod_builder_struct(b,
|
|
|
|
|
"i", seq,
|
|
|
|
|
"i", direction,
|
|
|
|
|
"i", port_id,
|
|
|
|
|
"I", id,
|
|
|
|
|
"i", memid,
|
|
|
|
|
"i", offset,
|
|
|
|
|
"i", size);
|
|
|
|
|
|
|
|
|
|
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-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-06-21 12:11:54 +02:00
|
|
|
uint32_t seq, res;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &seq,
|
|
|
|
|
"i", &res, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_resource_do(resource, struct pw_client_node_proxy_methods, done, 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-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t change_mask, max_input_ports, max_output_ports, n_params;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params;
|
2017-11-07 17:39:31 +01:00
|
|
|
int i;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &change_mask,
|
|
|
|
|
"i", &max_input_ports,
|
|
|
|
|
"i", &max_output_ports,
|
2017-11-07 17:39:31 +01:00
|
|
|
"i", &n_params, NULL) < 0)
|
2017-05-26 08:05:01 +02:00
|
|
|
return false;
|
|
|
|
|
|
2017-11-13 17:57:38 +01:00
|
|
|
params = alloca(n_params * sizeof(struct spa_pod *));
|
2017-11-07 17:39:31 +01:00
|
|
|
for (i = 0; i < n_params; i++)
|
|
|
|
|
if (spa_pod_parser_get(&prs, "O", ¶ms[i], NULL) < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_resource_do(resource, struct pw_client_node_proxy_methods, update, change_mask,
|
2017-07-13 15:21:52 +02:00
|
|
|
max_input_ports,
|
|
|
|
|
max_output_ports,
|
2017-11-07 17:39:31 +01:00
|
|
|
n_params,
|
|
|
|
|
params);
|
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-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-11-07 17:39:31 +01:00
|
|
|
uint32_t i, direction, port_id, change_mask, n_params;
|
2017-11-13 17:57:38 +01:00
|
|
|
const struct spa_pod **params = NULL;
|
2017-11-30 16:36:29 +01:00
|
|
|
struct spa_port_info info = { 0 }, *infop = NULL;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_pod *ipod;
|
2017-05-26 08:05:01 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"i", &direction,
|
|
|
|
|
"i", &port_id,
|
|
|
|
|
"i", &change_mask,
|
2017-11-07 17:39:31 +01:00
|
|
|
"i", &n_params, NULL) < 0)
|
2017-06-21 12:11:54 +02:00
|
|
|
return false;
|
2017-03-06 15:48:04 +01:00
|
|
|
|
2017-11-13 17:57:38 +01:00
|
|
|
params = alloca(n_params * sizeof(struct spa_pod *));
|
2017-06-21 12:11:54 +02:00
|
|
|
for (i = 0; i < n_params; i++)
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs, "O", ¶ms[i], NULL) < 0)
|
2017-06-21 12:11:54 +02:00
|
|
|
return false;
|
2017-04-27 17:17:47 +02:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
if (spa_pod_parser_get(&prs, "T", &ipod, NULL) < 0)
|
2017-06-21 12:11:54 +02:00
|
|
|
return false;
|
2017-03-14 20:18:31 +01:00
|
|
|
|
2017-06-21 12:11:54 +02:00
|
|
|
if (ipod) {
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser p2;
|
2017-06-21 12:11:54 +02:00
|
|
|
infop = &info;
|
|
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_pod(&p2, ipod);
|
|
|
|
|
if (spa_pod_parser_get(&p2,
|
|
|
|
|
"["
|
|
|
|
|
"i", &info.flags,
|
|
|
|
|
"i", &info.rate, NULL) < 0)
|
2017-06-21 12:11:54 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_resource_do(resource, struct pw_client_node_proxy_methods, port_update, direction,
|
2017-07-13 15:21:52 +02:00
|
|
|
port_id,
|
|
|
|
|
change_mask,
|
|
|
|
|
n_params,
|
|
|
|
|
params, infop);
|
2017-06-21 12:11:54 +02:00
|
|
|
return true;
|
2017-03-03 19:06:54 +01:00
|
|
|
}
|
|
|
|
|
|
2017-10-13 16:18:42 +02:00
|
|
|
static bool client_node_demarshal_set_active(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
|
|
|
|
struct spa_pod_parser prs;
|
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"b", &active, NULL) < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
pw_resource_do(resource, struct pw_client_node_proxy_methods, set_active, active);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-06-21 12:11:54 +02:00
|
|
|
struct spa_event *event;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs,
|
|
|
|
|
"["
|
|
|
|
|
"O", &event, NULL) < 0)
|
2017-06-21 12:11:54 +02:00
|
|
|
return false;
|
2017-03-03 19:06:54 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
pw_resource_do(resource, struct pw_client_node_proxy_methods, event, event);
|
2017-06-21 12:11:54 +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_destroy(void *object, void *data, size_t size)
|
|
|
|
|
{
|
|
|
|
|
struct pw_resource *resource = object;
|
2017-09-21 18:57:41 +02:00
|
|
|
struct spa_pod_parser prs;
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-09-21 18:57:41 +02:00
|
|
|
spa_pod_parser_init(&prs, data, size, 0);
|
|
|
|
|
if (spa_pod_parser_get(&prs, "[", NULL) < 0)
|
2017-06-21 12:11:54 +02:00
|
|
|
return false;
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-08-07 19:55:03 +02:00
|
|
|
pw_resource_do(resource, struct pw_client_node_proxy_methods, destroy);
|
2017-06-21 12:11:54 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2017-03-09 13:00:56 +01:00
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_client_node_proxy_methods pw_protocol_native_client_node_method_marshal = {
|
|
|
|
|
PW_VERSION_CLIENT_NODE_PROXY_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-10-13 16:18:42 +02:00
|
|
|
&client_node_marshal_set_active,
|
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-08-01 20:11:38 +02:00
|
|
|
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_method_demarshal[] = {
|
|
|
|
|
{ &client_node_demarshal_done, 0 },
|
|
|
|
|
{ &client_node_demarshal_update, PW_PROTOCOL_NATIVE_REMAP },
|
|
|
|
|
{ &client_node_demarshal_port_update, PW_PROTOCOL_NATIVE_REMAP },
|
2017-10-13 16:18:42 +02:00
|
|
|
{ &client_node_demarshal_set_active, 0 },
|
2017-08-01 20:11:38 +02:00
|
|
|
{ &client_node_demarshal_event_method, PW_PROTOCOL_NATIVE_REMAP },
|
|
|
|
|
{ &client_node_demarshal_destroy, 0 },
|
2017-03-09 13:00:56 +01:00
|
|
|
};
|
|
|
|
|
|
2017-08-04 16:49:13 +02:00
|
|
|
static const struct pw_client_node_proxy_events pw_protocol_native_client_node_event_marshal = {
|
|
|
|
|
PW_VERSION_CLIENT_NODE_PROXY_EVENTS,
|
2017-12-01 17:24:03 +01:00
|
|
|
&client_node_marshal_add_mem,
|
2017-06-27 13:24:37 +02:00
|
|
|
&client_node_marshal_transport,
|
2017-11-07 17:39:31 +01:00
|
|
|
&client_node_marshal_set_param,
|
2017-06-21 12:11:54 +02:00
|
|
|
&client_node_marshal_event_event,
|
2017-11-07 17:39:31 +01:00
|
|
|
&client_node_marshal_command,
|
2017-06-21 12:11:54 +02:00
|
|
|
&client_node_marshal_add_port,
|
|
|
|
|
&client_node_marshal_remove_port,
|
2017-11-07 17:39:31 +01:00
|
|
|
&client_node_marshal_port_set_param,
|
|
|
|
|
&client_node_marshal_port_use_buffers,
|
2017-06-21 12:11:54 +02:00
|
|
|
&client_node_marshal_port_command,
|
2017-11-30 16:36:29 +01:00
|
|
|
&client_node_marshal_port_set_io,
|
2017-03-03 19:06:54 +01:00
|
|
|
};
|
|
|
|
|
|
2017-08-01 20:11:38 +02:00
|
|
|
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_event_demarshal[] = {
|
2017-12-01 17:24:03 +01:00
|
|
|
{ &client_node_demarshal_add_mem, PW_PROTOCOL_NATIVE_REMAP },
|
2017-08-01 20:11:38 +02:00
|
|
|
{ &client_node_demarshal_transport, 0 },
|
2017-11-07 17:39:31 +01:00
|
|
|
{ &client_node_demarshal_set_param, PW_PROTOCOL_NATIVE_REMAP },
|
2017-08-01 20:11:38 +02:00
|
|
|
{ &client_node_demarshal_event_event, PW_PROTOCOL_NATIVE_REMAP },
|
2017-11-07 17:39:31 +01:00
|
|
|
{ &client_node_demarshal_command, PW_PROTOCOL_NATIVE_REMAP },
|
2017-08-01 20:11:38 +02:00
|
|
|
{ &client_node_demarshal_add_port, 0 },
|
|
|
|
|
{ &client_node_demarshal_remove_port, 0 },
|
2017-11-07 17:39:31 +01:00
|
|
|
{ &client_node_demarshal_port_set_param, PW_PROTOCOL_NATIVE_REMAP },
|
|
|
|
|
{ &client_node_demarshal_port_use_buffers, PW_PROTOCOL_NATIVE_REMAP },
|
2017-08-01 20:11:38 +02:00
|
|
|
{ &client_node_demarshal_port_command, PW_PROTOCOL_NATIVE_REMAP },
|
2017-11-30 16:36:29 +01:00
|
|
|
{ &client_node_demarshal_port_set_io, PW_PROTOCOL_NATIVE_REMAP },
|
2017-07-13 15:21:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
|
|
|
|
|
PW_TYPE_INTERFACE__ClientNode,
|
2017-06-21 12:11:54 +02:00
|
|
|
PW_VERSION_CLIENT_NODE,
|
2017-07-13 15:21:52 +02:00
|
|
|
&pw_protocol_native_client_node_method_marshal,
|
|
|
|
|
&pw_protocol_native_client_node_method_demarshal,
|
2017-11-20 15:26:44 +01:00
|
|
|
PW_CLIENT_NODE_PROXY_METHOD_NUM,
|
2017-07-13 15:21:52 +02:00
|
|
|
&pw_protocol_native_client_node_event_marshal,
|
|
|
|
|
pw_protocol_native_client_node_event_demarshal,
|
2017-11-20 15:26:44 +01:00
|
|
|
PW_CLIENT_NODE_PROXY_EVENT_NUM,
|
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-07-13 15:21:52 +02:00
|
|
|
pw_protocol_add_marshal(protocol, &pw_protocol_native_client_node_marshal);
|
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
|
|
|
}
|