names: add standard factory name definitions

Define a set of standard factory names and document what they
contain. This makes it possible to change the implementation by
mapping the factory-name to a different shared library.
This commit is contained in:
Wim Taymans 2019-06-21 13:31:34 +02:00
parent 4494f9c7c9
commit 6720ded529
40 changed files with 188 additions and 55 deletions

View file

@ -34,6 +34,7 @@
#include <spa/support/log.h>
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
#include <spa/monitor/device.h>
@ -109,9 +110,9 @@ static int emit_node(struct impl *this, snd_pcm_info_t *pcminfo, uint32_t id)
info = SPA_DEVICE_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Node;
if (snd_pcm_info_get_stream(pcminfo) == SND_PCM_STREAM_PLAYBACK)
info.factory_name = "api.alsa.pcm.sink";
info.factory_name = SPA_NAME_API_ALSA_PCM_SINK;
else
info.factory_name = "api.alsa.pcm.source";
info.factory_name = SPA_NAME_API_ALSA_PCM_SOURCE;
info.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
snprintf(device_name, 128, "%s,%d", this->props.device, snd_pcm_info_get_device(pcminfo));
@ -488,7 +489,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_alsa_device_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.alsa.device",
SPA_NAME_API_ALSA_DEVICE,
NULL,
impl_get_size,
impl_init,

View file

@ -35,6 +35,7 @@
#include <spa/support/log.h>
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
#include <spa/monitor/monitor.h>
@ -111,7 +112,7 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device *
info = SPA_MONITOR_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Device;
info.factory_name = "api.alsa.device";
info.factory_name = SPA_NAME_API_ALSA_DEVICE;
info.change_mask = SPA_MONITOR_OBJECT_CHANGE_MASK_FLAGS |
SPA_MONITOR_OBJECT_CHANGE_MASK_PROPS;
info.flags = 0;
@ -482,7 +483,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_alsa_monitor_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.alsa.monitor",
SPA_NAME_API_ALSA_MONITOR,
NULL,
impl_get_size,
impl_init,

View file

@ -30,6 +30,7 @@
#include <spa/node/utils.h>
#include <spa/monitor/device.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/param/audio/format.h>
#include <spa/pod/filter.h>
#include <spa/debug/pod.h>
@ -809,7 +810,7 @@ static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
const struct spa_handle_factory spa_alsa_sink_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.alsa.pcm.sink",
SPA_NAME_API_ALSA_PCM_SINK,
&info,
impl_get_size,
impl_init,

View file

@ -29,6 +29,7 @@
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/list.h>
#include <spa/monitor/device.h>
#include <spa/param/audio/format.h>
@ -821,7 +822,7 @@ static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
const struct spa_handle_factory spa_alsa_source_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.alsa.pcm.source",
SPA_NAME_API_ALSA_PCM_SOURCE,
&info,
impl_get_size,
impl_init,

View file

@ -28,6 +28,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/buffer/alloc.h>
#include <spa/node/io.h>
@ -1120,7 +1121,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_audioconvert_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_CONVERT,
NULL,
impl_get_size,
impl_init,

View file

@ -30,6 +30,7 @@
#include <spa/support/log.h>
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -1085,7 +1086,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_channelmix_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_PROCESS_CHANNELMIX,
NULL,
impl_get_size,
impl_init,

View file

@ -30,6 +30,7 @@
#include <spa/support/log.h>
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -1028,7 +1029,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_fmtconvert_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_PROCESS_FORMAT,
NULL,
impl_get_size,
impl_init,

View file

@ -30,6 +30,7 @@
#include <spa/support/cpu.h>
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -1126,7 +1127,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_merger_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_PROCESS_INTERLEAVE,
NULL,
impl_get_size,
impl_init,

View file

@ -28,6 +28,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -1015,7 +1016,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_resample_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_PROCESS_RESAMPLE,
NULL,
impl_get_size,
impl_init,

View file

@ -30,6 +30,7 @@
#include <spa/support/cpu.h>
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -1052,7 +1053,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_splitter_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_PROCESS_DEINTERLEAVE,
NULL,
impl_get_size,
impl_init,

View file

@ -28,6 +28,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -979,7 +980,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_audiomixer_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_AUDIO_MIXER,
NULL,
impl_get_size,
impl_init,

View file

@ -33,6 +33,7 @@
#include <spa/support/system.h>
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -1528,7 +1529,7 @@ static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
const struct spa_handle_factory spa_a2dp_sink_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.bluez5.a2dp.sink",
SPA_NAME_API_BLUEZ5_A2DP_SINK,
&info,
impl_get_size,
impl_init,

View file

@ -36,6 +36,7 @@
#include <spa/support/system.h>
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -1226,7 +1227,7 @@ static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);
const struct spa_handle_factory spa_a2dp_source_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.bluez5.a2dp.source",
SPA_NAME_API_BLUEZ5_A2DP_SOURCE,
&info,
impl_get_size,
impl_init,

View file

@ -33,6 +33,7 @@
#include <spa/support/log.h>
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
#include <spa/monitor/device.h>
@ -107,7 +108,7 @@ static int emit_source_node(struct impl *this)
info = SPA_DEVICE_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Node;
info.factory_name = "api.bluez5.a2dp.source";
info.factory_name = SPA_NAME_API_BLUEZ5_A2DP_SOURCE;
info.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
info.props = &SPA_DICT_INIT_ARRAY(items);
@ -154,7 +155,7 @@ static int emit_sink_node(struct impl *this)
info = SPA_DEVICE_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Node;
info.factory_name = "api.bluez5.a2dp.sink";
info.factory_name = SPA_NAME_API_BLUEZ5_A2DP_SINK;
info.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
info.props = &SPA_DICT_INIT_ARRAY(items);
@ -348,7 +349,7 @@ static const struct spa_dict handle_info = SPA_DICT_INIT_ARRAY(handle_info_items
const struct spa_handle_factory spa_bluez5_device_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.bluez5.device",
SPA_NAME_API_BLUEZ5_DEVICE,
&handle_info,
impl_get_size,
impl_init,

View file

@ -45,6 +45,7 @@
#include <spa/monitor/utils.h>
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include "a2dp-codecs.h"
#include "defs.h"
@ -499,7 +500,7 @@ static int device_add(struct spa_bt_monitor *monitor, struct spa_bt_device *devi
info = SPA_MONITOR_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Device;
info.factory_name = "api.bluez5.device";
info.factory_name = SPA_NAME_API_BLUEZ5_DEVICE;
info.change_mask = SPA_MONITOR_OBJECT_CHANGE_MASK_FLAGS |
SPA_MONITOR_OBJECT_CHANGE_MASK_PROPS;
info.flags = 0;
@ -2292,7 +2293,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_bluez5_monitor_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.bluez5.monitor",
SPA_NAME_API_BLUEZ5_MONITOR,
NULL,
impl_get_size,
impl_init,

View file

@ -106,10 +106,10 @@ int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t
return 0;
if (av_codec_is_encoder(c)) {
snprintf(name, 128, "ffenc_%s", c->name);
snprintf(name, 128, "encoder.%s", c->name);
f.init = ffmpeg_enc_init;
} else {
snprintf(name, 128, "ffdec_%s", c->name);
snprintf(name, 128, "decoder.%s", c->name);
f.init = ffmpeg_dec_init;
}
f.name = name;

View file

@ -34,6 +34,7 @@
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#define NAME "cpu"
@ -209,7 +210,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_support_cpu_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_SUPPORT_CPU,
NULL,
impl_get_size,
impl_init,

View file

@ -33,6 +33,7 @@
#include <dbus/dbus.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#include <spa/support/log.h>
#include <spa/support/plugin.h>
#include <spa/support/dbus.h>
@ -439,7 +440,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
static const struct spa_handle_factory dbus_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_SUPPORT_DBUS,
NULL,
impl_get_size,
impl_init,

View file

@ -34,6 +34,7 @@
#include <spa/support/plugin.h>
#include <spa/utils/ringbuffer.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#define NAME "logger"
@ -294,7 +295,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_support_logger_factory = {
SPA_VERSION_HANDLE_FACTORY,
.name = NAME,
.name = SPA_NAME_SUPPORT_LOG,
.info = NULL,
.get_size = impl_get_size,
.init = impl_init,

View file

@ -35,6 +35,7 @@
#include <spa/support/log.h>
#include <spa/support/plugin.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/type.h>
#include <spa/utils/ringbuffer.h>
@ -815,7 +816,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_support_loop_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_SUPPORT_LOOP,
NULL,
impl_get_size,
impl_init,

View file

@ -38,6 +38,7 @@
#include <spa/support/system.h>
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#define NAME "system"
@ -398,7 +399,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_support_system_factory = {
SPA_VERSION_HANDLE_FACTORY,
NAME,
SPA_NAME_SUPPORT_SYSTEM,
NULL,
impl_get_size,
impl_init,

View file

@ -32,6 +32,7 @@
#include <spa/support/log.h>
#include <spa/support/loop.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/pod/builder.h>
#include <spa/monitor/device.h>
#include <spa/monitor/utils.h>
@ -102,7 +103,7 @@ static int emit_info(struct impl *this, bool full)
oinfo = SPA_DEVICE_OBJECT_INFO_INIT();
oinfo.type = SPA_TYPE_INTERFACE_Node;
oinfo.factory_name = "api.v4l2.source";
oinfo.factory_name = SPA_NAME_API_V4L2_SOURCE;
oinfo.change_mask = SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS;
oinfo.props = &SPA_DICT_INIT(items, n_items);
@ -262,7 +263,7 @@ static int impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_v4l2_device_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.v4l2.device",
SPA_NAME_API_V4L2_DEVICE,
NULL,
impl_get_size,
impl_init,

View file

@ -36,6 +36,7 @@
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/monitor/monitor.h>
#include <spa/monitor/utils.h>
@ -99,7 +100,7 @@ static int emit_object_info(struct impl *this, uint32_t id, struct udev_device *
info = SPA_MONITOR_OBJECT_INFO_INIT();
info.type = SPA_TYPE_INTERFACE_Device;
info.factory_name = "api.v4l2.device";
info.factory_name = SPA_NAME_API_V4L2_DEVICE;
info.change_mask = SPA_MONITOR_OBJECT_CHANGE_MASK_FLAGS |
SPA_MONITOR_OBJECT_CHANGE_MASK_PROPS;
info.flags = 0;
@ -398,7 +399,7 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_v4l2_monitor_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.v4l2.monitor",
SPA_NAME_API_V4L2_MONITOR,
NULL,
impl_get_size,
impl_init,

View file

@ -33,6 +33,7 @@
#include <spa/support/loop.h>
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
@ -1044,7 +1045,7 @@ static int impl_enum_interface_info(const struct spa_handle_factory *factory,
const struct spa_handle_factory spa_v4l2_source_factory = {
SPA_VERSION_HANDLE_FACTORY,
"api.v4l2.source",
SPA_NAME_API_V4L2_SOURCE,
NULL,
impl_get_size,
impl_init,