mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
module: implement properties
This commit is contained in:
parent
c0a3220228
commit
46ad3155b5
13 changed files with 123 additions and 6 deletions
|
|
@ -32,6 +32,12 @@
|
|||
#include "module-client-node/client-node.h"
|
||||
#include "module-client-node/client-stream.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Allow clients to create and control remote nodes" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_core *core);
|
||||
|
||||
struct factory_data {
|
||||
|
|
@ -143,6 +149,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@
|
|||
#include "pipewire/module.h"
|
||||
#include "pipewire/utils.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Perform portal queries to check permissions" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct impl {
|
||||
struct pw_core *core;
|
||||
struct pw_type *type;
|
||||
|
|
@ -502,6 +508,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
pw_core_add_listener(core, &impl->core_listener, &core_events, impl);
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
|
|
|||
|
|
@ -30,6 +30,12 @@
|
|||
#include "pipewire/module.h"
|
||||
#include "pipewire/link.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Allow clients to create links" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct factory_data {
|
||||
struct pw_factory *this;
|
||||
struct pw_properties *properties;
|
||||
|
|
@ -222,6 +228,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@
|
|||
|
||||
#include "module-media-session/audio-dsp.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Manage media sessions" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
#define DEFAULT_CHANNELS 2
|
||||
#define DEFAULT_SAMPLE_RATE 48000
|
||||
#define DEFAULT_BUFFER_SIZE (64 * sizeof(float))
|
||||
|
|
@ -794,6 +800,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
pw_core_add_listener(core, &impl->core_listener, &core_events, impl);
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,12 @@
|
|||
#define UNIX_PATH_MAX 108
|
||||
#endif
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Native protocol using unix sockets" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
static bool debug_messages = 0;
|
||||
|
||||
#define LOCK_SUFFIX ".lock"
|
||||
|
|
@ -922,6 +928,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
|
||||
pw_module_add_listener(module, &d->module_listener, &module_events, d);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@
|
|||
#include "pipewire/module.h"
|
||||
#include "pipewire/utils.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Use RTKit to raise thread priorities" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct impl {
|
||||
struct pw_core *core;
|
||||
struct pw_type *type;
|
||||
|
|
@ -505,6 +511,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
|
||||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@
|
|||
#include "pipewire/module.h"
|
||||
#include "pipewire/private.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Suspend nodes when not in use" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct impl {
|
||||
struct pw_core *core;
|
||||
struct pw_type *t;
|
||||
|
|
@ -209,6 +215,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
pw_module_add_listener(module, &impl->module_listener, &module_events, impl);
|
||||
pw_core_add_listener(impl->core, &impl->core_listener, &core_events, impl);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@
|
|||
|
||||
#include "spa-monitor.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Manage SPA monitors" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct data {
|
||||
struct pw_spa_monitor *monitor;
|
||||
struct spa_hook module_listener;
|
||||
|
|
@ -84,6 +90,8 @@ int pipewire__module_init(struct pw_module *module, const char *args)
|
|||
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
|
||||
not_enough_arguments:
|
||||
|
|
|
|||
|
|
@ -31,6 +31,12 @@
|
|||
|
||||
#include "spa-node.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Provide a factory to make SPA nodes" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct factory_data {
|
||||
struct pw_core *core;
|
||||
struct pw_factory *this;
|
||||
|
|
@ -191,6 +197,8 @@ static int module_init(struct pw_module *module, struct pw_properties *propertie
|
|||
pw_log_debug("module %p: new", module);
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
pw_factory_register(factory, NULL, pw_module_get_global(module), NULL);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@
|
|||
#include "spa-monitor.h"
|
||||
#include "spa-node.h"
|
||||
|
||||
static const struct spa_dict_item module_props[] = {
|
||||
{ PW_MODULE_PROP_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
|
||||
{ PW_MODULE_PROP_DESCRIPTION, "Load and manage an SPA node" },
|
||||
{ PW_MODULE_PROP_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
struct node_data {
|
||||
struct pw_node *this;
|
||||
struct pw_core *core;
|
||||
|
|
@ -96,6 +102,8 @@ int pipewire__module_init(struct pw_module *module, const char *args)
|
|||
pw_log_debug("module %p: new", module);
|
||||
pw_module_add_listener(module, &data->module_listener, &module_events, data);
|
||||
|
||||
pw_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
|
||||
|
||||
return 0;
|
||||
|
||||
not_enough_arguments:
|
||||
|
|
|
|||
|
|
@ -233,34 +233,38 @@ pw_module_load(struct pw_core *core,
|
|||
|
||||
this = &impl->this;
|
||||
this->core = core;
|
||||
this->properties = properties;
|
||||
|
||||
spa_list_init(&this->resource_list);
|
||||
spa_hook_list_init(&this->listener_list);
|
||||
|
||||
pw_properties_set(properties, PW_MODULE_PROP_NAME, name);
|
||||
|
||||
this->info.name = name ? strdup(name) : NULL;
|
||||
this->info.filename = filename;
|
||||
this->info.args = args ? strdup(args) : NULL;
|
||||
this->info.props = NULL;
|
||||
|
||||
pw_properties_set(properties, PW_MODULE_PROP_NAME, name);
|
||||
this->info.props = &this->properties->dict;
|
||||
|
||||
spa_list_append(&core->module_list, &this->link);
|
||||
|
||||
this->global = pw_global_new(core,
|
||||
core->type.module, PW_VERSION_MODULE,
|
||||
properties,
|
||||
pw_properties_new(
|
||||
PW_MODULE_PROP_NAME, name,
|
||||
NULL),
|
||||
this);
|
||||
|
||||
if (this->global == NULL)
|
||||
goto no_global;
|
||||
|
||||
pw_global_add_listener(this->global, &this->global_listener, &global_events, this);
|
||||
pw_global_register(this->global, owner, parent);
|
||||
this->info.id = this->global->id;
|
||||
|
||||
if ((res = init_func(this, args)) < 0)
|
||||
goto init_failed;
|
||||
|
||||
pw_global_register(this->global, owner, parent);
|
||||
|
||||
pw_log_debug("loaded module: %s", this->info.name);
|
||||
|
||||
return this;
|
||||
|
|
@ -331,6 +335,29 @@ struct pw_global * pw_module_get_global(struct pw_module *module)
|
|||
return module->global;
|
||||
}
|
||||
|
||||
const struct pw_properties *pw_module_get_properties(struct pw_module *module)
|
||||
{
|
||||
return module->properties;
|
||||
}
|
||||
|
||||
int pw_module_update_properties(struct pw_module *module, const struct spa_dict *dict)
|
||||
{
|
||||
struct pw_resource *resource;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < dict->n_items; i++)
|
||||
pw_properties_set(module->properties, dict->items[i].key, dict->items[i].value);
|
||||
|
||||
module->info.props = &module->properties->dict;
|
||||
|
||||
module->info.change_mask |= PW_MODULE_CHANGE_MASK_PROPS;
|
||||
spa_list_for_each(resource, &module->resource_list, link)
|
||||
pw_module_resource_info(resource, &module->info);
|
||||
module->info.change_mask = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct pw_module_info *
|
||||
pw_module_get_info(struct pw_module *module)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,10 @@ struct pw_module_events {
|
|||
};
|
||||
|
||||
/** The name of the module */
|
||||
#define PW_MODULE_PROP_NAME "pipewire.module.name"
|
||||
#define PW_MODULE_PROP_NAME "pipewire.module.name"
|
||||
#define PW_MODULE_PROP_AUTHOR "pipewire.module.author"
|
||||
#define PW_MODULE_PROP_DESCRIPTION "pipewire.module.description"
|
||||
#define PW_MODULE_PROP_VERSION "pipewire.module.version"
|
||||
|
||||
struct pw_module *
|
||||
pw_module_load(struct pw_core *core,
|
||||
|
|
@ -79,6 +82,12 @@ struct pw_core * pw_module_get_core(struct pw_module *module);
|
|||
/** Get the global of a module */
|
||||
struct pw_global * pw_module_get_global(struct pw_module *module);
|
||||
|
||||
/** Get the node properties */
|
||||
const struct pw_properties *pw_module_get_properties(struct pw_module *module);
|
||||
|
||||
/** Update the module properties */
|
||||
int pw_module_update_properties(struct pw_module *module, const struct spa_dict *dict);
|
||||
|
||||
/** Get the module info */
|
||||
const struct pw_module_info *pw_module_get_info(struct pw_module *module);
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ struct pw_module {
|
|||
struct pw_global *global; /**< global object for this module */
|
||||
struct spa_hook global_listener;
|
||||
|
||||
struct pw_properties *properties; /**< properties of the module */
|
||||
struct pw_module_info info; /**< introspectable module info */
|
||||
|
||||
struct spa_list resource_list; /**< list of resources for this module */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue