PipeWire 1.4.1
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pod.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEBUG_POD_H
6#define SPA_DEBUG_POD_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
17#include <spa/debug/context.h>
18#include <spa/debug/mem.h>
19#include <spa/debug/types.h>
20#include <spa/pod/pod.h>
21#include <spa/pod/iter.h>
22
23#ifndef SPA_API_DEBUG_POD
24 #ifdef SPA_API_IMPL
25 #define SPA_API_DEBUG_POD SPA_API_IMPL
26 #else
27 #define SPA_API_DEBUG_POD static inline
28 #endif
29#endif
30
32spa_debugc_pod_value(struct spa_debug_context *ctx, int indent, const struct spa_type_info *info,
33 uint32_t type, void *body, uint32_t size)
35 switch (type) {
36 case SPA_TYPE_Bool:
37 spa_debugc(ctx, "%*s" "Bool %s", indent, "", (*(int32_t *) body) ? "true" : "false");
38 break;
40 spa_debugc(ctx, "%*s" "Id %-8d (%s)", indent, "", *(int32_t *) body,
41 spa_debug_type_find_name(info, *(int32_t *) body));
42 break;
43 case SPA_TYPE_Int:
44 spa_debugc(ctx, "%*s" "Int %d", indent, "", *(int32_t *) body);
45 break;
46 case SPA_TYPE_Long:
47 spa_debugc(ctx, "%*s" "Long %" PRIi64 "", indent, "", *(int64_t *) body);
48 break;
49 case SPA_TYPE_Float:
50 spa_debugc(ctx, "%*s" "Float %f", indent, "", *(float *) body);
51 break;
52 case SPA_TYPE_Double:
53 spa_debugc(ctx, "%*s" "Double %f", indent, "", *(double *) body);
54 break;
55 case SPA_TYPE_String:
56 spa_debugc(ctx, "%*s" "String \"%s\"", indent, "", (char *) body);
57 break;
58 case SPA_TYPE_Fd:
59 spa_debugc(ctx, "%*s" "Fd %d", indent, "", *(int *) body);
60 break;
62 {
63 struct spa_pod_pointer_body *b = (struct spa_pod_pointer_body *)body;
64 spa_debugc(ctx, "%*s" "Pointer %s %p", indent, "",
66 break;
67 }
69 {
70 struct spa_rectangle *r = (struct spa_rectangle *)body;
71 spa_debugc(ctx, "%*s" "Rectangle %" PRIu32 "x%" PRIu32 "", indent, "", r->width, r->height);
72 break;
73 }
75 {
76 struct spa_fraction *f = (struct spa_fraction *)body;
77 spa_debugc(ctx, "%*s" "Fraction %" PRIu32 "/%" PRIu32 "", indent, "", f->num, f->denom);
78 break;
79 }
80 case SPA_TYPE_Bitmap:
81 spa_debugc(ctx, "%*s" "Bitmap", indent, "");
82 break;
83 case SPA_TYPE_Array:
84 {
85 struct spa_pod_array_body *b = (struct spa_pod_array_body *)body;
86 void *p;
88
89 spa_debugc(ctx, "%*s" "Array: child.size %d, child.type %s", indent, "",
90 b->child.size, ti ? ti->name : "unknown");
91
92 info = info && info->values ? info->values : info;
94 spa_debugc_pod_value(ctx, indent + 2, info, b->child.type, p, b->child.size);
95 break;
96 }
97 case SPA_TYPE_Choice:
98 {
99 struct spa_pod_choice_body *b = (struct spa_pod_choice_body *)body;
100 void *p;
102
103 spa_debugc(ctx, "%*s" "Choice: type %s, flags %08x %d %d", indent, "",
104 ti ? ti->name : "unknown", b->flags, size, b->child.size);
105
107 spa_debugc_pod_value(ctx, indent + 2, info, b->child.type, p, b->child.size);
108 break;
109 }
110 case SPA_TYPE_Struct:
111 {
112 struct spa_pod *b = (struct spa_pod *)body, *p;
113 spa_debugc(ctx, "%*s" "Struct: size %d", indent, "", size);
114 SPA_POD_FOREACH(b, size, p)
115 spa_debugc_pod_value(ctx, indent + 2, info, p->type, SPA_POD_BODY(p), p->size);
116 break;
117 }
118 case SPA_TYPE_Object:
119 {
120 struct spa_pod_object_body *b = (struct spa_pod_object_body *)body;
121 struct spa_pod_prop *p;
122 const struct spa_type_info *ti, *ii;
123
124 ti = spa_debug_type_find(info, b->type);
125 ii = ti ? spa_debug_type_find(ti->values, 0) : NULL;
126 ii = ii ? spa_debug_type_find(ii->values, b->id) : NULL;
127
128 spa_debugc(ctx, "%*s" "Object: size %d, type %s (%d), id %s (%d)", indent, "", size,
129 ti ? ti->name : "unknown", b->type, ii ? ii->name : "unknown", b->id);
130
131 info = ti ? ti->values : info;
132
133 SPA_POD_OBJECT_BODY_FOREACH(b, size, p) {
134 ii = spa_debug_type_find(info, p->key);
135
136 spa_debugc(ctx, "%*s" "Prop: key %s (%d), flags %08x", indent+2, "",
137 ii ? ii->name : "unknown", p->key, p->flags);
138
139 spa_debugc_pod_value(ctx, indent + 4, ii ? ii->values : NULL,
140 p->value.type,
142 p->value.size);
143 }
144 break;
145 }
147 {
148 struct spa_pod_sequence_body *b = (struct spa_pod_sequence_body *)body;
149 const struct spa_type_info *ti, *ii;
150 struct spa_pod_control *c;
151
152 ti = spa_debug_type_find(info, b->unit);
153
154 spa_debugc(ctx, "%*s" "Sequence: size %d, unit %s", indent, "", size,
155 ti ? ti->name : "unknown");
156
159
160 spa_debugc(ctx, "%*s" "Control: offset %d, type %s", indent+2, "",
161 c->offset, ii ? ii->name : "unknown");
162
163 spa_debugc_pod_value(ctx, indent + 4, ii ? ii->values : NULL,
164 c->value.type,
166 c->value.size);
167 }
168 break;
169 }
170 case SPA_TYPE_Bytes:
171 spa_debugc(ctx, "%*s" "Bytes", indent, "");
172 spa_debugc_mem(ctx, indent + 2, body, size);
173 break;
174 case SPA_TYPE_None:
175 spa_debugc(ctx, "%*s" "None", indent, "");
176 spa_debugc_mem(ctx, indent + 2, body, size);
177 break;
178 default:
179 spa_debugc(ctx, "%*s" "unhandled POD type %d", indent, "", type);
180 break;
181 }
182 return 0;
183}
184
185SPA_API_DEBUG_POD int spa_debugc_pod(struct spa_debug_context *ctx, int indent,
186 const struct spa_type_info *info, const struct spa_pod *pod)
187{
188 return spa_debugc_pod_value(ctx, indent, info ? info : SPA_TYPE_ROOT,
189 SPA_POD_TYPE(pod),
190 SPA_POD_BODY(pod),
191 SPA_POD_BODY_SIZE(pod));
193
195spa_debug_pod_value(int indent, const struct spa_type_info *info,
196 uint32_t type, void *body, uint32_t size)
197{
198 return spa_debugc_pod_value(NULL, indent, info, type, body, size);
199}
200
201SPA_API_DEBUG_POD int spa_debug_pod(int indent,
202 const struct spa_type_info *info, const struct spa_pod *pod)
203{
204 return spa_debugc_pod(NULL, indent, info, pod);
205}
211#ifdef __cplusplus
212} /* extern "C" */
213#endif
214
215#endif /* SPA_DEBUG_POD_H */
uint32_t int int const char int r
Definition core.h:447
static const struct spa_type_info spa_type_control[]
Definition type-info.h:32
SPA_API_DEBUG_MEM int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
Definition mem.h:36
#define SPA_API_DEBUG_POD
Definition pod.h:34
#define spa_debugc(_c, _fmt,...)
Definition context.h:49
SPA_API_DEBUG_TYPES const struct spa_type_info * spa_debug_type_find(const struct spa_type_info *info, uint32_t type)
Definition types.h:37
SPA_API_DEBUG_POD int spa_debug_pod_value(int indent, const struct spa_type_info *info, uint32_t type, void *body, uint32_t size)
Definition pod.h:202
SPA_API_DEBUG_POD int spa_debug_pod(int indent, const struct spa_type_info *info, const struct spa_pod *pod)
Definition pod.h:208
SPA_API_DEBUG_POD int spa_debugc_pod(struct spa_debug_context *ctx, int indent, const struct spa_type_info *info, const struct spa_pod *pod)
Definition pod.h:192
SPA_API_DEBUG_POD int spa_debugc_pod_value(struct spa_debug_context *ctx, int indent, const struct spa_type_info *info, uint32_t type, void *body, uint32_t size)
Definition pod.h:39
SPA_API_DEBUG_TYPES const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition types.h:61
#define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter)
Definition iter.h:119
#define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter)
Definition iter.h:103
#define SPA_POD_BODY(pod)
Definition pod.h:39
#define SPA_POD_TYPE(pod)
Definition pod.h:28
#define SPA_POD_BODY_SIZE(pod)
Definition pod.h:26
#define SPA_POD_FOREACH(pod, size, iter)
Definition iter.h:111
#define SPA_POD_CONTENTS(type, pod)
Definition pod.h:35
#define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter)
Definition iter.h:127
#define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter)
Definition iter.h:95
static const struct spa_type_info spa_type_choice[]
Definition enum-types.h:41
#define SPA_TYPE_ROOT
Definition type-info.h:26
@ SPA_TYPE_Int
Definition type.h:45
@ SPA_TYPE_Rectangle
Definition type.h:51
@ SPA_TYPE_Long
Definition type.h:46
@ SPA_TYPE_Bool
Definition type.h:43
@ SPA_TYPE_Bytes
Definition type.h:50
@ SPA_TYPE_Bitmap
Definition type.h:53
@ SPA_TYPE_Object
Definition type.h:56
@ SPA_TYPE_Float
Definition type.h:47
@ SPA_TYPE_Fraction
Definition type.h:52
@ SPA_TYPE_None
Definition type.h:42
@ SPA_TYPE_Sequence
Definition type.h:57
@ SPA_TYPE_Double
Definition type.h:48
@ SPA_TYPE_Id
Definition type.h:44
@ SPA_TYPE_Choice
Definition type.h:60
@ SPA_TYPE_Pointer
Definition type.h:58
@ SPA_TYPE_Array
Definition type.h:54
@ SPA_TYPE_String
Definition type.h:49
@ SPA_TYPE_Fd
Definition type.h:59
@ SPA_TYPE_Struct
Definition type.h:55
spa/pod/iter.h
spa/pod/pod.h
spa/debug/context.h
spa/debug/mem.h
Definition context.h:45
Definition defs.h:137
uint32_t num
Definition defs.h:138
uint32_t denom
Definition defs.h:139
Definition pod.h:121
struct spa_pod child
Definition pod.h:122
Definition pod.h:154
struct spa_pod child
Definition pod.h:157
uint32_t type
type of choice, one of enum spa_choice_type
Definition pod.h:155
uint32_t flags
extra flags
Definition pod.h:156
Definition pod.h:234
struct spa_pod value
control value, depends on type
Definition pod.h:237
uint32_t type
type of control, enum spa_control_type
Definition pod.h:236
uint32_t offset
media offset
Definition pod.h:235
Definition pod.h:177
uint32_t type
one of enum spa_type
Definition pod.h:178
uint32_t id
id of the object, depends on the object type
Definition pod.h:179
Definition pod.h:188
const void * value
Definition pod.h:191
uint32_t type
pointer id, one of enum spa_type
Definition pod.h:189
Definition pod.h:208
uint32_t key
key of property, list of valid keys depends on the object type
Definition pod.h:209
uint32_t flags
flags for property
Definition pod.h:225
struct spa_pod value
Definition pod.h:226
Definition pod.h:241
uint32_t unit
Definition pod.h:242
Definition pod.h:43
uint32_t type
Definition pod.h:45
uint32_t size
Definition pod.h:44
Definition defs.h:116
Definition type.h:154
const struct spa_type_info * values
Definition type.h:158
spa/debug/types.h