mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
types: more work on types
This commit is contained in:
parent
acedfe71c0
commit
5825c62d6d
76 changed files with 1713 additions and 1477 deletions
|
|
@ -28,7 +28,7 @@
|
|||
#include <asoundlib.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/loop.h>
|
||||
#include <spa/monitor.h>
|
||||
#include <lib/debug.h>
|
||||
|
|
@ -45,15 +45,22 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t handle_factory;
|
||||
SpaMonitorTypes monitor_types;
|
||||
} URI;
|
||||
SpaTypeMonitor monitor;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory);
|
||||
spa_type_monitor_map (map, &type->monitor);
|
||||
}
|
||||
|
||||
struct _SpaALSAMonitor {
|
||||
SpaHandle handle;
|
||||
SpaMonitor monitor;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *main_loop;
|
||||
|
||||
|
|
@ -170,20 +177,20 @@ fill_item (SpaALSAMonitor *this, ALSAItem *item, struct udev_device *udevice)
|
|||
|
||||
spa_pod_builder_init (&b, this->item_buffer, sizeof (this->item_buffer));
|
||||
|
||||
spa_pod_builder_push_object (&b, &f[0], 0, this->uri.monitor_types.MonitorItem);
|
||||
spa_pod_builder_push_object (&b, &f[0], 0, this->type.monitor.MonitorItem);
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.flags, 0, SPA_POD_TYPE_INT, 1, 0),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.name, 0, SPA_POD_TYPE_STRING, 1, name),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.klass, 0, SPA_POD_TYPE_STRING, 1, "Audio/Device"),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.factory, 0, SPA_POD_TYPE_POINTER, 1, this->uri.handle_factory,
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.flags, 0, SPA_POD_TYPE_INT, 1, 0),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.name, 0, SPA_POD_TYPE_STRING, 1, name),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.klass, 0, SPA_POD_TYPE_STRING, 1, "Audio/Device"),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.factory, 0, SPA_POD_TYPE_POINTER, 1, this->type.handle_factory,
|
||||
factory),
|
||||
0);
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
SPA_POD_TYPE_PROP, &f[1], this->uri.monitor_types.info, 0,
|
||||
SPA_POD_TYPE_PROP, &f[1], this->type.monitor.info, 0,
|
||||
SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
|
|
@ -271,11 +278,11 @@ alsa_on_fd_events (SpaSource *source)
|
|||
str = "change";
|
||||
|
||||
if (strcmp (str, "add") == 0) {
|
||||
type = this->uri.monitor_types.Added;
|
||||
type = this->type.monitor.Added;
|
||||
} else if (strcmp (str, "change") == 0) {
|
||||
type = this->uri.monitor_types.Changed;
|
||||
type = this->type.monitor.Changed;
|
||||
} else if (strcmp (str, "remove") == 0) {
|
||||
type = this->uri.monitor_types.Removed;
|
||||
type = this->type.monitor.Removed;
|
||||
} else
|
||||
return;
|
||||
|
||||
|
|
@ -402,7 +409,7 @@ spa_alsa_monitor_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaALSAMonitor *) handle;
|
||||
|
||||
if (interface_id == this->uri.monitor_types.Monitor)
|
||||
if (interface_id == this->type.monitor.Monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -435,11 +442,11 @@ alsa_monitor_init (const SpaHandleFactory *factory,
|
|||
this = (SpaALSAMonitor *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
this->main_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
|
|
@ -450,8 +457,8 @@ alsa_monitor_init (const SpaHandleFactory *factory,
|
|||
spa_log_error (this->log, "a main-loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.handle_factory = spa_id_map_get_id (this->map, SPA_TYPE__HandleFactory);
|
||||
spa_monitor_types_map (this->map, &this->uri.monitor_types);
|
||||
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->monitor = alsamonitor;
|
||||
|
||||
|
|
|
|||
|
|
@ -82,13 +82,13 @@ spa_alsa_sink_node_get_props (SpaNode *node,
|
|||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP (&f[1], this->uri.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
|
||||
PROP_MM (&f[1], this->uri.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX),
|
||||
PROP_MM (&f[1], this->uri.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX),
|
||||
PROP (&f[1], this->uri.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event));
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
|
||||
PROP_MM (&f[1], this->type.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX),
|
||||
PROP_MM (&f[1], this->type.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX),
|
||||
PROP (&f[1], this->type.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event));
|
||||
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
||||
|
|
@ -111,10 +111,10 @@ spa_alsa_sink_node_set_props (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
this->uri.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size,
|
||||
this->uri.prop_periods, SPA_POD_TYPE_INT, &this->props.periods,
|
||||
this->uri.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event,
|
||||
this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
this->type.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size,
|
||||
this->type.prop_periods, SPA_POD_TYPE_INT, &this->props.periods,
|
||||
this->type.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event,
|
||||
0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -147,8 +147,8 @@ do_command (SpaLoop *loop,
|
|||
SpaResult res;
|
||||
SpaCommand *cmd = data;
|
||||
|
||||
if (SPA_COMMAND_TYPE (cmd) == this->uri.command_node.Start ||
|
||||
SPA_COMMAND_TYPE (cmd) == this->uri.command_node.Pause) {
|
||||
if (SPA_COMMAND_TYPE (cmd) == this->type.command_node.Start ||
|
||||
SPA_COMMAND_TYPE (cmd) == this->type.command_node.Pause) {
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_INPUT,
|
||||
0,
|
||||
|
|
@ -158,7 +158,7 @@ do_command (SpaLoop *loop,
|
|||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
if (async) {
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete,
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
|
||||
seq, res);
|
||||
spa_loop_invoke (this->main_loop,
|
||||
do_send_event,
|
||||
|
|
@ -181,8 +181,8 @@ spa_alsa_sink_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASink, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start ||
|
||||
SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start ||
|
||||
SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -302,17 +302,17 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype.raw,
|
||||
PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3, this->type.audio_format.S16,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S32),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
break;
|
||||
case 1:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac,
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype_audio.aac,
|
||||
SPA_POD_TYPE_NONE);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -385,23 +385,23 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
|
|||
this->info.params = this->params;
|
||||
|
||||
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
|
||||
PROP_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
|
||||
PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_RINGBUFFER),
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32),
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_RINGBUFFER),
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32),
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
|
||||
this->params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
this->info.extra = NULL;
|
||||
|
||||
|
|
@ -612,12 +612,12 @@ spa_alsa_sink_node_port_send_command (SpaNode *node,
|
|||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
|
|
@ -720,7 +720,7 @@ spa_alsa_sink_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaALSASink *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -753,20 +753,20 @@ alsa_sink_init (const SpaHandleFactory *factory,
|
|||
this = (SpaALSASink *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
this->data_loop = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
this->main_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = alsasink_node;
|
||||
this->stream = SND_PCM_STREAM_PLAYBACK;
|
||||
|
|
|
|||
|
|
@ -84,13 +84,13 @@ spa_alsa_source_node_get_props (SpaNode *node,
|
|||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP (&f[1], this->uri.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
|
||||
PROP_MM (&f[1], this->uri.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX),
|
||||
PROP_MM (&f[1], this->uri.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX),
|
||||
PROP (&f[1], this->uri.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event));
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)),
|
||||
PROP_MM (&f[1], this->type.prop_period_size, SPA_POD_TYPE_INT, this->props.period_size, 1, INT32_MAX),
|
||||
PROP_MM (&f[1], this->type.prop_periods, SPA_POD_TYPE_INT, this->props.periods, 1, INT32_MAX),
|
||||
PROP (&f[1], this->type.prop_period_event, SPA_POD_TYPE_BOOL, this->props.period_event));
|
||||
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
||||
|
|
@ -113,10 +113,10 @@ spa_alsa_source_node_set_props (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
this->uri.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size,
|
||||
this->uri.prop_periods, SPA_POD_TYPE_INT, &this->props.periods,
|
||||
this->uri.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event,
|
||||
this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
this->type.prop_period_size, SPA_POD_TYPE_INT, &this->props.period_size,
|
||||
this->type.prop_periods, SPA_POD_TYPE_INT, &this->props.periods,
|
||||
this->type.prop_period_event, SPA_POD_TYPE_BOOL, &this->props.period_event,
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ do_start (SpaLoop *loop,
|
|||
}
|
||||
|
||||
if (async) {
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete,
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
|
||||
seq, res);
|
||||
spa_loop_invoke (this->main_loop,
|
||||
do_send_event,
|
||||
|
|
@ -182,7 +182,7 @@ do_pause (SpaLoop *loop,
|
|||
}
|
||||
|
||||
if (async) {
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete,
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
|
||||
seq, res);
|
||||
spa_loop_invoke (this->main_loop,
|
||||
do_send_event,
|
||||
|
|
@ -205,7 +205,7 @@ spa_alsa_source_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaALSASource, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ spa_alsa_source_node_send_command (SpaNode *node,
|
|||
NULL,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -340,17 +340,17 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype.raw,
|
||||
PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3, this->type.audio_format.S16,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S32),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
break;
|
||||
case 1:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes_audio.aac,
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype_audio.aac,
|
||||
SPA_POD_TYPE_NONE);
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -434,15 +434,15 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
|
|||
this->info.params = this->params;
|
||||
|
||||
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
|
||||
PROP_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->period_frames * this->frame_size),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
|
||||
PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
this->info.extra = NULL;
|
||||
|
|
@ -671,11 +671,11 @@ spa_alsa_source_node_port_send_command (SpaNode *node,
|
|||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_pause (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
} else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
} else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
if (SPA_RESULT_IS_OK (res = spa_alsa_start (this, false))) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
|
|
@ -783,9 +783,9 @@ spa_alsa_source_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaALSASource *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else if (interface_id == this->uri.clock)
|
||||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -818,20 +818,20 @@ alsa_source_init (const SpaHandleFactory *factory,
|
|||
this = (SpaALSASource *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
this->data_loop = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
this->main_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = alsasource_node;
|
||||
this->clock = alsasource_clock;
|
||||
|
|
|
|||
|
|
@ -62,18 +62,18 @@ typedef struct {
|
|||
} FormatInfo;
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define _FORMAT_LE(fmt) offsetof(URI, audio_formats. fmt ## _OE)
|
||||
#define _FORMAT_BE(fmt) offsetof(URI, audio_formats. fmt)
|
||||
#define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt ## _OE)
|
||||
#define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt)
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define _FORMAT_LE(fmt) offsetof(URI, audio_formats. fmt)
|
||||
#define _FORMAT_BE(fmt) offsetof(URI, audio_formats. fmt ## _OE)
|
||||
#define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt)
|
||||
#define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt ## _OE)
|
||||
#endif
|
||||
|
||||
static const FormatInfo format_info[] =
|
||||
{
|
||||
{ offsetof(URI, audio_formats.UNKNOWN), SND_PCM_FORMAT_UNKNOWN },
|
||||
{ offsetof(URI, audio_formats.S8), SND_PCM_FORMAT_S8 },
|
||||
{ offsetof(URI, audio_formats.U8), SND_PCM_FORMAT_U8 },
|
||||
{ offsetof(Type, audio_format.UNKNOWN), SND_PCM_FORMAT_UNKNOWN },
|
||||
{ offsetof(Type, audio_format.S8), SND_PCM_FORMAT_S8 },
|
||||
{ offsetof(Type, audio_format.U8), SND_PCM_FORMAT_U8 },
|
||||
{ _FORMAT_LE (S16), SND_PCM_FORMAT_S16_LE },
|
||||
{ _FORMAT_BE (S16), SND_PCM_FORMAT_S16_BE },
|
||||
{ _FORMAT_LE (U16), SND_PCM_FORMAT_U16_LE },
|
||||
|
|
@ -93,12 +93,12 @@ static const FormatInfo format_info[] =
|
|||
};
|
||||
|
||||
static snd_pcm_format_t
|
||||
spa_alsa_format_to_alsa (URI *uri, uint32_t format)
|
||||
spa_alsa_format_to_alsa (Type *map, uint32_t format)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS (format_info); i++) {
|
||||
uint32_t f = *SPA_MEMBER (uri, format_info[i].format_offset, uint32_t);
|
||||
uint32_t f = *SPA_MEMBER (map, format_info[i].format_offset, uint32_t);
|
||||
if (f == format)
|
||||
return format_info[i].format;
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, SpaPortFormatFlags
|
|||
CHECK (snd_pcm_hw_params_set_access(hndl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED), "set_access");
|
||||
|
||||
/* set the sample format */
|
||||
format = spa_alsa_format_to_alsa (&state->uri, info->format);
|
||||
format = spa_alsa_format_to_alsa (&state->type, info->format);
|
||||
spa_log_info (state->log, "Stream parameters are %iHz, %s, %i channels", info->rate, snd_pcm_format_name(format), info->channels);
|
||||
CHECK (snd_pcm_hw_params_set_format (hndl, params, format), "set_format");
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ pull_frames_queue (SpaALSAState *state,
|
|||
snd_pcm_uframes_t frames)
|
||||
{
|
||||
if (spa_list_is_empty (&state->ready)) {
|
||||
SpaEvent event = SPA_EVENT_INIT (state->uri.event_node.NeedInput);
|
||||
SpaEvent event = SPA_EVENT_INIT (state->type.event_node.NeedInput);
|
||||
state->event_cb (&state->node, &event, state->user_data);
|
||||
}
|
||||
if (!spa_list_is_empty (&state->ready)) {
|
||||
|
|
@ -294,7 +294,7 @@ pull_frames_queue (SpaALSAState *state,
|
|||
|
||||
state->ready_offset += n_bytes;
|
||||
if (state->ready_offset >= size) {
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->uri.event_node.ReuseBuffer,
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->type.event_node.ReuseBuffer,
|
||||
0, b->outbuf->id);
|
||||
|
||||
spa_list_remove (&b->link);
|
||||
|
|
@ -349,7 +349,7 @@ pull_frames_ringbuffer (SpaALSAState *state,
|
|||
|
||||
b->outstanding = true;
|
||||
{
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->uri.event_node.ReuseBuffer,
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (state->type.event_node.ReuseBuffer,
|
||||
0, b->outbuf->id);
|
||||
state->event_cb (&state->node, (SpaEvent*)&rb, state->user_data);
|
||||
}
|
||||
|
|
@ -498,7 +498,7 @@ mmap_read (SpaALSAState *state)
|
|||
output->status = SPA_RESULT_OK;
|
||||
}
|
||||
{
|
||||
SpaEvent event = SPA_EVENT_INIT (state->uri.event_node.HaveOutput);
|
||||
SpaEvent event = SPA_EVENT_INIT (state->type.event_node.HaveOutput);
|
||||
state->event_cb (&state->node, &event, state->user_data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
|
||||
#include <asoundlib.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/list.h>
|
||||
|
|
@ -71,40 +71,40 @@ typedef struct {
|
|||
uint32_t prop_period_size;
|
||||
uint32_t prop_periods;
|
||||
uint32_t prop_period_event;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaMediaSubtypesAudio media_subtypes_audio;
|
||||
SpaPropAudio prop_audio;
|
||||
SpaAudioFormats audio_formats;
|
||||
SpaEventNode event_node;
|
||||
SpaCommandNode command_node;
|
||||
SpaAllocParamBuffers alloc_param_buffers;
|
||||
SpaAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypeMediaSubtypeAudio media_subtype_audio;
|
||||
SpaTypePropAudio prop_audio;
|
||||
SpaTypeAudioFormat audio_format;
|
||||
SpaTypeEventNode event_node;
|
||||
SpaTypeCommandNode command_node;
|
||||
SpaTypeAllocParamBuffers alloc_param_buffers;
|
||||
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock);
|
||||
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format);
|
||||
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props);
|
||||
uri->prop_device = spa_id_map_get_id (map, SPA_TYPE_PROPS__device);
|
||||
uri->prop_device_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceName);
|
||||
uri->prop_card_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__cardName);
|
||||
uri->prop_period_size = spa_id_map_get_id (map, SPA_TYPE_PROPS__periodSize);
|
||||
uri->prop_periods = spa_id_map_get_id (map, SPA_TYPE_PROPS__periods);
|
||||
uri->prop_period_event = spa_id_map_get_id (map, SPA_TYPE_PROPS__periodEvent);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
|
||||
type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
|
||||
type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
|
||||
type->prop_device = spa_type_map_get_id (map, SPA_TYPE_PROPS__device);
|
||||
type->prop_device_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceName);
|
||||
type->prop_card_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__cardName);
|
||||
type->prop_period_size = spa_type_map_get_id (map, SPA_TYPE_PROPS__periodSize);
|
||||
type->prop_periods = spa_type_map_get_id (map, SPA_TYPE_PROPS__periods);
|
||||
type->prop_period_event = spa_type_map_get_id (map, SPA_TYPE_PROPS__periodEvent);
|
||||
|
||||
spa_media_types_fill (&uri->media_types, map);
|
||||
spa_media_subtypes_map (map, &uri->media_subtypes);
|
||||
spa_media_subtypes_audio_map (map, &uri->media_subtypes_audio);
|
||||
spa_prop_audio_map (map, &uri->prop_audio);
|
||||
spa_audio_formats_map (map, &uri->audio_formats);
|
||||
spa_event_node_map (map, &uri->event_node);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers);
|
||||
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable);
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_media_subtype_audio_map (map, &type->media_subtype_audio);
|
||||
spa_type_prop_audio_map (map, &type->prop_audio);
|
||||
spa_type_audio_format_map (map, &type->audio_format);
|
||||
spa_type_event_node_map (map, &type->event_node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
|
||||
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
|
||||
}
|
||||
|
||||
struct _SpaALSAState {
|
||||
|
|
@ -114,8 +114,8 @@ struct _SpaALSAState {
|
|||
|
||||
uint32_t seq;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *main_loop;
|
||||
SpaLoop *data_loop;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/audio/format-utils.h>
|
||||
#include <lib/props.h>
|
||||
|
|
@ -58,22 +58,22 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
SpaCommandNode command_node;
|
||||
} URI;
|
||||
SpaTypeCommandNode command_node;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
}
|
||||
|
||||
struct _SpaAudioMixer {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaEventNodeCallback event_cb;
|
||||
|
|
@ -125,10 +125,10 @@ spa_audiomixer_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioMixer, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
|
|
@ -659,7 +659,7 @@ spa_audiomixer_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaAudioMixer *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -692,16 +692,16 @@ spa_audiomixer_init (const SpaHandleFactory *factory,
|
|||
this = (SpaAudioMixer *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = audiomixer_node;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/loop.h>
|
||||
|
|
@ -48,37 +48,37 @@ typedef struct {
|
|||
uint32_t prop_volume;
|
||||
uint32_t wave_sine;
|
||||
uint32_t wave_square;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaPropAudio prop_audio;
|
||||
SpaAudioFormats audio_formats;
|
||||
SpaEventNode event_node;
|
||||
SpaCommandNode command_node;
|
||||
SpaAllocParamBuffers alloc_param_buffers;
|
||||
SpaAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypePropAudio prop_audio;
|
||||
SpaTypeAudioFormat audio_format;
|
||||
SpaTypeEventNode event_node;
|
||||
SpaTypeCommandNode command_node;
|
||||
SpaTypeAllocParamBuffers alloc_param_buffers;
|
||||
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock);
|
||||
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format);
|
||||
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props);
|
||||
uri->prop_live = spa_id_map_get_id (map, SPA_TYPE_PROPS__live);
|
||||
uri->prop_wave = spa_id_map_get_id (map, SPA_TYPE_PROPS__waveType);
|
||||
uri->prop_freq = spa_id_map_get_id (map, SPA_TYPE_PROPS__frequency);
|
||||
uri->prop_volume = spa_id_map_get_id (map, SPA_TYPE_PROPS__volume);
|
||||
uri->wave_sine = spa_id_map_get_id (map, SPA_TYPE_PROPS__waveType ":sine");
|
||||
uri->wave_square = spa_id_map_get_id (map, SPA_TYPE_PROPS__waveType ":square");
|
||||
spa_media_types_fill (&uri->media_types, map);
|
||||
spa_media_subtypes_map (map, &uri->media_subtypes);
|
||||
spa_prop_audio_map (map, &uri->prop_audio);
|
||||
spa_audio_formats_map (map, &uri->audio_formats);
|
||||
spa_event_node_map (map, &uri->event_node);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers);
|
||||
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
|
||||
type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
|
||||
type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
|
||||
type->prop_live = spa_type_map_get_id (map, SPA_TYPE_PROPS__live);
|
||||
type->prop_wave = spa_type_map_get_id (map, SPA_TYPE_PROPS__waveType);
|
||||
type->prop_freq = spa_type_map_get_id (map, SPA_TYPE_PROPS__frequency);
|
||||
type->prop_volume = spa_type_map_get_id (map, SPA_TYPE_PROPS__volume);
|
||||
type->wave_sine = spa_type_map_get_id (map, SPA_TYPE_PROPS__waveType ":sine");
|
||||
type->wave_square = spa_type_map_get_id (map, SPA_TYPE_PROPS__waveType ":square");
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_prop_audio_map (map, &type->prop_audio);
|
||||
spa_type_audio_format_map (map, &type->audio_format);
|
||||
spa_type_event_node_map (map, &type->event_node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
|
||||
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
|
||||
}
|
||||
|
||||
typedef struct _SpaAudioTestSrc SpaAudioTestSrc;
|
||||
|
|
@ -108,8 +108,8 @@ struct _SpaAudioTestSrc {
|
|||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *data_loop;
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ static void
|
|||
reset_audiotestsrc_props (SpaAudioTestSrc *this, SpaAudioTestSrcProps *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->wave = this->uri. DEFAULT_WAVE;
|
||||
props->wave = this->type. DEFAULT_WAVE;
|
||||
props->freq = DEFAULT_FREQ;
|
||||
props->volume = DEFAULT_VOLUME;
|
||||
}
|
||||
|
|
@ -190,14 +190,14 @@ spa_audiotestsrc_node_get_props (SpaNode *node,
|
|||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP (&f[1], this->uri.prop_live, SPA_POD_TYPE_BOOL, this->props.live),
|
||||
PROP_EN (&f[1], this->uri.prop_wave, SPA_POD_TYPE_URI, 3, this->props.wave,
|
||||
this->uri.wave_sine,
|
||||
this->uri.wave_square),
|
||||
PROP_MM (&f[1], this->uri.prop_freq, SPA_POD_TYPE_DOUBLE, this->props.freq,
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP (&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL, this->props.live),
|
||||
PROP_EN (&f[1], this->type.prop_wave, SPA_POD_TYPE_URI, 3, this->props.wave,
|
||||
this->type.wave_sine,
|
||||
this->type.wave_square),
|
||||
PROP_MM (&f[1], this->type.prop_freq, SPA_POD_TYPE_DOUBLE, this->props.freq,
|
||||
0.0, 50000000.0),
|
||||
PROP_MM (&f[1], this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume,
|
||||
PROP_MM (&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume,
|
||||
0.0, 10.0));
|
||||
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
|
@ -220,10 +220,10 @@ spa_audiotestsrc_node_set_props (SpaNode *node,
|
|||
reset_audiotestsrc_props (this, &this->props);
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
this->uri.prop_wave, SPA_POD_TYPE_URI, &this->props.wave,
|
||||
this->uri.prop_freq, SPA_POD_TYPE_DOUBLE, &this->props.freq,
|
||||
this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
|
||||
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
this->type.prop_wave, SPA_POD_TYPE_URI, &this->props.wave,
|
||||
this->type.prop_freq, SPA_POD_TYPE_DOUBLE, &this->props.freq,
|
||||
this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ send_have_output (SpaAudioTestSrc *this)
|
|||
{
|
||||
|
||||
if (this->event_cb) {
|
||||
SpaEvent event = SPA_EVENT_INIT (this->uri.event_node.HaveOutput);
|
||||
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
|
|
@ -358,7 +358,7 @@ spa_audiotestsrc_node_send_command (SpaNode *node,
|
|||
set_timer (this, true);
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -484,13 +484,13 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3, this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype.raw,
|
||||
PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3, this->type.audio_format.S16,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S32),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -560,15 +560,15 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
|
|||
this->info.params = this->params;
|
||||
|
||||
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, 1024),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 1024),
|
||||
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 1024),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 1024),
|
||||
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
this->info.extra = NULL;
|
||||
|
|
@ -602,11 +602,11 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node,
|
|||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate),
|
||||
PROP (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels));
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype.raw,
|
||||
PROP (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate),
|
||||
PROP (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels));
|
||||
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
|
||||
|
||||
|
|
@ -909,9 +909,9 @@ spa_audiotestsrc_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaAudioTestSrc *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else if (interface_id == this->uri.clock)
|
||||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -953,22 +953,22 @@ audiotestsrc_init (const SpaHandleFactory *factory,
|
|||
this = (SpaAudioTestSrc *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
this->data_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
if (this->data_loop == NULL) {
|
||||
spa_log_error (this->log, "a data_loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = audiotestsrc_node;
|
||||
this->clock = audiotestsrc_clock;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
|
|
@ -52,15 +52,22 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
SpaCommandNode command_node;
|
||||
} URI;
|
||||
SpaTypeCommandNode command_node;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
}
|
||||
|
||||
struct _SpaFFMpegDec {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaEventNodeCallback event_cb;
|
||||
|
|
@ -105,10 +112,10 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
|
|
@ -491,7 +498,7 @@ spa_ffmpeg_dec_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaFFMpegDec *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -513,19 +520,18 @@ spa_ffmpeg_dec_init (SpaHandle *handle,
|
|||
this = (SpaFFMpegDec *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_TYPE__Node);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = ffmpeg_dec_node;
|
||||
spa_command_node_map (this->map, &this->uri.command_node);
|
||||
|
||||
this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
#include <lib/props.h>
|
||||
|
|
@ -57,17 +57,26 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t node;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaCommandNode command_node;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypeCommandNode command_node;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
}
|
||||
|
||||
struct _SpaFFMpegEnc {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
SpaEventNodeCallback event_cb;
|
||||
|
|
@ -112,10 +121,10 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
|
|
@ -258,8 +267,8 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if (format->body.media_type.value != this->uri.media_types.video ||
|
||||
format->body.media_subtype.value != this->uri.media_subtypes.raw)
|
||||
if (format->body.media_type.value != this->type.media_type.video ||
|
||||
format->body.media_subtype.value != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if ((res = spa_format_video_parse (format, &query_format) < 0))
|
||||
|
|
@ -504,7 +513,7 @@ spa_ffmpeg_enc_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaFFMpegEnc *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -526,19 +535,15 @@ spa_ffmpeg_enc_init (SpaHandle *handle,
|
|||
this = (SpaFFMpegEnc *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.node = spa_id_map_get_id (this->map, SPA_TYPE__Node);
|
||||
spa_media_types_fill (&this->uri.media_types, this->map);
|
||||
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
|
||||
spa_command_node_map (this->map, &this->uri.command_node);
|
||||
|
||||
this->node = ffmpeg_enc_node;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#include <libudev.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/loop.h>
|
||||
#include <spa/monitor.h>
|
||||
#include <lib/debug.h>
|
||||
|
|
@ -42,15 +42,22 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t handle_factory;
|
||||
SpaMonitorTypes monitor_types;
|
||||
} URI;
|
||||
SpaTypeMonitor monitor;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory);
|
||||
spa_type_monitor_map (map, &type->monitor);
|
||||
}
|
||||
|
||||
struct _SpaV4l2Monitor {
|
||||
SpaHandle handle;
|
||||
SpaMonitor monitor;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *main_loop;
|
||||
|
||||
|
|
@ -108,20 +115,20 @@ fill_item (SpaV4l2Monitor *this, V4l2Item *item, struct udev_device *udevice)
|
|||
|
||||
spa_pod_builder_init (&b, this->item_buffer, sizeof (this->item_buffer));
|
||||
|
||||
spa_pod_builder_push_object (&b, &f[0], 0, this->uri.monitor_types.MonitorItem);
|
||||
spa_pod_builder_push_object (&b, &f[0], 0, this->type.monitor.MonitorItem);
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.flags, 0, SPA_POD_TYPE_INT, 1, 0),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.name, 0, SPA_POD_TYPE_STRING, 1, name),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.klass, 0, SPA_POD_TYPE_STRING, 1, "Video/Source"),
|
||||
SPA_POD_PROP (&f[1], this->uri.monitor_types.factory, 0, SPA_POD_TYPE_POINTER, 1, this->uri.handle_factory,
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.id, 0, SPA_POD_TYPE_STRING, 1, udev_device_get_syspath (item->udevice)),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.flags, 0, SPA_POD_TYPE_INT, 1, 0),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.state, 0, SPA_POD_TYPE_INT, 1, SPA_MONITOR_ITEM_STATE_AVAILABLE),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.name, 0, SPA_POD_TYPE_STRING, 1, name),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.klass, 0, SPA_POD_TYPE_STRING, 1, "Video/Source"),
|
||||
SPA_POD_PROP (&f[1], this->type.monitor.factory, 0, SPA_POD_TYPE_POINTER, 1, this->type.handle_factory,
|
||||
&spa_v4l2_source_factory),
|
||||
0);
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
SPA_POD_TYPE_PROP, &f[1], this->uri.monitor_types.info, 0,
|
||||
SPA_POD_TYPE_PROP, &f[1], this->type.monitor.info, 0,
|
||||
SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
|
||||
|
||||
|
||||
|
|
@ -204,11 +211,11 @@ v4l2_on_fd_events (SpaSource *source)
|
|||
action = "change";
|
||||
|
||||
if (strcmp (action, "add") == 0) {
|
||||
type = this->uri.monitor_types.Added;
|
||||
type = this->type.monitor.Added;
|
||||
} else if (strcmp (action, "change") == 0) {
|
||||
type = this->uri.monitor_types.Changed;
|
||||
type = this->type.monitor.Changed;
|
||||
} else if (strcmp (action, "remove") == 0) {
|
||||
type = this->uri.monitor_types.Removed;
|
||||
type = this->type.monitor.Removed;
|
||||
} else
|
||||
return;
|
||||
|
||||
|
|
@ -333,7 +340,7 @@ spa_v4l2_monitor_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaV4l2Monitor *) handle;
|
||||
|
||||
if (interface_id == this->uri.monitor_types.Monitor)
|
||||
if (interface_id == this->type.monitor.Monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -366,23 +373,22 @@ v4l2_monitor_init (const SpaHandleFactory *factory,
|
|||
this = (SpaV4l2Monitor *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
this->main_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
spa_log_error (this->log, "a main-loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
this->uri.handle_factory = spa_id_map_get_id (this->map, SPA_TYPE__HandleFactory);
|
||||
spa_monitor_types_map (this->map, &this->uri.monitor_types);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->monitor = v4l2monitor;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include <spa/list.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/loop.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/format-builder.h>
|
||||
#include <lib/debug.h>
|
||||
#include <lib/props.h>
|
||||
|
|
@ -71,36 +71,36 @@ typedef struct {
|
|||
uint32_t prop_device;
|
||||
uint32_t prop_device_name;
|
||||
uint32_t prop_device_fd;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaMediaSubtypesVideo media_subtypes_video;
|
||||
SpaPropVideo prop_video;
|
||||
SpaVideoFormats video_formats;
|
||||
SpaEventNode event_node;
|
||||
SpaCommandNode command_node;
|
||||
SpaAllocParamBuffers alloc_param_buffers;
|
||||
SpaAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypeMediaSubtypeVideo media_subtype_video;
|
||||
SpaTypePropVideo prop_video;
|
||||
SpaTypeVideoFormat video_format;
|
||||
SpaTypeEventNode event_node;
|
||||
SpaTypeCommandNode command_node;
|
||||
SpaTypeAllocParamBuffers alloc_param_buffers;
|
||||
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock);
|
||||
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format);
|
||||
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props);
|
||||
uri->prop_device = spa_id_map_get_id (map, SPA_TYPE_PROPS__device);
|
||||
uri->prop_device_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceName);
|
||||
uri->prop_device_fd = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceFd);
|
||||
spa_media_types_fill (&uri->media_types, map);
|
||||
spa_media_subtypes_map (map, &uri->media_subtypes);
|
||||
spa_media_subtypes_video_map (map, &uri->media_subtypes_video);
|
||||
spa_prop_video_map (map, &uri->prop_video);
|
||||
spa_video_formats_map (map, &uri->video_formats);
|
||||
spa_event_node_map (map, &uri->event_node);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers);
|
||||
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
|
||||
type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
|
||||
type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
|
||||
type->prop_device = spa_type_map_get_id (map, SPA_TYPE_PROPS__device);
|
||||
type->prop_device_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceName);
|
||||
type->prop_device_fd = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceFd);
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_media_subtype_video_map (map, &type->media_subtype_video);
|
||||
spa_type_prop_video_map (map, &type->prop_video);
|
||||
spa_type_video_format_map (map, &type->video_format);
|
||||
spa_type_event_node_map (map, &type->event_node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
|
||||
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -148,9 +148,9 @@ struct _SpaV4l2Source {
|
|||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
SpaIDMap *map;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
URI uri;
|
||||
Type type;
|
||||
|
||||
uint32_t seq;
|
||||
|
||||
|
|
@ -206,10 +206,10 @@ spa_v4l2_source_node_get_props (SpaNode *node,
|
|||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP_R (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP_R (&f[1], this->uri.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd));
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP_R (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP_R (&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd));
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -231,7 +231,7 @@ spa_v4l2_source_node_set_props (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -279,7 +279,7 @@ do_pause (SpaLoop *loop,
|
|||
cmd);
|
||||
|
||||
if (async) {
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete,
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
|
||||
seq, res);
|
||||
spa_loop_invoke (this->state[0].main_loop,
|
||||
do_pause_done,
|
||||
|
|
@ -330,7 +330,7 @@ do_start (SpaLoop *loop,
|
|||
cmd);
|
||||
|
||||
if (async) {
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->uri.event_node.AsyncComplete,
|
||||
SpaEventNodeAsyncComplete ac = SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete,
|
||||
seq, res);
|
||||
spa_loop_invoke (this->state[0].main_loop,
|
||||
do_start_done,
|
||||
|
|
@ -354,7 +354,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaV4l2Source, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
SpaResult res;
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
|
|||
command,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
SpaV4l2State *state = &this->state[0];
|
||||
|
||||
if (!state->have_format)
|
||||
|
|
@ -396,7 +396,7 @@ spa_v4l2_source_node_send_command (SpaNode *node,
|
|||
command,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.ClockUpdate) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.ClockUpdate) {
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
else
|
||||
|
|
@ -587,28 +587,28 @@ spa_v4l2_source_node_port_get_format (SpaNode *node,
|
|||
b.data = state->format_buffer;
|
||||
b.size = sizeof (state->format_buffer);
|
||||
|
||||
spa_pod_builder_push_format (&b, &f[0], this->uri.format,
|
||||
spa_pod_builder_push_format (&b, &f[0], this->type.format,
|
||||
state->current_format.media_type,
|
||||
state->current_format.media_subtype);
|
||||
|
||||
if (state->current_format.media_subtype == this->uri.media_subtypes.raw) {
|
||||
if (state->current_format.media_subtype == this->type.media_subtype.raw) {
|
||||
spa_pod_builder_add (&b,
|
||||
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, state->current_format.info.raw.format),
|
||||
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.raw.size),
|
||||
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.raw.framerate),
|
||||
PROP (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, state->current_format.info.raw.format),
|
||||
PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.raw.size),
|
||||
PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.raw.framerate),
|
||||
0);
|
||||
}
|
||||
else if (state->current_format.media_subtype == this->uri.media_subtypes_video.mjpg ||
|
||||
state->current_format.media_subtype == this->uri.media_subtypes_video.jpeg) {
|
||||
else if (state->current_format.media_subtype == this->type.media_subtype_video.mjpg ||
|
||||
state->current_format.media_subtype == this->type.media_subtype_video.jpeg) {
|
||||
spa_pod_builder_add (&b,
|
||||
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.mjpg.size),
|
||||
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.mjpg.framerate),
|
||||
PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.mjpg.size),
|
||||
PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.mjpg.framerate),
|
||||
0);
|
||||
}
|
||||
else if (state->current_format.media_subtype == this->uri.media_subtypes_video.h264) {
|
||||
else if (state->current_format.media_subtype == this->type.media_subtype_video.h264) {
|
||||
spa_pod_builder_add (&b,
|
||||
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.h264.size),
|
||||
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.h264.framerate),
|
||||
PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.h264.size),
|
||||
PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.h264.framerate),
|
||||
0);
|
||||
} else
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
|
@ -807,10 +807,10 @@ spa_v4l2_source_node_port_send_command (SpaNode *node,
|
|||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
res = spa_v4l2_port_set_enabled (this, false);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
res = spa_v4l2_port_set_enabled (this, true);
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
@ -918,9 +918,9 @@ spa_v4l2_source_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaV4l2Source *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else if (interface_id == this->uri.clock)
|
||||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -954,17 +954,17 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
this = (SpaV4l2Source *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0)
|
||||
this->state[0].main_loop = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
this->state[0].data_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
if (this->state[0].main_loop == NULL) {
|
||||
|
|
@ -975,7 +975,7 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
spa_log_error (this->log, "a data_loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = v4l2source_node;
|
||||
this->clock = v4l2source_clock;
|
||||
|
|
|
|||
|
|
@ -169,54 +169,54 @@ typedef struct {
|
|||
off_t media_subtype_offset;
|
||||
} FormatInfo;
|
||||
|
||||
#define VIDEO offsetof(URI, media_types.video)
|
||||
#define IMAGE offsetof(URI, media_types.image)
|
||||
#define VIDEO offsetof(Type, media_type.video)
|
||||
#define IMAGE offsetof(Type, media_type.image)
|
||||
|
||||
#define RAW offsetof(URI, media_subtypes.raw)
|
||||
#define RAW offsetof(Type, media_subtype.raw)
|
||||
|
||||
#define BAYER offsetof(URI, media_subtypes_video.bayer)
|
||||
#define MJPG offsetof(URI, media_subtypes_video.mjpg)
|
||||
#define JPEG offsetof(URI, media_subtypes_video.jpeg)
|
||||
#define DV offsetof(URI, media_subtypes_video.dv)
|
||||
#define MPEGTS offsetof(URI, media_subtypes_video.mpegts)
|
||||
#define H264 offsetof(URI, media_subtypes_video.h264)
|
||||
#define H263 offsetof(URI, media_subtypes_video.h263)
|
||||
#define MPEG1 offsetof(URI, media_subtypes_video.mpeg1)
|
||||
#define MPEG2 offsetof(URI, media_subtypes_video.mpeg2)
|
||||
#define MPEG4 offsetof(URI, media_subtypes_video.mpeg4)
|
||||
#define XVID offsetof(URI, media_subtypes_video.xvid)
|
||||
#define VC1 offsetof(URI, media_subtypes_video.vc1)
|
||||
#define VP8 offsetof(URI, media_subtypes_video.vp8)
|
||||
#define BAYER offsetof(Type, media_subtype_video.bayer)
|
||||
#define MJPG offsetof(Type, media_subtype_video.mjpg)
|
||||
#define JPEG offsetof(Type, media_subtype_video.jpeg)
|
||||
#define DV offsetof(Type, media_subtype_video.dv)
|
||||
#define MPEGTS offsetof(Type, media_subtype_video.mpegts)
|
||||
#define H264 offsetof(Type, media_subtype_video.h264)
|
||||
#define H263 offsetof(Type, media_subtype_video.h263)
|
||||
#define MPEG1 offsetof(Type, media_subtype_video.mpeg1)
|
||||
#define MPEG2 offsetof(Type, media_subtype_video.mpeg2)
|
||||
#define MPEG4 offsetof(Type, media_subtype_video.mpeg4)
|
||||
#define XVID offsetof(Type, media_subtype_video.xvid)
|
||||
#define VC1 offsetof(Type, media_subtype_video.vc1)
|
||||
#define VP8 offsetof(Type, media_subtype_video.vp8)
|
||||
|
||||
#define FORMAT_UNKNOWN offsetof(URI, video_formats.UNKNOWN)
|
||||
#define FORMAT_ENCODED offsetof(URI, video_formats.ENCODED)
|
||||
#define FORMAT_RGB15 offsetof(URI, video_formats.RGB15)
|
||||
#define FORMAT_BGR15 offsetof(URI, video_formats.BGR15)
|
||||
#define FORMAT_RGB16 offsetof(URI, video_formats.RGB16)
|
||||
#define FORMAT_BGR offsetof(URI, video_formats.BGR)
|
||||
#define FORMAT_RGB offsetof(URI, video_formats.RGB)
|
||||
#define FORMAT_BGRA offsetof(URI, video_formats.BGRA)
|
||||
#define FORMAT_BGRx offsetof(URI, video_formats.BGRx)
|
||||
#define FORMAT_ARGB offsetof(URI, video_formats.ARGB)
|
||||
#define FORMAT_xRGB offsetof(URI, video_formats.xRGB)
|
||||
#define FORMAT_GRAY8 offsetof(URI, video_formats.GRAY8)
|
||||
#define FORMAT_GRAY16_LE offsetof(URI, video_formats.GRAY16_LE)
|
||||
#define FORMAT_GRAY16_BE offsetof(URI, video_formats.GRAY16_BE)
|
||||
#define FORMAT_YVU9 offsetof(URI, video_formats.YVU9)
|
||||
#define FORMAT_YV12 offsetof(URI, video_formats.YV12)
|
||||
#define FORMAT_YUY2 offsetof(URI, video_formats.YUY2)
|
||||
#define FORMAT_YVYU offsetof(URI, video_formats.YVYU)
|
||||
#define FORMAT_UYVY offsetof(URI, video_formats.UYVY)
|
||||
#define FORMAT_Y42B offsetof(URI, video_formats.Y42B)
|
||||
#define FORMAT_Y41B offsetof(URI, video_formats.Y41B)
|
||||
#define FORMAT_YUV9 offsetof(URI, video_formats.YUV9)
|
||||
#define FORMAT_I420 offsetof(URI, video_formats.I420)
|
||||
#define FORMAT_NV12 offsetof(URI, video_formats.NV12)
|
||||
#define FORMAT_NV12_64Z32 offsetof(URI, video_formats.NV12_64Z32)
|
||||
#define FORMAT_NV21 offsetof(URI, video_formats.NV21)
|
||||
#define FORMAT_NV16 offsetof(URI, video_formats.NV16)
|
||||
#define FORMAT_NV61 offsetof(URI, video_formats.NV61)
|
||||
#define FORMAT_NV24 offsetof(URI, video_formats.NV24)
|
||||
#define FORMAT_UNKNOWN offsetof(Type, video_format.UNKNOWN)
|
||||
#define FORMAT_ENCODED offsetof(Type, video_format.ENCODED)
|
||||
#define FORMAT_RGB15 offsetof(Type, video_format.RGB15)
|
||||
#define FORMAT_BGR15 offsetof(Type, video_format.BGR15)
|
||||
#define FORMAT_RGB16 offsetof(Type, video_format.RGB16)
|
||||
#define FORMAT_BGR offsetof(Type, video_format.BGR)
|
||||
#define FORMAT_RGB offsetof(Type, video_format.RGB)
|
||||
#define FORMAT_BGRA offsetof(Type, video_format.BGRA)
|
||||
#define FORMAT_BGRx offsetof(Type, video_format.BGRx)
|
||||
#define FORMAT_ARGB offsetof(Type, video_format.ARGB)
|
||||
#define FORMAT_xRGB offsetof(Type, video_format.xRGB)
|
||||
#define FORMAT_GRAY8 offsetof(Type, video_format.GRAY8)
|
||||
#define FORMAT_GRAY16_LE offsetof(Type, video_format.GRAY16_LE)
|
||||
#define FORMAT_GRAY16_BE offsetof(Type, video_format.GRAY16_BE)
|
||||
#define FORMAT_YVU9 offsetof(Type, video_format.YVU9)
|
||||
#define FORMAT_YV12 offsetof(Type, video_format.YV12)
|
||||
#define FORMAT_YUY2 offsetof(Type, video_format.YUY2)
|
||||
#define FORMAT_YVYU offsetof(Type, video_format.YVYU)
|
||||
#define FORMAT_UYVY offsetof(Type, video_format.UYVY)
|
||||
#define FORMAT_Y42B offsetof(Type, video_format.Y42B)
|
||||
#define FORMAT_Y41B offsetof(Type, video_format.Y41B)
|
||||
#define FORMAT_YUV9 offsetof(Type, video_format.YUV9)
|
||||
#define FORMAT_I420 offsetof(Type, video_format.I420)
|
||||
#define FORMAT_NV12 offsetof(Type, video_format.NV12)
|
||||
#define FORMAT_NV12_64Z32 offsetof(Type, video_format.NV12_64Z32)
|
||||
#define FORMAT_NV21 offsetof(Type, video_format.NV21)
|
||||
#define FORMAT_NV16 offsetof(Type, video_format.NV16)
|
||||
#define FORMAT_NV61 offsetof(Type, video_format.NV61)
|
||||
#define FORMAT_NV24 offsetof(Type, video_format.NV24)
|
||||
|
||||
static const FormatInfo format_info[] =
|
||||
{
|
||||
|
|
@ -354,7 +354,7 @@ video_format_to_format_info (SpaVideoFormat format)
|
|||
#endif
|
||||
|
||||
static const FormatInfo *
|
||||
find_format_info_by_media_type (URI *uri,
|
||||
find_format_info_by_media_type (Type *types,
|
||||
uint32_t type,
|
||||
uint32_t subtype,
|
||||
uint32_t format,
|
||||
|
|
@ -365,9 +365,9 @@ find_format_info_by_media_type (URI *uri,
|
|||
for (i = startidx; i < SPA_N_ELEMENTS (format_info); i++) {
|
||||
uint32_t media_type, media_subtype, media_format;
|
||||
|
||||
media_type = *SPA_MEMBER (uri, format_info[i].media_type_offset, uint32_t);
|
||||
media_subtype = *SPA_MEMBER (uri, format_info[i].media_subtype_offset, uint32_t);
|
||||
media_format = *SPA_MEMBER (uri, format_info[i].format_offset, uint32_t);
|
||||
media_type = *SPA_MEMBER (types, format_info[i].media_type_offset, uint32_t);
|
||||
media_subtype = *SPA_MEMBER (types, format_info[i].media_subtype_offset, uint32_t);
|
||||
media_format = *SPA_MEMBER (types, format_info[i].format_offset, uint32_t);
|
||||
|
||||
if ((media_type == type) &&
|
||||
(media_subtype == subtype) &&
|
||||
|
|
@ -378,22 +378,22 @@ find_format_info_by_media_type (URI *uri,
|
|||
}
|
||||
|
||||
static uint32_t
|
||||
enum_filter_format (URI *uri, const SpaFormat *filter, uint32_t index)
|
||||
enum_filter_format (Type *type, const SpaFormat *filter, uint32_t index)
|
||||
{
|
||||
uint32_t video_format = 0;
|
||||
|
||||
if ((filter->body.media_type.value == uri->media_types.video ||
|
||||
filter->body.media_type.value == uri->media_types.image)) {
|
||||
if (filter->body.media_subtype.value == uri->media_subtypes.raw) {
|
||||
if ((filter->body.media_type.value == type->media_type.video ||
|
||||
filter->body.media_type.value == type->media_type.image)) {
|
||||
if (filter->body.media_subtype.value == type->media_subtype.raw) {
|
||||
SpaPODProp *p;
|
||||
uint32_t n_values;
|
||||
const uint32_t *values;
|
||||
|
||||
if (!(p = spa_format_find_prop (filter, uri->prop_video.format)))
|
||||
return uri->video_formats.UNKNOWN;
|
||||
if (!(p = spa_format_find_prop (filter, type->prop_video.format)))
|
||||
return type->video_format.UNKNOWN;
|
||||
|
||||
if (p->body.value.type != SPA_POD_TYPE_URI)
|
||||
return uri->video_formats.UNKNOWN;
|
||||
return type->video_format.UNKNOWN;
|
||||
|
||||
values = SPA_POD_BODY_CONST (&p->body.value);
|
||||
n_values = SPA_POD_PROP_N_VALUES (p);
|
||||
|
|
@ -407,7 +407,7 @@ enum_filter_format (URI *uri, const SpaFormat *filter, uint32_t index)
|
|||
}
|
||||
} else {
|
||||
if (index == 0)
|
||||
video_format = uri->video_formats.ENCODED;
|
||||
video_format = type->video_format.ENCODED;
|
||||
}
|
||||
}
|
||||
return video_format;
|
||||
|
|
@ -538,11 +538,11 @@ next_fmtdesc:
|
|||
|
||||
while (state->next_fmtdesc) {
|
||||
if (filter) {
|
||||
video_format = enum_filter_format (&this->uri, filter, state->fmtdesc.index);
|
||||
if (video_format == this->uri.video_formats.UNKNOWN)
|
||||
video_format = enum_filter_format (&this->type, filter, state->fmtdesc.index);
|
||||
if (video_format == this->type.video_format.UNKNOWN)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
info = find_format_info_by_media_type (&this->uri,
|
||||
info = find_format_info_by_media_type (&this->type,
|
||||
filter->body.media_type.value,
|
||||
filter->body.media_subtype.value,
|
||||
video_format,
|
||||
|
|
@ -572,7 +572,7 @@ next_frmsize:
|
|||
SpaPODProp *p;
|
||||
|
||||
/* check if we have a fixed frame size */
|
||||
if (!(p = spa_format_find_prop (filter, this->uri.prop_video.size)))
|
||||
if (!(p = spa_format_find_prop (filter, this->type.prop_video.size)))
|
||||
goto do_frmsize;
|
||||
|
||||
if (p->body.value.type != SPA_POD_TYPE_RECTANGLE)
|
||||
|
|
@ -605,7 +605,7 @@ do_frmsize:
|
|||
uint32_t i, n_values;
|
||||
|
||||
/* check if we have a fixed frame size */
|
||||
if (!(p = spa_format_find_prop (filter, this->uri.prop_video.size)))
|
||||
if (!(p = spa_format_find_prop (filter, this->type.prop_video.size)))
|
||||
goto have_size;
|
||||
|
||||
range = p->body.flags & SPA_POD_PROP_RANGE_MASK;
|
||||
|
|
@ -658,26 +658,26 @@ have_size:
|
|||
}
|
||||
}
|
||||
|
||||
media_type = *SPA_MEMBER (&this->uri, info->media_type_offset, uint32_t);
|
||||
media_subtype = *SPA_MEMBER (&this->uri, info->media_subtype_offset, uint32_t);
|
||||
video_format = *SPA_MEMBER (&this->uri, info->format_offset, uint32_t);
|
||||
media_type = *SPA_MEMBER (&this->type, info->media_type_offset, uint32_t);
|
||||
media_subtype = *SPA_MEMBER (&this->type, info->media_subtype_offset, uint32_t);
|
||||
video_format = *SPA_MEMBER (&this->type, info->format_offset, uint32_t);
|
||||
|
||||
spa_pod_builder_push_format (&b, &f[0], this->uri.format,
|
||||
spa_pod_builder_push_format (&b, &f[0], this->type.format,
|
||||
media_type,
|
||||
media_subtype);
|
||||
|
||||
if (media_subtype == this->uri.media_subtypes.raw) {
|
||||
if (media_subtype == this->type.media_subtype.raw) {
|
||||
spa_pod_builder_add (&b,
|
||||
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, video_format),
|
||||
PROP (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, video_format),
|
||||
0);
|
||||
}
|
||||
spa_pod_builder_add (&b,
|
||||
PROP (&f[1], this->uri.prop_video.size, SPA_POD_TYPE_RECTANGLE, state->frmsize.discrete.width,
|
||||
PROP (&f[1], this->type.prop_video.size, SPA_POD_TYPE_RECTANGLE, state->frmsize.discrete.width,
|
||||
state->frmsize.discrete.height),
|
||||
0);
|
||||
|
||||
spa_pod_builder_push_prop (&b, &f[1],
|
||||
this->uri.prop_video.framerate,
|
||||
this->type.prop_video.framerate,
|
||||
SPA_POD_PROP_RANGE_NONE |
|
||||
SPA_POD_PROP_FLAG_UNSET |
|
||||
SPA_POD_PROP_FLAG_READWRITE);
|
||||
|
|
@ -705,7 +705,7 @@ have_size:
|
|||
uint32_t i, n_values;
|
||||
const SpaFraction step = { 1, 1 }, *values;
|
||||
|
||||
if (!(p = spa_format_find_prop (filter, this->uri.prop_video.framerate)))
|
||||
if (!(p = spa_format_find_prop (filter, this->type.prop_video.framerate)))
|
||||
goto have_framerate;
|
||||
|
||||
if (p->body.value.type != SPA_POD_TYPE_FRACTION)
|
||||
|
|
@ -804,27 +804,27 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
|
|||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
|
||||
if (format->media_subtype == this->uri.media_subtypes.raw) {
|
||||
if (format->media_subtype == this->type.media_subtype.raw) {
|
||||
video_format = format->info.raw.format;
|
||||
size = &format->info.raw.size;
|
||||
framerate = &format->info.raw.framerate;
|
||||
}
|
||||
else if (format->media_subtype == this->uri.media_subtypes_video.mjpg ||
|
||||
format->media_subtype == this->uri.media_subtypes_video.jpeg) {
|
||||
video_format = this->uri.video_formats.ENCODED;
|
||||
else if (format->media_subtype == this->type.media_subtype_video.mjpg ||
|
||||
format->media_subtype == this->type.media_subtype_video.jpeg) {
|
||||
video_format = this->type.video_format.ENCODED;
|
||||
size = &format->info.mjpg.size;
|
||||
framerate = &format->info.mjpg.framerate;
|
||||
}
|
||||
else if (format->media_subtype == this->uri.media_subtypes_video.h264) {
|
||||
video_format = this->uri.video_formats.ENCODED;
|
||||
else if (format->media_subtype == this->type.media_subtype_video.h264) {
|
||||
video_format = this->type.video_format.ENCODED;
|
||||
size = &format->info.h264.size;
|
||||
framerate = &format->info.h264.framerate;
|
||||
}
|
||||
else {
|
||||
video_format = this->uri.video_formats.ENCODED;
|
||||
video_format = this->type.video_format.ENCODED;
|
||||
}
|
||||
|
||||
info = find_format_info_by_media_type (&this->uri,
|
||||
info = find_format_info_by_media_type (&this->type,
|
||||
format->media_type,
|
||||
format->media_subtype,
|
||||
video_format,
|
||||
|
|
@ -893,15 +893,15 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
|
|||
state->info.params = state->params;
|
||||
|
||||
spa_pod_builder_init (&b, state->params_buffer, sizeof (state->params_buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, fmt.fmt.pix.sizeimage),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, fmt.fmt.pix.bytesperline),
|
||||
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, fmt.fmt.pix.sizeimage),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, fmt.fmt.pix.bytesperline),
|
||||
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
state->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
state->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
state->info.extra = NULL;
|
||||
|
|
@ -979,7 +979,7 @@ v4l2_on_fd_events (SpaSource *source)
|
|||
return;
|
||||
|
||||
{
|
||||
SpaEvent event = SPA_EVENT_INIT (this->uri.event_node.HaveOutput);
|
||||
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,14 +144,14 @@ drawing_data_init (DrawingData *dd,
|
|||
SpaVideoInfo *format = &this->current_format;
|
||||
SpaRectangle *size = &format->info.raw.size;
|
||||
|
||||
if ((format->media_type != this->uri.media_types.video) ||
|
||||
(format->media_subtype != this->uri.media_subtypes.raw))
|
||||
if ((format->media_type != this->type.media_type.video) ||
|
||||
(format->media_subtype != this->type.media_subtype.raw))
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
if (format->info.raw.format == this->uri.video_formats.RGB) {
|
||||
if (format->info.raw.format == this->type.video_format.RGB) {
|
||||
dd->draw_pixel = draw_pixel_rgb;
|
||||
}
|
||||
else if (format->info.raw.format == this->uri.video_formats.UYVY) {
|
||||
else if (format->info.raw.format == this->type.video_format.UYVY) {
|
||||
dd->draw_pixel = draw_pixel_uyvy;
|
||||
}
|
||||
else
|
||||
|
|
@ -282,9 +282,9 @@ draw (SpaVideoTestSrc *this, char *data)
|
|||
return res;
|
||||
|
||||
pattern = this->props.pattern;
|
||||
if (pattern == this->uri.pattern_smpte_snow)
|
||||
if (pattern == this->type.pattern_smpte_snow)
|
||||
draw_smpte_snow (&dd);
|
||||
else if (pattern == this->uri.pattern_snow)
|
||||
else if (pattern == this->type.pattern_snow)
|
||||
draw_snow (&dd);
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/clock.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/loop.h>
|
||||
|
|
@ -46,35 +46,35 @@ typedef struct {
|
|||
uint32_t prop_pattern;
|
||||
uint32_t pattern_smpte_snow;
|
||||
uint32_t pattern_snow;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaPropVideo prop_video;
|
||||
SpaVideoFormats video_formats;
|
||||
SpaEventNode event_node;
|
||||
SpaCommandNode command_node;
|
||||
SpaAllocParamBuffers alloc_param_buffers;
|
||||
SpaAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypePropVideo prop_video;
|
||||
SpaTypeVideoFormat video_format;
|
||||
SpaTypeEventNode event_node;
|
||||
SpaTypeCommandNode command_node;
|
||||
SpaTypeAllocParamBuffers alloc_param_buffers;
|
||||
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
uri->clock = spa_id_map_get_id (map, SPA_TYPE__Clock);
|
||||
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format);
|
||||
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props);
|
||||
uri->prop_live = spa_id_map_get_id (map, SPA_TYPE_PROPS__live);
|
||||
uri->prop_pattern = spa_id_map_get_id (map, SPA_TYPE_PROPS__patternType);
|
||||
uri->pattern_smpte_snow = spa_id_map_get_id (map, SPA_TYPE_PROPS__patternType ":smpte-snow");
|
||||
uri->pattern_snow = spa_id_map_get_id (map, SPA_TYPE_PROPS__patternType ":snow");
|
||||
spa_media_types_fill (&uri->media_types, map);
|
||||
spa_media_subtypes_map (map, &uri->media_subtypes);
|
||||
spa_prop_video_map (map, &uri->prop_video);
|
||||
spa_video_formats_map (map, &uri->video_formats);
|
||||
spa_event_node_map (map, &uri->event_node);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers);
|
||||
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock);
|
||||
type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
|
||||
type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
|
||||
type->prop_live = spa_type_map_get_id (map, SPA_TYPE_PROPS__live);
|
||||
type->prop_pattern = spa_type_map_get_id (map, SPA_TYPE_PROPS__patternType);
|
||||
type->pattern_smpte_snow = spa_type_map_get_id (map, SPA_TYPE_PROPS__patternType ":smpte-snow");
|
||||
type->pattern_snow = spa_type_map_get_id (map, SPA_TYPE_PROPS__patternType ":snow");
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_prop_video_map (map, &type->prop_video);
|
||||
spa_type_video_format_map (map, &type->video_format);
|
||||
spa_type_event_node_map (map, &type->event_node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
|
||||
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
|
||||
}
|
||||
|
||||
typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
|
||||
|
|
@ -102,8 +102,8 @@ struct _SpaVideoTestSrc {
|
|||
SpaNode node;
|
||||
SpaClock clock;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
SpaLoop *data_loop;
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ static void
|
|||
reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->pattern = this->uri. DEFAULT_PATTERN;
|
||||
props->pattern = this->type. DEFAULT_PATTERN;
|
||||
}
|
||||
|
||||
#define PROP(f,key,type,...) \
|
||||
|
|
@ -182,12 +182,12 @@ spa_videotestsrc_node_get_props (SpaNode *node,
|
|||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP (&f[1], this->uri.prop_live, SPA_POD_TYPE_BOOL, this->props.live),
|
||||
PROP_EN (&f[1], this->uri.prop_pattern, SPA_POD_TYPE_URI, 3,
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP (&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL, this->props.live),
|
||||
PROP_EN (&f[1], this->type.prop_pattern, SPA_POD_TYPE_URI, 3,
|
||||
this->props.pattern,
|
||||
this->uri.pattern_smpte_snow,
|
||||
this->uri.pattern_snow));
|
||||
this->type.pattern_smpte_snow,
|
||||
this->type.pattern_snow));
|
||||
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
||||
|
|
@ -209,8 +209,8 @@ spa_videotestsrc_node_set_props (SpaNode *node,
|
|||
reset_videotestsrc_props (this, &this->props);
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
this->uri.prop_pattern, SPA_POD_TYPE_URI, &this->props.pattern,
|
||||
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
this->type.prop_pattern, SPA_POD_TYPE_URI, &this->props.pattern,
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ send_have_output (SpaVideoTestSrc *this)
|
|||
{
|
||||
|
||||
if (this->event_cb) {
|
||||
SpaEvent event = SPA_EVENT_INIT (this->uri.event_node.HaveOutput);
|
||||
SpaEvent event = SPA_EVENT_INIT (this->type.event_node.HaveOutput);
|
||||
this->event_cb (&this->node, &event, this->user_data);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -315,7 +315,7 @@ spa_videotestsrc_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
struct timespec now;
|
||||
|
||||
if (!this->have_format)
|
||||
|
|
@ -339,7 +339,7 @@ spa_videotestsrc_node_send_command (SpaNode *node,
|
|||
set_timer (this, true);
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -465,17 +465,17 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.video, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, 3,
|
||||
this->uri.video_formats.RGB,
|
||||
this->uri.video_formats.RGB,
|
||||
this->uri.video_formats.UYVY),
|
||||
PROP_U_MM (&f[1], this->uri.prop_video.size, SPA_POD_TYPE_RECTANGLE,
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.video, this->type.media_subtype.raw,
|
||||
PROP_U_EN (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, 3,
|
||||
this->type.video_format.RGB,
|
||||
this->type.video_format.RGB,
|
||||
this->type.video_format.UYVY),
|
||||
PROP_U_MM (&f[1], this->type.prop_video.size, SPA_POD_TYPE_RECTANGLE,
|
||||
320, 240,
|
||||
1, 1,
|
||||
INT32_MAX, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_video.framerate, SPA_POD_TYPE_FRACTION,
|
||||
PROP_U_MM (&f[1], this->type.prop_video.framerate, SPA_POD_TYPE_FRACTION,
|
||||
25, 1,
|
||||
0, 1,
|
||||
INT32_MAX, 1));
|
||||
|
|
@ -542,10 +542,10 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
|
|||
SpaPODBuilder b = { NULL };
|
||||
SpaPODFrame f[2];
|
||||
|
||||
if (raw_info->format == this->uri.video_formats.RGB) {
|
||||
if (raw_info->format == this->type.video_format.RGB) {
|
||||
this->bpp = 3;
|
||||
}
|
||||
else if (raw_info->format == this->uri.video_formats.UYVY) {
|
||||
else if (raw_info->format == this->type.video_format.UYVY) {
|
||||
this->bpp = 2;
|
||||
}
|
||||
else
|
||||
|
|
@ -560,15 +560,15 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
|
|||
this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4);
|
||||
|
||||
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, this->stride),
|
||||
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, this->stride),
|
||||
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
this->info.extra = NULL;
|
||||
|
|
@ -603,11 +603,11 @@ spa_videotestsrc_node_port_get_format (SpaNode *node,
|
|||
|
||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.video, this->uri.media_subtypes.raw,
|
||||
PROP (&f[1], this->uri.prop_video.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->uri.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size),
|
||||
PROP (&f[1], this->uri.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate));
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.video, this->type.media_subtype.raw,
|
||||
PROP (&f[1], this->type.prop_video.format, SPA_POD_TYPE_URI, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->type.prop_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size),
|
||||
PROP (&f[1], this->type.prop_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate));
|
||||
*format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -909,9 +909,9 @@ spa_videotestsrc_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaVideoTestSrc *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else if (interface_id == this->uri.clock)
|
||||
else if (interface_id == this->type.clock)
|
||||
*interface = &this->clock;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -953,11 +953,11 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
this = (SpaVideoTestSrc *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0)
|
||||
this->data_loop = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
|
|
@ -968,7 +968,7 @@ videotestsrc_init (const SpaHandleFactory *factory,
|
|||
spa_log_error (this->log, "a data_loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = videotestsrc_node;
|
||||
this->clock = videotestsrc_clock;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#include <spa/log.h>
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/audio/format-utils.h>
|
||||
|
|
@ -67,40 +67,40 @@ typedef struct {
|
|||
uint32_t props;
|
||||
uint32_t prop_volume;
|
||||
uint32_t prop_mute;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaPropAudio prop_audio;
|
||||
SpaAudioFormats audio_formats;
|
||||
SpaEventNode event_node;
|
||||
SpaCommandNode command_node;
|
||||
SpaAllocParamBuffers alloc_param_buffers;
|
||||
SpaAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypePropAudio prop_audio;
|
||||
SpaTypeAudioFormat audio_format;
|
||||
SpaTypeEventNode event_node;
|
||||
SpaTypeCommandNode command_node;
|
||||
SpaTypeAllocParamBuffers alloc_param_buffers;
|
||||
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
uri->format = spa_id_map_get_id (map, SPA_TYPE__Format);
|
||||
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props);
|
||||
uri->prop_volume = spa_id_map_get_id (map, SPA_TYPE_PROPS__volume);
|
||||
uri->prop_mute = spa_id_map_get_id (map, SPA_TYPE_PROPS__mute);
|
||||
spa_media_types_fill (&uri->media_types, map);
|
||||
spa_media_subtypes_map (map, &uri->media_subtypes);
|
||||
spa_prop_audio_map (map, &uri->prop_audio);
|
||||
spa_audio_formats_map (map, &uri->audio_formats);
|
||||
spa_event_node_map (map, &uri->event_node);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
spa_alloc_param_buffers_map (map, &uri->alloc_param_buffers);
|
||||
spa_alloc_param_meta_enable_map (map, &uri->alloc_param_meta_enable);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->format = spa_type_map_get_id (map, SPA_TYPE__Format);
|
||||
type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
|
||||
type->prop_volume = spa_type_map_get_id (map, SPA_TYPE_PROPS__volume);
|
||||
type->prop_mute = spa_type_map_get_id (map, SPA_TYPE_PROPS__mute);
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_prop_audio_map (map, &type->prop_audio);
|
||||
spa_type_audio_format_map (map, &type->audio_format);
|
||||
spa_type_event_node_map (map, &type->event_node);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
|
||||
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
|
||||
}
|
||||
|
||||
struct _SpaVolume {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
uint8_t props_buffer[512];
|
||||
|
|
@ -165,9 +165,9 @@ spa_volume_node_get_props (SpaNode *node,
|
|||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP_MM (&f[1], this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, 0.0, 10.0),
|
||||
PROP (&f[1], this->uri.prop_mute, SPA_POD_TYPE_BOOL, this->props.mute));
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP_MM (&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, 0.0, 10.0),
|
||||
PROP (&f[1], this->type.prop_mute, SPA_POD_TYPE_BOOL, this->props.mute));
|
||||
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
||||
|
|
@ -189,8 +189,8 @@ spa_volume_node_set_props (SpaNode *node,
|
|||
reset_volume_props (&this->props);
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
|
||||
this->uri.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute,
|
||||
this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
|
||||
this->type.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute,
|
||||
0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -207,10 +207,10 @@ spa_volume_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaVolume, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
}
|
||||
else
|
||||
|
|
@ -322,14 +322,14 @@ next:
|
|||
|
||||
switch (index++) {
|
||||
case 0:
|
||||
spa_pod_builder_format (&b, &f[0], this->uri.format,
|
||||
this->uri.media_types.audio, this->uri.media_subtypes.raw,
|
||||
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_URI, 3,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S16,
|
||||
this->uri.audio_formats.S32),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype.raw,
|
||||
PROP_U_EN (&f[1], this->type.prop_audio.format, SPA_POD_TYPE_URI, 3,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S32),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
@ -399,15 +399,15 @@ spa_volume_node_port_set_format (SpaNode *node,
|
|||
port->info.params = port->params;
|
||||
|
||||
spa_pod_builder_init (&b, port->params_buffer, sizeof (port->params_buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.size, SPA_POD_TYPE_INT, 16),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 16),
|
||||
PROP_U_MM (&f[1], this->uri.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP (&f[1], this->uri.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
|
||||
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 16),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 16),
|
||||
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
port->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->uri.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->uri.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_INT, SPA_META_TYPE_HEADER));
|
||||
port->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
|
||||
|
||||
port->info.extra = NULL;
|
||||
|
|
@ -662,7 +662,7 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port)
|
|||
static void
|
||||
release_buffer (SpaVolume *this, SpaBuffer *buffer)
|
||||
{
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (this->uri.event_node.ReuseBuffer,
|
||||
SpaEventNodeReuseBuffer rb = SPA_EVENT_NODE_REUSE_BUFFER_INIT (this->type.event_node.ReuseBuffer,
|
||||
0, buffer->id);
|
||||
this->event_cb (&this->node, (SpaEvent *)&rb, this->user_data);
|
||||
}
|
||||
|
|
@ -811,7 +811,7 @@ spa_volume_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaVolume *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -844,16 +844,16 @@ volume_init (const SpaHandleFactory *factory,
|
|||
this = (SpaVolume *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = volume_node;
|
||||
reset_volume_props (&this->props);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <spa/id-map.h>
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
|
|
@ -75,30 +75,30 @@ typedef struct {
|
|||
uint32_t prop_device;
|
||||
uint32_t prop_device_name;
|
||||
uint32_t prop_device_fd;
|
||||
SpaMediaTypes media_types;
|
||||
SpaMediaSubtypes media_subtypes;
|
||||
SpaCommandNode command_node;
|
||||
} URI;
|
||||
SpaTypeMediaType media_type;
|
||||
SpaTypeMediaSubtype media_subtype;
|
||||
SpaTypeCommandNode command_node;
|
||||
} Type;
|
||||
|
||||
static inline void
|
||||
init_uri (URI *uri, SpaIDMap *map)
|
||||
init_type (Type *type, SpaTypeMap *map)
|
||||
{
|
||||
uri->node = spa_id_map_get_id (map, SPA_TYPE__Node);
|
||||
uri->props = spa_id_map_get_id (map, SPA_TYPE__Props);
|
||||
uri->prop_device = spa_id_map_get_id (map, SPA_TYPE_PROPS__device);
|
||||
uri->prop_device_name = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceName);
|
||||
uri->prop_device_fd = spa_id_map_get_id (map, SPA_TYPE_PROPS__deviceFd);
|
||||
spa_media_types_fill (&uri->media_types, map);
|
||||
spa_media_subtypes_map (map, &uri->media_subtypes);
|
||||
spa_command_node_map (map, &uri->command_node);
|
||||
type->node = spa_type_map_get_id (map, SPA_TYPE__Node);
|
||||
type->props = spa_type_map_get_id (map, SPA_TYPE__Props);
|
||||
type->prop_device = spa_type_map_get_id (map, SPA_TYPE_PROPS__device);
|
||||
type->prop_device_name = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceName);
|
||||
type->prop_device_fd = spa_type_map_get_id (map, SPA_TYPE_PROPS__deviceFd);
|
||||
spa_type_media_type_map (map, &type->media_type);
|
||||
spa_type_media_subtype_map (map, &type->media_subtype);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
}
|
||||
|
||||
struct _SpaXvSink {
|
||||
SpaHandle handle;
|
||||
SpaNode node;
|
||||
|
||||
URI uri;
|
||||
SpaIDMap *map;
|
||||
Type type;
|
||||
SpaTypeMap *map;
|
||||
SpaLog *log;
|
||||
|
||||
uint8_t props_buffer[512];
|
||||
|
|
@ -146,10 +146,10 @@ spa_xv_sink_node_get_props (SpaNode *node,
|
|||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
spa_pod_builder_props (&b, &f[0], this->uri.props,
|
||||
PROP (&f[1], this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP_R (&f[1], this->uri.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP_R (&f[1], this->uri.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd));
|
||||
spa_pod_builder_props (&b, &f[0], this->type.props,
|
||||
PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)),
|
||||
PROP_R (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)),
|
||||
PROP_R (&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd));
|
||||
*props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -170,7 +170,7 @@ spa_xv_sink_node_set_props (SpaNode *node,
|
|||
reset_xv_sink_props (&this->props);
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->uri.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -187,12 +187,12 @@ spa_xv_sink_node_send_command (SpaNode *node,
|
|||
|
||||
this = SPA_CONTAINER_OF (node, SpaXvSink, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Start) {
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
spa_xv_start (this);
|
||||
|
||||
update_state (this, SPA_NODE_STATE_STREAMING);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->uri.command_node.Pause) {
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
spa_xv_stop (this);
|
||||
|
||||
update_state (this, SPA_NODE_STATE_PAUSED);
|
||||
|
|
@ -329,8 +329,8 @@ spa_xv_sink_node_port_set_format (SpaNode *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if (format->body.media_type.value == this->uri.media_types.video) {
|
||||
if (format->body.media_subtype.value == this->uri.media_subtypes.raw) {
|
||||
if (format->body.media_type.value == this->type.media_type.video) {
|
||||
if (format->body.media_subtype.value == this->type.media_subtype.raw) {
|
||||
if ((res = spa_format_video_parse (format, &info) < 0))
|
||||
return res;
|
||||
} else
|
||||
|
|
@ -531,7 +531,7 @@ spa_xv_sink_get_interface (SpaHandle *handle,
|
|||
|
||||
this = (SpaXvSink *) handle;
|
||||
|
||||
if (interface_id == this->uri.node)
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
|
@ -564,16 +564,16 @@ xv_sink_init (const SpaHandleFactory *factory,
|
|||
this = (SpaXvSink *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].uri, SPA_TYPE__IDMap) == 0)
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].uri, SPA_TYPE__Log) == 0)
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "an id-map is needed");
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_uri (&this->uri, this->map);
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = xvsink_node;
|
||||
reset_xv_sink_props (&this->props);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue