Created
April 27, 2024 21:20
-
-
Save lunks/55a12f2c2a096449fa0b792fb3da4d53 to your computer and use it in GitHub Desktop.
Some handy utilities for a C noob messing with pipewire
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void check_props(struct impl *impl) { | |
uint32_t i; | |
for (i=0; i<impl->props->dict.n_items; i++) { | |
if (spa_strstartswith(impl->props->dict.items[i].key, "media.")) | |
pw_log_debug("tag props %s", impl->props->dict.items[i].key); | |
} | |
} | |
static void check_combine_props(struct impl *impl) { | |
uint32_t i; | |
for (i=0; i<impl->combine_props->dict.n_items; i++) { | |
if (spa_strstartswith(impl->combine_props->dict.items[i].key, "media.")) | |
pw_log_debug("tag combine_props %s", impl->combine_props->dict.items[i].key); | |
} | |
} | |
static void check_stream_props(struct impl *impl) { | |
uint32_t i; | |
for (i=0; i<impl->stream_props->dict.n_items; i++) { | |
if (spa_strstartswith(impl->stream_props->dict.items[i].key, "media.")) | |
pw_log_debug("tag stream_props %s", impl->stream_props->dict.items[i].key); | |
} | |
} | |
static void check_pod(const struct spa_pod *pod) { | |
if (pod == NULL) { | |
pw_log_debug("null"); | |
return; | |
} | |
switch (SPA_POD_TYPE(pod)) { | |
case SPA_TYPE_Object: | |
{ | |
pw_log_debug("Object"); | |
const struct spa_pod_object *obj = (const struct spa_pod_object *)pod; | |
break; | |
} | |
case SPA_TYPE_Struct: | |
{ | |
pw_log_debug("Struct"); | |
const struct spa_pod_struct *str = (const struct spa_pod_struct *)pod; | |
break; | |
} | |
case SPA_TYPE_Array: | |
{ | |
pw_log_debug("Array"); | |
const struct spa_pod_array *arr = (const struct spa_pod_array *)pod; | |
break; | |
} | |
case SPA_TYPE_Bool: | |
{ | |
pw_log_debug("Boolean"); | |
pw_log_debug("Value: %d", SPA_POD_VALUE(struct spa_pod_bool, pod)); | |
break; | |
} | |
case SPA_TYPE_Id: | |
{ | |
pw_log_debug("ID"); | |
pw_log_debug("Value: %d", SPA_POD_VALUE(struct spa_pod_id, pod)); | |
break; | |
} | |
case SPA_TYPE_Int: | |
{ | |
pw_log_debug("Integer"); | |
pw_log_debug("Value: %d", SPA_POD_VALUE(struct spa_pod_int, pod)); | |
break; | |
} | |
case SPA_TYPE_Long: | |
{ | |
pw_log_debug("Long"); | |
pw_log_debug("Value: %ld", SPA_POD_VALUE(struct spa_pod_long, pod)); | |
break; | |
} | |
case SPA_TYPE_Float: | |
{ | |
pw_log_debug("Float"); | |
pw_log_debug("Value: %f", SPA_POD_VALUE(struct spa_pod_float, pod)); | |
break; | |
} | |
case SPA_TYPE_Double: | |
{ | |
pw_log_debug("Double"); | |
pw_log_debug("Value: %f", SPA_POD_VALUE(struct spa_pod_double, pod)); | |
break; | |
} | |
case SPA_TYPE_String: | |
{ | |
pw_log_debug("String"); | |
const char *s = (const char *)SPA_POD_CONTENTS(struct spa_pod_string, pod); | |
pw_log_debug("Value: %s", s); | |
break; | |
} | |
case SPA_TYPE_Bytes: | |
{ | |
pw_log_debug("Bytes"); | |
break; | |
} | |
case SPA_TYPE_Rectangle: | |
{ | |
pw_log_debug("Rectangle"); | |
break; | |
} | |
case SPA_TYPE_Fraction: | |
{ | |
pw_log_debug("Fraction"); | |
break; | |
} | |
default: | |
pw_log_debug("Unsupported SPA pod type"); | |
break; | |
} | |
} | |
static void log_spa_pod_struct(const struct spa_pod_struct *pod) { | |
struct spa_pod *prop; | |
SPA_POD_STRUCT_FOREACH(pod, prop) { | |
check_pod(prop); | |
} | |
} | |
static void process_spa_pod_object(const struct spa_pod_object *obj) { | |
const struct spa_pod_prop *prop; | |
SPA_POD_OBJECT_FOREACH(obj, prop) { | |
pw_log_debug("key: %d", prop->key); | |
if (prop->key == 1) { | |
check_pod(&prop->value); | |
} | |
if (prop->key == 2) { | |
log_spa_pod_struct((const struct spa_pod_struct *)&prop->value); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment