2017-03-24 18:11:11 +01:00
|
|
|
/* Simple Plugin API
|
|
|
|
|
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <lib/props.h>
|
|
|
|
|
|
2017-05-25 13:28:15 +02:00
|
|
|
int
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_object_filter(const struct spa_pod_object *obj,
|
|
|
|
|
struct spa_pod_object *filter,
|
|
|
|
|
struct spa_pod_builder *result)
|
2017-03-24 18:11:11 +01:00
|
|
|
{
|
2017-05-26 08:05:01 +02:00
|
|
|
int res;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
if (obj == NULL || result == NULL)
|
2017-05-26 08:05:01 +02:00
|
|
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
|
|
|
|
|
|
|
|
|
if (filter == NULL) {
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_builder_raw_padded(result, obj, SPA_POD_SIZE(obj));
|
2017-05-26 08:05:01 +02:00
|
|
|
return SPA_RESULT_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-08 15:48:31 +01:00
|
|
|
spa_pod_builder_push_object(result, obj->body.id, obj->body.type);
|
2017-05-26 08:05:01 +02:00
|
|
|
res = spa_props_filter(result,
|
2017-11-07 17:39:31 +01:00
|
|
|
SPA_POD_CONTENTS(struct spa_pod_object, obj),
|
|
|
|
|
SPA_POD_CONTENTS_SIZE(struct spa_pod_object, obj),
|
|
|
|
|
SPA_POD_CONTENTS(struct spa_pod_object, filter),
|
|
|
|
|
SPA_POD_CONTENTS_SIZE(struct spa_pod_object, filter));
|
2017-11-08 15:48:31 +01:00
|
|
|
spa_pod_builder_pop(result);
|
2017-05-26 08:05:01 +02:00
|
|
|
|
|
|
|
|
return res;
|
2017-03-24 18:11:11 +01:00
|
|
|
}
|
2017-06-20 12:30:07 +02:00
|
|
|
|
|
|
|
|
int
|
2017-11-07 17:39:31 +01:00
|
|
|
spa_pod_object_compare(const struct spa_pod_object *obj1,
|
|
|
|
|
const struct spa_pod_object *obj2)
|
2017-06-20 12:30:07 +02:00
|
|
|
{
|
2017-11-07 17:39:31 +01:00
|
|
|
if (obj1 == NULL || obj2 == NULL)
|
2017-06-20 12:30:07 +02:00
|
|
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
|
|
|
|
|
2017-11-07 17:39:31 +01:00
|
|
|
return spa_props_compare(SPA_POD_CONTENTS(struct spa_pod_object, obj1),
|
|
|
|
|
SPA_POD_CONTENTS_SIZE(struct spa_pod_object, obj1),
|
|
|
|
|
SPA_POD_CONTENTS(struct spa_pod_object, obj2),
|
|
|
|
|
SPA_POD_CONTENTS_SIZE(struct spa_pod_object, obj2));
|
2017-06-20 12:30:07 +02:00
|
|
|
}
|