mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									c0a6c83227
								
							
						
					
					
						commit
						842abad9e1
					
				
					 1 changed files with 52 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue