m-default-nodes: move common code to a new header
This commit is contained in:
@@ -9,37 +9,14 @@
|
||||
#include <wp/wp.h>
|
||||
#include <errno.h>
|
||||
#include <pipewire/keys.h>
|
||||
#include <spa/utils/json.h>
|
||||
|
||||
#define DEFAULT_CONFIG_KEYS 1
|
||||
#include "module-default-nodes/common.h"
|
||||
|
||||
#define NAME "default-nodes"
|
||||
#define DEFAULT_SAVE_INTERVAL_MS 1000
|
||||
#define DEFAULT_USE_PERSISTENT_STORAGE TRUE
|
||||
|
||||
enum {
|
||||
AUDIO_SINK,
|
||||
AUDIO_SOURCE,
|
||||
VIDEO_SOURCE,
|
||||
N_DEFAULT_NODES
|
||||
};
|
||||
|
||||
static const gchar * DEFAULT_KEY[N_DEFAULT_NODES] = {
|
||||
[AUDIO_SINK] = "default.audio.sink",
|
||||
[AUDIO_SOURCE] = "default.audio.source",
|
||||
[VIDEO_SOURCE] = "default.video.source",
|
||||
};
|
||||
|
||||
static const gchar * DEFAULT_CONFIG_KEY[N_DEFAULT_NODES] = {
|
||||
[AUDIO_SINK] = "default.configured.audio.sink",
|
||||
[AUDIO_SOURCE] = "default.configured.audio.source",
|
||||
[VIDEO_SOURCE] = "default.configured.video.source",
|
||||
};
|
||||
|
||||
static const gchar * MEDIA_CLASS[N_DEFAULT_NODES] = {
|
||||
[AUDIO_SINK] = "Audio/Sink",
|
||||
[AUDIO_SOURCE] = "Audio/Source",
|
||||
[VIDEO_SOURCE] = "Video/Source",
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SAVE_INTERVAL_MS,
|
||||
@@ -189,30 +166,6 @@ reevaluate_default_node (WpDefaultNodes * self, WpMetadata *m, gint node_t)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
json_object_find(const char *obj, const char *key, char *value, size_t len)
|
||||
{
|
||||
struct spa_json it[2];
|
||||
const char *v;
|
||||
char k[128];
|
||||
|
||||
spa_json_init(&it[0], obj, strlen(obj));
|
||||
if (spa_json_enter_object(&it[0], &it[1]) <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
while (spa_json_get_string(&it[1], k, sizeof(k)-1) > 0) {
|
||||
if (strcmp(k, key) == 0) {
|
||||
if (spa_json_get_string(&it[1], value, len) <= 0)
|
||||
continue;
|
||||
return 0;
|
||||
} else {
|
||||
if (spa_json_next(&it[1], &v) <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static void
|
||||
on_metadata_changed (WpMetadata *m, guint32 subject,
|
||||
const gchar *key, const gchar *type, const gchar *value, gpointer d)
|
||||
|
Reference in New Issue
Block a user