7¤0ìofSA¨2ã03333333335:µö'R
Û"»#åÛÙeOéÇú7Ûÿ*�¾ÝÂˆƒ83ˆˆ$c)-i 6PØÓ   ŒHDòxL –ô`ÀŽ“"�L%ò`$�ã8£(
¢ 
c�AÈ †hd4  Ä7EM2d                    	 *   respectively. */
	SPA_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM,		/**< The top half of the frame contains the
							 *   left eye, and the bottom half the right
							 *   eye. */
	SPA_VIDEO_MULTIVIEW_MODE_CHECKERBOARD,		/**< Pixels are arranged with alternating
							 *   pixels representing left and right eye
							 *   views in a checkerboard fashion. */
	/* Padding for new frame packing modes */

	SPAruct spa_pod_struct);
				spa_pod_builder_push_struct(b, &f);
				res = spa_pod_filter_part(b,
					SPA_PTROFF(pp,filter_offset,const struct spa_pod),
					SPA_POD_SIZE(pp) - filter_offset,
					SPA_PTROFF(pf,filter_offset,const struct spa_pod),
					SPA_POD_SIZE(pf) - filter_offset);
			        spa_pod_builder_pop(b, &f);
				do_advance = true;
			}
			else
				do_copy = true;
			break;

		default:
			if (pf != NULL) {
				if (SPA_POD_SIZE(pp) != SPA_POD_SIZE(pf))
					return -EINVAL;
				if (memcmp(pp, pf, SPA_POD_SIZE(pp)) != 0)e,void), size) > 0)
				continue;

			res = spa_pod_filter_is_step_of(type, a2, SPA_PTROFF(a1,size*2,void), size);
			if (res == 0)
				continue;
			if (res == -ENOTSUP)
				return -EINVAL;

			spa_pod_builder_raw(b, a2, size);
			n_copied++;
		}
		if (n_copied == 0)
			return -EINVAL;
		nc->body.type = SPA_CHOICE_Enum;
	}
	if (p1c == SPA_CHOICE_Step && p2c == SPA_CHOICE_Flags)
		return -ENOTSUP;

	if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Range)
		return -ENOTSUP;
	if (p1c == SPA_CHOICE_Flags && p2c == SPA_CHOICE_Step)
		retype, val, alt, size) == 0) {
				best = alt;
				break;
			}
			if (best == NULL)
				best = alt;
		}
		if (best)
			memcpy(val, best, size);

		if (nvals <= 1)
			choice->body.type = SPA_CHOICE_None;
		break;
	}
	}
	return 0;
}

SPA_API_POD_FILTER int spa_pod_filter_flags_value(struct spa_pod_builder *b,
		uint32_t type, const void *r1, const void *r2, uint32_t size SPA_UNUSED)
{
	switch (type) {
	case SPA_TYPE_Int:
	{
		int32_t val = (*(int32_t *) r1) & (*(int32_t *) r2);
		if (val == 0)
			return 0;
		spa_pod_builder_int(b, valval, int len)
{
	return len == 4 && strncmp(val, "null", 4) == 0;
}

/* float */
SPA_API_JSON int spa_json_parse_float(const char *val, int len, float *result)
{
	char buf[96];
	char *end;
	int pos;

	if (len <= 0 || len >= (int)sizeof(buf))
		return 0;

	for (pos = 0; pos < len; ++pos) {
		switch (val[pos]) {
		case '+': case '-': case '0' ... '9': case '.': case 'e': case 'E': break;
		default: return 0;
		}
	}

	memcpy(buf, val, len);
	buf[len] = '\0';

	*result = spa_strtof(buf, &end);
	return len > 0 && end == buf + len;
}

SPLAG, flag & __PREV_ARRAY_FLAG);
				} else if (((iter->depth-1) >> 6) < SPA_N_ELEMENTS(array_stack)) {
					uint64_t mask = 1ULL << ((iter->depth-1) & 0x3f);
					SPA_FLAG_UPDATE(iter->state, __ARRAY_FLAG,
							SPA_FLAG_IS_SET(array_stack[(iter->depth-1) >> 6], mask));
				} else {
					/* too deep */
					_SPA_ERROR(TOO_DEEP_NESTING);
				}
				continue;
			case '\\':
				/* disallow bare escape */
				_SPA_ERROR(ESCAPE_NOT_ALLOWED);
			default:
				/* allow bare ascii */
				if (!(cur >= 32 && cur <= 126))
					_SPA_ERROR(CHARAOBJECT_VALUE,
		__ERROR_TOO_DEEP_NESTING,
		__ERROR_EXPECTED_ARRAY_CLOSE,
		__ERROR_EXPECTED_OBJECT_CLOSE,
		__ERROR_MISMATCHED_BRACKET,
		__ERROR_ESCAPE_NOT_ALLOWED,
		__ERROR_CHARACTERS_NOT_ALLOWED,
		__ERROR_INVALID_ESCAPE,
		__ERROR_INVALID_STATE,
		__ERROR_UNFINISHED_STRING,
	};
	uint64_t array_stack[8] = {0};		/* array context flags of depths 1...512 */

	*value = iter->cur;

	if (iter->state & SPA_JSON_ERROR_FLAG)
		return -1;

	for (; iter->cur < iter->end; iter->cur++) {
		unsigned char cur = (unsigned char)*iter->cur;
		uA	"\x1B[0;35m"
#define SPA_ANSI_CYAN		"\x1B[0;36m"
#define SPA_ANSI_WHITE		"\x1B[0;37m"
#define SPA_ANSI_BRIGHT_BLACK	"\x1B[90m"
#define SPA_ANSI_BRIGHT_RED	"\x1B[91m"
#define SPA_ANSI_BRIGHT_GREEN	"\x1B[92m"
#define SPA_ANSI_BRIGHT_YELLOW	"\x1B[93m"
#define SPA_ANSI_BRIGHT_BLUE	"\x1B[94m"
#define SPA_ANSI_BRIGHT_MAGENTA	"\x1B[95m"
#define SPA_ANSI_BRIGHT_CYAN	"\x1B[96m"
#define SPA_ANSI_BRIGHT_WHITE	"\x1B[97m"

/* Shortcut because it's a common use-case and easier than combining both */
#define SPA_ANSI_BOLD_BLACK	"\x1B[1;30m"
#de	} *ext;

	if (update == NULL)
		return info;

	if (info == NULL) {
		ext = (struct extended_info *) calloc(1, sizeof(*ext));
		if (ext == NULL)
			return NULL;

		info = &ext->info;
		info->id = update->id;
	} else {
		ext = SPA_CONTAINER_OF(info, struct extended_info, info);
	}

	info->change_mask = update->change_mask;

	if (update->change_mask & PW_SESSION_CHANGE_MASK_PROPS) {
		if (!ext->props_storage) {
			ext->props_storage = pw_properties_new(NULL, NULL);
			info->props = &ext->props_storage->dict;
		}
		pw_properties_clear
	/**
	 * Get a new connection wrapper for the given bus type.
	 *
	 * The connection wrapper is completely configured to operate
	 * in the main context of the handle that manages the spa_dbus
	 * interface.
	 *
	 * \param dbus the dbus manager
	 * \param type the bus type to wrap
	 * \param error location for the DBusError
	 * \return a new dbus connection wrapper or NULL on error
	 */
	struct spa_dbus_connection * (*get_connection) (void *object,
							enum spa_dbus_type type);
};

/** \copydoc spa_dbus_methods.get_connection
 nst struct pw_device_info *update);
/** Merge and existing \ref pw_device_info with \a update */
struct pw_device_info *
pw_device_info_merge(struct pw_device_info *info,
		const struct pw_device_info *update, bool reset);
/** Free a \ref pw_device_info */
void pw_device_info_free(struct pw_device_info *info);

#define PW_DEVICE_EVENT_INFO	0
#define PW_DEVICE_EVENT_PARAM	1
#define PW_DEVICE_EVENT_NUM	2

/** Device events */
struct pw_device_events {
#define PW_VERSION_DEVICE_EVENTS	0
	uint32_t version;
	/**
	 * Notify device info
	

SPA_API_DEBUG_NODE int spa_debugc_port_info(struct spa_debug_context *ctx, int indent, const struct spa_port_info *info)
{
        spa_debugc(ctx, "%*s" "struct spa_port_info %p:", indent, "", info);
        spa_debugc(ctx, "%*s" " flags: \t%08" PRIx64, indent, "", info->flags);
        spa_debugc(ctx, "%*s" " rate: \t%d/%d", indent, "", info->rate.num, info->rate.denom);
        spa_debugc(ctx, "%*s" " props:", indent, "");
        if (info->props)
                spa_debugc_dict(ctx, indent + 2, info->props);
        else
     a_list_insert_list(struct spa_list *list, struct spa_list *other)
{
	if (spa_list_is_empty(other))
		return;
	other->next->prev = list;
	other->prev->next = list->next;
	list->next->prev = other->prev;
	list->next = other->next;
}

SPA_API_LIST void spa_list_remove(struct spa_list *elem)
{
	elem->prev->next = elem->next;
	elem->next->prev = elem->prev;
}

#define spa_list_first(head, type, member)				\
	SPA_CONTAINER_OF((head)->next, type, member)

#define spa_list_last(head, type, member)				\
	SPA_CONTAINER_OF((head)->prev, type,ute", NULL },
	{ SPA_PARAM_Control, SPA_TYPE_Sequence, SPA_TYPE_INFO_PARAM_ID_BASE "Control", NULL },
	{ SPA_PARAM_Latency, SPA_TYPE_OBJECT_ParamLatency, SPA_TYPE_INFO_PARAM_ID_BASE "Latency", NULL },
	{ SPA_PARAM_ProcessLatency, SPA_TYPE_OBJECT_ParamProcessLatency, SPA_TYPE_INFO_PARAM_ID_BASE "ProcessLatency", NULL },
	{ SPA_PARAM_Tag, SPA_TYPE_OBJECT_ParamTag, SPA_TYPE_INFO_PARAM_ID_BASE "Tag", NULL },
	{ 0, 0, NULL, NULL },
};

/* base for parameter objects */
#define SPA_TYPE_INFO_Param			SPA_TYPE_INFO_OBJECT_BASE "Param"
#defi_TYPE_INFO_PARAM_ID_BASE "EnumFormat", NULL },
	{ SPA_PARAM_Format, SPA_TYPE_OBJECT_Format, SPA_TYPE_INFO_PARAM_ID_BASE "Format", NULL },
	{ SPA_PARAM_Buffers, SPA_TYPE_OBJECT_ParamBuffers, SPA_TYPE_INFO_PARAM_ID_BASE "Buffers", NULL },
	{ SPA_PARAM_Meta, SPA_TYPE_OBJECT_ParamMeta, SPA_TYPE_INFO_PARAM_ID_BASE "Meta", NULL },
	{ SPA_PARAM_IO, SPA_TYPE_OBJECT_ParamIO, SPA_TYPE_INFO_PARAM_ID_BASE "IO", NULL },
	{ SPA_PARAM_EnumProfile, SPA_TYPE_OBJECT_ParamProfile, SPA_TYPE_INFO_PARAM_ID_BASE "EnumProfile", NULL },
	{ SPA_PARAM_ProfilA_TYPE_INFO_BUFFER_BASE		SPA_TYPE_INFO_Buffer ":"

/** Buffers contain data of a certain type */
#define SPA_TYPE_INFO_Data			SPA_TYPE_INFO_ENUM_BASE "Data"
#define SPA_TYPE_INFO_DATA_BASE			SPA_TYPE_INFO_Data ":"

/** base type for fd based memory */
#define SPA_TYPE_INFO_DATA_Fd			SPA_TYPE_INFO_DATA_BASE "Fd"
#define SPA_TYPE_INFO_DATA_FD_BASE		SPA_TYPE_INFO_DATA_Fd ":"

static const struct spa_type_info spa_type_data_type[] = {
	{ SPA_DATA_Invalid, SPA_TYPE_Int, SPA_TYPE_INFO_DATA_BASE "Invalid", NULL },
	{ SPA_DATA_MemPtr, SPA__DICT((items),SPA_N_ELEMENTS(items))
#define SPA_DICT_ITEMS(...) SPA_DICT_ARRAY(((struct spa_dict_item[]) { __VA_ARGS__}))

#define SPA_DICT_INIT(items,n_items) SPA_DICT(items,n_items)
#define SPA_DICT_INIT_ARRAY(items) SPA_DICT_ARRAY(items)

#define spa_dict_for_each(item, dict)				\
	for ((item) = (dict)->items;				\
	     (item) < &(dict)->items[(dict)->n_items];		\
	     (item)++)

SPA_API_DICT int spa_dict_item_compare(const void *i1, const void *i2)
{
	const struct spa_dict_item *it1 = (const struct spa_dict_item *)i1,
	      "TrueHD", NULL },
	{ SPA_AUDIO_IEC958_CODEC_DTSHD, SPA_TYPE_Int, SPA_TYPE_INFO_AUDIO_IEC958_CODEC_BASE "DTS-HD", NULL },
	{ 0, 0, NULL, NULL },
};

SPA_API_AUDIO_IEC958_TYPES uint32_t spa_type_audio_iec958_codec_from_short_name(const char *name)
{
	return spa_type_from_short_name(name, spa_type_audio_iec958_codec, SPA_AUDIO_IEC958_CODEC_UNKNOWN);
}
SPA_API_AUDIO_IEC958_TYPES const char * spa_type_audio_iec958_codec_to_short_name(uint32_t type)
{
	return spa_type_to_short_name(type, spa_type_audio_iec958_codec, "UNKNOWN");
}
/**
 *timerspec *new_value,
			struct itimerspec *old_value);
	int (*timerfd_gettime) (void *object,
			int fd, struct itimerspec *curr_value);
	int (*timerfd_read) (void *object, int fd, uint64_t *expirations);

	/* events */
	int (*eventfd_create) (void *object, int flags);
	int (*eventfd_write) (void *object, int fd, uint64_t count);
	int (*eventfd_read) (void *object, int fd, uint64_t *count);

	/* signals */
	int (*signalfd_create) (void *object, int signal, int flags);
	int (*signalfd_read) (void *object, int fd, int *signal);
};

_HUP	(1 << 4)

/* flags */
#define SPA_FD_CLOEXEC			(1<<0)
#define SPA_FD_NONBLOCK			(1<<1)
#define SPA_FD_EVENT_SEMAPHORE		(1<<2)
#define SPA_FD_TIMER_ABSTIME		(1<<3)
#define SPA_FD_TIMER_CANCEL_ON_SET	(1<<4)

struct spa_poll_event {
	uint32_t events;
	void *data;
};

struct spa_system_methods {
#define SPA_VERSION_SYSTEM_METHODS	0
	uint32_t version;

	/* read/write/ioctl */
	ssize_t (*read) (void *object, int fd, void *buf, size_t count);
	ssize_t (*write) (void *object, int fd, const void *buf, size_t count);
	int (*ioctl) (voidASE "direction", spa_type_direction, },
	{ SPA_PARAM_ROUTE_device, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_ROUTE_BASE "device", NULL, },
	{ SPA_PARAM_ROUTE_name, SPA_TYPE_String, SPA_TYPE_INFO_PARAM_ROUTE_BASE "name", NULL, },
	{ SPA_PARAM_ROUTE_description, SPA_TYPE_String, SPA_TYPE_INFO_PARAM_ROUTE_BASE "description", NULL, },
	{ SPA_PARAM_ROUTE_priority, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_ROUTE_BASE "priority", NULL, },
	{ SPA_PARAM_ROUTE_available, SPA_TYPE_Id, SPA_TYPE_INFO_PARAM_ROUTE_BASE "available", spa_type_param_availability, }"", (*(int32_t *) body) ? "true" : "false");
		break;
	case SPA_TYPE_Id:
		spa_debugc(ctx, "%*s" "Id %-8d (%s)", indent, "", *(int32_t *) body,
		       spa_debug_type_find_name(info, *(int32_t *) body));
		break;
	case SPA_TYPE_Int:
		spa_debugc(ctx, "%*s" "Int %d", indent, "", *(int32_t *) body);
		break;
	case SPA_TYPE_Long:
		spa_debugc(ctx, "%*s" "Long %" PRIi64 "", indent, "", *(int64_t *) body);
		break;
	case SPA_TYPE_Float:
		spa_debugc(ctx, "%*s" "Float %f", indent, "", *(float *) body);
		break;
	case SPA_TYPE_Double:
		er of CPU cores */
	uint32_t (*get_count) (void *object);

	/** get maximum required alignment of data */
	uint32_t (*get_max_align) (void *object);

	/* check if running in a VM. Since:1 */
	uint32_t (*get_vm_type) (void *object);

	/* denormals will be handled as zero, either with FTZ or DAZ.
	 * Since:2 */
	int (*zero_denormals) (void *object, bool enable);
};

SPA_API_CPU uint32_t spa_cpu_get_flags(struct spa_cpu *c)
{
	return spa_api_method_r(uint32_t, 0, spa_cpu, &c->iface, get_flags, 0);
}
SPA_API_CPU int spa_cpu_force_flagsct spa_debug_log_ctx){ { spa_debug_log_log }, _l, _lev, _t,	\
		_file, _line, _func }

#define SPA_LOGT_DEBUG_INIT(_l,_lev,_t)						\
	SPA_LOGF_DEBUG_INIT(_l,_lev,_t,__FILE__,__LINE__,__func__)

#define SPA_LOG_DEBUG_INIT(l,lev) 	\
	SPA_LOGT_DEBUG_INIT(l,lev,SPA_LOG_TOPIC_DEFAULT)

#define spa_debug_log_pod(l,lev,indent,info,pod) 				\
({										\
	struct spa_debug_log_ctx c = SPA_LOG_DEBUG_INIT(l,lev);			\
	if (SPA_UNLIKELY(spa_log_level_topic_enabled(c.log, c.topic, c.level)))	\
		spa_debugc_pod(&c.ctx, indent, info, pod);			\
e <sys/un.h>
#ifndef _POSIX_C_SOURCE
# include <sys/mount.h>
#endif
#include <errno.h>

#ifndef ENODATA
#define ENODATA 9919
#endif

#include <spa/utils/cleanup.h>
#include <spa/utils/defs.h>
#include <spa/pod/pod.h>

/** \defgroup pw_utils Utilities
 *
 * Various utility functions
 */

/**
 * \addtogroup pw_utils
 * \{
 */

/** a function to destroy an item */
typedef void (*pw_destroy_t) (void *object);

const char *
pw_split_walk(const char *str, const char *delimiter, size_t *len, const char **state);

char **
pw_split_strv(contx, "%*s" "struct spa_buffer %p:", indent, "", buffer);
	spa_debugc(ctx, "%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
	for (i = 0; i < buffer->n_metas; i++) {
		struct spa_meta *m = &buffer->metas[i];
		const char *type_name;

		type_name = spa_debug_type_find_name(spa_type_meta_type, m->type);
		spa_debugc(ctx, "%*s" "  meta %d: type %d (%s), data %p, size %d:", indent, "", i, m->type,
			type_name, m->data, m->size);

		switch (m->type) {
		case SPA_META_Header:
		{
			struct spa_meta_header *h = (stf /* SPA_NODE_H */
/* PipeWire */
/* SPDX-FileCopyrightText: Copyright Â© 2021 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef PIPEWIRE_CONF_H
#define PIPEWIRE_CONF_H

#include <spa/utils/json-core.h>

#include <pipewire/context.h>

/** \defgroup pw_conf Configuration
 * Loading/saving properties from/to configuration files.
 */

/**
 * \addtogroup pw_conf
 * \{
 */

int pw_conf_load_conf_for_context(struct pw_properties *props, struct pw_properties *conf);
int pw_conf_load_conf(const char *prefix, const char *name, struio areas while running. This
	 * is normally done by synchronizing the port io updates with the
	 * data processing loop.
	 *
	 * \param direction a spa_direction
	 * \param port_id a port id
	 * \param id the id of the io area, the available ids can be
	 *        enumerated with the port parameters.
	 * \param data a io area memory
	 * \param size the size of \a data
	 * \return 0 on success
	 *         -EINVAL when invalid input is given
	 *         -ENOENT when \a id is unknown
	 *         -ENOSPC when \a size is too small
	 */
aram);

	/**
	 * Tell the port to use the given buffers
	 *
	 * When \a flags contains SPA_NODE_BUFFERS_FLAG_ALLOC, the data
	 * in the buffers should point to an array of at least 1 data entry
	 * with the desired supported type that will be filled by this function.
	 *
	 * The port should also have a spa_io_buffers io area configured to exchange
	 * the buffers with the port.
	 *
	 * For an input port, all the buffers will remain dequeued.
	 * Once a buffer has been queued on a port in the spa_io_buffers,
	 * it should not be reu      an async result
	 */
	int (*sync) (void *object, int seq);

	/**
	 * Enumerate the parameters of a node.
	 *
	 * Parameters are identified with an \a id. Some parameters can have
	 * multiple values, see the documentation of the parameter id.
	 *
	 * Parameters can be filtered by passing a non-NULL \a filter.
	 *
	 * The function will emit the result event up to \a max times with
	 * the result value. The seq in the result will either be the \a seq
	 * number when executed synchronously or the async return value of
	 * this fM_FLAG_FIXATE	(1 << 1)	/**< Fixate the non-optional unset fields */
#define SPA_NODE_PARAM_FLAG_NEAREST	(1 << 2)	/**< Allow set fields to be rounded to the
							  *  nearest allowed field value. */

/** flags to pass to the use_buffers functions */
#define SPA_NODE_BUFFERS_FLAG_ALLOC	(1 << 0)	/**< Allocate memory for the buffers. This flag
							  *  is ignored when the port does not have the
							  *  SPA_PORT_FLAG_CAN_ALLOC_BUFFERS set. */


#define SPA_NODE_METHOD_ADD_LISTENER		0
#define SPA_NODE_METHOD_SET_CALLBACKS		1
#deNFIG		(1u<<3)	/**< input ports can be reconfigured with
							  *  PortConfig parameter */
#define SPA_NODE_FLAG_OUT_PORT_CONFIG		(1u<<4)	/**< output ports can be reconfigured with
							  *  PortConfig parameter */
#define SPA_NODE_FLAG_NEED_CONFIGURE		(1u<<5)	/**< node needs configuration before it can
							  *  be started. */
#define SPA_NODE_FLAG_ASYNC			(1u<<6)	/**< the process function might not
							  *  immediately produce or consume data
							  *  but might offload the work to a worker
							  *  thread. */
	uint6up pw_impl_port
 * \{
 */
struct pw_impl_port;
struct pw_impl_link;
struct pw_control;

#include <pipewire/impl.h>

enum pw_impl_port_state {
	PW_IMPL_PORT_STATE_ERROR = -1,	/**< the port is in error */
	PW_IMPL_PORT_STATE_INIT = 0,		/**< the port is being created */
	PW_IMPL_PORT_STATE_CONFIGURE = 1,	/**< the port is ready for format negotiation */
	PW_IMPL_PORT_STATE_READY = 2,	/**< the port is ready for buffer allocation */
	PW_IMPL_PORT_STATE_PAUSED = 3,	/**< the port is paused */
};

/** Port events, use \ref pw_impl_port_add_api_method_fast_r(int, -ENOTSUP,
			spa_loop_control, &object->iface, iterate, 0, timeout);
}
SPA_API_LOOP int spa_loop_control_check(struct spa_loop_control *object)
{
	return spa_api_method_r(int, -ENOTSUP,
			spa_loop_control, &object->iface, check, 1);
}

typedef void (*spa_source_io_func_t) (void *data, int fd, uint32_t mask);
typedef void (*spa_source_idle_func_t) (void *data);
typedef void (*spa_source_event_func_t) (void *data, uint64_t count);
typedef void (*spa_source_timer_func_t) (void *data, uint64_t expirations);
typet size, bool block, void *user_data)
{
	return spa_api_method_r(int, -ENOTSUP,
			spa_loop, &object->iface, invoke, 0, func, seq, data,
			size, block, user_data);
}

/** Control hooks. These hooks can't be removed from their
 *  callbacks and must be removed from a safe place (when the loop
 *  is not running or when it is locked). */
struct spa_loop_control_hooks {
#define SPA_VERSION_LOOP_CONTROL_HOOKS	0
	uint32_t version;
	/** Executed right before waiting for events. It is typically used to
	 * release locks. */
	void (*beforeinclude <errno.h>

#include <spa/utils/defs.h>
#include <spa/utils/hook.h>
#include <spa/support/system.h>

#ifndef SPA_API_LOOP
 #ifdef SPA_API_IMPL
  #define SPA_API_LOOP SPA_API_IMPL
 #else
  #define SPA_API_LOOP static inline
 #endif
#endif

/** \defgroup spa_loop Loop
 * Event loop interface
 */

/**
 * \addtogroup spa_loop
 * \{
 */

#define SPA_TYPE_INTERFACE_Loop		SPA_TYPE_INFO_INTERFACE_BASE "Loop"
#define SPA_TYPE_INTERFACE_DataLoop	SPA_TYPE_INFO_INTERFACE_BASE "DataLoop"
#define SPA_VERSION_LOOP		0
struct spa_loop { stru     Int : xrun_count))  */
	SPA_PROFILER_followerClock,			/**< follower clock information
							  *  (Struct(
							  *      Int : clock id,
							  *      String: clock name,
							  *      Long : clock nsec,
							  *      Fraction : clock rate,
							  *      Long : clock position,
							  *      Long : clock duration,
							  *      Long : clock delay,
							  *      Double : clock rate_diff,
							  *      Long : clock next_nsec,
							  *      Long : xrun duration)) */
	SPA_PROFILER_START_CUSTOM	= 0x1000000,
};

/ts using the
	 * provided array with permissions
	 *
	 * Globals can use the default permissions or can have specific
	 * permissions assigned to them.
	 *
	 * \param n_permissions number of permissions
	 * \param permissions array of permissions
	 *
	 * This requires W and X permissions on the client.
	 */
	int (*update_permissions) (void *object, uint32_t n_permissions,
			const struct pw_permission *permissions);
};

/** \copydoc pw_client_methods.add_listener
 * \sa pw_client_methods.add_listener */
PW_API_CLIENT_IMPL int pw_clition, uint32_t *n_channels)
{
	struct spa_json iter;
        char v[256];
	uint32_t channels = 0;

        if (spa_json_begin_array_relax(&iter, str, len) <= 0)
                return 0;

        while (spa_json_get_string(&iter, v, sizeof(v)) > 0 &&
		channels < SPA_AUDIO_MAX_CHANNELS) {
                position[channels++] = spa_type_audio_channel_from_short_name(v);
        }
	*n_channels = channels;
	return channels;
}

SPA_API_AUDIO_RAW_JSON int
spa_audio_info_raw_update(struct spa_audio_info_raw *info, const char *key, const_fetch_int64(const struct pw_properties *properties, const char *key, int64_t *value);

int
pw_properties_fetch_bool(const struct pw_properties *properties, const char *key, bool *value);

PW_API_PROPERTIES uint32_t
pw_properties_get_uint32(const struct pw_properties *properties, const char *key, uint32_t deflt)
{
	uint32_t val = deflt;
	pw_properties_fetch_uint32(properties, key, &val);
	return val;
}

PW_API_PROPERTIES int32_t
pw_properties_get_int32(const struct pw_properties *properties, const char *key, int32_t deflt)
{
	int32de_process(n)) != SPA_STATUS_OK)
		spa_graph_node_trigger(node);

        return state->status;
}

SPA_API_GRAPH int spa_graph_node_impl_reuse_buffer(void *data, struct spa_graph_node *node SPA_UNUSED,
		uint32_t port_id, uint32_t buffer_id)
{
	struct spa_node *n = (struct spa_node *)data;
	return spa_node_port_reuse_buffer(n, port_id, buffer_id);
}

static const struct spa_graph_node_callbacks spa_graph_node_impl_default = {
	.version = SPA_VERSION_GRAPH_NODE_CALLBACKS,
	.process = spa_graph_node_impl_process,
	.reuse_buffer = spate->pending, graph->state->required);

	spa_list_init(&pending);

	spa_list_for_each(n, &graph->nodes, link) {
		struct spa_graph_state *s = n->state;
		spa_graph_state_reset(s);
		spa_debug("graph %p node %p: state %p pending %d/%d status %d", graph, n,
				s, s->pending, s->required, s->status);
		if (--s->pending == 0)
			spa_list_append(&pending, &n->sched_link);
	}
	spa_list_for_each_safe(n, t, &pending, sched_link)
		spa_graph_node_process(n);

	return 0;
}

SPA_API_GRAPH int spa_graph_finish(struct spa_graph *graph)
{
	spa_dize"		/**< a video size as "<width>x<height" */

#define PW_KEY_TARGET_OBJECT		"target.object"		/**< a target object to link to. This can be
								  * and object name or object.serial */

#ifndef PW_REMOVE_DEPRECATED
# ifdef PW_ENABLE_DEPRECATED
#  define PW_KEY_PRIORITY_MASTER	"priority.master"	/**< deprecated, use priority.driver */
#  define PW_KEY_NODE_TARGET		"node.target"		/**< deprecated since 0.3.64, use target.object. */
#  define PW_KEY_LOOP_RETRY_TIMEOUT	"loop.retry-timeout"	/**< deprecated since 1.3.0 */
# else
#  defee PW_KEY_MEDIA_ROLE) this device
								  *  is particularly well suited for, due to
								  *  latency, quality or form factor. */
#define PW_KEY_DEVICE_CACHE_PARAMS	"device.cache-params"	/**< cache the device spa params */

/** module properties */
#define PW_KEY_MODULE_ID		"module.id"		/**< the module id */
#define PW_KEY_MODULE_NAME		"module.name"		/**< the name of the module */
#define PW_KEY_MODULE_AUTHOR		"module.author"		/**< the author's name */
#define PW_KEY_MODULE_DESCRIPTION	"module.description"	/**< a human readabf the graph as
								  *  a fraction. Ex: 1/48000 */
#define PW_KEY_NODE_LOCK_RATE		"node.lock-rate"	/**< don't change rate when this node
								  *  is active */
#define PW_KEY_NODE_FORCE_RATE		"node.force-rate"	/**< force a rate while the node is
								  *  active. A value of 0 takes the denominator
								  *  of node.rate */

#define PW_KEY_NODE_DONT_RECONNECT	"node.dont-reconnect"	/**< don't reconnect this node. The node is
								  *  initially linked to target.object or the
								  *  default node. If the target ise prefix directory */
#define PW_KEY_CONFIG_OVERRIDE_NAME	"config.override.name"	/**< a config override file name */

/* loop */
#define PW_KEY_LOOP_NAME		"loop.name"		/**< the name of a loop */
#define PW_KEY_LOOP_CLASS		"loop.class"		/**< the classes this loop handles, array of strings */
#define PW_KEY_LOOP_RT_PRIO		"loop.rt-prio"		/**< realtime priority of the loop */
#define PW_KEY_LOOP_CANCEL		"loop.cancel"		/**< if the loop can be canceled */

/* context */
#define PW_KEY_CONTEXT_PROFILE_MODULES	"context.profile.modules"	/**listener,
			  const struct pw_impl_node_rt_events *events,
			  void *data);
void pw_impl_node_remove_rt_listener(struct pw_impl_node *node,
			  struct spa_hook *listener);

/** Iterate the ports in the given direction. The callback should return
 * 0 to fetch the next item, any other value stops the iteration and returns
 * the value. When all callbacks return 0, this function returns 0 when all
 * items are iterated. */
int pw_impl_node_for_each_port(struct pw_impl_node *node,
			  enum pw_direction direction,
			  int (*callbaa port was removed */
        void (*port_removed) (void *data, struct pw_impl_port *port);

	/** the node info changed */
	void (*info_changed) (void *data, const struct pw_node_info *info);
	/** a port on the node changed info */
	void (*port_info_changed) (void *data, struct pw_impl_port *port,
			const struct pw_port_info *info);
	/** the node active state changed */
	void (*active_changed) (void *data, bool active);

	/** a new state is requested on the node */
	void (*state_request) (void *data, enum pw_node_state state);
	/*object. The W flag must be
				  *  present in order to call methods that modify the object. */
#define PW_PERM_M	0010	/**< metadata can be set on object, Since 0.3.9 */
#define PW_PERM_L	0020	/**< a link can be made between a node that doesn't have
				  *  permission to see the other node, Since 0.3.77 */

#define PW_PERM_RW	(PW_PERM_R|PW_PERM_W)
#define PW_PERM_RWX	(PW_PERM_RW|PW_PERM_X)
#define PW_PERM_RWXM	(PW_PERM_RWX|PW_PERM_M)
#define PW_PERM_RWXML	(PW_PERM_RWXM|PW_PERM_L)

#define PW_PERM_IS_R(p) (((p)&PW_PERM_R) == PW_PERegin_resource) (struct pw_resource *resource,
			uint8_t opcode, struct pw_protocol_native_message **msg);

	uint32_t (*add_resource_fd) (struct pw_resource *resource, int fd);
	int (*get_resource_fd) (struct pw_resource *resource, uint32_t index);

	int (*end_resource) (struct pw_resource *resource,
			     struct spa_pod_builder *builder);
};

#define pw_protocol_native_begin_proxy(p,...)		pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,begin_proxy,p,__VA_ARGS__)
#define pw_protocol_native_add_proxy_fd(p,..t *props);

/** Make a new thread loop with the given loop, name and optional properties.
 * When \a loop is NULL, a new loop will be created. */
struct pw_thread_loop *
pw_thread_loop_new_full(struct pw_loop *loop, const char *name, const struct spa_dict *props);

/** Destroy a thread loop */
void pw_thread_loop_destroy(struct pw_thread_loop *loop);

/** Add an event listener */
void pw_thread_loop_add_listener(struct pw_thread_loop *loop,
				 struct spa_hook *listener,
				 const struct pw_thread_loop_events *events,
				 void *	\
		char *strval = va_arg(args, char *);				\
		size_t len = va_arg(args, int);					\
		spa_pod_builder_string_len(builder, strval, len);		\
		break;								\
	}									\
	case 'y':								\
	{									\
		void *ptr  = va_arg(args, void *);				\
		int len = va_arg(args, int);					\
		spa_pod_builder_bytes(builder, ptr, len);			\
		break;								\
	}									\
	case 'R':								\
	{									\
		struct spa_rectangle *rectval =					\
			va_arg(args, struct spa_rectangle *);			\
		spa_pod_builder_rectangle(builder,				\
				rectval-> spa_pod_array p =
	    { {sizeof(struct spa_pod_array_body) - sizeof(struct spa_pod), SPA_TYPE_Array},
	    {{0, 0}} };
	uint32_t offset = builder->state.offset;
	int res = spa_pod_builder_raw(builder, &p, sizeof(p) - sizeof(struct spa_pod));
	spa_pod_builder_push(builder, frame, &p.pod, offset);
	return res;
}

SPA_API_POD_BUILDER int
spa_pod_builder_array(struct spa_pod_builder *builder,
		      uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems)
{
	const struct spa_pod_array p = {
		{(uint32_t)(sizeofd_pointer_body), SPA_TYPE_Pointer }, { (type), 0, (value) } })

SPA_API_POD_BUILDER int
spa_pod_builder_pointer(struct spa_pod_builder *builder, uint32_t type, const void *val)
{
	const struct spa_pod_pointer p = SPA_POD_INIT_Pointer(type, val);
	return spa_pod_builder_primitive(builder, &p.pod);
}

#define SPA_POD_INIT_Fd(fd) ((struct spa_pod_fd){ { sizeof(int64_t), SPA_TYPE_Fd }, (fd) })

SPA_API_POD_BUILDER int spa_pod_builder_fd(struct spa_pod_builder *builder, int64_t fd)
{
	const struct spa_pod_fd p = SPA_POD_INIT_Fd(fd);
	re data, size, NULL))
			data_offset = SPA_PTRDIFF(data, builder->data);

		res = -ENOSPC;
		if (offset <= builder->size)
			spa_callbacks_call_res(&builder->callbacks,
					struct spa_pod_builder_callbacks, res,
					overflow, 0, offset + size);
	}
	if (res == 0 && data) {
		if (data_offset != (size_t) -1)
			data = SPA_PTROFF(builder->data, data_offset, const void);

		memcpy(SPA_PTROFF(builder->data, offset, void), data, size);
	}

	builder->state.offset += size;

	for (f = builder->state.frame; f ; f = f->parent)
		f->pod.size +=_TOPIC_ENUM_DEFINE(__start_spa_log_topic, __stop_spa_log_topic)

/** \fn spa_log_error */

/** keys can be given when initializing the logger handle */
#define SPA_KEY_LOG_LEVEL		"log.level"		/**< the default log level */
#define SPA_KEY_LOG_COLORS		"log.colors"		/**< enable colors in the logger, set to "force" to enable
								  *  colors even when not logging to a terminal */
#define SPA_KEY_LOG_FILE		"log.file"		/**< log to the specified file instead of
								  *  stderr. */
#define SPA_KEY_LOG_TIMESTAMP		"log.timestamp"		/**pa_log_topic * const * const topics;
	/** End of topics array */
	struct spa_log_topic * const * const topics_end;
};


struct spa_log_methods {
#define SPA_VERSION_LOG_METHODS		1
	uint32_t version;
	/**
	 * Log a message with the given log level.
	 *
	 * \note If compiled with this header, this function is only called
	 * for implementations of version 0. For versions 1 and above, see
	 * logt() instead.
	 *
	 * \param log a spa_log
	 * \param level a spa_log_level
	 * \param file the file name
	 * \param line the line number
	 * T_ParamLatency, id,
			SPA_PARAM_LATENCY_direction, SPA_POD_Id(info->direction),
			SPA_PARAM_LATENCY_minQuantum, SPA_POD_Float(info->min_quantum),
			SPA_PARAM_LATENCY_maxQuantum, SPA_POD_Float(info->max_quantum),
			SPA_PARAM_LATENCY_minRate, SPA_POD_Int(info->min_rate),
			SPA_PARAM_LATENCY_maxRate, SPA_POD_Int(info->max_rate),
			SPA_PARAM_LATENCY_minNs, SPA_POD_Long(info->min_ns),
			SPA_PARAM_LATENCY_maxNs, SPA_POD_Long(info->max_ns));
}

SPA_API_LATENCY_UTILS int
spa_process_latency_parse(const struct spa_pod *latency, struc Data that will be copied into the internal ring buffer and made
 *             available to func. Because this data is copied, it is okay to
 *             pass a pointer to a local variable, but do not pass a pointer to
 *             an object that has identity.
 * \param size The size of data to copy.
 * \param block If \true, do not return until func has been called. Otherwise,
 *              returns immediately. Passing \true does not risk a deadlock because
 *              the data thread is never allowed to wait on any othata_loop_in_thread(struct pw_data_loop *loop);
/** Get the thread object */
struct spa_thread *pw_data_loop_get_thread(struct pw_data_loop *loop);

/** invoke func in the context of the thread or in the caller thread when
 * the loop is not running. May be called from the loop's thread, but otherwise
 * can only be called by a single thread at a time.
 * If called from the loop's thread, all callbacks previously queued with
 * pw_data_loop_invoke() will be run synchronously, which might cause
 * unexpected reentrancy problems.
 *
 Text: Copyright Â© 2022 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_UTILS_JSON_POD_H
#define SPA_UTILS_JSON_POD_H

#ifdef __cplusplus
extern "C" {
#endif

#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/pod/pod.h>
#include <spa/pod/builder.h>
#include <spa/debug/types.h>

#ifndef SPA_API_JSON_POD
 #ifdef SPA_API_IMPL
  #define SPA_API_JSON_POD SPA_API_IMPL
 #else
  #define SPA_API_JSON_POD static inline
 #endif
#endif

/** \defgroup spa_json_pod JSON to POD
 * JSON to POD conversion
 */

/SPA_AUDIO_CHANNEL_RC, }
#define SPA_AUDIO_LAYOUT_MPEG_7_1A	8, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \
					     SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_LFE, \
					     SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, \
					     SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR, }
#define SPA_AUDIO_LAYOUT_MPEG_7_1B	8, { SPA_AUDIO_CHANNEL_FC, SPA_AUDIO_CHANNEL_SL, \
					     SPA_AUDIO_CHANNEL_SR, SPA_AUDIO_CHANNEL_FL, \
					     SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_RL, \
					     SPA_AUDIO_CHANNEL_RR, SPA_AUDIO_CHANNEL_LFE, }
#deED
int pw_filter_get_time(struct pw_filter *filter, struct pw_time *time);

/** Get the current time in nanoseconds. This value can be compared with
 * the nsec value in the spa_io_position. RT safe. Since 1.1.0 */
uint64_t pw_filter_get_nsec(struct pw_filter *filter);

/** Get the data loop that is doing the processing of this filter. This loop
 * is assigned after pw_filter_connect(). Since 1.1.0 */
struct pw_loop *pw_filter_get_data_loop(struct pw_filter *filter);

/** Get a buffer that can be filled for output ports or consumed the duration of the buffer in ticks.
					  *  For output ports, this field is set by the user.
					  *  This field is added for all queued buffers and
					  *  returned in the time info. */
};
#endif

/** Events for a filter. These events are always called from the mainloop
 * unless explicitly documented otherwise. */
struct pw_filter_events {
#define PW_VERSION_FILTER_EVENTS	1
	uint32_t version;

	void (*destroy) (void *data);
	/** when the filter state changes. Since 1.4 this also sets errno when the
	 * new state is PW_FILTPipeWire filter object class
 *
 * The filter object provides a convenient way to implement
 * processing filters.
 *
 * See also \ref api_pw_core
 */

/**
 * \addtogroup pw_filter
 * \{
 */
struct pw_filter;

#include <spa/buffer/buffer.h>
#include <spa/node/io.h>
#include <spa/param/param.h>
#include <spa/pod/command.h>
#include <spa/pod/event.h>

#include <pipewire/core.h>
#include <pipewire/stream.h>

/** \enum pw_filter_state The state of a filter  */
enum pw_filter_state {
	PW_FILTER_STATE_ERROR = -1,		/**< the stream is in eroup pw_impl_metadata Metadata Impl
 *
 * The metadata is used to store key/type/value pairs per object id.
 */

/**
 * \addtogroup pw_impl_metadata
 * \{
 */
struct pw_impl_metadata;

#include <pipewire/context.h>
#include <pipewire/impl-client.h>
#include <pipewire/global.h>
#include <pipewire/properties.h>
#include <pipewire/resource.h>

#include "pipewire/extensions/metadata.h"

/** Metadata events, listen to them with \ref pw_impl_metadata_add_listener */
struct pw_impl_metadata_events {
#define PW_VERSION_IMPL_METADATA_EVENTSwith an id and are used to
	 * exchange state between client and server
	 *
	 * \param id the id of the io area
	 * \param mem_id the id of the memory to use
	 * \param offset offset of io area in memory
	 * \param size size of the io area
	 */
	int (*set_io) (void *data,
			uint32_t id,
			uint32_t mem_id,
			uint32_t offset,
			uint32_t size);
	/**
	 * Receive an event from the client node
	 * \param event the received event */
	int (*event) (void *data, const struct spa_event *event);
	/**
	 * Notify of a new node command
	 *
	 CE_BASE "ClientNode"

/*
 * version 4: new port_set_mix_info event added
 * version 5: driver nodes are scheduled on the client
 * version 6: client needs to set activation INACTIVE -> FINISHED
 */
#define PW_VERSION_CLIENT_NODE			6
struct pw_client_node;

#ifndef PW_API_CLIENT_NODE_IMPL
#define PW_API_CLIENT_NODE_IMPL static inline
#endif

#define PW_EXTENSION_MODULE_CLIENT_NODE		PIPEWIRE_MODULE_PREFIX "module-client-node"

/** information about a buffer */
struct pw_client_node_buffer {
	uint32_t mem_id;		/**< the memory id for t_ARGS__);		\
	_res;								\
})

#define pw_endpoint_add_listener(c,...)		pw_endpoint_method(c,add_listener,0,__VA_ARGS__)
#define pw_endpoint_subscribe_params(c,...)	pw_endpoint_method(c,subscribe_params,0,__VA_ARGS__)
#define pw_endpoint_enum_params(c,...)		pw_endpoint_method(c,enum_params,0,__VA_ARGS__)
#define pw_endpoint_set_param(c,...)		pw_endpoint_method(c,set_param,0,__VA_ARGS__)
#define pw_endpoint_create_link(c,...)		pw_endpoint_method(c,create_link,0,__VA_ARGS__)

/* Endpoint Stream */

#define PW_ENDPOINT_STREAM_EVENT_ num,
			const struct spa_pod *filter);

	/**
	 * Set a parameter on the session
	 *
	 * \param id the parameter id to set
	 * \param flags extra parameter flags
	 * \param param the parameter to set
	 *
	 * This requires X and W permissions.
	 */
	int (*set_param) (void *object, uint32_t id, uint32_t flags,
			  const struct spa_pod *param);
};

#define pw_session_method(o,method,version,...)				\
({									\
	int _res = -ENOTSUP;						\
	spa_interface_call_res((struct spa_interface*)o,		\
			struct pw_session_methods, _res,		\
	udio_info_ra {
	uint32_t rate;				/*< sample rate */
	uint32_t channels;			/*< number of channels */
};

#define SPA_AUDIO_INFO_RA_INIT(...)		((struct spa_audio_info_ra) { __VA_ARGS__ })

/**
 * \}
 */

#ifdef __cplusplus
}  /* extern "C" */
#endif

#endif /* SPA_AUDIO_RA_H */
/* PipeWire */
/* SPDX-FileCopyrightText: Copyright Â© 2019 Collabora Ltd. */
/*                         @author George Kiagiadakis <george.kiagiadakis@collabora.com> */
/* SPDX-License-Identifier: MIT */

#ifndef PIPEWIRE_EXT_SESSION_MANAGER_INTERFACES_H
#de);

/** Update the client permissions */
int pw_impl_client_update_permissions(struct pw_impl_client *client, uint32_t n_permissions,
		const struct pw_permission *permissions);

/** check if a client has permissions for global_id, Since 0.3.9 */
int pw_impl_client_check_permissions(struct pw_impl_client *client,
		uint32_t global_id, uint32_t permissions);

/** Get the client properties */
const struct pw_properties *pw_impl_client_get_properties(struct pw_impl_client *client);

/** Get the context used to create this client */
stnged between the client
 * and server will automatically be remapped.
 *
 * \section sec_page_client_impl_resources Resources
 *
 * When a client binds to context global object, a resource is made for this
 * binding and a unique id is assigned to the resources. The client and
 * server will use this id as the destination when exchanging messages.
 * See also \ref pw_resource
 */

/** \defgroup pw_impl_client Client Impl
 *
 * \brief PipeWire client object class
 *
 * The client object represents a client connection with the PipeWies)
{
	spa_return_val_if_fail(spa_pod_is_array(pod), NULL);
	*n_values = SPA_POD_ARRAY_N_VALUES(pod);
	return SPA_POD_ARRAY_VALUES(pod);
}

SPA_API_POD_ITER uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type,
		void *values, uint32_t max_values)
{
	uint32_t n_values;
	void *v = spa_pod_get_array(pod, &n_values);
	if (v == NULL || max_values == 0 || SPA_POD_ARRAY_VALUE_TYPE(pod) != type)
		return 0;
	n_values = SPA_MIN(n_values, max_values);
	memcpy(values, v, SPA_POD_ARRAY_VALUE_SIZE(pod) * n_values);
	return n_va_POD_CONTROL_SIZE(iter), 8), struct spa_pod_control);
}

#define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter)							\
	for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_array_body), void);	\
	     (body)->child.size > 0 && spa_ptrinside(body, _size, iter, (body)->child.size, NULL);	\
	     (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))

#define SPA_POD_ARRAY_FOREACH(obj, iter)							\
	SPA_POD_ARRAY_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)

#define SPA_POD_CHOICE_BODa_hook *hook,
					 const void *funcs, void *data)
{
	spa_zero(*hook);
	hook->cb = SPA_CALLBACKS_INIT(funcs, data);
	spa_list_prepend(&list->list, &hook->link);
}

/** Remove a hook */
SPA_API_HOOK void spa_hook_remove(struct spa_hook *hook)
{
	if (spa_list_is_initialized(&hook->link))
		spa_list_remove(&hook->link);
	if (hook->removed)
		hook->removed(hook);
}

/** Remove all hooks from the list */
SPA_API_HOOK void spa_hook_list_clean(struct spa_hook_list *list)
{
	struct spa_hook *h;
	spa_list_consume(h, &list->list, link)
		spahod_null_r(rtype,def,type,co,o,method,version,...)	\
({									\
	rtype _res = def;						\
	struct type *_co = co;						\
	if (SPA_LIKELY(_co != NULL)) {					\
		struct spa_interface *_i = o;				\
		spa_interface_call_res(_i, struct type ##_methods,	\
				_res, method, version, ##__VA_ARGS__);	\
	}								\
	_res;								\
})
#define spa_api_method_fast_v(type,o,method,version,...)		\
({									\
	struct spa_interface *_i = o;					\
	spa_interface_call_fast(_i, struct type ##_methods,		\
			method, version, ##__VA_ARGS__);		\
})
        methods->bar(myfoo, "Invoking bar() on myfoo");
 * }
 * \endcode
 *
 * The typecast used in `foo_bar()` allows `struct foo` to be opaque to the
 * caller. The implementation may assign the callback methods at object
 * instantiation, and the caller will transparently invoke the method on the
 * given object. For example, the following code assigns a different `bar()` method on
 * Mondays - the caller does not need to know this.
 * \code{.c}
 *
 * static void bar_stdout(struct foo *f, const char *msg) {
 *     printf(msg);
 ces
 *
 * \brief Generic implementation of implementation-independent interfaces
 *
 * A SPA Interface is a generic struct that, together with a few macros,
 * provides a generic way of invoking methods on objects without knowing the
 * details of the implementation.
 *
 * The primary interaction with interfaces is through macros that expand into
 * the right method call. For the implementation of an interface, we need two
 * structs and a macro to invoke the `bar` method:
 *
 * \code{.c}
 * // this struct must be public and define/
	SPA_META_TRANSFORMATION_Flipped270,	/**< flip then rotate around 270 degree counter-clockwise */
};

/** a transformation of the buffer */
struct spa_meta_videotransform {
	uint32_t transform;			/**< orientation transformation that was applied to the buffer,
						  *  one of enum spa_meta_videotransform_value */
};

/**
 * A timeline point for explicit sync
 *
 * Metadata to describe the time on the timeline when the buffer
 * can be acquired and when it can be reused.
 *
 * This metadata will require negotiation of 2 extra fds}

SPA_API_STRING char *spa_dtoa(char *str, size_t size, double val)
{
	int i, l;
	l = spa_scnprintf(str, size, "%f", val);
	for (i = 0; i < l; i++)
		if (str[i] == ',')
			str[i] = '.';
	return str;
}

struct spa_strbuf {
	char *buffer;
	size_t maxsize;
	size_t pos;
};

SPA_API_STRING void spa_strbuf_init(struct spa_strbuf *buf, char *buffer, size_t maxsize)
{
	buf->buffer = buffer;
	buf->maxsize = maxsize;
	buf->pos = 0;
	if (maxsize > 0)
		buf->buffer[0] = '\0';
}

SPA_PRINTF_FUNC(2, 3)
SPA_API_STRING int spa_strbuf_append(struc in the C locale.
 *
 * If \a endptr is not NULL, a pointer to the character after the last character
 * used in the conversion is stored in the location referenced by endptr.
 *
 * \return the result float.
 */
SPA_API_STRING float spa_strtof(const char *str, char **endptr)
{
#ifndef __LOCALE_C_ONLY
	static locale_t locale = NULL;
	locale_t prev;
#endif
	float v;
#ifndef __LOCALE_C_ONLY
	if (SPA_UNLIKELY(locale == NULL))
		locale = newlocale(LC_ALL_MASK, "C", NULL);
	prev = uselocale(locale);
#endif
	v = strtof(str, endptr);
#ifndart emitting
					  *  scheduling events */
	SPA_NODE_COMMAND_Enable,
	SPA_NODE_COMMAND_Disable,
	SPA_NODE_COMMAND_Flush,
	SPA_NODE_COMMAND_Drain,
	SPA_NODE_COMMAND_Marker,
	SPA_NODE_COMMAND_ParamBegin,	/**< begin a set of parameter enumerations or
					  *  configuration that require the device to
					  *  remain opened, like query formats and then
					  *  set a format */
	SPA_NODE_COMMAND_ParamEnd,	/**< end a transaction */
	SPA_NODE_COMMAND_RequestProcess,/**< Sent to a driver when some other node emitted
					  *  the RequesA_DATA_MemId,			/**< memory is identified with an id. The actual memory
					  *  can be obtained in some other way and can be identified
					  *  with this id. */
	SPA_DATA_SyncObj,		/**< a syncobj, usually requires a spa_meta_sync_timeline metadata
					  *  with timeline points. */

	_SPA_DATA_LAST,			/**< not part of ABI */
};

/** Chunk of memory, can change for each buffer */
struct spa_chunk {
	uint32_t offset;		/**< offset of valid data. Should be taken
					  *  modulo the data maxsize to get the offset
					  *  in the dglobal_add_listener(struct pw_global *global,
			    struct spa_hook *listener,
			    const struct pw_global_events *events,
			    void *data);

/** Get the permissions of the global for a given client */
uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_client *client);

/** Get the context object of this global */
struct pw_context *pw_global_get_context(struct pw_global *global);

/** Get the global type */
const char *pw_global_get_type(struct pw_global *global);

/** Check a global type */
bool pw_gthe proxy */
struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);

/** Generate an sync method for a proxy. This will generate a done event
 * with the same seq number of the reply. */
int pw_proxy_sync(struct pw_proxy *proxy, int seq);

/** Set the global id this proxy is bound to. This is usually used internally
 * and will also emit the bound event */
int pw_proxy_set_bound_id(struct pw_proxy *proxy, uint32_t global_id);
/** Get the global id bound to this proxy of SPA_ID_INVALID when not bound
 * to a global */
ui_LOG316,	/**< Logarithmic transfer characteristic 316.22777:1 range */
	SPA_VIDEO_TRANSFER_BT2020_12,	/**< Gamma 2.2 curve with a linear segment in the lower
					 *   range. Used for BT.2020 with 12 bits per
					 *   component. \since 1.6. */
	SPA_VIDEO_TRANSFER_ADOBERGB,	/**< Gamma 2.19921875. \since 1.8 */
};

/**
 * The color primaries define the how to transform linear RGB values to and from
 * the CIE XYZ colorspace.
 */
enum spa_video_color_primaries {
	SPA_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0,	/**< unknown color primaries */
op = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {
		info->flags |= SPA_VIDEO_FLAG_MODIFIER;
		if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)
			info->flags |= SPA_VIDEO_FLAG_MODIFIER_FIXATION_REQUIRED;
	}

	return spa_pod_parse_object(format,
		SPA_TYPE_OBJECT_Format, NULL,
		SPA_FORMAT_VIDEO_format,		SPA_POD_OPT_Id(&info->format),
		SPA_FORMAT_VIDEO_modifier,		SPA_POD_OPT_Long(&info->modifier));
}

SPA_API_VIDEO_DSP_UTILS struct spa_pod *
spa_format_video_dsp_builNVAL;

	switch (info->media_subtype) {
	case SPA_MEDIA_SUBTYPE_raw:
		return spa_format_audio_raw_parse(format, &info->info.raw);
	case SPA_MEDIA_SUBTYPE_dsp:
		return spa_format_audio_dsp_parse(format, &info->info.dsp);
	case SPA_MEDIA_SUBTYPE_iec958:
		return spa_format_audio_iec958_parse(format, &info->info.iec958);
	case SPA_MEDIA_SUBTYPE_dsd:
		return spa_format_audio_dsd_parse(format, &info->info.dsd);
	case SPA_MEDIA_SUBTYPE_mp3:
		return spa_format_audio_mp3_parse(format, &info->info.mp3);
	case SPA_MEDIA_SUBTYPE_aac:
		retct,
				    enum spa_log_level level,
				    const char *file,
				    int line,
				    const char *func,
				    const char *fmt, ...)
{
	va_list args;
	va_start(args, fmt);
	spa_log_impl_logv(object, level, file, line, func, fmt, args);
	va_end(args);
}

static inline void spa_log_impl_topic_init(void *object SPA_UNUSED, struct spa_log_topic *topic SPA_UNUSED)
{
	/* noop */
}

#define SPA_LOG_IMPL_DEFINE(name)		\
struct {					\
	struct spa_log log;			\
	struct spa_log_methods methods;		\
} name

#define SPA_LOG_IMPL_INIT(name)	r_t) (p)))
#define SPA_INT_TO_PTR(u) ((void*) ((intptr_t) (u)))

#define SPA_STRINGIFY_1(...)	#__VA_ARGS__
#define SPA_STRINGIFY(...)	SPA_STRINGIFY_1(__VA_ARGS__)

struct spa_error_location {
	int line;
	int col;
	size_t len;
	const char *location;
	const char *reason;
};

#define spa_return_if_fail(expr)					\
	do {								\
		if (SPA_UNLIKELY(!(expr))) {				\
			fprintf(stderr, "'%s' failed at %s:%u %s()\n",	\
				#expr , __FILE__, __LINE__, __func__);	\
			return;						\
		}							\
	} while(false)

#define spa_return_val_if_faiay[16];
 * struct foo *f;
 * SPA_FOR_EACH_ELEMENT(array, f) {
 *	f->bar = baz;
 * }
 * ```
 */
#define SPA_FOR_EACH_ELEMENT(arr, ptr) \
	for ((ptr) = arr; (ptr) < (arr) + SPA_N_ELEMENTS(arr); (ptr)++)

#define SPA_FOR_EACH_ELEMENT_VAR(arr, var) \
	for (__typeof__((arr)[0])* var = arr; (var) < (arr) + SPA_N_ELEMENTS(arr); (var)++)

#define SPA_ABS(a)			\
({					\
	__typeof__(a) _a = (a);		\
	SPA_LIKELY(_a >= 0) ? _a : -_a;	\
})
#define SPA_MIN(a,b)					\
({							\
	__typeof__(a) _min_a = (a);			\
	__typeof__(b) _min_b = (b);			\
	Se SPA_ALIGNOF __alignof__
#endif

#define SPA_STATIC_ASSERT(expr, ...) SPA_STATIC_ASSERT_IMPL(expr, ## __VA_ARGS__, "`" #expr "` evaluated to false")

#define SPA_CONCAT_NOEXPAND(a, b) a ## b
#define SPA_CONCAT(a, b) SPA_CONCAT_NOEXPAND(a, b)

#include <inttypes.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdio.h>

/**
 * \defgroup spa_utils_defs Miscellaneous
 * Helper macros and functions
 */

/**
 * \addtogroup spa_utils_defs
 * \{
 */

/**
 * SPA_FALLTHROUGH is an annotation to sLIKELY(pw_map_check_id(map, id))) {
		union pw_map_item *item = pw_map_get_item(map, id);
		if (!pw_map_item_is_free(item))
			return item->data;
	}
	return NULL;
}

/** Iterate all map items
 * \param map the map to iterate
 * \param func the function to call for each item, the item data and \a data is
 *		passed to the function. When \a func returns a non-zero result,
 *		iteration ends and the result is returned.
 * \param data data to pass to \a func
 * \return the result of the last call to \a func or 0 when all callbacks retu>1)

/** Initialize a map
 * \param map the map to initialize
 * \param size the initial size of the map
 * \param extend the amount to bytes to grow the map with when needed
 */
PW_API_MAP void pw_map_init(struct pw_map *map, size_t size, size_t extend)
{
	pw_array_init(&map->items, extend * sizeof(union pw_map_item));
	pw_array_ensure_size(&map->items, size * sizeof(union pw_map_item));
	map->free_list = SPA_ID_INVALID;
}

/** Clear a map and free the data storage. All previously returned ids
 * must be treated as invalid.
 */
PW= close(_old_value); \
	_res; \
})

/* ========================================================================== */

#if defined(__has_attribute) && __has_attribute(__cleanup__)

#define spa_cleanup(func) __attribute__((__cleanup__(func)))

#define SPA_DEFINE_AUTO_CLEANUP(name, type, ...) \
typedef __typeof__(type) _spa_auto_cleanup_type_ ## name; \
static inline void _spa_auto_cleanup_func_ ## name (__typeof__(type) *thing) \
{ \
	int _save_errno = errno; \
	__VA_ARGS__ \
	errno = _save_errno; \
}

#define spa_auto(name) \
	spa_cvents, &data);
	if (res >= 0) {
		res = spa_node_port_enum_params(node, 0, direction, port_id,
				id, *index, 1, filter);
		spa_hook_remove(&listener);
	}

	if (data.data.param == NULL) {
		if (res > 0)
			res = 0;
	} else {
		*index = data.data.next;
		*param = data.data.param;
		res = 1;
	}
	return res;
}

#define spa_node_emit(hooks,method,version,...)					\
		spa_hook_list_call_simple(hooks, struct spa_node_events,	\
				method, version, ##__VA_ARGS__)

#define spa_node_emit_info(hooks,...)		spa_node_emit(hooks,info, 0, __VA_At struct spa_result_node_params *) result;
	uint32_t offset = d->builder->state.offset;
	if (spa_pod_builder_raw_padded(d->builder, r->param, SPA_POD_SIZE(r->param)) < 0)
		return;
	d->data.next = r->next;
	d->data.param = spa_pod_builder_deref(d->builder, offset);
}

SPA_API_NODE_UTILS int spa_node_enum_params_sync(struct spa_node *node,
			uint32_t id, uint32_t *index,
			const struct spa_pod *filter,
			struct spa_pod **param,
			struct spa_pod_builder *builder)
{
	struct spa_result_node_params_data data = { builder, {0}};
	stru struct spa_pod_builder *b,
			struct spa_pod **param);
	int (*get_props) (void *object, struct spa_pod_builder *b, struct spa_pod **props);
	int (*set_props) (void *object, enum spa_direction direction, const struct spa_pod *props);

	int (*activate) (void *object, const struct spa_dict *props);
	int (*deactivate) (void *object);

	int (*reset) (void *object);

	int (*process) (void *object, const void *in[], void *out[], uint32_t n_samples);
};

SPA_API_FILTER_GRAPH int spa_filter_graph_add_listener(struct spa_filter_graph *objecME_API_ALSA_COMPRESS_OFFLOAD_SINK		"api.alsa.compress.offload.sink"	/**< an alsa Node interface for
												  * compressed audio */

/** keys for bluez5 factory names */
#define SPA_NAME_API_BLUEZ5_ENUM_DBUS	"api.bluez5.enum.dbus"		/**< a dbus Device interface */
#define SPA_NAME_API_BLUEZ5_DEVICE	"api.bluez5.device"		/**< a Device interface */
#define SPA_NAME_API_BLUEZ5_MEDIA_SINK	"api.bluez5.media.sink"		/**< a playback Node interface for A2DP/BAP profiles */
#define SPA_NAME_API_BLUEZ5_MEDIA_SOURCE	"api.bluez5.media.source"/**< mixes the raw audio on N input
									  *  ports together on the output
									  *  port */
#define SPA_NAME_AUDIO_MIXER_DSP	"audio.mixer.dsp"		/**< mixes mono audio with fixed input
									  *  and output buffer sizes. supported
									  *  formats must include f32 and
									  *  optionally f64 and s24_32 */

/** audio processing */
#define SPA_NAME_AUDIO_PROCESS_FORMAT	"audio.process.format"		/**< processes raw audio from one format
									  *  to another */
#define SPA_NAME_AUDIO_PROCESS_CHANNELMIX	\
					"audiANNEL_FC,           /**< front center */
	SPA_AUDIO_CHANNEL_LFE,          /**< LFE */
	SPA_AUDIO_CHANNEL_SL,           /**< side left */
	SPA_AUDIO_CHANNEL_SR,           /**< side right */
	SPA_AUDIO_CHANNEL_FLC,          /**< front left center */
	SPA_AUDIO_CHANNEL_FRC,          /**< front right center */
	SPA_AUDIO_CHANNEL_RC,           /**< rear center */
	SPA_AUDIO_CHANNEL_RL,           /**< rear left */
	SPA_AUDIO_CHANNEL_RR,           /**< rear right */
	SPA_AUDIO_CHANNEL_TC,           /**< top center */
	SPA_AUDIO_CHANNEL_TFORMAT_U24_BE,
	SPA_AUDIO_FORMAT_S20_LE,
	SPA_AUDIO_FORMAT_S20_BE,
	SPA_AUDIO_FORMAT_U20_LE,
	SPA_AUDIO_FORMAT_U20_BE,
	SPA_AUDIO_FORMAT_S18_LE,
	SPA_AUDIO_FORMAT_S18_BE,
	SPA_AUDIO_FORMAT_U18_LE,
	SPA_AUDIO_FORMAT_U18_BE,
	SPA_AUDIO_FORMAT_F32_LE,
	SPA_AUDIO_FORMAT_F32_BE,
	SPA_AUDIO_FORMAT_F64_LE,
	SPA_AUDIO_FORMAT_F64_BE,

	SPA_AUDIO_FORMAT_ULAW,
	SPA_AUDIO_FORMAT_ALAW,

	/* planar formats */
	SPA_AUDIO_FORMAT_START_Planar		= 0x200,
	SPA_AUDIO_FORMAT_U8P,
	SPA_AUDIO_FORMAT_S16P,
	SPA_AUDIO_FORMAT_S24_32P,
	SPA_AUDIO_FORMAT_S32P,
 enum_params and then
	 * modified but it is also possible to set another spa_pod
	 * as long as its keys and types match a supported object.
	 *
	 * Objects with property keys that are not known are ignored.
	 *
	 * This function must be called from the main thread.
	 *
	 * \param object \ref spa_device
	 * \param id the parameter id to configure
	 * \param flags additional flags
	 * \param param the parameter to configure
	 *
	 * \return 0 on success
	 *         -EINVAL when invalid arguments are given
	 *         -ENOTSUP when tA_TYPE_INTERFACE_Device	SPA_TYPE_INFO_INTERFACE_BASE "Device"

#define SPA_VERSION_DEVICE		0
struct spa_device { struct spa_interface iface; };

/**
 * Information about the device and parameters it supports
 *
 * This information is part of the info event on a device.
 */
struct spa_device_info {
#define SPA_VERSION_DEVICE_INFO 0
	uint32_t version;

#define SPA_DEVICE_CHANGE_MASK_FLAGS		(1u<<0)
#define SPA_DEVICE_CHANGE_MASK_PROPS		(1u<<1)
#define SPA_DEVICE_CHANGE_MASK_PARAMS		(1u<<2)
	uint64_t change_mask;
	uint64_t flags;
	consformat != SPA_AUDIO_FORMAT_UNKNOWN)
		spa_pod_builder_add(builder,
			SPA_FORMAT_AUDIO_format,	SPA_POD_Id(info->format), 0);
	if (info->rate != 0)
		spa_pod_builder_add(builder,
			SPA_FORMAT_AUDIO_rate,		SPA_POD_Int(info->rate), 0);
	if (info->channels != 0) {
		spa_pod_builder_add(builder,
			SPA_FORMAT_AUDIO_channels,	SPA_POD_Int(info->channels), 0);
		if (!SPA_FLAG_IS_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
			spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_position,
				SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Id,
					n \a size.
 *
 * \param rbuf a struct \ref spa_ringbuffer
 * \param buffer memory to read from
 * \param size the size of \a buffer
 * \param offset offset in \a buffer to read from
 * \param data destination memory
 * \param len number of bytes to read
 */
SPA_API_RINGBUFFER void
spa_ringbuffer_read_data(struct spa_ringbuffer *rbuf SPA_UNUSED,
			 const void *buffer, uint32_t size,
			 uint32_t offset, void *data, uint32_t len)
{
	uint32_t l0 = SPA_MIN(len, size - offset), l1 = len - l0;
	spa_memcpy(data, SPA_PTROFF(buffer, offsetDEFAULT my_topic
 *
 *  void foo() {
 *      pw_log_debug("bar");
 *  }
 * \endcode
 *
 * This macro also emits GCC attribute constructor/destructor
 * functions that automatically call pw_log_topic_register/unregister.
 */
#define PW_LOG_TOPIC_STATIC(var, topic) \
  PW_LOG_TOPIC_DEFINE_STATIC(var ## _value, topic) \
  static struct spa_log_topic * const var = &(var ## _value)

/**
 * Declare a static log topic named \a var.
 * See \ref PW_LOG_TOPIC_STATIC for an example usage.
 */
#define PW_LOG_TOPIC_EXTERN(var) \
  extern structfer *buffer);

/** Return a buffer to the queue without using it. This makes the buffer
 * immediately available to dequeue again. RT safe. */
int pw_stream_return_buffer(struct pw_stream *stream, struct pw_buffer *buffer);

/** Activate or deactivate the stream */
int pw_stream_set_active(struct pw_stream *stream, bool active);

/** Flush a stream. When \a drain is true, the drained callback will
 * be called when all data is played or recorded. The stream can be resumed
 * after the drain by setting it active again with
 * \ref p;

const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);

int pw_stream_update_properties(struct pw_stream *stream, const struct spa_dict *dict);

/** Connect a stream for input or output on \a port_path.
 * \return 0 on success < 0 on error.
 *
 * You should connect to the process event and use pw_stream_dequeue_buffer()
 * to get the latest metadata and data. */
int
pw_stream_connect(struct pw_stream *stream,		/**< a \ref pw_stream */
		  enum pw_direction direction,		/**< the stream direction */
		  uintroyed for this stream */
        void (*remove_buffer) (void *data, struct pw_buffer *buffer);

        /** when a buffer can be queued (for playback streams) or
         *  dequeued (for capture streams). This is normally called from the
	 *  mainloop but can also be called directly from the realtime data
	 *  thread if the user is prepared to deal with this. */
        void (*process) (void *data);

	/** The stream is drained */
        void (*drained) (void *data);

	/** A command notify, Since 0.3.39:1 */
	void (*command) (voialue, and pw_time.ticks, were captured at pw_time.now and can be extrapolated
 * to the current time like this:
 *
 *\code{.c}
 *    uint64_t now = pw_stream_get_nsec(stream);
 *    int64_t diff = now - pw_time.now;
 *    int64_t elapsed = (pw_time.rate.denom * diff) / (pw_time.rate.num * SPA_NSEC_PER_SEC);
 *\endcode
 *
 * pw_time.delay contains the total delay that a signal will travel through the
 * graph. This includes the delay caused by filters in the graph as well as delays
 * caused by the hardware. The delay is usually quiref pw_time. See
 * the documentation of these functions.
 *
 * \section sec_stream_driving Driving the graph
 *
 * Starting in 0.3.34, it is possible for a stream to drive the graph.
 * This allows interrupt-driven scheduling for drivers implemented as
 * PipeWire streams, without having to reimplement the stream as a SPA
 * plugin.
 *
 * A stream cannot drive the graph unless it is in the
 * \ref PW_STREAM_STATE_STREAMING state and \ref pw_stream_is_driving() returns
 * true. It must then use pw_stream_trigger_process() to start eams" are used to exchange data with the
 * PipeWire server. A stream is a wrapper around a proxy for a pw_client_node
 * with an adapter. This means the stream will automatically do conversion
 * to the type required by the server.
 *
 * Streams can be used to:
 *
 * \li Consume a stream from PipeWire. This is a PW_DIRECTION_INPUT stream.
 * \li Produce a stream to PipeWire. This is a PW_DIRECTION_OUTPUT stream
 *
 * You can connect the stream port to a specific server port or let PipeWire
 * choose a port for you.
 *
 * For more * Notify a port param
	 *
	 * Event emitted as a result of the enum_params method.
	 *
	 * \param seq the sequence number of the request
	 * \param id the param id
	 * \param index the param index
	 * \param next the param index of the next param
	 * \param param the parameter
	 */
	void (*param) (void *data, int seq,
		       uint32_t id, uint32_t index, uint32_t next,
		       const struct spa_pod *param);
};

#define PW_PORT_METHOD_ADD_LISTENER	0
#define PW_PORT_METHOD_SUBSCRIBE_PARAMS	1
#define PW_PORT_METHOD_ENUM_PARAMS	2
#def, init, 1, handle, info,
			support, n_support);
}
SPA_API_PLUGIN int
spa_handle_factory_enum_interface_info(const struct spa_handle_factory *object,
		const struct spa_interface_info **info, uint32_t *index)
{
	return spa_api_func_r(int, -ENOTSUP, object, enum_interface_info, 1,
			info, index);
}

/**
 * The function signature of the entry point in a plugin.
 *
 * \param factory a location to hold the factory result
 * \param index index to keep track of the enumeration
 * \return 1 on success
 *         0 when there are no more e. */
	int32_t seq;			/**< private seq field. You can use this to keep
					  *  state of a pending update. */
	uint32_t padding[4];
};

#define SPA_PARAM_INFO(id,flags) ((struct spa_param_info){ (id), (flags) })

enum spa_param_bitorder {
	SPA_PARAM_BITORDER_unknown,	/**< unknown bitorder */
	SPA_PARAM_BITORDER_msb,		/**< most significant bit */
	SPA_PARAM_BITORDER_lsb,		/**< least significant bit */
};

enum spa_param_availability {
	SPA_PARAM_AVAILABILITY_unknown,	/**< unknown availability */
	SPA_PARAM_AVAILABILITY_no,	/**< not< 0 otherwise with an errno style error
 *
 * A module should provide an init function with this signature. This function
 * will be called when a module is loaded.
 */
typedef int (*pw_impl_module_init_func_t) (struct pw_impl_module *module, const char *args);

/** Module events added with \ref pw_impl_module_add_listener */
struct pw_impl_module_events {
#define PW_VERSION_IMPL_MODULE_EVENTS	0
	uint32_t version;

	/** The module is destroyed. This is the time to unregister and
	 * destroy any objects created by the module. */
	vo_memmap * pw_mempool_find_tag(struct pw_mempool *pool, uint32_t tag[5], size_t size);

/** Unmap a region */
int pw_memmap_free(struct pw_memmap *map);


/** parameters to map a memory range */
struct pw_map_range {
	uint32_t start;		/** offset in first page with start of data */
	uint32_t offset;	/** page aligned offset to map */
	uint32_t size;		/** size to map */
};

#define PW_MAP_RANGE_INIT (struct pw_map_range){ 0, }

/** Calculate parameters to mmap() memory into \a range so that
 * \a size bytes at \a offset can be mapped wern "C" {
#endif

#ifndef PW_API_MEM
#define PW_API_MEM static inline
#endif

/** \defgroup pw_memblock Memory Blocks
 * Memory allocation and pools.
 */

/**
 * \addtogroup pw_memblock
 * \{
 */

/** Flags passed to \ref pw_mempool_alloc() */
enum pw_memblock_flags {
	PW_MEMBLOCK_FLAG_NONE =		0,
	PW_MEMBLOCK_FLAG_READABLE =	(1 << 0),	/**< memory is readable */
	PW_MEMBLOCK_FLAG_WRITABLE =	(1 << 1),	/**< memory is writable */
	PW_MEMBLOCK_FLAG_SEAL =		(1 << 2),	/**< seal the fd */
	PW_MEMBLOCK_FLAG_MAP =		(1 << 3),	/**< mmap the fdDEO_FORMAT_BASE "GBR_10BE", NULL },
	{ SPA_VIDEO_FORMAT_GBR_10LE,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "GBR_10LE", NULL },
	{ SPA_VIDEO_FORMAT_NV16,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "NV16", NULL },
	{ SPA_VIDEO_FORMAT_NV24,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "NV24", NULL },
	{ SPA_VIDEO_FORMAT_NV12_64Z32,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "NV12_64Z32", NULL },
	{ SPA_VIDEO_FORMAT_A420_10BE,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "A420_10BE", NULL },
	{ SPA_VIDEO_FORMAT_A420_10LE,	ine SPA_API_VIDEO_RAW_TYPES static inline
 #endif
#endif

#define SPA_TYPE_INFO_VideoFormat		SPA_TYPE_INFO_ENUM_BASE "VideoFormat"
#define SPA_TYPE_INFO_VIDEO_FORMAT_BASE		SPA_TYPE_INFO_VideoFormat ":"

static const struct spa_type_info spa_type_video_format[] = {
	{ SPA_VIDEO_FORMAT_UNKNOWN,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "UNKNOWN", NULL },
	{ SPA_VIDEO_FORMAT_ENCODED,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "ENCODED", NULL },
	{ SPA_VIDEO_FORMAT_I420,	SPA_TYPE_Int, SPA_TYPE_INFO_VIDEO_FORMAT_BASE "I420", NULLCT_ParamProcessLatency
 *
 * The processing latency indicates logical time delay between a sample in an input port,
 * and a corresponding sample in an output port, relative to the graph time.
 */
enum spa_param_process_latency {
	SPA_PARAM_PROCESS_LATENCY_START,
	SPA_PARAM_PROCESS_LATENCY_quantum,	/**< latency relative to quantum (Float) */
	SPA_PARAM_PROCESS_LATENCY_rate,		/**< latency (Int) relative to graph rate */
	SPA_PARAM_PROCESS_LATENCY_ns,		/**< latency (Long) in nanoseconds */
};

/** Helper structure for managing procesvideo_chroma_site chroma_site;			/**< the chroma siting */
	enum spa_video_color_range color_range;			/**< the color range. This is the valid range for the samples.
								 *   It is used to convert the samples to Y'PbPr values. */
	enum spa_video_color_matrix color_matrix;		/**< the color matrix. Used to convert between Y'PbPr and
								 *   non-linear RGB (R'G'B') */
	enum spa_video_transfer_function transfer_function;	/**< the transfer function. used to convert between R'G'B' and RGB */
	enum spa_video_color_primaries color_ppw_get_host_name(void);

const char *
pw_get_client_name(void);

bool pw_check_option(const char *option, const char *value);

enum pw_direction
pw_direction_reverse(enum pw_direction direction);

int pw_set_domain(const char *domain);
const char *pw_get_domain(void);

uint32_t pw_get_support(struct spa_support *support, uint32_t max_support);

struct spa_handle *pw_load_spa_handle(const char *lib,
		const char *factory_name,
		const struct spa_dict *info,
		uint32_t n_support,
		const struct spa_support support[]);

int pw_unload_UDIO_interleave,		/**< Interleave bytes (Int) */
	SPA_FORMAT_AUDIO_bitrate,		/**< bit rate (Int) */
	SPA_FORMAT_AUDIO_blockAlign,    	/**< audio data block alignment (Int) */

	SPA_FORMAT_AUDIO_AAC_streamFormat,	/**< AAC stream format, (Id enum spa_audio_aac_stream_format) */

	SPA_FORMAT_AUDIO_WMA_profile,		/**< WMA profile (Id enum spa_audio_wma_profile) */

	SPA_FORMAT_AUDIO_AMR_bandMode,		/**< AMR band mode (Id enum spa_audio_amr_band_mode) */


	/* Video Format keys */
	SPA_FORMAT_START_Video = 0x20000,
	SPA_FORMAT_VIDEO_forma,
	SPA_MEDIA_SUBTYPE_control,		/**< control stream, data contains
						  *  spa_pod_sequence with control info. */
};

/** properties for audio SPA_TYPE_OBJECT_Format */
enum spa_format {
	SPA_FORMAT_START,

	SPA_FORMAT_mediaType,		/**< media type (Id enum spa_media_type) */
	SPA_FORMAT_mediaSubtype,	/**< media subtype (Id enum spa_media_subtype) */

	/* Audio format keys */
	SPA_FORMAT_START_Audio = 0x10000,
	SPA_FORMAT_AUDIO_format,		/**< audio format, (Id enum spa_audio_format) */
	SPA_FORMAT_AUDIO_flags,			/**< optional flags IVIEW_FLAGS_RIGHT_FLOPPED = (1 << 4),	/**< The right view is horizontally mirrored */
	SPA_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT = (1 << 14),	/**< For frame-packed multiview
								 *   modes, indicates that the individual
								 *   views have been encoded with half the true
								 *   width or height and should be scaled back
								 *   up for display. This flag is used for
								 *   overriding input layout interpretation
								 *   by adjusting pixel-aspect-ratio.
								 *   For side-by-side, column interleaved or
				esentations.
 * In conjunction with \ref spa_video_multiview_flags, describes how
 * multiview content is being transported in the stream.
 */
enum spa_video_multiview_mode {
	/** A special value indicating no multiview information. Used in spa_video_info and other
	 * places to indicate that no specific multiview handling has been requested or provided.
	 * This value is never carried on caps. */
	SPA_VIDEO_MULTIVIEW_MODE_NONE = -1,
	SPA_VIDEO_MULTIVIEW_MODE_MONO = 0,		/**< All frames are monoscopic */
	/* Single view modes */
	SP_prop *p1, *p2;

				if (SPA_POD_TYPE(pf) != SPA_POD_TYPE(pp))
					return -EINVAL;

				spa_pod_builder_push_object(b, &f, op->body.type, op->body.id);
				p2 = NULL;
				SPA_POD_OBJECT_FOREACH(op, p1) {
					p2 = spa_pod_object_find_prop(of, p2, p1->key);
					if (p2 != NULL)
						res = spa_pod_filter_prop(b, p1, p2);
					else if ((p1->flags & SPA_POD_PROP_FLAG_MANDATORY) != 0)
						res = -EINVAL;
					else
						spa_pod_builder_raw_padded(b, p1, SPA_POD_PROP_SIZE(p1));
					if (res < 0)
						break;
				}
				if (res >= 0) {
PA_CHOICE_Enum && p2c == SPA_CHOICE_None) ||
	    (p1c == SPA_CHOICE_Enum && p2c == SPA_CHOICE_Enum)) {
		int n_copied = 0;
		/* copy all equal values but don't copy the default value again */
		for (j = 0, a2 = alt2; j < nalt2; j++, a2 = SPA_PTROFF(a2, size, void)) {
			for (k = 0, a1 = alt1; k < nalt1; k++, a1 = SPA_PTROFF(a1,size,void)) {
				if (spa_pod_compare_value(type, a1, a2, size) == 0) {
					if (p2c == SPA_CHOICE_Enum || j > 0)
						spa_pod_builder_raw(b, a1, size);
					n_copied++;
				}
			}
		}
		if (n_copied == 0)
= v - 'a' + 10;
		else if (v >= 'A' && v <= 'F')
			v = v - 'A' + 10;
		else
			return -1;
		*res = (*res << 4) | v;
	}
	return 1;
}

SPA_API_JSON int spa_json_parse_stringn(const char *val, int len, char *result, int maxlen)
{
	const char *p;
	if (maxlen <= len)
		return -ENOSPC;
	if (!spa_json_is_string(val, len)) {
		if (result != val)
			memmove(result, val, len);
		result += len;
	} else {
		for (p = val+1; p < val + len; p++) {
			if (*p == '\\') {
				p++;
				if (*p == 'n')
					*result++ = '\n';
				else if (*p == 'r')
			A_ERROR

error:
	iter->state = err;
	while (iter->parent) {
		if (iter->parent->state & SPA_JSON_ERROR_FLAG)
			break;
		iter->parent->state = err;
		iter->parent->cur = iter->cur;
		iter = iter->parent;
	}
	return -1;
}

/**
 * Return if there was a parse error, and its possible location.
 *
 * \since 1.1.0
 */
SPA_API_JSON bool spa_json_get_error(struct spa_json *iter, const char *start,
		struct spa_error_location *loc)
{
	static const char *reasons[] = {
		"System error",
		"Invalid array separator",
		"Expected object key",
		; goto error; }
 again:
		flag = iter->state & __FLAGS;
		switch (iter->state & ~__FLAGS) {
		case __NONE:
			flag &= ~(__KEY_FLAG | __PREV_ARRAY_FLAG);
			iter->state = __STRUCT | flag;
			iter->depth = 0;
			goto again;
		case __STRUCT:
			switch (cur) {
			case '\0': case '\t': case ' ': case '\r': case '\n': case ',':
				continue;
			case ':': case '=':
				if (flag & __ARRAY_FLAG)
					_SPA_ERROR(INVALID_ARRAY_SEPARATOR);
				if (!(flag & __KEY_FLAG))
					_SPA_ERROR(EXPECTED_OBJECT_KEY);
				iter->state |= __SUB_FLAG;
				co_info {
		struct pw_properties *props_storage;
		struct pw_endpoint_link_info info;
	} *ext = SPA_CONTAINER_OF(info, struct extended_info, info);

	pw_properties_free(ext->props_storage);
	free(info->error);
	free((void *) info->params);
	free(ext);
}

/**
 * \}
 */

#ifdef __cplusplus
}  /* extern "C" */
#endif

#endif /* PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H */
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright Â© 2021 Red Hat, Inc. */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_UTILS_ANSI_H
#define SPA_UT;
		pw_properties_update(ext->props_storage, update->props);
	}
	if (update->change_mask & PW_SESSION_CHANGE_MASK_PARAMS) {
		info->n_params = update->n_params;
		free((void *) info->params);
		if (update->params) {
			size_t size = info->n_params * sizeof(struct spa_param_info);
			info->params = (struct spa_param_info *) malloc(size);
			memcpy(info->params, update->params, size);
		}
		else
			info->params = NULL;
	}
	return info;
}

static inline void
pw_session_info_free (struct pw_session_info *info)
{
	struct extended_info {stener, 0,
			listener, events, data);
}
/** \copydoc pw_device_methods.subscribe_params
 * \sa pw_device_methods.subscribe_params */
PW_API_DEVICE_IMPL int pw_device_subscribe_params(struct pw_device *object, uint32_t *ids, uint32_t n_ids)
{
	return spa_api_method_r(int, -ENOTSUP,
			pw_device, (struct spa_interface*)object, subscribe_params, 0,
			ids, n_ids);
}
/** \copydoc pw_device_methods.enum_params
 * \sa pw_device_methods.enum_params */
PW_API_DEVICE_IMPL int pw_device_enum_params(struct pw_device *object,
		int seq, uint3CE_METHOD_NUM			4

/** Device methods */
struct pw_device_methods {
#define PW_VERSION_DEVICE_METHODS	0
	uint32_t version;

	int (*add_listener) (void *object,
			struct spa_hook *listener,
			const struct pw_device_events *events,
			void *data);
	/**
	 * Subscribe to parameter changes
	 *
	 * Automatically emit param events for the given ids when
	 * they are changed.
	 *
	 * \param ids an array of param ids
	 * \param n_ids the number of ids in \a ids
	 *
	 * This requires X permissions on the device.
	 */
	int (*subscribe_param },
	{ SPA_PARAM_BUFFERS_metaType, SPA_TYPE_Int, SPA_TYPE_INFO_PARAM_BLOCK_INFO_BASE "metaType", NULL },
	{ 0, 0, NULL, NULL },
};

/**
 * \}
 */

#ifdef __cplusplus
}  /* extern "C" */
#endif

#endif /* SPA_PARAM_BUFFERS_TYPES_H */
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright Â© 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_DEBUG_NODE_H
#define SPA_DEBUG_NODE_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \addtogroup spa_debug
 * \{
 */

#include <spa/node/node.h>
#include <spa/debug/contexr)

#define spa_list_prev(pos, member)					\
	SPA_CONTAINER_OF((pos)->member.prev, __typeof__(*(pos)), member)

#define spa_list_consume(pos, head, member)				\
	for ((pos) = spa_list_first(head, __typeof__(*(pos)), member);	\
	     !spa_list_is_empty(head);					\
	     (pos) = spa_list_first(head, __typeof__(*(pos)), member))

#define spa_list_for_each_next(pos, head, curr, member)			\
	for ((pos) = spa_list_first(curr, __typeof__(*(pos)), member);	\
	     !spa_list_is_end(pos, head, member);			\
	     (pos) = spa_list_next(pos, m_BASE "Buffer", NULL },
	{ SPA_TYPE_POINTER_Meta, SPA_TYPE_Pointer, SPA_TYPE_INFO_POINTER_BASE "Meta", NULL },
	{ SPA_TYPE_POINTER_Dict, SPA_TYPE_Pointer, SPA_TYPE_INFO_POINTER_BASE "Dict", NULL },

	{ SPA_TYPE_EVENT_START, SPA_TYPE_Object, SPA_TYPE_INFO_Event, NULL },
	{ SPA_TYPE_EVENT_Device, SPA_TYPE_Object, SPA_TYPE_INFO_EVENT_BASE "Device", spa_type_device_event },
	{ SPA_TYPE_EVENT_Node, SPA_TYPE_Object, SPA_TYPE_INFO_EVENT_BASE "Node", spa_type_node_event },

	{ SPA_TYPE_COMMAND_START, SPA_TYPE_Object, SPA_TYPE_INFO_Command,{
#endif

#include <spa/utils/type-info.h>

#include <spa/monitor/event.h>

/**
 * \addtogroup spa_device
 * \{
 */

#define SPA_TYPE_INFO_DeviceEvent		SPA_TYPE_INFO_EVENT_BASE "Device"
#define SPA_TYPE_INFO_DEVICE_EVENT_BASE		SPA_TYPE_INFO_DeviceEvent ":"

#define SPA_TYPE_INFO_DeviceEventId		SPA_TYPE_INFO_ENUM_BASE "DeviceEventId"
#define SPA_TYPE_INFO_DEVICE_EVENT_ID_BASE	SPA_TYPE_INFO_DeviceEventId ":"

static const struct spa_type_info spa_type_device_event_id[] = {
	{ SPA_DEVICE_EVENT_ObjectConfig, SPA_TYPE_EVENT_Device, SPA_O_META_BASE "Region"
#define SPA_TYPE_INFO_META_REGION_BASE		SPA_TYPE_INFO_META_Region ":"

#define SPA_TYPE_INFO_META_ARRAY_Region		SPA_TYPE_INFO_META_ARRAY_BASE "Region"
#define SPA_TYPE_INFO_META_ARRAY_REGION_BASE	SPA_TYPE_INFO_META_ARRAY_Region ":"

/* VideoTransform meta */
#define SPA_TYPE_INFO_META_Transformation	SPA_TYPE_INFO_ENUM_BASE "Meta:Transformation"
#define SPA_TYPE_INFO_META_TRANSFORMATION_BASE	SPA_TYPE_INFO_META_Transformation ":"

static const struct spa_type_info spa_type_meta_videotransform_type[] = {
	{ SPA_ME) == NULL))
			return -errno;
		arr->data = data;
		arr->alloc = alloc;
	}
	return 0;
}

/** Add \a ref size bytes to \a arr. A pointer to memory that can
 * hold at least \a size bytes is returned or NULL when an error occurred
 * and errno will be set.*/
PW_API_ARRAY void *pw_array_add(struct pw_array *arr, size_t size)
{
	void *p;

	if (pw_array_ensure_size(arr, size) < 0)
		return NULL;

	p = SPA_PTROFF(arr->data, arr->size, void);
	arr->size += size;

	return p;
}

/** Add a pointer to array. Returns 0 on success and a negati pos);				\
	     (pos) = (__typeof__(pos)) pw_array_first(array))

#define pw_array_remove(a,p)						\
({									\
	(a)->size -= sizeof(*(p));					\
	memmove(p, SPA_PTROFF((p), sizeof(*(p)), void),			\
                SPA_PTRDIFF(pw_array_end(a),(p)));			\
})

/** Initialize the array with given extend. Extend needs to be > 0 or else
 * the array will not be able to expand. */
PW_API_ARRAY void pw_array_init(struct pw_array *arr, size_t extend)
{
	arr->data = NULL;
	arr->size = arr->alloc = 0;
	arr->extend = extend;
}

/** Clear ck_gettime, 0, clockid, value);
}
SPA_API_SYSTEM int spa_system_clock_getres(struct spa_system *object,
			int clockid, struct timespec *res)
{
	return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, clock_getres, 0, clockid, res);
}

SPA_API_SYSTEM int spa_system_pollfd_create(struct spa_system *object, int flags)
{
	return spa_api_method_fast_r(int, -ENOTSUP, spa_system, &object->iface, pollfd_create, 0, flags);
}
SPA_API_SYSTEM int spa_system_pollfd_add(struct spa_system *object, int pfd, int fd, uint32_t eventsYPE_INFO_PROPS_BASE "params", NULL },
	{ 0, 0, NULL, NULL },
};

/** Enum Property info */
#define SPA_TYPE_INFO_PropInfo			SPA_TYPE_INFO_PARAM_BASE "PropInfo"
#define SPA_TYPE_INFO_PROP_INFO_BASE		SPA_TYPE_INFO_PropInfo ":"

static const struct spa_type_info spa_type_prop_info[] = {
	{ SPA_PROP_INFO_START, SPA_TYPE_Id, SPA_TYPE_INFO_PROP_INFO_BASE, spa_type_param, },
	{ SPA_PROP_INFO_id, SPA_TYPE_Id, SPA_TYPE_INFO_PROP_INFO_BASE "id", spa_type_props },
	{ SPA_PROP_INFO_name, SPA_TYPE_String, SPA_TYPE_INFO_PROP_INFO_BASE "name", NU_INFO_PROPS_BASE "frequency", NULL },
	{ SPA_PROP_volume, SPA_TYPE_Float, SPA_TYPE_INFO_PROPS_BASE "volume", NULL },
	{ SPA_PROP_mute, SPA_TYPE_Bool, SPA_TYPE_INFO_PROPS_BASE "mute", NULL },
	{ SPA_PROP_patternType, SPA_TYPE_Int, SPA_TYPE_INFO_PROPS_BASE "patternType", NULL },
	{ SPA_PROP_ditherType, SPA_TYPE_Int, SPA_TYPE_INFO_PROPS_BASE "ditherType", NULL },
	{ SPA_PROP_truncate, SPA_TYPE_Bool, SPA_TYPE_INFO_PROPS_BASE "truncate", NULL },
	{ SPA_PROP_channelVolumes, SPA_TYPE_Array, SPA_TYPE_INFO_PROPS_BASE "channelVolumes", spa_t;

			spa_debugc_pod_value(ctx, indent + 4, ii ? ii->values : NULL,
					p->value.type,
					SPA_POD_CONTENTS(struct spa_pod_prop, p),
					p->value.size);
		}
		break;
	}
	case SPA_TYPE_Sequence:
	{
		struct spa_pod_sequence_body *b = (struct spa_pod_sequence_body *)body;
		const struct spa_type_info *ti, *ii;
		struct spa_pod_control *c;

		ti = spa_debug_type_find(info, b->unit);

		spa_debugc(ctx, "%*s" "Sequence: size %d, unit %s", indent, "", size,
		       ti ? ti->name : "unknown");

		SPA_POD_SEQUENCE_BODY_FOREACH(b, size,(1<<0)	/**< standard */
#define SPA_CPU_FLAG_VSX		(1<<1)	/**< ISA 2.06 */
#define SPA_CPU_FLAG_POWER8		(1<<2)	/**< ISA 2.07 */

/* ARM specific */
#define SPA_CPU_FLAG_ARMV5TE		(1 << 0)
#define SPA_CPU_FLAG_ARMV6		(1 << 1)
#define SPA_CPU_FLAG_ARMV6T2		(1 << 2)
#define SPA_CPU_FLAG_VFP		(1 << 3)
#define SPA_CPU_FLAG_VFPV3		(1 << 4)
#define SPA_CPU_FLAG_NEON		(1 << 5)
#define SPA_CPU_FLAG_ARMV8		(1 << 6)

/* RISCV specific */
#define SPA_CPU_FLAG_RISCV_V		(1 << 0)

#define SPA_CPU_FORCE_AUTODETECT	((uint32_t)-1)

#define SPA_CPU_VM__UNUSED_RESULT
ssize_t pw_getrandom(void *buf, size_t buflen, unsigned int flags);

void pw_random(void *buf, size_t buflen);

#define pw_rand32() ({ uint32_t val; pw_random(&val, sizeof(val)); val; })

void* pw_reallocarray(void *ptr, size_t nmemb, size_t size);

#ifdef PW_ENABLE_DEPRECATED
#define PW_DEPRECATED(v)        (v)
#else
#define PW_DEPRECATED(v)	({ __typeof__(v) _v SPA_DEPRECATED = (v); (void)_v; (v); })
#endif /* PW_ENABLE_DEPRECATED */

/**
 * \}
 */

SPA_DEFINE_AUTO_CLEANUP(pw_strv, char **, {
	spa_clear_ptr(*thing, p spa_pod
 * \{
 */

struct spa_command_body {
	struct spa_pod_object_body body;
};

struct spa_command {
	struct spa_pod		pod;
	struct spa_command_body body;
};

#define SPA_COMMAND_TYPE(cmd)		((cmd)->body.body.type)
#define SPA_COMMAND_ID(cmd,type)	(SPA_COMMAND_TYPE(cmd) == (type) ? \
						(cmd)->body.body.id : SPA_ID_INVALID)

#define SPA_COMMAND_INIT_FULL(t,size,type,id,...) ((t)			\
	{ { (size), SPA_TYPE_Object },					\
	  { { (type), (id) }, ##__VA_ARGS__ } })

#define SPA_COMMAND_INIT(type,id)					\
	SPA_COMMAND_INIT_FULL(s (struct spa_meta_region*)m->data;
			spa_debugc(ctx, "%*s" "    struct spa_meta_region:", indent, "");
			spa_debugc(ctx, "%*s" "      x:      %d", indent, "", h->region.position.x);
			spa_debugc(ctx, "%*s" "      y:      %d", indent, "", h->region.position.y);
			spa_debugc(ctx, "%*s" "      width:  %d", indent, "", h->region.size.width);
			spa_debugc(ctx, "%*s" "      height: %d", indent, "", h->region.size.height);
			break;
		}
		case SPA_META_VideoDamage:
		{
			struct spa_meta_region *h;
			spa_meta_for_each(h, m) {
				spadd(builder,
			SPA_FORMAT_VIDEO_framerate,	SPA_POD_Fraction(&info->framerate), 0);
	if (info->max_framerate.denom != 0)
		spa_pod_builder_add(builder,
			SPA_FORMAT_VIDEO_maxFramerate,	SPA_POD_Fraction(&info->max_framerate), 0);
	return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
}

/**
 * \}
 */

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* SPA_VIDEO_MJPG_UTILS_H */
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright Â© 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_AUDIO_DSP_UTILS_, sync, 0,
			seq);
}
SPA_API_NODE int spa_node_enum_params(struct spa_node *object, int seq,
			    uint32_t id, uint32_t start, uint32_t max,
			    const struct spa_pod *filter)
{
	return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, enum_params, 0,
			seq, id, start, max, filter);
}
SPA_API_NODE int spa_node_set_param(struct spa_node *object,
			  uint32_t id, uint32_t flags,
			  const struct spa_pod *param)
{
	return spa_api_method_r(int, -ENOTSUP, spa_node, &object->iface, set_param, 0,
			id, flags, param);
}
SPeuse_buffer() should be called or the
	 * buffer_id should be placed in the spa_io_buffers area before calling
	 * process.
	 *
	 * Passing NULL as \a buffers will remove the reference that the port has
	 * on the buffers.
	 *
	 * When this function returns async, use the spa_node_sync operation to
	 * wait for completion.
	 *
	 * This function must be called from the main thread. The node muse be paused
	 * or the port SPA_IO_Buffers area is NULL when this function is called.
	 *
	 * \param object an object implementing the interfparam node a spa_node
	 * \param callbacks callbacks to set
	 * \return 0 on success
	 *         -EINVAL when node is NULL
	 */
	int (*set_callbacks) (void *object,
			      const struct spa_node_callbacks *callbacks,
			      void *data);
	/**
	 * Perform a sync operation.
	 *
	 * This method will emit the result event with the given sequence
	 * number synchronously or with the returned async return value
	 * asynchronously.
	 *
	 * Because all methods are serialized in the node, this can be used
	 * to wait for completion of alluct spa_result_node_params {
	uint32_t id;		/**< id of parameter */
	uint32_t index;		/**< index of parameter */
	uint32_t next;		/**< next index of iteration */
	struct spa_pod *param;	/**< the result param */
};

#define SPA_NODE_EVENT_INFO		0
#define SPA_NODE_EVENT_PORT_INFO	1
#define SPA_NODE_EVENT_RESULT		2
#define SPA_NODE_EVENT_EVENT		3
#define SPA_NODE_EVENT_NUM		4

/** events from the spa_node.
 *
 * All event are called from the main thread and multiple
 * listeners can be registered for the events with
 * spa_node_add_lidebug_context *ctx, int indent, const void *data, size_t size)
{
	const uint8_t *t = (const uint8_t*)data;
	char buffer[512];
	size_t i;
	int pos = 0;

	for (i = 0; i < size; i++) {
		if (i % 16 == 0)
			pos = sprintf(buffer, "%p: ", &t[i]);
		pos += sprintf(buffer + pos, "%02x ", t[i]);
		if (i % 16 == 15 || i == size - 1) {
			spa_debugc(ctx, "%*s" "%s", indent, "", buffer);
		}
	}
	return 0;
}

SPA_API_DEBUG_MEM int spa_debug_mem(int indent, const void *data, size_t size)
{
	return spa_debugc_mem(NULL, indent, data, size);
}
/**ruct pw_port_info *info);

	/** a new link is added on this port */
	void (*link_added) (void *data, struct pw_impl_link *link);

	/** a link is removed from this port */
	void (*link_removed) (void *data, struct pw_impl_link *link);

	/** the state of the port changed */
	void (*state_changed) (void *data, enum pw_impl_port_state old,
			enum pw_impl_port_state state, const char *error);

	/** a control was added to the port */
	void (*control_added) (void *data, struct pw_control *control);

	/** a control was removed from the poespec *value,
		struct timespec *interval, bool absolute)
{
	return spa_api_method_r(int, -ENOTSUP,
			spa_loop_utils, &object->iface, update_timer, 0, source,
			value, interval, absolute);
}
SPA_API_LOOP struct spa_source *
spa_loop_utils_add_signal(struct spa_loop_utils *object, int signal_number,
		spa_source_signal_func_t func, void *data)
{
	return spa_api_method_r(struct spa_source *, NULL,
			spa_loop_utils, &object->iface, add_signal, 0,
			signal_number, func, data);
}
SPA_API_LOOP void spa_loop_utils_destroy_source(struc* up to \a timeout milliseconds and then dispatch the fds with activity.
	 * The number of dispatched fds is returned.
	 */
	int (*iterate) (void *object, int timeout);

	/** Check context of the loop
	 * \param ctrl the control
	 *
	 * This function will check if the current thread is currently the
	 * one that did the enter call. Since version 1:1.
	 *
	 * returns 1 on success, 0 or negative errno value on error.
	 */
	int (*check) (void *object);
};

SPA_API_LOOP int spa_loop_control_get_fd(struct spa_loop_control *object)
{
	re

/**
 * Register sources and work items to an event loop
 */
struct spa_loop_methods {
	/* the version of this structure. This can be used to expand this
	 * structure in the future */
#define SPA_VERSION_LOOP_METHODS	0
	uint32_t version;

	/** Add a source to the loop. Must be called from the loop's own thread.
	 *
	 * \param[in] object The callbacks data.
	 * \param[in] source The source.
	 * \return 0 on success, negative errno-style value on failure.
	 */
	int (*add_source) (void *object,
			   struct spa_source *source);

	/*available */
	uint32_t session_id;			/**< the id of the controlling session */
	struct spa_dict *props;			/**< extra properties */
	struct spa_param_info *params;		/**< parameters */
	uint32_t n_params;			/**< number of items in \a params */
};

struct pw_endpoint_stream_info {
#define PW_VERSION_ENDPOINT_STREAM_INFO		0
	uint32_t version;			/**< version of this structure */
	uint32_t id;				/**< the stream id (local or global) */
	uint32_t endpoint_id;			/**< the endpoint id (global) */
	char *name;				/**< name of the stream */
#dlient after connect */
#define PW_ID_CLIENT			1

/** The client information. Extra information can be added in later versions */
struct pw_client_info {
	uint32_t id;			/**< id of the global */
#define PW_CLIENT_CHANGE_MASK_PROPS	(1 << 0)
#define PW_CLIENT_CHANGE_MASK_ALL	((1 << 1)-1)
	uint64_t change_mask;		/**< bitfield of changed fields since last call */
	struct spa_dict *props;		/**< extra properties */
};

/** Update an existing \ref pw_client_info with \a update with reset */
struct pw_client_info *
pw_client_info_update(str)
			info->channels = SPA_MIN(v, SPA_AUDIO_MAX_CHANNELS);
	} else if (spa_streq(key, SPA_KEY_AUDIO_POSITION)) {
		if (force || info->channels == 0) {
			if (spa_audio_parse_position(val, strlen(val), info->position, &info->channels) > 0)
				SPA_FLAG_CLEAR(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
		}
	}
	return 0;
}

SPA_API_AUDIO_RAW_JSON int SPA_SENTINEL
spa_audio_info_raw_init_dict_keys(struct spa_audio_info_raw *info,
		const struct spa_dict *defaults,
		const struct spa_dict *dict, ...)
{
	spa_zero(*info);
	SPA_FLAG_SET(infoSPA_PARAM_PROFILER_TYPES_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \addtogroup spa_param
 * \{
 */

#include <spa/param/param-types.h>
#include <spa/param/profiler.h>

#define SPA_TYPE_INFO_Profiler		SPA_TYPE_INFO_OBJECT_BASE "Profiler"
#define SPA_TYPE_INFO_PROFILER_BASE	SPA_TYPE_INFO_Profiler ":"

static const struct spa_type_info spa_type_profiler[] = {
	{ SPA_PROFILER_START, SPA_TYPE_Id, SPA_TYPE_INFO_PROFILER_BASE, spa_type_param, },
	{ SPA_PROFILER_info, SPA_TYPE_Struct, SPA_TYPE_INFO_PROFILER_BASE "info", NULL, },
	{
#ifdef __cplusplus
extern "C" {
#endif

/**
 * \addtogroup spa_param
 * \{
 */

#include <spa/param/video/raw.h>

struct spa_video_info_dsp {
	enum spa_video_format format;
	uint32_t flags;
	uint64_t modifier;
};

#define SPA_VIDEO_INFO_DSP_INIT(...)	((struct spa_video_info_dsp) { __VA_ARGS__ })

/**
 * \}
 */

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* SPA_VIDEO_DSP_H */
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright Â© 2023 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_AUDIO_APE_UTILS_uct spa_graph_state *state)
{
	spa_list_init(&node->ports[SPA_DIRECTION_INPUT]);
	spa_list_init(&node->ports[SPA_DIRECTION_OUTPUT]);
	spa_list_init(&node->links);
	node->flags = 0;
	node->subgraph = NULL;
	node->state = state;
	node->state->required = node->state->pending = 0;
	node->state->status = SPA_STATUS_OK;
	node->graph_link.signal = spa_graph_link_signal_graph;
	node->graph_link.signal_data = node;
	spa_debug("node %p init state %p", node, state);
}


SPA_API_GRAPH int spa_graph_node_impl_sub_process(void *data SPA_UNUSED, 
#define PW_KEY_AUDIO_RATE		"audio.rate"		/**< an audio samplerate */
#define PW_KEY_AUDIO_CHANNELS		"audio.channels"	/**< number of audio channels */
#define PW_KEY_AUDIO_FORMAT		"audio.format"		/**< an audio format. Ex: "S16LE" */
#define PW_KEY_AUDIO_ALLOWED_RATES	"audio.allowed-rates"	/**< a list of allowed samplerates
								  *  ex. "[ 44100 48000 ]" */

/** video related properties */
#define PW_KEY_VIDEO_RATE		"video.framerate"	/**< a video framerate */
#define PW_KEY_VIDEO_FORMAT		"video.format"		/**< a video format */
#ddevice.bus"		/**< bus of the device if applicable. One of
								  *  "isa", "pci", "usb", "firewire",
								  *  "bluetooth" */
#define PW_KEY_DEVICE_SUBSYSTEM		"device.subsystem"	/**< device subsystem */
#define PW_KEY_DEVICE_SYSFS_PATH	"device.sysfs.path"	/**< device sysfs path */
#define PW_KEY_DEVICE_ICON		"device.icon"		/**< icon for the device. A base64 blob
								  *  containing PNG image data */
#define PW_KEY_DEVICE_ICON_NAME		"device.icon-name"	/**< an XDG icon name for the device.
								  *  Ex. "sound-card-speakY_NODE_SUPPORTS_REQUEST	"node.supports-request"	/**< The node supports emiting RequestProcess events
								  *  when it wants the graph to be scheduled.
								  *  A value of 0 disables support, a value of > 0
								  *  enables with increasing preference. */
#define PW_KEY_NODE_DRIVER_ID		"node.driver-id"	/**< the node id of the node assigned as driver
								  *   for this node */
#define PW_KEY_NODE_ASYNC		"node.async"		/**< the node wants async scheduling */
#define PW_KEY_NODE_LOOP_NAME		"node.loop.name"	/**< the loop nEY_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_ID		"object.id"		/**< a global object id */
#define PW_KEY_OBJECT_SERIAL		"object.serial"		/**< a 64 bit object serial number. This is a number
								  *  incremented for each object that is created.
								  *  The lower 32 bits are guaranteed to never be
								  *  SPA_ID_INVALID. */
#define PW_KEY_OBJECT_LINGER	ne PW_KEY_PROTOCOL			"pipewire.protocol"	/**< protocol used for connection */
#define PW_KEY_ACCESS			"pipewire.access"	/**< how the client access is controlled */
#define PW_KEY_CLIENT_ACCESS		"pipewire.client.access"/**< how the client wants to be access
								  *  controlled */

/** Various keys related to the identity of a client process and its security.
 * Must be obtained from trusted sources by the protocol and placed as
 * read-only properties. */
#define PW_KEY_SEC_PID			"pipewire.sec.pid"	/**< Client pid, set by protocta);
	/** the driver node did not complete processing */
	void (*incomplete) (void *data);
	/** the node had a timeout */
	void (*timeout) (void *data);
};

/** Create a new node */
struct pw_impl_node *
pw_context_create_node(struct pw_context *context,	/**< the context */
	    struct pw_properties *properties,	/**< extra properties */
	    size_t user_data_size		/**< user data size */);

/** Complete initialization of the node and register */
int pw_impl_node_register(struct pw_impl_node *node,		/**< node to register */
		     st/audio/format.h>
#include <spa/param/format-utils.h>

#ifndef SPA_API_AUDIO_RA_UTILS
 #ifdef SPA_API_IMPL
  #define SPA_API_AUDIO_RA_UTILS SPA_API_IMPL
 #else
  #define SPA_API_AUDIO_RA_UTILS static inline
 #endif
#endif

SPA_API_AUDIO_RA_UTILS int
spa_format_audio_ra_parse(const struct spa_pod *format, struct spa_audio_info_ra *info)
{
	int res;
	res = spa_pod_parse_object(format,
			SPA_TYPE_OBJECT_Format, NULL,
			SPA_FORMAT_AUDIO_rate,		SPA_POD_OPT_Int(&info->rate),
			SPA_FORMAT_AUDIO_channels,	SPA_POD_OPT_Int(&info->channels)on *implementation,
				   void *data);

void *pw_impl_factory_create_object(struct pw_impl_factory *factory,
			       struct pw_resource *resource,
			       const char *type,
			       uint32_t version,
			       struct pw_properties *properties,
			       uint32_t new_id);

/** Find a factory by name */
struct pw_impl_factory *
pw_context_find_factory(struct pw_context *context	/**< the context */,
		     const char *name			/**< the factory name */);

/**
 * \}
 */

#ifdef __cplusplus
}
#endif

#endif /* PIPEWIRE_IMPL_FACTORY_Hion to this is for the data processing callbacks, which are
 * explcitly marked as being emitted from the data realtime threads. One
 * such callback is the \ref pw_stream::process() callback when the
 * \ref PW_STREAM_FLAG_RT_PROCESS is set.
 *
 */
/** \defgroup pw_thread_loop Thread Loop
 *
 * The threaded loop object runs a \ref pw_loop in a separate thread
 * and ensures proper locking is done.
 *
 * All of the loop callbacks will be executed with the loop
 * lock held.
 *
 * \see \ref page_thread_loop
 */

/**
 * \addtogroup pifndef PIPEWIRE_THREAD_LOOP_H
#define PIPEWIRE_THREAD_LOOP_H

#ifdef __cplusplus
extern "C" {
#endif

#include <pipewire/loop.h>

/** \page page_thread_loop Thread Loop
 *
 * \see \ref pw_thread_loop
 *
 * \section sec_thread_loop_overview Overview
 *
 * The threaded loop implementation is a special wrapper around the
 * regular \ref pw_loop implementation.
 *
 * The added feature in the threaded loop is that it spawns a new thread
 * that runs the wrapped loop. This allows a synchronous application to use
 * the asynchronous API wD_BUILDER uint32_t spa_choice_from_id(char id)
{
	switch (id) {
	case 'r':
		return SPA_CHOICE_Range;
	case 's':
		return SPA_CHOICE_Step;
	case 'e':
		return SPA_CHOICE_Enum;
	case 'f':
		return SPA_CHOICE_Flags;
	case 'n':
	default:
		return SPA_CHOICE_None;
	}
}

#define SPA_POD_BUILDER_COLLECT(builder,type,args)				\
do {										\
	switch (type) {								\
	case 'b':								\
		spa_pod_builder_bool(builder, !!va_arg(args, int));		\
		break;								\
	case 'I':								\
		spa_pod_builder_id(builder, va_arg(args, uint32_t));		\itive(builder, &p.pod);
}

#define SPA_POD_INIT_Rectangle(val) ((struct spa_pod_rectangle){ { sizeof(struct spa_rectangle), SPA_TYPE_Rectangle }, (val) })

SPA_API_POD_BUILDER int
spa_pod_builder_rectangle(struct spa_pod_builder *builder, uint32_t width, uint32_t height)
{
	const struct spa_pod_rectangle p = SPA_POD_INIT_Rectangle(SPA_RECTANGLE(width, height));
	return spa_pod_builder_primitive(builder, &p.pod);
}

#define SPA_POD_INIT_Fraction(val) ((struct spa_pod_fraction){ { sizeof(struct spa_fraction), SPA_TYPE_Fraction }, (vader, const void *data, uint32_t size)
{
	int r, res = spa_pod_builder_raw(builder, data, size);
	if ((r = spa_pod_builder_pad(builder, size)) < 0)
		res = r;
	return res;
}

SPA_API_POD_BUILDER void *spa_pod_builder_pop(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
{
	struct spa_pod *pod;

	if (SPA_FLAG_IS_SET(builder->state.flags, SPA_POD_BUILDER_FLAG_FIRST)) {
		const struct spa_pod p = { 0, SPA_TYPE_None };
		spa_pod_builder_raw(builder, &p, sizeof(p));
	}
	if ((pod = (struct spa_pod*)spa_pod_builder_frame(buildeist args)
{
	if (SPA_UNLIKELY(spa_log_level_topic_enabled(l, topic, level))) {
		struct spa_interface *i = &l->iface;
		if (!spa_interface_call(i,
				struct spa_log_methods, logtv, 1,
				level, topic,
				file, line, func, fmt, args))
		    spa_interface_call(i,
				struct spa_log_methods, logv, 0,
				level, file, line, func, fmt, args);
	}
}

#define spa_logt_lev(l,lev,t,...)					\
	spa_log_logt(l,lev,t,__FILE__,__LINE__,__func__,__VA_ARGS__)

#define spa_log_lev(l,lev,...)					\
	spa_logt_lev(l,lev,SPA_LOG_TOPIC_DEFAULT,__VA_Aparam func the function name
	 * \param fmt printf style format
	 * \param args format arguments
	 *
	 * \since 1
	 */
	void (*logtv) (void *object,
		      enum spa_log_level level,
		      const struct spa_log_topic *topic,
		      const char *file,
		      int line,
		      const char *func,
		      const char *fmt,
		      va_list args) SPA_PRINTF_FUNC(7, 0);

	/**
	 * Initializes a \ref spa_log_topic to the correct logging level.
	 *
	 * \deprecated
	 * Plugin host should obtain log topics from \ref SPA_LOG_TOPIC_ENUM_NAME
	 *_NONE = 0,
	SPA_LOG_LEVEL_ERROR,
	SPA_LOG_LEVEL_WARN,
	SPA_LOG_LEVEL_INFO,
	SPA_LOG_LEVEL_DEBUG,
	SPA_LOG_LEVEL_TRACE,
};

/**
 * The Log interface
 */
#define SPA_TYPE_INTERFACE_Log	SPA_TYPE_INFO_INTERFACE_BASE "Log"


struct spa_log {
	/** the version of this log. This can be used to expand this
	 * structure in the future */
#define SPA_VERSION_LOG		0
	struct spa_interface iface;
	/**
	 * Logging level, everything above this level is not logged
	 */
	enum spa_log_level level;
};

/**
 * \struct spa_log_topic
 *
 * Identifier forTILS_H
#define SPA_PARAM_LATENCY_UTILS_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \addtogroup spa_param
 * \{
 */

#include <float.h>

#include <spa/pod/builder.h>
#include <spa/pod/parser.h>
#include <spa/param/latency.h>

#ifndef SPA_API_LATENCY_UTILS
 #ifdef SPA_API_IMPL
  #define SPA_API_LATENCY_UTILS SPA_API_IMPL
 #else
  #define SPA_API_LATENCY_UTILS static inline
 #endif
#endif

SPA_API_LATENCY_UTILS int
spa_latency_info_compare(const struct spa_latency_info *a, const struct spa_latency_info *b)
{
	if (a->min_quantum id(b, type);
			break;
		case SPA_TYPE_Struct:
		case SPA_TYPE_String:
			spa_pod_builder_string(b, val);
			break;
		default:
			spa_pod_builder_none(b);
			break;
		}
	}
	return 0;
}

SPA_API_JSON_POD int spa_json_to_pod_checked(struct spa_pod_builder *b, uint32_t flags,
		const struct spa_type_info *info, const char *value, int len,
		struct spa_error_location *loc)
{
	struct spa_json iter;
	const char *val;
	int res;

	if (loc)
		spa_zero(*loc);

	if ((res = spa_json_begin(&iter, value, len, &val)) <= 0)
		goto error;

	res = s;

		spa_json_enter(iter, &it[0]);
		while ((l = spa_json_object_next(&it[0], key, sizeof(key), &v)) > 0) {
			const struct spa_type_info *pi;
			if ((pi = spa_debug_type_find_short(ti->values, key)) != NULL)
				type = pi->type;
			else if (!spa_atou32(key, &type, 0))
				continue;
			spa_pod_builder_prop(b, type, 0);
			if ((res = spa_json_to_pod_part(b, flags, id, pi, &it[0], v, l)) < 0)
				return res;
		}
		if (l < 0)
			return l;
		spa_pod_builder_pop(b, &f[0]);
	}
	else if (spa_json_is_array(value, len)) {
		if (info == NULLif

#include <spa/utils/endian.h>

/**
 * \addtogroup spa_param
 * \{
 */
#include <spa/param/audio/raw.h>

struct spa_audio_layout_info {
	uint32_t n_channels;
	uint32_t position[SPA_AUDIO_MAX_CHANNELS];
};

#define SPA_AUDIO_LAYOUT_Mono		1, { SPA_AUDIO_CHANNEL_MONO, }
#define SPA_AUDIO_LAYOUT_Stereo		2, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, }
#define SPA_AUDIO_LAYOUT_Quad		4, { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, \
					     SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, }
#define SPA_AUDIO_LAYOUT_Pentagonal	5, { SPA char *error,		/**< an error message */
			...
			) SPA_PRINTF_FUNC(3, 4);

/** Update params, use NULL port_data for global filter params */
int
pw_filter_update_params(struct pw_filter *filter,	/**< a \ref pw_filter */
			void *port_data,		/**< data associated with port */
			const struct spa_pod **params,	/**< an array of params. */
			uint32_t n_params		/**< number of elements in \a params */);


/** Query the time on the filter, deprecated, use the spa_io_position in the
 * process() method for timing information. RT safe. */
queue/queue a buffer from another process()
							  *  function. since 0.3.73 */
};

enum pw_filter_port_flags {
	PW_FILTER_PORT_FLAG_NONE		= 0,		/**< no flags */
	PW_FILTER_PORT_FLAG_MAP_BUFFERS		= (1 << 0),	/**< mmap the buffers except DmaBuf that is not
								  *  explicitly marked as mappable. */
	PW_FILTER_PORT_FLAG_ALLOC_BUFFERS	= (1 << 1),	/**< the application will allocate buffer
								  *  memory. In the add_buffer event, the
								  *  data of the buffer should be set */
};

/** Create a new unconnected \ref pw_fil,
			struct pw_properties *properties);

void pw_impl_metadata_destroy(struct pw_impl_metadata *metadata);

void *pw_impl_metadata_get_user_data(struct pw_impl_metadata *metadata);

int pw_impl_metadata_set_implementation(struct pw_impl_metadata *metadata,
		struct pw_metadata *impl);

struct pw_metadata *pw_impl_metadata_get_implementation(struct pw_impl_metadata *metadata);

/** Get the global of this metadata */
struct pw_global *pw_impl_metadata_get_global(struct pw_impl_metadata *metadata);

/** Add an event listener */
void pbject, uint32_t version, size_t user_data_size);
	/**
	 * Update the node ports and properties
	 *
	 * Update the maximum number of ports and the params of the
	 * client node.
	 * \param change_mask bitfield with changed parameters
	 * \param max_input_ports new max input ports
	 * \param max_output_ports new max output ports
	 * \param params new params
	 */
	int (*update) (void *object,
#define PW_CLIENT_NODE_UPDATE_PARAMS		(1 << 0)
#define PW_CLIENT_NODE_UPDATE_INFO		(1 << 1)
			uint32_t change_mask,
			uint32_t n_params,
			co spa_dict *props);
	/**
	 * A port was removed from the node
	 *
	 * \param direction a port direction
	 * \param port_id the remove port id
	 */
	int (*remove_port) (void *data,
			     enum spa_direction direction,
			     uint32_t port_id);
	/**
	 * A parameter was configured on the port
	 *
	 * \param direction a port direction
	 * \param port_id the port id
	 * \param id the id of the parameter
	 * \param flags flags used when setting the param
	 * \param param the new param
	 */
	int (*port_set_param) (void *data,
				enum spuct pw_memblock *mem;	/**< allocated buffer memory */
	struct spa_buffer **buffers;	/**< port buffers */
	uint32_t n_buffers;		/**< number of port buffers */
	uint32_t flags;			/**< flags */
};

int pw_buffers_negotiate(struct pw_context *context, uint32_t flags,
		struct spa_node *outnode, uint32_t out_port_id,
		struct spa_node *innode, uint32_t in_port_id,
		struct pw_buffers *result);

void pw_buffers_clear(struct pw_buffers *buffers);

/**
 * \}
 */

#ifdef __cplusplus
}
#endif

#endif /* PIPEWIRE_BUFFERS_H */
/* PipeWire */
/..)		pw_endpoint_stream_method(c,enum_params,0,__VA_ARGS__)
#define pw_endpoint_stream_set_param(c,...)		pw_endpoint_stream_method(c,set_param,0,__VA_ARGS__)

/* Endpoint Link */

#define PW_ENDPOINT_LINK_EVENT_INFO		0
#define PW_ENDPOINT_LINK_EVENT_PARAM		1
#define PW_ENDPOINT_LINK_EVENT_NUM		2

struct pw_endpoint_link_events {
#define PW_VERSION_ENDPOINT_LINK_EVENTS	0
	uint32_t version;			/**< version of this structure */

	/**
	 * Notify endpoint link info
	 *
	 * \param info info about the endpoint link
	 */
	void (*info) (voidnumeration of endpoint parameters. For each param, a
	 * param event will be emitted.
	 *
	 * \param seq a sequence number returned in the reply
	 * \param id the parameter id to enumerate
	 * \param start the start index or 0 for the first param
	 * \param num the maximum number of params to retrieve
	 * \param filter a param filter or NULL
	 *
	 * This requires X permissions.
	 */
	int (*enum_params) (void *object, int seq,
			uint32_t id, uint32_t start, uint32_t num,
			const struct spa_pod *filter);

	/**
	 * Set a parameter oversion 1:3 */
	int (*init2) (void *object, const struct spa_dict *args,
			struct spa_audio_info_raw *play_info,
			struct spa_audio_info_raw *rec_info,
			struct spa_audio_info_raw *out_info);
};

SPA_API_AUDIO_AEC int spa_audio_aec_add_listener(struct spa_audio_aec *object,
			struct spa_hook *listener,
			const struct spa_audio_aec_events *events,
			void *data)
{
	return spa_api_method_r(int, -ENOTSUP,
			spa_audio_aec, &object->iface, add_listener, 0, listener, events, data);
}

SPA_API_AUDIO_AEC int spa_audio_aec_init(structnels));
	return res;
}

SPA_API_AUDIO_MP3_UTILS struct spa_pod *
spa_format_audio_mp3_build(struct spa_pod_builder *builder, uint32_t id,
			   const struct spa_audio_info_mp3 *info)
{
	struct spa_pod_frame f;
	spa_pod_builder_push_object(builder, &f, SPA_TYPE_OBJECT_Format, id);
	spa_pod_builder_add(builder,
			SPA_FORMAT_mediaType,		SPA_POD_Id(SPA_MEDIA_TYPE_audio),
			SPA_FORMAT_mediaSubtype,	SPA_POD_Id(SPA_MEDIA_SUBTYPE_mp3),
			SPA_FORMAT_AUDIO_format,	SPA_POD_Id(SPA_AUDIO_FORMAT_ENCODED),
			0);
	if (info->rate != 0)
		spa_popewire/resource.h>
#include <pipewire/permission.h>

/** The events that a client can emit */
struct pw_impl_client_events {
#define PW_VERSION_IMPL_CLIENT_EVENTS	0
        uint32_t version;

	/** emitted when the client is destroyed */
	void (*destroy) (void *data);

	/** emitted right before the client is freed */
	void (*free) (void *data);

	/** the client is initialized */
	void (*initialized) (void *data);

	/** emitted when the client info changed */
	void (*info_changed) (void *data, const struct pw_client_info *info);

	/*_Choice &&
			SPA_POD_BODY_SIZE(pod) >= sizeof(struct spa_pod_choice_body));
}

SPA_API_POD_ITER struct spa_pod *spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
{
	if (pod->type == SPA_TYPE_Choice) {
		*n_vals = SPA_POD_CHOICE_N_VALUES(pod);
		if ((*choice = SPA_POD_CHOICE_TYPE(pod)) == SPA_CHOICE_None)
			*n_vals = SPA_MIN(1u, SPA_POD_CHOICE_N_VALUES(pod));
		return (struct spa_pod*)SPA_POD_CHOICE_CHILD(pod);
	} else {
		*n_vals = 1;
		*choice = SPA_CHOICE_None;
		return (struct spa_pod*)pod;
	}
}truct spa_pod_bool, pod);
	return 0;
}

SPA_API_POD_ITER int spa_pod_is_id(const struct spa_pod *pod)
{
	return (SPA_POD_TYPE(pod) == SPA_TYPE_Id && SPA_POD_BODY_SIZE(pod) >= sizeof(uint32_t));
}

SPA_API_POD_ITER int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
{
	if (!spa_pod_is_id(pod))
		return -EINVAL;
	*value = SPA_POD_VALUE(struct spa_pod_id, pod);
	return 0;
}

SPA_API_POD_ITER int spa_pod_is_int(const struct spa_pod *pod)
{
	return (SPA_POD_TYPE(pod) == SPA_TYPE_Int && SPA_POD_BODY_SIZE(pod) >= sizeof(int32_tspa_pod pod;
	struct spa_pod_frame *parent;
	uint32_t offset;
	uint32_t flags;
};

SPA_API_POD_ITER bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
{
	size_t remaining;

	return spa_ptr_type_inside(pod, size, iter, struct spa_pod, &remaining) &&
	       remaining >= SPA_POD_BODY_SIZE(iter);
}

SPA_API_POD_ITER void *spa_pod_next(const void *iter)
{
	return SPA_PTROFF(iter, SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), void);
}

SPA_API_POD_ITER struct spa_pod_prop *spa_pod_prop_first(const struct spa_pod_object_boe public interface
 * #define VERSION_BAR_EVENTS 0 // version of the vtable
 * struct bar_events {
 *    uint32_t version; // NOTE: an integral member named `version`
 *                      //       must be present in the vtable
 *    void (*boom)(void *data, const char *msg);
 * };
 *
 * // private implementation
 * struct party {
 *     struct spa_hook_list bar_list;
 * };
 *
 * void party_add_event_listener(struct party *p, struct spa_hook *listener,
 *                               const struct bar_events *events, void *data)
 (_version), SPA_CALLBACKS_INIT(_funcs,_data), })

/**
 * Invoke method named \a method in the \a callbacks.
 * The \a method_type defines the type of the method struct.
 * Returns true if the method could be called, false otherwise.
 */
#define spa_callbacks_call(callbacks,type,method,vers,...)			\
({										\
	const type *_f = (const type *) (callbacks)->funcs;			\
	bool _res = SPA_CALLBACK_CHECK(_f,method,vers);				\
	if (SPA_LIKELY(_res))							\
		(_f->method)((callbacks)->data, ## __VA_ARGS__);		\
	_res;									\
})

#defi, const char *name);

/**
 * \}
 */

#ifdef __cplusplus
}  /* extern "C" */
#endif

#endif /* PIPEWIRE_PROTOCOL_H */
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright Â© 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_HOOK_H
#define SPA_HOOK_H

#ifdef __cplusplus
extern "C" {
#endif

#include <spa/utils/defs.h>
#include <spa/utils/list.h>

#ifndef SPA_API_HOOK
 #ifdef SPA_API_IMPL
  #define SPA_API_HOOK SPA_API_IMPL
 #else
  #define SPA_API_HOOK static inline
 #endif
#endif

/** \defgroup spa_interfacpewire/context.h>
#include <pipewire/properties.h>
#include <pipewire/utils.h>

#define PW_TYPE_INFO_Protocol		"PipeWire:Protocol"
#define PW_TYPE_INFO_PROTOCOL_BASE	PW_TYPE_INFO_Protocol ":"

struct pw_protocol_client {
	struct spa_list link;		/**< link in protocol client_list */
	struct pw_protocol *protocol;	/**< the owner protocol */

	struct pw_core *core;

	int (*connect) (struct pw_protocol_client *client,
			const struct spa_dict *props,
			void (*done_callback) (void *data, int result),
			void *data);
	int (*connect_fd) ( element.
 *
 * This structure is available on the buffer structure and contains
 * the type of the metadata and a pointer/size to the actual metadata
 * itself.
 */
struct spa_meta {
	uint32_t type;		/**< metadata type, one of enum spa_meta_type */
	uint32_t size;		/**< size of metadata */
	void *data;		/**< pointer to metadata */
};

SPA_API_META void *spa_meta_first(const struct spa_meta *m) {
	return m->data;
}

SPA_API_META void *spa_meta_end(const struct spa_meta *m) {
	return SPA_PTROFF(m->data,m->size,void);
}
#define spa_mr, uint32_t *val, int base)
{
	char *endptr;
	unsigned long long v;

	if (!str || *str =='\0')
		return false;

	errno = 0;
	v = strtoull(str, &endptr, base);
	if (errno != 0 || *endptr != '\0')
		return false;

	if (v != (uint32_t)v)
		return false;

	*val = v;
	return true;
}

/**
 * Convert \a str to an int64_t with the given \a base and store the
 * result in \a val.
 *
 * On failure, the value of \a val is unmodified.
 *
 * \return true on success, false otherwise
 */
SPA_API_STRING bool spa_atoi64(const char *str, int64_t *vasplus
} /* extern "C" */
#endif

#endif /* SPA_ATOMIC_H */
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright Â© 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */

#ifndef SPA_PARAM_ROUTE_H
#define SPA_PARAM_ROUTE_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * \addtogroup spa_param
 * \{
 */

#include <spa/param/param.h>

/** properties for SPA_TYPE_OBJECT_Pa