Loading...
Searching...
No Matches
peer-utils.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_PARAM_PEER_PARAM_UTILS_H
#define SPA_PARAM_PEER_PARAM_UTILS_H
#include <float.h>
#include <spa/utils/dict.h>
#include <spa/pod/builder.h>
#include <spa/pod/iter.h>
#include <spa/pod/parser.h>
#include <spa/pod/compare.h>
#include <spa/param/peer.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_PEER_PARAM_UTILS
#ifdef SPA_API_IMPL
#define SPA_API_PEER_PARAM_UTILS SPA_API_IMPL
#else
#define SPA_API_PEER_PARAM_UTILS static inline
#endif
#endif
SPA_API_PEER_PARAM_UTILS int
spa_peer_param_parse(const struct spa_pod *param, struct spa_peer_param_info *info,
size_t size, void **state)
{
int res;
const struct spa_pod_object *obj = (const struct spa_pod_object*)param;
const struct spa_pod_prop *first, *start, *cur;
if ((res = spa_pod_parse_object(param,
SPA_TYPE_OBJECT_PeerParam, NULL)) < 0)
return res;
first = spa_pod_prop_first(&obj->body);
start = *state ? spa_pod_prop_next((struct spa_pod_prop*)*state) : first;
res = 0;
for (cur = start; spa_pod_prop_is_inside(&obj->body, obj->pod.size, cur);
cur = spa_pod_prop_next(cur)) {
info->peer_id = cur->key;
info->param = &cur->value;
*state = (void*)cur;
return 1;
}
return 0;
}
SPA_API_PEER_PARAM_UTILS void
spa_peer_param_build_start(struct spa_pod_builder *builder, struct spa_pod_frame *f, uint32_t id)
{
spa_pod_builder_push_object(builder, f, SPA_TYPE_OBJECT_PeerParam, id);
}
SPA_API_PEER_PARAM_UTILS void
spa_peer_param_build_add_param(struct spa_pod_builder *builder, uint32_t peer_id,
const struct spa_pod *param)
{
spa_pod_builder_prop(builder, peer_id, 0);
if (param)
spa_pod_builder_primitive(builder, param);
else
spa_pod_builder_none(builder);
}
SPA_API_PEER_PARAM_UTILS struct spa_pod *
spa_peer_param_build_end(struct spa_pod_builder *builder, struct spa_pod_frame *f)
{
return (struct spa_pod*)spa_pod_builder_pop(builder, f);
}
*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_PARAM_PEER_PARAM_UTILS_H */
builder.h
spa/pod/builder.h
compare.h
spa/pod/compare.h
res
uint32_t int int res
Definition core.h:433
spa_peer_param_build_start
SPA_API_PEER_PARAM_UTILS void spa_peer_param_build_start(struct spa_pod_builder *builder, struct spa_pod_frame *f, uint32_t id)
Definition peer-utils.h:69
spa_peer_param_parse
SPA_API_PEER_PARAM_UTILS int spa_peer_param_parse(const struct spa_pod *param, struct spa_peer_param_info *info, size_t size, void **state)
Definition peer-utils.h:42
spa_peer_param_build_add_param
SPA_API_PEER_PARAM_UTILS void spa_peer_param_build_add_param(struct spa_pod_builder *builder, uint32_t peer_id, const struct spa_pod *param)
Definition peer-utils.h:75
SPA_API_PEER_PARAM_UTILS
#define SPA_API_PEER_PARAM_UTILS
Definition peer-utils.h:37
spa_peer_param_build_end
SPA_API_PEER_PARAM_UTILS struct spa_pod * spa_peer_param_build_end(struct spa_pod_builder *builder, struct spa_pod_frame *f)
Definition peer-utils.h:86
spa_pod_builder_pop
SPA_API_POD_BUILDER void * spa_pod_builder_pop(struct spa_pod_builder *builder, struct spa_pod_frame *frame)
Definition builder.h:213
spa_pod_prop_first
SPA_API_POD_ITER struct spa_pod_prop * spa_pod_prop_first(const struct spa_pod_object_body *body)
Definition iter.h:51
spa_pod_builder_none
SPA_API_POD_BUILDER int spa_pod_builder_none(struct spa_pod_builder *builder)
Definition builder.h:262
spa_pod_prop_is_inside
SPA_API_POD_ITER bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body, uint32_t size, const struct spa_pod_prop *iter)
Definition iter.h:56
spa_pod_builder_push_object
SPA_API_POD_BUILDER int spa_pod_builder_push_object(struct spa_pod_builder *builder, struct spa_pod_frame *frame, uint32_t type, uint32_t id)
Definition builder.h:475
spa_pod_prop_next
SPA_API_POD_ITER struct spa_pod_prop * spa_pod_prop_next(const struct spa_pod_prop *iter)
Definition iter.h:65
spa_pod_builder_primitive
SPA_API_POD_BUILDER int spa_pod_builder_primitive(struct spa_pod_builder *builder, const struct spa_pod *p)
Definition builder.h:250
spa_pod_parse_object
#define spa_pod_parse_object(pod, type, id,...)
Definition parser.h:935
spa_pod_builder_prop
SPA_API_POD_BUILDER int spa_pod_builder_prop(struct spa_pod_builder *builder, uint32_t key, uint32_t flags)
Definition builder.h:490
SPA_TYPE_OBJECT_PeerParam
@ SPA_TYPE_OBJECT_PeerParam
Definition type.h:98
iter.h
spa/pod/iter.h
parser.h
spa/pod/parser.h
peer.h
spa/param/peer.h
spa_peer_param_info
Definition peer.h:30
spa_pod_builder
Definition builder.h:63
spa_pod_frame
Definition body.h:38
spa_pod_object
Definition pod.h:202
spa_pod_object::pod
struct spa_pod pod
Definition pod.h:203
spa_pod_object::body
struct spa_pod_object_body body
Definition pod.h:204
spa_pod_prop
Definition pod.h:227
spa_pod_prop::key
uint32_t key
key of property, list of valid keys depends on the object type
Definition pod.h:228
spa_pod_prop::value
struct spa_pod value
Definition pod.h:249
spa_pod
Definition pod.h:57
spa_pod::size
uint32_t size
Definition pod.h:58
dict.h
spa/utils/dict.h