mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2025-12-20 06:30:04 +01:00
spa-pod: add _filter() method
This commit is contained in:
parent
079139f01d
commit
9dca92c698
2 changed files with 39 additions and 0 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include <spa/utils/type-info.h>
|
||||
#include <spa/pod/builder.h>
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/pod/filter.h>
|
||||
|
||||
#define WP_SPA_POD_BUILDER_REALLOC_STEP_SIZE 64
|
||||
#define WP_SPA_POD_ID_PROPERTY_NAME_MAX 16
|
||||
|
|
@ -1811,6 +1812,41 @@ wp_spa_pod_fixate (WpSpaPod *self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the intersection between \a self and \a filter
|
||||
*
|
||||
* This is typically used to intersect pods that describe formats, in order to
|
||||
* find a common format that is accceptable by both sides. For that purpose,
|
||||
* this is not exactly an intersection with its mathematical meaning.
|
||||
* Object properties can be thought of as format constraints. When one side does
|
||||
* not specify a specific property, it is considered to accept any value for it,
|
||||
* so the value of this property from the other side is added in the result.
|
||||
*
|
||||
* Both input pods are left unmodified after this function call.
|
||||
*
|
||||
* If NULL is passed in the \a filter, this function just copies \a self and
|
||||
* returns the copy.
|
||||
*
|
||||
* \param self the first pod
|
||||
* \param filter (nullable): the second pod
|
||||
* \return (transfer full) (nullable): a new pod that contains the intersection
|
||||
* between \a self and \a filter, or NULL if the intersection was not possible
|
||||
* to make
|
||||
*/
|
||||
WpSpaPod *
|
||||
wp_spa_pod_filter (WpSpaPod *self, WpSpaPod *filter)
|
||||
{
|
||||
char buffer[1024];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(&buffer, sizeof(buffer));
|
||||
struct spa_pod *result = NULL;
|
||||
|
||||
g_return_val_if_fail (self, NULL);
|
||||
|
||||
if (spa_pod_filter(&b, &result, self->pod, filter ? filter->pod : NULL) >= 0)
|
||||
return wp_spa_pod_new_wrap_copy (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Increases the reference count of a spa pod builder
|
||||
*
|
||||
|
|
|
|||
|
|
@ -289,6 +289,9 @@ WpIterator *wp_spa_pod_new_iterator (WpSpaPod *pod);
|
|||
WP_API
|
||||
gboolean wp_spa_pod_fixate (WpSpaPod *self);
|
||||
|
||||
WP_API
|
||||
WpSpaPod *wp_spa_pod_filter (WpSpaPod *self, WpSpaPod *filter);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpSpaPod, wp_spa_pod_unref)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue