diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index d6c6c77c5..0f13230c5 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -131,8 +131,33 @@ static int follower_enum_params(struct impl *this, return 0; } -static int convert_enum_port_config(struct impl *this, - int seq, uint32_t id, uint32_t start, uint32_t num, +static void replace_mode(struct spa_pod *filter, enum spa_param_port_config_mode tmode, enum spa_param_port_config_mode rmode) +{ + const struct spa_pod_prop *prop; + if ((prop = spa_pod_find_prop(filter, NULL, SPA_PARAM_PORT_CONFIG_mode)) != NULL) { + switch (SPA_POD_TYPE(&prop->value)) { + case SPA_TYPE_Choice:; + enum spa_param_port_config_mode *modes = SPA_POD_CHOICE_VALUES((struct spa_pod_choice *)&prop->value); + for (uint32_t i = 0; i < SPA_POD_CHOICE_N_VALUES((struct spa_pod_choice *)&prop->value); i++) { + if (modes[i] == tmode) + modes[i] = rmode; + } + break; + case SPA_TYPE_Id:; + struct spa_pod_id *p = (struct spa_pod_id*)&prop->value; + if (p->value == tmode) + p->value = rmode; + break; + default: + break; + + } + + } +} + +static int adapter_enum_port_config(struct impl *this, + uint32_t id, struct spa_result_node_params *result, const struct spa_pod *filter, struct spa_pod_builder *builder) { struct spa_pod *f1, *f2 = NULL; @@ -149,9 +174,38 @@ static int convert_enum_port_config(struct impl *this, else { f2 = f1; } - return spa_node_enum_params(this->convert, seq, id, start, num, f2); + + res = spa_node_enum_params_sync(this->convert, + id, &result->next, f2, &result->param, builder); + spa_log_info(this->log, "convert_enum_port_config"); + spa_debug_log_pod(this->log, SPA_LOG_LEVEL_INFO, 2, NULL, result->param); + replace_mode(result->param, SPA_PARAM_PORT_CONFIG_MODE_none, SPA_PARAM_PORT_CONFIG_MODE_passthrough); + spa_debug_log_pod(this->log, SPA_LOG_LEVEL_INFO, 2, NULL, result->param); + return res; } +// static int convert_enum_port_config(struct impl *this, +// int seq, uint32_t id, uint32_t start, uint32_t num, +// const struct spa_pod *filter, struct spa_pod_builder *builder) +// { +// struct spa_pod *f1, *f2 = NULL; +// int res; +// +// f1 = spa_pod_builder_add_object(builder, +// SPA_TYPE_OBJECT_ParamPortConfig, id, +// SPA_PARAM_PORT_CONFIG_direction, SPA_POD_Id(this->direction)); +// +// if (filter) { +// if ((res = spa_pod_filter(builder, &f2, f1, filter)) < 0) +// return res; +// } +// else { +// f2 = f1; +// } +// +// return spa_node_enum_params(this->convert, seq, id, start, num, f2); +// } + static int impl_node_enum_params(void *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter) @@ -181,7 +235,9 @@ next: switch (id) { case SPA_PARAM_EnumPortConfig: - return convert_enum_port_config(this, seq, id, start, num, filter, &b.b); + // return convert_enum_port_config(this, seq, id, start, num, filter, &b.b); + res = adapter_enum_port_config(this, id, &result, filter, &b.b); + break; case SPA_PARAM_PortConfig: if (this->passthrough) { switch (result.index) { @@ -198,7 +254,9 @@ next: return 0; } } else { - return convert_enum_port_config(this, seq, id, start, num, filter, &b.b); + // return convert_enum_port_config(this, seq, id, start, num, filter, &b.b); + res = adapter_enum_port_config(this, id, &result, filter, &b.b); + break; } break; case SPA_PARAM_PropInfo: