2023-02-08 18:12:00 +01:00
|
|
|
/* PipeWire */
|
|
|
|
|
/* SPDX-FileCopyrightText: Copyright © 2020 Wim Taymans */
|
|
|
|
|
/* SPDX-License-Identifier: MIT */
|
2020-11-17 11:37:39 +01:00
|
|
|
|
2021-06-18 23:51:54 +02:00
|
|
|
#include <spa/utils/defs.h>
|
2021-05-18 11:36:13 +10:00
|
|
|
#include <spa/utils/string.h>
|
|
|
|
|
|
2024-01-23 12:22:45 +01:00
|
|
|
#include "client.h"
|
2021-10-18 15:00:33 +02:00
|
|
|
#include "defs.h"
|
2021-06-18 23:51:54 +02:00
|
|
|
#include "extension.h"
|
2024-01-23 12:22:45 +01:00
|
|
|
#include "message.h"
|
|
|
|
|
#include "module.h"
|
2021-06-18 23:51:54 +02:00
|
|
|
|
2024-01-23 12:22:45 +01:00
|
|
|
static const struct extension *find_extension_command(struct module *module, uint32_t command)
|
2020-11-17 11:37:39 +01:00
|
|
|
{
|
2024-01-23 12:22:45 +01:00
|
|
|
uint32_t i;
|
|
|
|
|
|
|
|
|
|
if (module->info->extension == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
for (i = 0; module->info->extension[i].name; i++) {
|
|
|
|
|
if (module->info->extension[i].command == command)
|
|
|
|
|
return &module->info->extension[i];
|
2020-11-17 11:37:39 +01:00
|
|
|
}
|
2021-10-18 15:28:59 +02:00
|
|
|
return NULL;
|
2020-11-17 11:37:39 +01:00
|
|
|
}
|
2024-01-23 12:22:45 +01:00
|
|
|
|
|
|
|
|
int extension_process(struct module *module, struct client *client, uint32_t tag, struct message *m)
|
|
|
|
|
{
|
|
|
|
|
uint32_t command;
|
|
|
|
|
const struct extension *ext;
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
if ((res = message_get(m,
|
|
|
|
|
TAG_U32, &command,
|
|
|
|
|
TAG_INVALID)) < 0)
|
|
|
|
|
return -EPROTO;
|
|
|
|
|
|
|
|
|
|
ext = find_extension_command(module, command);
|
|
|
|
|
if (ext == NULL)
|
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
if (ext->process == NULL)
|
|
|
|
|
return -EPROTO;
|
|
|
|
|
|
|
|
|
|
pw_log_info("client %p [%s]: %s %s tag:%u",
|
|
|
|
|
client, client->name, module->info->name, ext->name, tag);
|
|
|
|
|
|
|
|
|
|
return ext->process(module, client, command, tag, m);
|
|
|
|
|
}
|