mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	types: work on types
Move static pod types to type system work on type info for types Move the event and command ids to an enum to make it easier to extend later.
This commit is contained in:
		
							parent
							
								
									fca3e1d85d
								
							
						
					
					
						commit
						805e3bb6c1
					
				
					 82 changed files with 812 additions and 924 deletions
				
			
		
							
								
								
									
										131
									
								
								src/examples/sdl.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								src/examples/sdl.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,131 @@
 | 
			
		|||
/* PipeWire
 | 
			
		||||
 * 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 <SDL2/SDL.h>
 | 
			
		||||
 | 
			
		||||
#include <spa/utils/type.h>
 | 
			
		||||
#include <spa/pod/builder.h>
 | 
			
		||||
#include <spa/param/video/raw.h>
 | 
			
		||||
#include <spa/param/video/format.h>
 | 
			
		||||
 | 
			
		||||
static struct {
 | 
			
		||||
	Uint32 format;
 | 
			
		||||
	uint32_t id;
 | 
			
		||||
} sdl_video_formats[] = {
 | 
			
		||||
	{ SDL_PIXELFORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_INDEX1LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_INDEX1LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_INDEX1MSB, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_INDEX4LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_INDEX4MSB, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_INDEX8, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGB332, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGB444, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGB555, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGR555, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ARGB4444, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGBA4444, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ABGR4444, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGRA4444, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ARGB1555, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGBA5551, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ABGR1555, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGRA5551, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGB565, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGR565, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGB24, SPA_VIDEO_FORMAT_RGB,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGB888, SPA_VIDEO_FORMAT_RGB,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGBX8888, SPA_VIDEO_FORMAT_RGBx,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGR24, SPA_VIDEO_FORMAT_BGR,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGR888, SPA_VIDEO_FORMAT_BGR,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGRX8888, SPA_VIDEO_FORMAT_BGRx,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ARGB2101010, SPA_VIDEO_FORMAT_UNKNOWN,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_RGBA8888, SPA_VIDEO_FORMAT_RGBA,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ARGB8888, SPA_VIDEO_FORMAT_ARGB,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_BGRA8888, SPA_VIDEO_FORMAT_BGRA,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_ABGR8888, SPA_VIDEO_FORMAT_ABGR,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_YV12, SPA_VIDEO_FORMAT_YV12,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_IYUV, SPA_VIDEO_FORMAT_I420,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_YUY2, SPA_VIDEO_FORMAT_YUY2,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_UYVY, SPA_VIDEO_FORMAT_UYVY,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_YVYU, SPA_VIDEO_FORMAT_YVYU,},
 | 
			
		||||
#if SDL_VERSION_ATLEAST(2,0,4)
 | 
			
		||||
	{ SDL_PIXELFORMAT_NV12, SPA_VIDEO_FORMAT_NV12,},
 | 
			
		||||
	{ SDL_PIXELFORMAT_NV21, SPA_VIDEO_FORMAT_NV21,},
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static uint32_t sdl_format_to_id(Uint32 format)
 | 
			
		||||
{
 | 
			
		||||
	size_t i;
 | 
			
		||||
	for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
 | 
			
		||||
		if (sdl_video_formats[i].format == format)
 | 
			
		||||
			return sdl_video_formats[i].id;
 | 
			
		||||
	}
 | 
			
		||||
	return SPA_VIDEO_FORMAT_UNKNOWN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Uint32 id_to_sdl_format(uint32_t id)
 | 
			
		||||
{
 | 
			
		||||
	size_t i;
 | 
			
		||||
	for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
 | 
			
		||||
		if (sdl_video_formats[i].id == id)
 | 
			
		||||
			return sdl_video_formats[i].format;
 | 
			
		||||
	}
 | 
			
		||||
	return SDL_PIXELFORMAT_UNKNOWN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct spa_pod_builder *b)
 | 
			
		||||
{
 | 
			
		||||
	int i, c;
 | 
			
		||||
 | 
			
		||||
	spa_pod_builder_push_object(b, SPA_ID_PARAM_EnumFormat, SPA_ID_OBJECT_Format);
 | 
			
		||||
	spa_pod_builder_id(b, SPA_MEDIA_TYPE_video);
 | 
			
		||||
	spa_pod_builder_id(b, SPA_MEDIA_SUBTYPE_raw);
 | 
			
		||||
 | 
			
		||||
	spa_pod_builder_push_prop(b, SPA_FORMAT_VIDEO_format,
 | 
			
		||||
				  SPA_POD_PROP_FLAG_UNSET |
 | 
			
		||||
				  SPA_POD_PROP_RANGE_ENUM);
 | 
			
		||||
	for (i = 0, c = 0; i < info->num_texture_formats; i++) {
 | 
			
		||||
		uint32_t id = sdl_format_to_id(info->texture_formats[i]);
 | 
			
		||||
		if (id == 0)
 | 
			
		||||
			continue;
 | 
			
		||||
		if (c++ == 0)
 | 
			
		||||
			spa_pod_builder_id(b, id);
 | 
			
		||||
		spa_pod_builder_id(b, id);
 | 
			
		||||
	}
 | 
			
		||||
	for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
 | 
			
		||||
		uint32_t id = sdl_video_formats[i].id;
 | 
			
		||||
		if (id != SPA_VIDEO_FORMAT_UNKNOWN)
 | 
			
		||||
			spa_pod_builder_id(b, id);
 | 
			
		||||
	}
 | 
			
		||||
	spa_pod_builder_pop(b);
 | 
			
		||||
	spa_pod_builder_add(b,
 | 
			
		||||
		":", SPA_FORMAT_VIDEO_size,      "Rru", &SPA_RECTANGLE(WIDTH, HEIGHT),
 | 
			
		||||
			SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1,1),
 | 
			
		||||
					     &SPA_RECTANGLE(info->max_texture_width,
 | 
			
		||||
							    info->max_texture_height)),
 | 
			
		||||
		":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1),
 | 
			
		||||
			SPA_POD_PROP_MIN_MAX(&SPA_FRACTION(0,1),
 | 
			
		||||
					     &SPA_FRACTION(30,1)),
 | 
			
		||||
		NULL);
 | 
			
		||||
	return spa_pod_builder_pop(b);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -34,8 +34,7 @@ extern "C" {
 | 
			
		|||
struct pw_protocol_native_demarshal {
 | 
			
		||||
	int (*func) (void *object, void *data, size_t size);
 | 
			
		||||
 | 
			
		||||
#define PW_PROTOCOL_NATIVE_REMAP	(1<<0)
 | 
			
		||||
#define PW_PROTOCOL_NATIVE_PERM_W	(1<<1)
 | 
			
		||||
#define PW_PROTOCOL_NATIVE_PERM_W	(1<<0)
 | 
			
		||||
	uint32_t flags;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -944,7 +944,7 @@ impl_node_port_send_command(struct spa_node *node,
 | 
			
		|||
		return 0;
 | 
			
		||||
 | 
			
		||||
	spa_log_trace(this->log, "send command %s",
 | 
			
		||||
			spa_debug_type_find_name(spa_debug_types, SPA_COMMAND_TYPE(command)));
 | 
			
		||||
			spa_debug_type_find_name(spa_debug_types, SPA_NODE_COMMAND_ID(command)));
 | 
			
		||||
 | 
			
		||||
	pw_client_node_resource_port_command(this->resource,
 | 
			
		||||
					     direction, port_id,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -899,10 +899,10 @@ static const struct pw_client_node_proxy_methods pw_protocol_native_client_node_
 | 
			
		|||
 | 
			
		||||
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 },
 | 
			
		||||
	{ &client_node_demarshal_update, 0 },
 | 
			
		||||
	{ &client_node_demarshal_port_update, 0 },
 | 
			
		||||
	{ &client_node_demarshal_set_active, 0 },
 | 
			
		||||
	{ &client_node_demarshal_event_method, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_event_method, 0 },
 | 
			
		||||
	{ &client_node_demarshal_destroy, 0 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -923,18 +923,18 @@ static const struct pw_client_node_proxy_events pw_protocol_native_client_node_e
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_client_node_event_demarshal[] = {
 | 
			
		||||
	{ &client_node_demarshal_add_mem, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_add_mem, 0 },
 | 
			
		||||
	{ &client_node_demarshal_transport, 0 },
 | 
			
		||||
	{ &client_node_demarshal_set_param, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_set_io, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_event_event, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_command, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_set_param, 0 },
 | 
			
		||||
	{ &client_node_demarshal_set_io, 0 },
 | 
			
		||||
	{ &client_node_demarshal_event_event, 0 },
 | 
			
		||||
	{ &client_node_demarshal_command, 0 },
 | 
			
		||||
	{ &client_node_demarshal_add_port, 0 },
 | 
			
		||||
	{ &client_node_demarshal_remove_port, 0 },
 | 
			
		||||
	{ &client_node_demarshal_port_set_param, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_port_use_buffers, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_port_command, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_port_set_io, PW_PROTOCOL_NATIVE_REMAP },
 | 
			
		||||
	{ &client_node_demarshal_port_set_param, 0 },
 | 
			
		||||
	{ &client_node_demarshal_port_use_buffers, 0 },
 | 
			
		||||
	{ &client_node_demarshal_port_command, 0 },
 | 
			
		||||
	{ &client_node_demarshal_port_set_io, 0 },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_marshal pw_protocol_native_client_node_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,11 +142,11 @@ static int impl_node_send_command(struct spa_node *node, const struct spa_comman
 | 
			
		|||
 | 
			
		||||
	this = SPA_CONTAINER_OF(node, struct impl, node);
 | 
			
		||||
 | 
			
		||||
	switch (SPA_COMMAND_TYPE(command)) {
 | 
			
		||||
	case SPA_ID_COMMAND_NODE_Start:
 | 
			
		||||
	switch (SPA_NODE_COMMAND_ID(command)) {
 | 
			
		||||
	case SPA_NODE_COMMAND_Start:
 | 
			
		||||
		this->started = true;
 | 
			
		||||
		break;
 | 
			
		||||
	case SPA_ID_COMMAND_NODE_Pause:
 | 
			
		||||
	case SPA_NODE_COMMAND_Pause:
 | 
			
		||||
		this->started = false;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,73 +109,6 @@ struct client_data {
 | 
			
		|||
	bool busy;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
static bool pod_remap_data(uint32_t type, void *body, uint32_t size, struct pw_map *types)
 | 
			
		||||
{
 | 
			
		||||
	void *t;
 | 
			
		||||
 | 
			
		||||
	switch (type) {
 | 
			
		||||
	case SPA_POD_TYPE_ID:
 | 
			
		||||
		if ((t = pw_map_lookup(types, *(int32_t *) body)) == NULL)
 | 
			
		||||
			return false;
 | 
			
		||||
		*(int32_t *) body = PW_MAP_PTR_TO_ID(t);
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
	case SPA_POD_TYPE_PROP:
 | 
			
		||||
	{
 | 
			
		||||
		struct spa_pod_prop_body *b = body;
 | 
			
		||||
 | 
			
		||||
		if ((t = pw_map_lookup(types, b->key)) == NULL)
 | 
			
		||||
			return false;
 | 
			
		||||
		b->key = PW_MAP_PTR_TO_ID(t);
 | 
			
		||||
 | 
			
		||||
		if (b->value.type == SPA_POD_TYPE_ID) {
 | 
			
		||||
			void *alt;
 | 
			
		||||
			if (!pod_remap_data
 | 
			
		||||
			    (b->value.type, SPA_POD_BODY(&b->value), b->value.size, types))
 | 
			
		||||
				return false;
 | 
			
		||||
 | 
			
		||||
			SPA_POD_PROP_ALTERNATIVE_FOREACH(b, size, alt)
 | 
			
		||||
				if (!pod_remap_data(b->value.type, alt, b->value.size, types))
 | 
			
		||||
					return false;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	case SPA_POD_TYPE_OBJECT:
 | 
			
		||||
	{
 | 
			
		||||
		struct spa_pod_object_body *b = body;
 | 
			
		||||
		struct spa_pod *p;
 | 
			
		||||
 | 
			
		||||
		if ((t = pw_map_lookup(types, b->id)) != NULL)
 | 
			
		||||
			b->id = PW_MAP_PTR_TO_ID(t);
 | 
			
		||||
		else
 | 
			
		||||
			b->id = SPA_ID_INVALID;
 | 
			
		||||
 | 
			
		||||
		if ((t = pw_map_lookup(types, b->type)) == NULL)
 | 
			
		||||
			return false;
 | 
			
		||||
		b->type = PW_MAP_PTR_TO_ID(t);
 | 
			
		||||
 | 
			
		||||
		SPA_POD_OBJECT_BODY_FOREACH(b, size, p)
 | 
			
		||||
			if (!pod_remap_data(p->type, SPA_POD_BODY(p), p->size, types))
 | 
			
		||||
				return false;
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	case SPA_POD_TYPE_STRUCT:
 | 
			
		||||
	{
 | 
			
		||||
		struct spa_pod *b = body, *p;
 | 
			
		||||
 | 
			
		||||
		SPA_POD_FOREACH(b, size, p)
 | 
			
		||||
			if (!pod_remap_data(p->type, SPA_POD_BODY(p), p->size, types))
 | 
			
		||||
				return false;
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	default:
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
process_messages(struct client_data *data)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -230,12 +163,6 @@ process_messages(struct client_data *data)
 | 
			
		|||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
		if (demarshal[opcode].flags & PW_PROTOCOL_NATIVE_REMAP)
 | 
			
		||||
			if (!pod_remap_data(SPA_POD_TYPE_STRUCT, message, size, &client->types))
 | 
			
		||||
				goto invalid_message;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		if (debug_messages) {
 | 
			
		||||
			fprintf(stderr, "<<<<<<<<< in: %d %d %d\n", id, opcode, size);
 | 
			
		||||
		        spa_debug_pod(0, spa_debug_types, (struct spa_pod *)message);
 | 
			
		||||
| 
						 | 
				
			
			@ -562,16 +489,6 @@ on_remote_data(void *data, int fd, enum spa_io mask)
 | 
			
		|||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
			if (demarshal[opcode].flags & PW_PROTOCOL_NATIVE_REMAP) {
 | 
			
		||||
				if (!pod_remap_data(SPA_POD_TYPE_STRUCT, message, size, &this->types)) {
 | 
			
		||||
                                        pw_log_error
 | 
			
		||||
                                            ("protocol-native %p: invalid message received %u for %u", this,
 | 
			
		||||
                                             opcode, id);
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
#endif
 | 
			
		||||
			if (debug_messages) {
 | 
			
		||||
				fprintf(stderr, "<<<<<<<<< in: %d %d %d\n", id, opcode, size);
 | 
			
		||||
			        spa_debug_pod(0, spa_debug_types, (struct spa_pod *)message);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1086,7 +1086,7 @@ static const struct pw_protocol_native_demarshal pw_protocol_native_core_method_
 | 
			
		|||
	{ &core_demarshal_get_registry, 0, },
 | 
			
		||||
	{ &core_demarshal_client_update, 0, },
 | 
			
		||||
	{ &core_demarshal_permissions, 0, },
 | 
			
		||||
	{ &core_demarshal_create_object, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ &core_demarshal_create_object, 0, },
 | 
			
		||||
	{ &core_demarshal_destroy, 0, }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1122,7 +1122,7 @@ static const struct pw_registry_proxy_methods pw_protocol_native_registry_method
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_registry_method_demarshal[] = {
 | 
			
		||||
	{ ®istry_demarshal_bind, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ ®istry_demarshal_bind, 0, },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_registry_proxy_events pw_protocol_native_registry_event_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			@ -1132,7 +1132,7 @@ static const struct pw_registry_proxy_events pw_protocol_native_registry_event_m
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_registry_event_demarshal[] = {
 | 
			
		||||
	{ ®istry_demarshal_global, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ ®istry_demarshal_global, 0, },
 | 
			
		||||
	{ ®istry_demarshal_global_remove, 0, }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1171,7 +1171,7 @@ static const struct pw_factory_proxy_events pw_protocol_native_factory_event_mar
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_factory_event_demarshal[] = {
 | 
			
		||||
	{ &factory_demarshal_info, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ &factory_demarshal_info, 0, },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const struct pw_protocol_marshal pw_protocol_native_factory_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			@ -1189,7 +1189,7 @@ static const struct pw_node_proxy_methods pw_protocol_native_node_method_marshal
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_node_method_demarshal[] = {
 | 
			
		||||
	{ &node_demarshal_enum_params, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ &node_demarshal_enum_params, 0, },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_node_proxy_events pw_protocol_native_node_event_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			@ -1199,8 +1199,8 @@ static const struct pw_node_proxy_events pw_protocol_native_node_event_marshal =
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_node_event_demarshal[] = {
 | 
			
		||||
	{ &node_demarshal_info, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ &node_demarshal_param, PW_PROTOCOL_NATIVE_REMAP, }
 | 
			
		||||
	{ &node_demarshal_info, 0, },
 | 
			
		||||
	{ &node_demarshal_param, 0, }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_marshal pw_protocol_native_node_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			@ -1221,7 +1221,7 @@ static const struct pw_port_proxy_methods pw_protocol_native_port_method_marshal
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_port_method_demarshal[] = {
 | 
			
		||||
	{ &port_demarshal_enum_params, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ &port_demarshal_enum_params, 0, },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_port_proxy_events pw_protocol_native_port_event_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			@ -1231,8 +1231,8 @@ static const struct pw_port_proxy_events pw_protocol_native_port_event_marshal =
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_port_event_demarshal[] = {
 | 
			
		||||
	{ &port_demarshal_info, PW_PROTOCOL_NATIVE_REMAP, },
 | 
			
		||||
	{ &port_demarshal_param, PW_PROTOCOL_NATIVE_REMAP, }
 | 
			
		||||
	{ &port_demarshal_info, 0, },
 | 
			
		||||
	{ &port_demarshal_param, 0, }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_marshal pw_protocol_native_port_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			@ -1270,7 +1270,7 @@ static const struct pw_link_proxy_events pw_protocol_native_link_event_marshal =
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_native_demarshal pw_protocol_native_link_event_demarshal[] = {
 | 
			
		||||
	{ &link_demarshal_info, PW_PROTOCOL_NATIVE_REMAP, }
 | 
			
		||||
	{ &link_demarshal_info, 0, }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct pw_protocol_marshal pw_protocol_native_link_marshal = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -219,14 +219,14 @@ static void on_monitor_event(void *data, struct spa_event *event)
 | 
			
		|||
	now_nsec = now.tv_sec * SPA_NSEC_PER_SEC + now.tv_nsec;
 | 
			
		||||
 | 
			
		||||
	item = SPA_POD_CONTENTS(struct spa_event, event);
 | 
			
		||||
	switch(SPA_EVENT_TYPE(event)) {
 | 
			
		||||
	case SPA_ID_EVENT_MONITOR_Added:
 | 
			
		||||
	switch (SPA_MONITOR_EVENT_ID(event)) {
 | 
			
		||||
	case SPA_MONITOR_EVENT_Added:
 | 
			
		||||
		add_item(this, item, now_nsec);
 | 
			
		||||
		break;
 | 
			
		||||
	case SPA_ID_EVENT_MONITOR_Removed:
 | 
			
		||||
	case SPA_MONITOR_EVENT_Removed:
 | 
			
		||||
		remove_item(this, item, now_nsec);
 | 
			
		||||
		break;
 | 
			
		||||
	case SPA_ID_EVENT_MONITOR_Changed:
 | 
			
		||||
	case SPA_MONITOR_EVENT_Changed:
 | 
			
		||||
		change_item(this, item, now_nsec);
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -187,31 +187,31 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
 | 
			
		|||
			pw_log_info("configure prop %s", key);
 | 
			
		||||
 | 
			
		||||
			switch(prop->body.value.type) {
 | 
			
		||||
			case SPA_POD_TYPE_BOOL:
 | 
			
		||||
			case SPA_ID_Bool:
 | 
			
		||||
				SPA_POD_VALUE(struct spa_pod_bool, &prop->body.value) =
 | 
			
		||||
					pw_properties_parse_bool(value);
 | 
			
		||||
				break;
 | 
			
		||||
			case SPA_POD_TYPE_ID:
 | 
			
		||||
			case SPA_ID_Enum:
 | 
			
		||||
				SPA_POD_VALUE(struct spa_pod_id, &prop->body.value) =
 | 
			
		||||
					spa_debug_type_find_id(spa_debug_types, value);
 | 
			
		||||
				break;
 | 
			
		||||
			case SPA_POD_TYPE_INT:
 | 
			
		||||
			case SPA_ID_Int:
 | 
			
		||||
				SPA_POD_VALUE(struct spa_pod_int, &prop->body.value) =
 | 
			
		||||
					pw_properties_parse_int(value);
 | 
			
		||||
				break;
 | 
			
		||||
			case SPA_POD_TYPE_LONG:
 | 
			
		||||
			case SPA_ID_Long:
 | 
			
		||||
				SPA_POD_VALUE(struct spa_pod_long, &prop->body.value) =
 | 
			
		||||
					pw_properties_parse_int64(value);
 | 
			
		||||
				break;
 | 
			
		||||
			case SPA_POD_TYPE_FLOAT:
 | 
			
		||||
			case SPA_ID_Float:
 | 
			
		||||
				SPA_POD_VALUE(struct spa_pod_float, &prop->body.value) =
 | 
			
		||||
					pw_properties_parse_float(value);
 | 
			
		||||
				break;
 | 
			
		||||
			case SPA_POD_TYPE_DOUBLE:
 | 
			
		||||
			case SPA_ID_Double:
 | 
			
		||||
				SPA_POD_VALUE(struct spa_pod_double, &prop->body.value) =
 | 
			
		||||
					pw_properties_parse_double(value);
 | 
			
		||||
				break;
 | 
			
		||||
			case SPA_POD_TYPE_STRING:
 | 
			
		||||
			case SPA_ID_String:
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ static int do_pause_node(struct pw_node *this)
 | 
			
		|||
 | 
			
		||||
	pw_log_debug("node %p: pause node", this);
 | 
			
		||||
	res = spa_node_send_command(this->node,
 | 
			
		||||
				    &SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Pause));
 | 
			
		||||
				    &SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause));
 | 
			
		||||
	if (res < 0)
 | 
			
		||||
		pw_log_debug("node %p: pause node error %s", this, spa_strerror(res));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +97,7 @@ static int start_node(struct pw_node *this)
 | 
			
		|||
 | 
			
		||||
	pw_log_debug("node %p: start node", this);
 | 
			
		||||
	res = spa_node_send_command(this->node,
 | 
			
		||||
				    &SPA_COMMAND_INIT(SPA_ID_COMMAND_NODE_Start));
 | 
			
		||||
				    &SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Start));
 | 
			
		||||
	if (res < 0)
 | 
			
		||||
		pw_log_debug("node %p: start node error %s", this, spa_strerror(res));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -885,8 +885,8 @@ static void client_node_command(void *object, uint32_t seq, const struct spa_com
 | 
			
		|||
	struct pw_remote *remote = proxy->remote;
 | 
			
		||||
	int res;
 | 
			
		||||
 | 
			
		||||
	switch (SPA_COMMAND_TYPE(command)) {
 | 
			
		||||
	case SPA_ID_COMMAND_NODE_Pause:
 | 
			
		||||
	switch (SPA_NODE_COMMAND_ID(command)) {
 | 
			
		||||
	case SPA_NODE_COMMAND_Pause:
 | 
			
		||||
		pw_log_debug("node %p: pause %d", proxy, seq);
 | 
			
		||||
 | 
			
		||||
		pw_loop_update_io(remote->core->data_loop,
 | 
			
		||||
| 
						 | 
				
			
			@ -898,7 +898,7 @@ static void client_node_command(void *object, uint32_t seq, const struct spa_com
 | 
			
		|||
 | 
			
		||||
		pw_client_node_proxy_done(data->node_proxy, seq, res);
 | 
			
		||||
		break;
 | 
			
		||||
	case SPA_ID_COMMAND_NODE_Start:
 | 
			
		||||
	case SPA_NODE_COMMAND_Start:
 | 
			
		||||
		pw_log_debug("node %p: start %d", proxy, seq);
 | 
			
		||||
 | 
			
		||||
		pw_loop_update_io(remote->core->data_loop,
 | 
			
		||||
| 
						 | 
				
			
			@ -911,7 +911,7 @@ static void client_node_command(void *object, uint32_t seq, const struct spa_com
 | 
			
		|||
		pw_client_node_proxy_done(data->node_proxy, seq, res);
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		pw_log_warn("unhandled node command %d", SPA_COMMAND_TYPE(command));
 | 
			
		||||
		pw_log_warn("unhandled node command %d", SPA_NODE_COMMAND_ID(command));
 | 
			
		||||
		pw_client_node_proxy_done(data->node_proxy, seq, -ENOTSUP);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -251,14 +251,14 @@ static int impl_send_command(struct spa_node *node, const struct spa_command *co
 | 
			
		|||
	struct stream *impl = SPA_CONTAINER_OF(node, struct stream, impl_node);
 | 
			
		||||
	struct pw_stream *stream = &impl->this;
 | 
			
		||||
 | 
			
		||||
	switch (SPA_COMMAND_TYPE(command)) {
 | 
			
		||||
	case SPA_ID_COMMAND_NODE_Pause:
 | 
			
		||||
	switch (SPA_NODE_COMMAND_ID(command)) {
 | 
			
		||||
	case SPA_NODE_COMMAND_Pause:
 | 
			
		||||
		if (stream->state == PW_STREAM_STATE_STREAMING) {
 | 
			
		||||
			pw_log_debug("stream %p: pause", stream);
 | 
			
		||||
			stream_set_state(stream, PW_STREAM_STATE_PAUSED, NULL);
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	case SPA_ID_COMMAND_NODE_Start:
 | 
			
		||||
	case SPA_NODE_COMMAND_Start:
 | 
			
		||||
		if (stream->state == PW_STREAM_STATE_PAUSED) {
 | 
			
		||||
			pw_log_debug("stream %p: start %d", stream, impl->direction);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -273,7 +273,7 @@ static int impl_send_command(struct spa_node *node, const struct spa_command *co
 | 
			
		|||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		pw_log_warn("unhandled node command %d", SPA_COMMAND_TYPE(command));
 | 
			
		||||
		pw_log_warn("unhandled node command %d", SPA_NODE_COMMAND_ID(command));
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,8 @@
 | 
			
		|||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include <spa/utils/type.h>
 | 
			
		||||
 | 
			
		||||
#include "pipewire/log.h"
 | 
			
		||||
#include "pipewire/work-queue.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue