diff --git a/lib/wp/endpoint.c b/lib/wp/endpoint.c index 017db5dbd28e3015b381256d3dafb1c4c36b312b..1ee3aef34886fe461b7e5f082858d48225a4c5fc 100644 --- a/lib/wp/endpoint.c +++ b/lib/wp/endpoint.c @@ -34,6 +34,7 @@ #include <spa/pod/builder.h> #include <spa/pod/parser.h> #include <spa/pod/filter.h> +#include <spa/utils/result.h> /* WpEndpoint */ @@ -422,6 +423,44 @@ wp_endpoint_iterate_streams (WpEndpoint * self) return wp_object_manager_iterate (priv->streams_om); } +/** + * wp_endpoint_create_link: + * @self: the endpoint + * @props: the link properties + * + * Creates a #WpEndpointLink between @self and another endpoint, which + * must be specified in @props. + * @props may contain: + * - `endpoint-link.output.endpoint`: the bound id of the endpoint + * that is in the %WP_DIRECTION_OUTPUT direction + * - `endpoint-link.output.stream`: the bound id of the endpoint stream + * that is in the %WP_DIRECTION_OUTPUT direction + * - `endpoint-link.input.endpoint`: the bound id of the endpoint + * that is in the %WP_DIRECTION_INPUT direction + * - `endpoint-link.input.stream`: the bound id of the endpoint stream + * that is in the %WP_DIRECTION_INPUT direction + * + * If either stream id are not specified (or set to -1), then the first + * available stream of this endpoint is used for the link. + * + * The id of @self is not necessary to be specified, so only one of + * `endpoint-link.output.endpoint`, `endpoint-link.input.endpoint` + * is actually required. + */ +void +wp_endpoint_create_link (WpEndpoint * self, WpProperties * props) +{ + WpEndpointPrivate *priv = + wp_endpoint_get_instance_private (WP_ENDPOINT (self)); + int res; + + res = pw_endpoint_create_link (priv->iface, wp_properties_peek_dict (props)); + if (res < 0) { + wp_warning_object (self, "pw_endpoint_create_link: %d: %s", res, + spa_strerror (res)); + } +} + /* WpImplEndpoint */ enum { diff --git a/lib/wp/endpoint.h b/lib/wp/endpoint.h index bfaeda1e283febdb3a902e718f625bba4e335cd1..e7beebc4b57b3549b0066cb377107945f5fd6a34 100644 --- a/lib/wp/endpoint.h +++ b/lib/wp/endpoint.h @@ -76,6 +76,9 @@ WpEndpointStream * wp_endpoint_find_stream (WpEndpoint * self, guint32 bound_id) WP_API WpIterator * wp_endpoint_iterate_streams (WpEndpoint * self); +WP_API +void wp_endpoint_create_link (WpEndpoint * self, WpProperties * props); + G_END_DECLS #endif