summaryrefslogtreecommitdiff
path: root/src/modules/module-client-node/client-stream.c
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2018-10-18 12:59:31 +0200
committerWim Taymans <wtaymans@redhat.com>2018-10-18 12:59:31 +0200
commit842abad9e182f8d647a5a6206a3c5cb7b793d3fa (patch)
tree6cb457991d2522d3af6f09b951dd2811fa8eebe4 /src/modules/module-client-node/client-stream.c
parentc0a6c83227e650f20d50a71e9965315e9dbe9d9b (diff)
client-stream: implement enum_param and set_param better
Make it possible to enumerate the parameters and get/set properties when available on the adapter.
Diffstat (limited to 'src/modules/module-client-node/client-stream.c')
-rw-r--r--src/modules/module-client-node/client-stream.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/modules/module-client-node/client-stream.c b/src/modules/module-client-node/client-stream.c
index aef318ed..cc87961a 100644
--- a/src/modules/module-client-node/client-stream.c
+++ b/src/modules/module-client-node/client-stream.c
@@ -31,6 +31,7 @@
#include <spa/node/node.h>
#include <spa/buffer/alloc.h>
#include <spa/pod/parser.h>
+#include <spa/pod/filter.h>
#include <spa/param/audio/format-utils.h>
#include "pipewire/pipewire.h"
@@ -110,18 +111,60 @@ static int impl_node_enum_params(struct spa_node *node,
{
struct node *this;
struct impl *impl;
- int res;
+ struct spa_pod *param;
+ struct spa_pod_builder b = { 0 };
+ uint8_t buffer[1024];
spa_return_val_if_fail(node != NULL, -EINVAL);
+ spa_return_val_if_fail(index != NULL, -EINVAL);
+ spa_return_val_if_fail(builder != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct node, node);
impl = this->impl;
- res = spa_node_port_enum_params(impl->cnode,
+ next:
+ spa_pod_builder_init(&b, buffer, sizeof(buffer));
+
+ switch (id) {
+ case SPA_PARAM_List:
+ {
+ uint32_t list[] = { SPA_PARAM_Props,
+ SPA_PARAM_EnumFormat,
+ SPA_PARAM_Format };
+
+ if (*index < SPA_N_ELEMENTS(list))
+ param = spa_pod_builder_object(&b,
+ SPA_TYPE_OBJECT_ParamList, id,
+ SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
+ 0);
+ else
+ return 0;
+ break;
+ }
+ case SPA_PARAM_Props:
+ if (impl->adapter != impl->cnode) {
+ return spa_node_enum_params(impl->adapter,
+ id, index,
+ filter, result, builder);
+ }
+ return 0;
+
+ case SPA_PARAM_EnumFormat:
+ case SPA_PARAM_Format:
+ return spa_node_port_enum_params(impl->cnode,
impl->direction, 0,
id, index,
filter, result, builder);
- return res;
+
+ default:
+ return -ENOENT;
+ }
+ (*index)++;
+
+ if (spa_pod_filter(builder, result, param, filter) < 0)
+ goto next;
+
+ return 1;
}
static void try_link_controls(struct impl *impl)
@@ -183,6 +226,12 @@ static int impl_node_set_param(struct spa_node *node, uint32_t id, uint32_t flag
try_link_controls(impl);
}
break;
+ case SPA_PARAM_Props:
+ if (impl->adapter != impl->cnode) {
+ if ((res = spa_node_set_param(impl->adapter, id, flags, param)) < 0)
+ return res;
+ }
+ break;
default:
res = -ENOTSUP;
break;