mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	protocol-native: improve v0 compatibility
This commit is contained in:
		
							parent
							
								
									651013bfab
								
							
						
					
					
						commit
						eab6dda513
					
				
					 2 changed files with 102 additions and 41 deletions
				
			
		| 
						 | 
				
			
			@ -540,8 +540,6 @@ static int remap_to_v2(struct pw_impl_client *client, const struct spa_type_info
 | 
			
		|||
		ti = spa_debug_type_find(info, b->type);
 | 
			
		||||
		ii = ti ? spa_debug_type_find(ti->values, 0) : NULL;
 | 
			
		||||
 | 
			
		||||
		pw_log_debug("type:%d id:%d", b->type, b->id);
 | 
			
		||||
 | 
			
		||||
		if (b->type == SPA_TYPE_COMMAND_Node) {
 | 
			
		||||
			spa_pod_builder_push_object(builder, &f[0], 0,
 | 
			
		||||
				pw_protocol_native0_type_to_v2(client, ii ? ii->values : NULL, b->id));
 | 
			
		||||
| 
						 | 
				
			
			@ -773,7 +771,9 @@ static int core_demarshal_update_types_server(void *object, const struct pw_prot
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < n_types; i++, first_id++) {
 | 
			
		||||
		int type_id = pw_protocol_native0_find_type(client, types[i]);
 | 
			
		||||
		uint32_t type_id = pw_protocol_native0_find_type(client, types[i]);
 | 
			
		||||
		if (type_id == SPA_ID_INVALID)
 | 
			
		||||
			continue;
 | 
			
		||||
		if (pw_map_insert_at(&compat_v2->types, first_id, PW_MAP_ID_TO_PTR(type_id)) < 0)
 | 
			
		||||
			pw_log_error("can't add type %d->%d for client", first_id, type_id);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -789,13 +789,30 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t permissi
 | 
			
		|||
	struct spa_pod_frame f;
 | 
			
		||||
	uint32_t i, n_items, parent_id;
 | 
			
		||||
	uint32_t type_id;
 | 
			
		||||
	const char *str;
 | 
			
		||||
 | 
			
		||||
	type_id = pw_protocol_native0_find_type(client, type);
 | 
			
		||||
	if (type_id == SPA_ID_INVALID)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_V0_EVENT_GLOBAL, NULL);
 | 
			
		||||
 | 
			
		||||
	n_items = props ? props->n_items : 0;
 | 
			
		||||
 | 
			
		||||
	type_id = pw_protocol_native0_find_type(client, type);
 | 
			
		||||
	parent_id = 0;
 | 
			
		||||
	if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
 | 
			
		||||
		if ((str = spa_dict_lookup(props, "node.id")) != NULL)
 | 
			
		||||
			parent_id = atoi(str);
 | 
			
		||||
	} else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
 | 
			
		||||
		if ((str = spa_dict_lookup(props, "device.id")) != NULL)
 | 
			
		||||
			parent_id = atoi(str);
 | 
			
		||||
	} else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0 ||
 | 
			
		||||
	    strcmp(type, PW_TYPE_INTERFACE_Device) == 0 ||
 | 
			
		||||
	    strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) {
 | 
			
		||||
		if ((str = spa_dict_lookup(props, "module.id")) != NULL)
 | 
			
		||||
			parent_id = atoi(str);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	version = 0;
 | 
			
		||||
 | 
			
		||||
        spa_pod_builder_push_struct(b, &f);
 | 
			
		||||
| 
						 | 
				
			
			@ -890,11 +907,14 @@ static void factory_marshal_info(void *object, const struct pw_factory_info *inf
 | 
			
		|||
	struct spa_pod_frame f;
 | 
			
		||||
	uint32_t i, n_items, type, version;
 | 
			
		||||
 | 
			
		||||
	type = pw_protocol_native0_find_type(client, info->type);
 | 
			
		||||
	if (type == SPA_ID_INVALID)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	b = pw_protocol_native_begin_resource(resource, PW_FACTORY_V0_EVENT_INFO, NULL);
 | 
			
		||||
 | 
			
		||||
	n_items = info->props ? info->props->n_items : 0;
 | 
			
		||||
 | 
			
		||||
	type = pw_protocol_native0_find_type(client, info->type);
 | 
			
		||||
	version = 0;
 | 
			
		||||
 | 
			
		||||
        spa_pod_builder_push_struct(b, &f);
 | 
			
		||||
| 
						 | 
				
			
			@ -954,11 +974,22 @@ static void node_marshal_param(void *object, int seq, uint32_t id, uint32_t inde
 | 
			
		|||
		const struct spa_pod *param)
 | 
			
		||||
{
 | 
			
		||||
	struct pw_resource *resource = object;
 | 
			
		||||
	struct pw_impl_client *client = pw_resource_get_client(resource);
 | 
			
		||||
	struct spa_pod_builder *b;
 | 
			
		||||
	struct spa_pod_frame f;
 | 
			
		||||
 | 
			
		||||
	b = pw_protocol_native_begin_resource(resource, PW_NODE_V0_EVENT_PARAM, NULL);
 | 
			
		||||
 | 
			
		||||
	spa_pod_builder_add_struct(b, "I", id, "i", index, "i", next, "P", param);
 | 
			
		||||
	id = pw_protocol_native0_type_to_v2(client, spa_type_param, id),
 | 
			
		||||
 | 
			
		||||
	spa_pod_builder_push_struct(b, &f);
 | 
			
		||||
	spa_pod_builder_add(b,
 | 
			
		||||
			"I", id,
 | 
			
		||||
			"i", index,
 | 
			
		||||
			"i", next,
 | 
			
		||||
			NULL);
 | 
			
		||||
	pw_protocol_native0_pod_to_v2(client, (struct spa_pod *)param, b);
 | 
			
		||||
	spa_pod_builder_pop(b, &f);
 | 
			
		||||
 | 
			
		||||
	pw_protocol_native_end_resource(resource, b);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -992,16 +1023,34 @@ static void port_marshal_info(void *object, const struct pw_port_info *info)
 | 
			
		|||
	struct spa_pod_builder *b;
 | 
			
		||||
	struct spa_pod_frame f;
 | 
			
		||||
	uint32_t i, n_items;
 | 
			
		||||
	uint64_t change_mask = 0;
 | 
			
		||||
	const char *port_name;
 | 
			
		||||
 | 
			
		||||
	b = pw_protocol_native_begin_resource(resource, PW_PORT_V0_EVENT_INFO, NULL);
 | 
			
		||||
 | 
			
		||||
	n_items = info->props ? info->props->n_items : 0;
 | 
			
		||||
 | 
			
		||||
#define PW_PORT_V0_CHANGE_MASK_NAME                (1 << 0)
 | 
			
		||||
#define PW_PORT_V0_CHANGE_MASK_PROPS               (1 << 1)
 | 
			
		||||
#define PW_PORT_V0_CHANGE_MASK_ENUM_PARAMS         (1 << 2)
 | 
			
		||||
 | 
			
		||||
	change_mask |= PW_PORT_V0_CHANGE_MASK_NAME;
 | 
			
		||||
	if (info->change_mask & PW_PORT_CHANGE_MASK_PROPS)
 | 
			
		||||
		change_mask |= PW_PORT_V0_CHANGE_MASK_PROPS;
 | 
			
		||||
	if (info->change_mask & PW_PORT_CHANGE_MASK_PARAMS)
 | 
			
		||||
		change_mask |= PW_PORT_V0_CHANGE_MASK_ENUM_PARAMS;
 | 
			
		||||
 | 
			
		||||
	port_name = NULL;
 | 
			
		||||
	if (info->props != NULL)
 | 
			
		||||
		port_name = spa_dict_lookup(info->props, "port.name");
 | 
			
		||||
	if (port_name == NULL)
 | 
			
		||||
		port_name = "port.name";
 | 
			
		||||
 | 
			
		||||
        spa_pod_builder_push_struct(b, &f);
 | 
			
		||||
	spa_pod_builder_add(b,
 | 
			
		||||
			    "i", info->id,
 | 
			
		||||
			    "l", info->change_mask,
 | 
			
		||||
			    "s", "port.name",
 | 
			
		||||
			    "l", change_mask,
 | 
			
		||||
			    "s", port_name,
 | 
			
		||||
			    "i", n_items, NULL);
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < n_items; i++) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1020,12 +1069,20 @@ static void port_marshal_param(void *object, int seq, uint32_t id, uint32_t inde
 | 
			
		|||
	struct pw_resource *resource = object;
 | 
			
		||||
	struct pw_impl_client *client = pw_resource_get_client(resource);
 | 
			
		||||
	struct spa_pod_builder *b;
 | 
			
		||||
	struct spa_pod_frame f;
 | 
			
		||||
 | 
			
		||||
	b = pw_protocol_native_begin_resource(resource, PW_PORT_V0_EVENT_PARAM, NULL);
 | 
			
		||||
 | 
			
		||||
	id = pw_protocol_native0_type_to_v2(client, pw_type_info(), id),
 | 
			
		||||
	id = pw_protocol_native0_type_to_v2(client, spa_type_param, id),
 | 
			
		||||
 | 
			
		||||
	spa_pod_builder_add_struct(b, "I", id, "i", index, "i", next, "P", param);
 | 
			
		||||
	spa_pod_builder_push_struct(b, &f);
 | 
			
		||||
	spa_pod_builder_add(b,
 | 
			
		||||
			"I", id,
 | 
			
		||||
			"i", index,
 | 
			
		||||
			"i", next,
 | 
			
		||||
			NULL);
 | 
			
		||||
	pw_protocol_native0_pod_to_v2(client, (struct spa_pod *)param, b);
 | 
			
		||||
	spa_pod_builder_pop(b, &f);
 | 
			
		||||
 | 
			
		||||
	pw_protocol_native_end_resource(resource, b);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -108,7 +108,10 @@ const struct type_info {
 | 
			
		|||
	{ "Spa:Enum:MediaType:image", SPA_TYPE_INFO_MEDIA_TYPE_BASE "image", SPA_MEDIA_TYPE_image, },
 | 
			
		||||
	{ "Spa:Enum:MediaType:binary", SPA_TYPE_INFO_MEDIA_TYPE_BASE "binary", SPA_MEDIA_TYPE_binary, },
 | 
			
		||||
	{ "Spa:Enum:MediaType:stream", SPA_TYPE_INFO_MEDIA_TYPE_BASE "stream", SPA_MEDIA_TYPE_stream, },
 | 
			
		||||
	{ "Spa:Enum:MediaType:application", SPA_TYPE_INFO_MEDIA_TYPE_BASE "application", SPA_MEDIA_TYPE_application, },
 | 
			
		||||
	{ "Spa:Enum:MediaSubtype:raw", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "raw", SPA_MEDIA_SUBTYPE_raw, },
 | 
			
		||||
	{ "Spa:Enum:MediaSubtype:dsp", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "dsp", SPA_MEDIA_SUBTYPE_dsp, },
 | 
			
		||||
	{ "Spa:Enum:MediaSubtype:control", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "control", SPA_MEDIA_SUBTYPE_control, },
 | 
			
		||||
	{ "Spa:Enum:MediaSubtype:h264", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "h264", SPA_MEDIA_SUBTYPE_h264, },
 | 
			
		||||
	{ "Spa:Enum:MediaSubtype:mjpg", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "mjpg", SPA_MEDIA_SUBTYPE_mjpg, },
 | 
			
		||||
	{ "Spa:Enum:MediaSubtype:dv", SPA_TYPE_INFO_MEDIA_SUBTYPE_BASE "dv", SPA_MEDIA_SUBTYPE_dv, },
 | 
			
		||||
| 
						 | 
				
			
			@ -237,35 +240,36 @@ const struct type_info {
 | 
			
		|||
	{ "Spa:Enum:VideoFormat:I422_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I422_12LE", SPA_VIDEO_FORMAT_I422_12LE,},
 | 
			
		||||
	{ "Spa:Enum:VideoFormat:Y444_12BE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "Y444_12BE", SPA_VIDEO_FORMAT_Y444_12BE,},
 | 
			
		||||
	{ "Spa:Enum:VideoFormat:Y444_12LE", SPA_TYPE_INFO_VIDEO_FORMAT_BASE "Y444_12LE", SPA_VIDEO_FORMAT_Y444_12LE,},
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:ENCODED", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S8", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U8", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S16LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U16LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24_32LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24_32LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S32LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U32LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S20LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U20LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S18LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U18LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F32LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F64LE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S16BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U16BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24_32BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24_32BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S32BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U32BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S20BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U20BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S18BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U18BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F32BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F64BE", },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:ENCODED", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "ENCODED", SPA_AUDIO_FORMAT_ENCODED,},
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S8", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S8", SPA_AUDIO_FORMAT_S8, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U8", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "U8", SPA_AUDIO_FORMAT_U8, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S16LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S16_LE", SPA_AUDIO_FORMAT_S16_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U16LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "U16_LE", SPA_AUDIO_FORMAT_U16_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24_32LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S24_32_LE", SPA_AUDIO_FORMAT_S24_32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24_32LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "U24_32_LE", SPA_AUDIO_FORMAT_U24_32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F32P", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "F32P", SPA_AUDIO_FORMAT_F32P, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S32LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U32LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "U32_LE", SPA_AUDIO_FORMAT_U32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S24_LE", SPA_AUDIO_FORMAT_S24_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "U24_LE", SPA_AUDIO_FORMAT_U24_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S20LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U20LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S18LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U18LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F32LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F64LE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S16BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U16BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24_32BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24_32BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S32BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U32BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S24BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U24BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S20BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U20BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:S18BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:U18BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F32BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
	{ "Spa:Enum:AudioFormat:F64BE", SPA_TYPE_INFO_AUDIO_FORMAT_BASE "S32_LE", SPA_AUDIO_FORMAT_S32_LE, },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue