mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	keys: add object.register property
Add a new object.register boolean property. Make adapter and remote-note only register when object.register is true. Make stream and filter not register themselves. They are always exported to a remote server and thus don't need local registration. Fixes #1309
This commit is contained in:
		
							parent
							
								
									2c5d89ff19
								
							
						
					
					
						commit
						324894e605
					
				
					 5 changed files with 27 additions and 8 deletions
				
			
		| 
						 | 
					@ -168,7 +168,7 @@ static void *create_object(void *_data,
 | 
				
			||||||
	const char *str, *factory_name;
 | 
						const char *str, *factory_name;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	struct node_data *nd;
 | 
						struct node_data *nd;
 | 
				
			||||||
	bool linger;
 | 
						bool linger, do_register;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (properties == NULL)
 | 
						if (properties == NULL)
 | 
				
			||||||
		goto error_properties;
 | 
							goto error_properties;
 | 
				
			||||||
| 
						 | 
					@ -179,6 +179,9 @@ static void *create_object(void *_data,
 | 
				
			||||||
	str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
 | 
						str = pw_properties_get(properties, PW_KEY_OBJECT_LINGER);
 | 
				
			||||||
	linger = str ? pw_properties_parse_bool(str) : false;
 | 
						linger = str ? pw_properties_parse_bool(str) : false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						str = pw_properties_get(properties, PW_KEY_OBJECT_REGISTER);
 | 
				
			||||||
 | 
						do_register = str ? pw_properties_parse_bool(str) : true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	client = resource ? pw_resource_get_client(resource): NULL;
 | 
						client = resource ? pw_resource_get_client(resource): NULL;
 | 
				
			||||||
	if (client && !linger) {
 | 
						if (client && !linger) {
 | 
				
			||||||
		pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
 | 
							pw_properties_setf(properties, PW_KEY_CLIENT_ID, "%d",
 | 
				
			||||||
| 
						 | 
					@ -231,7 +234,10 @@ static void *create_object(void *_data,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_impl_node_add_listener(adapter, &nd->adapter_listener, &node_events, nd);
 | 
						pw_impl_node_add_listener(adapter, &nd->adapter_listener, &node_events, nd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (do_register)
 | 
				
			||||||
		pw_impl_node_register(adapter, NULL);
 | 
							pw_impl_node_register(adapter, NULL);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							pw_impl_node_initialized(adapter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return adapter;
 | 
						return adapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1275,6 +1275,11 @@ struct pw_proxy *pw_core_spa_node_export(struct pw_core *core,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pw_impl_node *node;
 | 
						struct pw_impl_node *node;
 | 
				
			||||||
	struct pw_proxy *proxy;
 | 
						struct pw_proxy *proxy;
 | 
				
			||||||
 | 
						const char *str;
 | 
				
			||||||
 | 
						bool do_register;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						str = props ? spa_dict_lookup(props, PW_KEY_OBJECT_REGISTER) : NULL;
 | 
				
			||||||
 | 
						do_register = str ? pw_properties_parse_bool(str) : true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	node = pw_context_create_node(pw_core_get_context(core),
 | 
						node = pw_context_create_node(pw_core_get_context(core),
 | 
				
			||||||
			props ? pw_properties_new_dict(props) : NULL, 0);
 | 
								props ? pw_properties_new_dict(props) : NULL, 0);
 | 
				
			||||||
| 
						 | 
					@ -1282,6 +1287,8 @@ struct pw_proxy *pw_core_spa_node_export(struct pw_core *core,
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_impl_node_set_implementation(node, (struct spa_node*)object);
 | 
						pw_impl_node_set_implementation(node, (struct spa_node*)object);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (do_register)
 | 
				
			||||||
		pw_impl_node_register(node, NULL);
 | 
							pw_impl_node_register(node, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	proxy = node_export(core, node, true, user_data_size);
 | 
						proxy = node_export(core, node, true, user_data_size);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1454,6 +1454,7 @@ pw_filter_connect(struct pw_filter *filter,
 | 
				
			||||||
	const char *str;
 | 
						const char *str;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
	uint32_t i;
 | 
						uint32_t i;
 | 
				
			||||||
 | 
						struct spa_dict_item items[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_debug(NAME" %p: connect", filter);
 | 
						pw_log_debug(NAME" %p: connect", filter);
 | 
				
			||||||
	impl->flags = flags;
 | 
						impl->flags = flags;
 | 
				
			||||||
| 
						 | 
					@ -1506,8 +1507,11 @@ pw_filter_connect(struct pw_filter *filter,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_debug(NAME" %p: export node %p", filter, &impl->impl_node);
 | 
						pw_log_debug(NAME" %p: export node %p", filter, &impl->impl_node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						items[0] = SPA_DICT_ITEM_INIT(PW_KEY_OBJECT_REGISTER, "false");
 | 
				
			||||||
	filter->proxy = pw_core_export(filter->core,
 | 
						filter->proxy = pw_core_export(filter->core,
 | 
				
			||||||
			SPA_TYPE_INTERFACE_Node, NULL, &impl->impl_node, 0);
 | 
								SPA_TYPE_INTERFACE_Node, &SPA_DICT_INIT_ARRAY(items),
 | 
				
			||||||
 | 
								&impl->impl_node, 0);
 | 
				
			||||||
	if (filter->proxy == NULL) {
 | 
						if (filter->proxy == NULL) {
 | 
				
			||||||
		res = -errno;
 | 
							res = -errno;
 | 
				
			||||||
		goto error_proxy;
 | 
							goto error_proxy;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,8 +61,13 @@ extern "C" {
 | 
				
			||||||
#define PW_KEY_LIBRARY_NAME_LOOP	"library.name.loop"	/**< name of the loop library to use */
 | 
					#define PW_KEY_LIBRARY_NAME_LOOP	"library.name.loop"	/**< name of the loop library to use */
 | 
				
			||||||
#define PW_KEY_LIBRARY_NAME_DBUS	"library.name.dbus"	/**< name of the dbus library to use */
 | 
					#define PW_KEY_LIBRARY_NAME_DBUS	"library.name.dbus"	/**< name of the dbus library to use */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** object properties */
 | 
				
			||||||
#define PW_KEY_OBJECT_PATH		"object.path"		/**< unique path to construct the object */
 | 
					#define PW_KEY_OBJECT_PATH		"object.path"		/**< unique path to construct the object */
 | 
				
			||||||
#define PW_KEY_OBJECT_ID		"object.id"		/**< a global object id */
 | 
					#define PW_KEY_OBJECT_ID		"object.id"		/**< a global object id */
 | 
				
			||||||
 | 
					#define PW_KEY_OBJECT_LINGER		"object.linger"		/**< the object lives on even after the client
 | 
				
			||||||
 | 
													  *  that created it has been destroyed */
 | 
				
			||||||
 | 
					#define PW_KEY_OBJECT_REGISTER		"object.register"	/**< If the object should be registered. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* config */
 | 
					/* config */
 | 
				
			||||||
#define PW_KEY_CONFIG_PREFIX		"config.prefix"		/**< a config prefix directory */
 | 
					#define PW_KEY_CONFIG_PREFIX		"config.prefix"		/**< a config prefix directory */
 | 
				
			||||||
| 
						 | 
					@ -259,10 +264,6 @@ extern "C" {
 | 
				
			||||||
#define PW_KEY_STREAM_CAPTURE_SINK	"stream.capture.sink"	/**< Try to capture the sink output instead of
 | 
					#define PW_KEY_STREAM_CAPTURE_SINK	"stream.capture.sink"	/**< Try to capture the sink output instead of
 | 
				
			||||||
								  *  source output */
 | 
													  *  source output */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** object properties */
 | 
					 | 
				
			||||||
#define PW_KEY_OBJECT_LINGER		"object.linger"		/**< the object lives on even after the client
 | 
					 | 
				
			||||||
								  *  that created it has been destroyed */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** Media */
 | 
					/** Media */
 | 
				
			||||||
#define PW_KEY_MEDIA_TYPE		"media.type"		/**< Media type, one of
 | 
					#define PW_KEY_MEDIA_TYPE		"media.type"		/**< Media type, one of
 | 
				
			||||||
								  *  Audio, Video, Midi */
 | 
													  *  Audio, Video, Midi */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1747,6 +1747,7 @@ pw_stream_connect(struct pw_stream *stream,
 | 
				
			||||||
			goto error_node;
 | 
								goto error_node;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		pw_properties_setf(props, "adapt.follower.node", "pointer:%p", follower);
 | 
							pw_properties_setf(props, "adapt.follower.node", "pointer:%p", follower);
 | 
				
			||||||
 | 
							pw_properties_set(props, "object.register", "false");
 | 
				
			||||||
		impl->node = pw_impl_factory_create_object(factory,
 | 
							impl->node = pw_impl_factory_create_object(factory,
 | 
				
			||||||
				NULL,
 | 
									NULL,
 | 
				
			||||||
				PW_TYPE_INTERFACE_Node,
 | 
									PW_TYPE_INTERFACE_Node,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue