+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* Simple Plugin API */ |
| 2 | /* SPDX-FileCopyrightText: Copyright © 2023 Wim Taymans */ |
| 3 | /* SPDX-License-Identifier: MIT */ |
| 4 | |
| 5 | #ifndef SPA_PARAM_PEER_PARAM_UTILS_H |
| 6 | #define SPA_PARAM_PEER_PARAM_UTILS_H |
| 7 | |
| 8 | #include <float.h> |
| 9 | |
| 10 | #include <spa/utils/dict.h> |
| 11 | #include <spa/pod/builder.h> |
| 12 | #include <spa/pod/iter.h> |
| 13 | #include <spa/pod/parser.h> |
| 14 | #include <spa/pod/compare.h> |
| 15 | #include <spa/param/peer.h> |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | /** |
| 22 | * \addtogroup spa_param |
| 23 | * \{ |
| 24 | */ |
| 25 | |
| 26 | #ifndef SPA_API_PEER_PARAM_UTILS |
| 27 | #ifdef SPA_API_IMPL |
| 28 | #define SPA_API_PEER_PARAM_UTILS SPA_API_IMPL |
| 29 | #else |
| 30 | #define SPA_API_PEER_PARAM_UTILS static inline |
| 31 | #endif |
| 32 | #endif |
| 33 | |
| 34 | SPA_API_PEER_PARAM_UTILS int |
| 35 | spa_peer_param_parse(const struct spa_pod *param, struct spa_peer_param_info *info, |
| 36 | size_t size, void **state) |
| 37 | { |
| 38 | int res; |
| 39 | const struct spa_pod_object *obj = (const struct spa_pod_object*)param; |
| 40 | const struct spa_pod_prop *first, *start, *cur; |
| 41 | |
| 42 | if ((res = spa_pod_parse_object(param, |
| 43 | SPA_TYPE_OBJECT_PeerParam, NULL)) < 0) |
| 44 | return res; |
| 45 | |
| 46 | first = spa_pod_prop_first(&obj->body); |
| 47 | start = *state ? spa_pod_prop_next((struct spa_pod_prop*)*state) : first; |
| 48 | |
| 49 | res = 0; |
| 50 | for (cur = start; spa_pod_prop_is_inside(&obj->body, obj->pod.size, cur); |
| 51 | cur = spa_pod_prop_next(cur)) { |
| 52 | info->peer_id = cur->key; |
| 53 | info->param = &cur->value; |
| 54 | *state = (void*)cur; |
| 55 | return 1; |
| 56 | } |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | SPA_API_PEER_PARAM_UTILS void |
| 62 | spa_peer_param_build_start(struct spa_pod_builder *builder, struct spa_pod_frame *f, uint32_t id) |
| 63 | { |
| 64 | spa_pod_builder_push_object(builder, f, SPA_TYPE_OBJECT_PeerParam, id); |
| 65 | } |
| 66 | |
| 67 | SPA_API_PEER_PARAM_UTILS void |
| 68 | spa_peer_param_build_add_param(struct spa_pod_builder *builder, uint32_t peer_id, |
| 69 | const struct spa_pod *param) |
| 70 | { |
| 71 | spa_pod_builder_prop(builder, peer_id, 0); |
| 72 | if (param) |
| 73 | spa_pod_builder_primitive(builder, param); |
| 74 | else |
| 75 | spa_pod_builder_none(builder); |
| 76 | } |
| 77 | |
| 78 | SPA_API_PEER_PARAM_UTILS struct spa_pod * |
| 79 | spa_peer_param_build_end(struct spa_pod_builder *builder, struct spa_pod_frame *f) |
| 80 | { |
| 81 | return (struct spa_pod*)spa_pod_builder_pop(builder, f); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * \} |
| 86 | */ |
| 87 | |
| 88 | #ifdef __cplusplus |
| 89 | } /* extern "C" */ |
| 90 | #endif |
| 91 | |
| 92 | #endif /* SPA_PARAM_PEER_PARAM_UTILS_H */ |