format: make helper function to parse media type

This commit is contained in:
Wim Taymans 2018-08-29 14:50:58 +02:00
parent 5976beb149
commit 80de83f38a
24 changed files with 127 additions and 100 deletions

View file

@ -799,8 +799,8 @@ gst_caps_from_format (const struct spa_pod *format)
uint32_t media_type, media_subtype;
struct spa_pod_prop *prop;
spa_pod_object_parse(format, "I", &media_type,
"I", &media_subtype);
if (spa_format_parse(format, &media_type, &media_subtype) < 0)
return res;
if (media_type == SPA_MEDIA_TYPE_video) {
if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {

View file

@ -892,9 +892,8 @@ static void client_node_initialized(void *data)
return;
}
spa_pod_object_parse(format,
"I", &media_type,
"I", &media_subtype);
if (spa_format_parse(format, &media_type, &media_subtype) < 0)
return;
pw_log_debug("client-stream %p: %s/%s", &impl->this,
spa_debug_type_find_name(spa_debug_types, media_type),

View file

@ -634,9 +634,8 @@ static int collect_audio_format(void *data, uint32_t id,
uint32_t media_type, media_subtype;
struct spa_audio_info_raw info;
spa_pod_object_parse(param,
"I", &media_type,
"I", &media_subtype);
if (spa_format_parse(param, &media_type, &media_subtype) < 0)
return 0;
if (media_type != SPA_MEDIA_TYPE_audio ||
media_subtype != SPA_MEDIA_SUBTYPE_raw)

View file

@ -541,6 +541,7 @@ static int port_set_format(struct spa_node *node,
{
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
struct port *port;
int res;
port = GET_PORT(this, direction, port_id);
@ -554,9 +555,8 @@ static int port_set_format(struct spa_node *node,
} else {
struct spa_audio_info info = { 0 };
spa_pod_object_parse(format,
"I", &info.media_type,
"I", &info.media_subtype);
if ((res = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0)
return res;
if (info.media_type != SPA_MEDIA_TYPE_audio ||
info.media_subtype != SPA_MEDIA_SUBTYPE_raw)