mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
types: more work on types
This commit is contained in:
parent
acedfe71c0
commit
5825c62d6d
76 changed files with 1713 additions and 1477 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue