mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
pod: add more helpers
Implement more unit-tests
This commit is contained in:
parent
767e7efc0e
commit
2622e085a9
12 changed files with 745 additions and 182 deletions
|
|
@ -374,7 +374,7 @@ static void node_event_param(void *object,
|
|||
n->media_subtype != SPA_MEDIA_SUBTYPE_raw)
|
||||
return;
|
||||
|
||||
spa_pod_fixate((struct spa_pod*)param);
|
||||
spa_pod_object_fixate((struct spa_pod_object*)param);
|
||||
|
||||
if (spa_format_audio_raw_parse(param, &info) < 0)
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -816,6 +816,7 @@ gst_caps_from_format (const struct spa_pod *format)
|
|||
GstCaps *res = NULL;
|
||||
uint32_t media_type, media_subtype;
|
||||
struct spa_pod_prop *prop;
|
||||
const struct spa_pod_object *obj = (const struct spa_pod_object *) format;
|
||||
|
||||
if (spa_format_parse(format, &media_type, &media_subtype) < 0)
|
||||
return res;
|
||||
|
|
@ -823,7 +824,7 @@ gst_caps_from_format (const struct spa_pod *format)
|
|||
if (media_type == SPA_MEDIA_TYPE_video) {
|
||||
if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
|
||||
res = gst_caps_new_empty_simple ("video/x-raw");
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_VIDEO_format))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_VIDEO_format))) {
|
||||
handle_id_prop (prop, "format", video_id_to_string, res);
|
||||
}
|
||||
}
|
||||
|
|
@ -836,13 +837,13 @@ gst_caps_from_format (const struct spa_pod *format)
|
|||
"alignment", G_TYPE_STRING, "au",
|
||||
NULL);
|
||||
}
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_VIDEO_size))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_VIDEO_size))) {
|
||||
handle_rect_prop (prop, "width", "height", res);
|
||||
}
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_VIDEO_framerate))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_VIDEO_framerate))) {
|
||||
handle_fraction_prop (prop, "framerate", res);
|
||||
}
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_VIDEO_maxFramerate))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_VIDEO_maxFramerate))) {
|
||||
handle_fraction_prop (prop, "max-framerate", res);
|
||||
}
|
||||
} else if (media_type == SPA_MEDIA_TYPE_audio) {
|
||||
|
|
@ -850,13 +851,13 @@ gst_caps_from_format (const struct spa_pod *format)
|
|||
res = gst_caps_new_simple ("audio/x-raw",
|
||||
"layout", G_TYPE_STRING, "interleaved",
|
||||
NULL);
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_AUDIO_format))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_AUDIO_format))) {
|
||||
handle_id_prop (prop, "format", audio_id_to_string, res);
|
||||
}
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_AUDIO_rate))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_AUDIO_rate))) {
|
||||
handle_int_prop (prop, "rate", res);
|
||||
}
|
||||
if ((prop = spa_pod_find_prop (format, SPA_FORMAT_AUDIO_channels))) {
|
||||
if ((prop = spa_pod_object_find_prop (obj, SPA_FORMAT_AUDIO_channels))) {
|
||||
handle_int_prop (prop, "channels", res);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/pod/filter.h>
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/debug/types.h>
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
|
|
@ -372,7 +373,7 @@ static int impl_node_enum_params(struct spa_node *node,
|
|||
|
||||
param = this->params[(*index)++];
|
||||
|
||||
if (!spa_pod_is_object_type(param, id))
|
||||
if (param == NULL || !spa_pod_is_object_id(param, id))
|
||||
continue;
|
||||
|
||||
if (spa_pod_filter(builder, result, param, filter) == 0)
|
||||
|
|
@ -523,7 +524,7 @@ do_update_port(struct node *this,
|
|||
for (i = 0; i < port->n_params; i++) {
|
||||
port->params[i] = params[i] ? pw_spa_pod_copy(params[i]) : NULL;
|
||||
|
||||
if (spa_pod_is_object_id(port->params[i], SPA_PARAM_Format))
|
||||
if (port->params[i] && spa_pod_is_object_id(port->params[i], SPA_PARAM_Format))
|
||||
port->have_format = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -664,7 +665,7 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
param = port->params[(*index)++];
|
||||
|
||||
if (!spa_pod_is_object_id(param, id))
|
||||
if (param == NULL || !spa_pod_is_object_id(param, id))
|
||||
continue;
|
||||
|
||||
if (spa_pod_filter(builder, result, param, filter) == 0)
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
if (!spa_pod_is_object_id(param, id))
|
||||
if (param == NULL || !spa_pod_is_object_id(param, id))
|
||||
continue;
|
||||
|
||||
if (spa_pod_filter(builder, result, param, filter) == 0)
|
||||
|
|
@ -460,7 +460,7 @@ static int port_set_format(struct spa_node *node,
|
|||
spa_debug_format(2, NULL, format);
|
||||
|
||||
clear_params(stream, PARAM_TYPE_FORMAT);
|
||||
if (spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format)) {
|
||||
if (format && spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format)) {
|
||||
p = add_param(stream, PARAM_TYPE_FORMAT, format);
|
||||
if (p == NULL)
|
||||
goto no_mem;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue