mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
indent -kr -i8 -l100
This commit is contained in:
parent
11f23a3ffa
commit
d1a06ae247
28 changed files with 7034 additions and 10381 deletions
|
|
@ -66,8 +66,7 @@ struct type {
|
|||
struct spa_type_data data;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
|
||||
|
|
@ -123,23 +122,17 @@ struct impl {
|
|||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
|
||||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -150,11 +143,9 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
this->started = true;
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -225,10 +216,7 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -236,22 +224,20 @@ impl_node_add_port (struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_FREE_IN_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_FREE_IN_PORT(this, direction, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
|
||||
this->port_count++;
|
||||
spa_list_init(&this->in_ports[port_id].queue);
|
||||
|
||||
this->in_ports[port_id].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_REMOVABLE |
|
||||
SPA_PORT_INFO_FLAG_OPTIONAL |
|
||||
SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
SPA_PORT_INFO_FLAG_OPTIONAL | SPA_PORT_INFO_FLAG_IN_PLACE;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
|
@ -304,10 +290,16 @@ next:
|
|||
switch (count++) {
|
||||
case 0:
|
||||
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.format_audio.format, SPA_POD_TYPE_ID, this->type.audio_format.S16),
|
||||
PROP_U_MM (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
this->type.media_type.audio,
|
||||
this->type.media_subtype.raw,
|
||||
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
|
||||
this->type.audio_format.S16),
|
||||
PROP_U_MM(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
|
||||
44100,
|
||||
1, INT32_MAX),
|
||||
PROP_U_MM(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
|
||||
2,
|
||||
1, INT32_MAX));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -324,11 +316,10 @@ next:
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
clear_buffers (struct impl *this, struct port *port)
|
||||
static int clear_buffers(struct impl *this, struct port *port)
|
||||
{
|
||||
if (port->n_buffers > 0) {
|
||||
spa_log_info (this->log, "audio-mixer %p: clear buffers %p", this, port);
|
||||
spa_log_info(this->log, NAME " %p: clear buffers %p", this, port);
|
||||
port->n_buffers = 0;
|
||||
spa_list_init(&port->queue);
|
||||
}
|
||||
|
|
@ -358,7 +349,8 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
clear_buffers(this, port);
|
||||
} else {
|
||||
struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE(format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
SPA_FORMAT_MEDIA_SUBTYPE(format),
|
||||
};
|
||||
|
||||
if (info.media_type != this->type.media_type.audio ||
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
|
|
@ -399,10 +391,14 @@ impl_node_port_get_format (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
|
||||
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.format_audio.format, SPA_POD_TYPE_ID, this->format.info.raw.format),
|
||||
PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->format.info.raw.rate),
|
||||
PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->format.info.raw.channels));
|
||||
this->type.media_type.audio,
|
||||
this->type.media_subtype.raw,
|
||||
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
|
||||
this->format.info.raw.format),
|
||||
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
|
||||
this->format.info.raw.rate),
|
||||
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
|
||||
this->format.info.raw.channels));
|
||||
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -466,7 +462,8 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
spa_return_val_if_fail(port->have_format, SPA_RESULT_NO_FORMAT);
|
||||
|
||||
|
|
@ -483,9 +480,9 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
if (!((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd ||
|
||||
d[0].type == this->type.data.DmaBuf) &&
|
||||
d[0].data != NULL)) {
|
||||
spa_log_error (this->log, "volume %p: invalid memory on buffer %p", this, buffers[i]);
|
||||
d[0].type == this->type.data.DmaBuf) && d[0].data != NULL)) {
|
||||
spa_log_error(this->log, "volume %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
if (!b->outstanding)
|
||||
|
|
@ -523,14 +520,14 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT_NUM(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
recycle_buffer (struct impl *this, uint32_t id)
|
||||
static void recycle_buffer(struct impl *this, uint32_t id)
|
||||
{
|
||||
struct port *port = &this->out_ports[0];
|
||||
struct buffer *b = &port->buffers[id];
|
||||
|
|
@ -545,10 +542,7 @@ recycle_buffer (struct impl *this, uint32_t id)
|
|||
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -556,7 +550,8 @@ impl_node_port_reuse_buffer (struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
|
||||
recycle_buffer(this, buffer_id);
|
||||
|
||||
|
|
@ -593,8 +588,7 @@ add_port_data (struct impl *this, void *out, size_t outsize, struct port *port,
|
|||
|
||||
if (layer == 0) {
|
||||
memcpy(op, ip, outsize);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (i = 0; i < size; i++)
|
||||
op[i] = SPA_CLAMP(op[i] + ip[i], INT16_MIN, INT16_MAX);
|
||||
}
|
||||
|
|
@ -616,8 +610,7 @@ add_port_data (struct impl *this, void *out, size_t outsize, struct port *port,
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
mix_output (struct impl *this, size_t n_bytes)
|
||||
static int mix_output(struct impl *this, size_t n_bytes)
|
||||
{
|
||||
struct buffer *outbuf;
|
||||
int i, layer;
|
||||
|
|
@ -663,8 +656,7 @@ mix_output (struct impl *this, size_t n_bytes)
|
|||
return SPA_RESULT_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
|
@ -691,12 +683,12 @@ impl_node_process_input (struct spa_node *node)
|
|||
continue;
|
||||
|
||||
if (port->queued_bytes == 0 &&
|
||||
input->status == SPA_RESULT_HAVE_BUFFER &&
|
||||
input->buffer_id != SPA_ID_INVALID) {
|
||||
input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) {
|
||||
struct buffer *b = &port->buffers[input->buffer_id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn (this->log, NAME " %p: buffer %u in use", this, input->buffer_id);
|
||||
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
|
||||
input->buffer_id);
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -723,8 +715,7 @@ impl_node_process_input (struct spa_node *node)
|
|||
return output->status;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -760,8 +751,7 @@ impl_node_process_output (struct spa_node *node)
|
|||
}
|
||||
if (min_queued != SIZE_MAX && min_queued > 0) {
|
||||
output->status = mix_output(this, min_queued);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* take requested output range and apply to input */
|
||||
for (i = 0; i < MAX_PORTS; i++) {
|
||||
struct port *port = &this->in_ports[i];
|
||||
|
|
@ -773,8 +763,7 @@ impl_node_process_output (struct spa_node *node)
|
|||
if (port->queued_bytes == 0) {
|
||||
input->range = output->range;
|
||||
input->status = SPA_RESULT_NEED_BUFFER;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
input->status = SPA_RESULT_OK;
|
||||
}
|
||||
spa_log_trace(this->log, NAME " %p: port %d %d queued %zd, res %d", this,
|
||||
|
|
@ -810,10 +799,7 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -830,8 +816,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -876,8 +861,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Node,},
|
||||
};
|
||||
|
||||
|
|
@ -899,8 +883,8 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiomixer_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_audiomixer_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@
|
|||
extern const struct spa_handle_factory spa_audiomixer_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include <spa/format-builder.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
#define IMPL_NAME "audiotestsrc"
|
||||
#define NAME "audiotestsrc"
|
||||
|
||||
#define SAMPLES_TO_TIME(this,s) ((s) * SPA_NSEC_PER_SEC / (this)->current_format.info.raw.rate)
|
||||
#define BYTES_TO_SAMPLES(this,b) ((b)/(this)->bpf)
|
||||
|
|
@ -63,8 +63,7 @@ struct type {
|
|||
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
|
||||
|
|
@ -96,6 +95,7 @@ struct props {
|
|||
};
|
||||
|
||||
#define MAX_BUFFERS 16
|
||||
#define MAX_PORTS 1
|
||||
|
||||
struct buffer {
|
||||
struct spa_buffer *outbuf;
|
||||
|
|
@ -129,7 +129,6 @@ struct impl {
|
|||
struct itimerspec timerspec;
|
||||
|
||||
struct spa_port_info info;
|
||||
uint32_t params[2];
|
||||
uint8_t params_buffer[1024];
|
||||
struct spa_port_io *io;
|
||||
|
||||
|
|
@ -151,15 +150,15 @@ struct impl {
|
|||
struct spa_list empty;
|
||||
};
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
#define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS)
|
||||
#define CHECK_PORT(this,d,p) (CHECK_PORT_NUM(this,d,p) && this->io)
|
||||
|
||||
#define DEFAULT_LIVE true
|
||||
#define DEFAULT_WAVE wave_sine
|
||||
#define DEFAULT_FREQ 440.0
|
||||
#define DEFAULT_VOLUME 1.0
|
||||
|
||||
static void
|
||||
impl_reset_props (struct impl *this, struct props *props)
|
||||
static void reset_props(struct impl *this, struct props *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->wave = this->type.DEFAULT_WAVE;
|
||||
|
|
@ -180,9 +179,7 @@ impl_reset_props (struct impl *this, struct props *props)
|
|||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
|
||||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -195,13 +192,17 @@ impl_node_get_props (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
|
||||
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_ID, 3, this->props.wave,
|
||||
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_ID, 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,
|
||||
PROP_MM(&f[1], this->type.prop_freq, SPA_POD_TYPE_DOUBLE,
|
||||
this->props.freq,
|
||||
0.0, 50000000.0),
|
||||
PROP_MM (&f[1], this->type.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, struct spa_props);
|
||||
|
|
@ -209,9 +210,7 @@ impl_node_get_props (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -220,7 +219,7 @@ impl_node_set_props (struct spa_node *node,
|
|||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (props == NULL) {
|
||||
impl_reset_props (this, &this->props);
|
||||
reset_props(this, &this->props);
|
||||
} else {
|
||||
spa_props_query(props,
|
||||
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
|
|
@ -238,18 +237,9 @@ impl_node_set_props (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static inline int
|
||||
send_have_output (struct impl *this)
|
||||
{
|
||||
if (this->callbacks.have_output)
|
||||
this->callbacks.have_output (&this->node, this->user_data);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
#include "render.c"
|
||||
|
||||
static void
|
||||
set_timer (struct impl *this, bool enabled)
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if (enabled) {
|
||||
|
|
@ -269,8 +259,7 @@ set_timer (struct impl *this, bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
read_timer (struct impl *this)
|
||||
static void read_timer(struct impl *this)
|
||||
{
|
||||
uint64_t expirations;
|
||||
|
||||
|
|
@ -280,8 +269,7 @@ read_timer (struct impl *this)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
make_buffer (struct impl *this)
|
||||
static int make_buffer(struct impl *this)
|
||||
{
|
||||
struct buffer *b;
|
||||
struct spa_port_io *io = this->io;
|
||||
|
|
@ -291,6 +279,7 @@ make_buffer (struct impl *this)
|
|||
|
||||
if (spa_list_is_empty(&this->empty)) {
|
||||
set_timer(this, false);
|
||||
spa_log_error(this->log, NAME " %p: out of buffers", this);
|
||||
return SPA_RESULT_OUT_OF_BUFFERS;
|
||||
}
|
||||
b = spa_list_first(&this->empty, struct buffer, link);
|
||||
|
|
@ -304,7 +293,7 @@ make_buffer (struct impl *this)
|
|||
n_bytes = io->range.max_size;
|
||||
}
|
||||
|
||||
spa_log_trace (this->log, IMPL_NAME " %p: dequeue buffer %d %d %d", this, b->outbuf->id,
|
||||
spa_log_trace(this->log, NAME " %p: dequeue buffer %d %d %d", this, b->outbuf->id,
|
||||
b->outbuf->datas[0].maxsize, n_bytes);
|
||||
|
||||
if (b->rb) {
|
||||
|
|
@ -321,10 +310,13 @@ make_buffer (struct impl *this)
|
|||
|
||||
if (offset + n_bytes > b->rb->ringbuffer.size) {
|
||||
uint32_t l0 = b->rb->ringbuffer.size - offset;
|
||||
this->render_func (this, SPA_MEMBER (b->outbuf->datas[0].data, offset, void), l0 / this->bpf);
|
||||
this->render_func (this, b->outbuf->datas[0].data, (n_bytes - l0) / this->bpf);
|
||||
this->render_func(this, SPA_MEMBER(b->outbuf->datas[0].data, offset, void),
|
||||
l0 / this->bpf);
|
||||
this->render_func(this, b->outbuf->datas[0].data,
|
||||
(n_bytes - l0) / this->bpf);
|
||||
} else {
|
||||
this->render_func (this, SPA_MEMBER (b->outbuf->datas[0].data, offset, void), n_samples);
|
||||
this->render_func(this, SPA_MEMBER(b->outbuf->datas[0].data, offset, void),
|
||||
n_samples);
|
||||
}
|
||||
spa_ringbuffer_write_update(&b->rb->ringbuffer, index + n_bytes);
|
||||
} else {
|
||||
|
|
@ -351,8 +343,7 @@ make_buffer (struct impl *this)
|
|||
return io->status;
|
||||
}
|
||||
|
||||
static void
|
||||
on_output (struct spa_source *source)
|
||||
static void on_output(struct spa_source *source)
|
||||
{
|
||||
struct impl *this = source->data;
|
||||
int res;
|
||||
|
|
@ -360,12 +351,10 @@ on_output (struct spa_source *source)
|
|||
res = make_buffer(this);
|
||||
|
||||
if (res == SPA_RESULT_HAVE_BUFFER)
|
||||
send_have_output (this);
|
||||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -396,8 +385,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = true;
|
||||
set_timer(this, true);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -409,8 +397,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -428,11 +415,10 @@ impl_node_set_callbacks (struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
if (this->data_loop == NULL && callbacks->have_output) {
|
||||
if (this->data_loop == NULL && callbacks->have_output != NULL) {
|
||||
spa_log_error(this->log, "a data_loop is needed for async operation");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
|
|
@ -475,18 +461,13 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -522,14 +503,20 @@ next:
|
|||
switch (count++) {
|
||||
case 0:
|
||||
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.format_audio.format, SPA_POD_TYPE_ID, 5, this->type.audio_format.S16,
|
||||
this->type.media_type.audio,
|
||||
this->type.media_subtype.raw,
|
||||
PROP_U_EN(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID, 5,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S32,
|
||||
this->type.audio_format.F32,
|
||||
this->type.audio_format.F64),
|
||||
PROP_U_MM (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
PROP_U_MM(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
|
||||
44100,
|
||||
1, INT32_MAX),
|
||||
PROP_U_MM(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
|
||||
2,
|
||||
1, INT32_MAX));
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
|
@ -546,11 +533,10 @@ next:
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
clear_buffers (struct impl *this)
|
||||
static int clear_buffers(struct impl *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
spa_log_info (this->log, IMPL_NAME " %p: clear buffers", this);
|
||||
spa_log_info(this->log, NAME " %p: clear buffers", this);
|
||||
this->n_buffers = 0;
|
||||
spa_list_init(&this->empty);
|
||||
this->started = false;
|
||||
|
|
@ -579,7 +565,8 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
clear_buffers(this);
|
||||
} else {
|
||||
struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE(format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
SPA_FORMAT_MEDIA_SUBTYPE(format),
|
||||
};
|
||||
int idx;
|
||||
int sizes[4] = { 2, 4, 4, 8 };
|
||||
|
||||
|
|
@ -636,10 +623,14 @@ impl_node_port_get_format (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
|
||||
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.format_audio.format, SPA_POD_TYPE_ID, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate),
|
||||
PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels));
|
||||
this->type.media_type.audio,
|
||||
this->type.media_subtype.raw,
|
||||
PROP(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID,
|
||||
this->current_format.info.raw.format),
|
||||
PROP(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
|
||||
this->current_format.info.raw.rate),
|
||||
PROP(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
|
||||
this->current_format.info.raw.channels));
|
||||
|
||||
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
|
||||
|
||||
|
|
@ -689,16 +680,23 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
switch (index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
|
||||
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 1024 * this->bpf),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, this->bpf),
|
||||
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
|
||||
1024 * this->bpf),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
|
||||
this->bpf),
|
||||
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
|
||||
32,
|
||||
2, 32),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
|
||||
16));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
|
||||
this->type.meta.Header),
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
|
||||
sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -752,9 +750,9 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
if ((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd ||
|
||||
d[0].type == this->type.data.DmaBuf) &&
|
||||
d[0].data == NULL) {
|
||||
spa_log_error (this->log, IMPL_NAME " %p: invalid memory on buffer %p", this, buffers[i]);
|
||||
d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
}
|
||||
spa_list_insert(this->empty.prev, &b->link);
|
||||
}
|
||||
|
|
@ -798,20 +796,19 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT_NUM(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
this->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static inline void
|
||||
reuse_buffer (struct impl *this, uint32_t id)
|
||||
static inline void reuse_buffer(struct impl *this, uint32_t id)
|
||||
{
|
||||
struct buffer *b = &this->buffers[id];
|
||||
spa_return_if_fail(b->outstanding);
|
||||
|
||||
spa_log_trace (this->log, IMPL_NAME " %p: reuse buffer %d", this, id);
|
||||
spa_log_trace(this->log, NAME " %p: reuse buffer %d", this, id);
|
||||
|
||||
b->outstanding = false;
|
||||
spa_list_insert(this->empty.prev, &b->link);
|
||||
|
|
@ -820,10 +817,7 @@ reuse_buffer (struct impl *this, uint32_t id)
|
|||
set_timer(this, true);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -849,14 +843,12 @@ impl_node_port_send_command (struct spa_node *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
|
@ -907,16 +899,12 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_clock_get_props (struct spa_clock *clock,
|
||||
struct spa_props **props)
|
||||
static int impl_clock_get_props(struct spa_clock *clock, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clock_set_props (struct spa_clock *clock,
|
||||
const struct spa_props *props)
|
||||
static int impl_clock_set_props(struct spa_clock *clock, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -955,10 +943,7 @@ static const struct spa_clock impl_clock = {
|
|||
impl_clock_get_time,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -977,8 +962,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -1027,7 +1011,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
|
||||
this->node = impl_node;
|
||||
this->clock = impl_clock;
|
||||
impl_reset_props (this, &this->props);
|
||||
reset_props(this, &this->props);
|
||||
|
||||
spa_list_init(&this->empty);
|
||||
|
||||
|
|
@ -1044,12 +1028,11 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
spa_log_info (this->log, IMPL_NAME " %p: initialized", this);
|
||||
spa_log_info(this->log, NAME " %p: initialized", this);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -1078,7 +1061,7 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
}
|
||||
|
||||
const struct spa_handle_factory spa_audiotestsrc_factory = {
|
||||
IMPL_NAME,
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@
|
|||
extern const struct spa_handle_factory spa_audiotestsrc_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ struct type {
|
|||
struct spa_type_command_node command_node;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
spa_type_media_type_map(map, &type->media_type);
|
||||
|
|
@ -81,23 +80,17 @@ struct impl {
|
|||
bool started;
|
||||
};
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int spa_ffmpeg_dec_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int spa_ffmpeg_dec_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int spa_ffmpeg_dec_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -108,11 +101,9 @@ spa_ffmpeg_dec_node_send_command (struct spa_node *node,
|
|||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
this->started = true;
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -179,9 +170,7 @@ spa_ffmpeg_dec_node_get_port_ids (struct spa_node *node,
|
|||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
spa_ffmpeg_dec_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -241,14 +230,16 @@ spa_ffmpeg_dec_node_port_set_format (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE(format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
SPA_FORMAT_MEDIA_SUBTYPE(format),
|
||||
};
|
||||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
|
|
@ -282,7 +273,8 @@ spa_ffmpeg_dec_node_port_get_format (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
|
@ -309,7 +301,8 @@ spa_ffmpeg_dec_node_port_get_info (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -379,20 +372,19 @@ spa_ffmpeg_dec_node_port_set_io (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_process_input (struct spa_node *node)
|
||||
static int spa_ffmpeg_dec_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_process_output (struct spa_node *node)
|
||||
static int spa_ffmpeg_dec_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -418,9 +410,7 @@ spa_ffmpeg_dec_node_process_output (struct spa_node *node)
|
|||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
spa_ffmpeg_dec_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -468,9 +458,7 @@ static const struct spa_node ffmpeg_dec_node = {
|
|||
};
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
spa_ffmpeg_dec_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ struct type {
|
|||
struct spa_type_command_node command_node;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
spa_type_media_type_map(map, &type->media_type);
|
||||
|
|
@ -85,23 +84,17 @@ struct impl {
|
|||
bool started;
|
||||
};
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int spa_ffmpeg_enc_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int spa_ffmpeg_enc_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int spa_ffmpeg_enc_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -112,11 +105,9 @@ spa_ffmpeg_enc_node_send_command (struct spa_node *node,
|
|||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
this->started = true;
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -125,8 +116,7 @@ spa_ffmpeg_enc_node_send_command (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
size_t callbacks_size, void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -145,8 +135,7 @@ static int
|
|||
spa_ffmpeg_enc_node_get_n_ports(struct spa_node *node,
|
||||
uint32_t * n_input_ports,
|
||||
uint32_t * max_input_ports,
|
||||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
uint32_t * n_output_ports, uint32_t * max_output_ports)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -167,8 +156,7 @@ static int
|
|||
spa_ffmpeg_enc_node_get_port_ids(struct spa_node *node,
|
||||
uint32_t n_input_ports,
|
||||
uint32_t * input_ids,
|
||||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
uint32_t n_output_ports, uint32_t * output_ids)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -183,17 +171,14 @@ spa_ffmpeg_enc_node_get_port_ids (struct spa_node *node,
|
|||
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
spa_ffmpeg_enc_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -203,8 +188,7 @@ spa_ffmpeg_enc_node_port_enum_formats (struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_format **format,
|
||||
const struct spa_format *filter,
|
||||
uint32_t index)
|
||||
const struct spa_format *filter, uint32_t index)
|
||||
{
|
||||
//struct impl *this;
|
||||
//struct port *port;
|
||||
|
|
@ -234,8 +218,7 @@ static int
|
|||
spa_ffmpeg_enc_node_port_set_format(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
const struct spa_format *format)
|
||||
uint32_t flags, const struct spa_format *format)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -248,14 +231,16 @@ spa_ffmpeg_enc_node_port_set_format (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE(format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
SPA_FORMAT_MEDIA_SUBTYPE(format),
|
||||
};
|
||||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
|
|
@ -275,8 +260,7 @@ spa_ffmpeg_enc_node_port_set_format (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_port_get_format(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_format **format)
|
||||
uint32_t port_id, const struct spa_format **format)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -289,7 +273,8 @@ spa_ffmpeg_enc_node_port_get_format (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
|
@ -302,8 +287,7 @@ spa_ffmpeg_enc_node_port_get_format (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
uint32_t port_id, const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -316,7 +300,8 @@ spa_ffmpeg_enc_node_port_get_info (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -325,9 +310,7 @@ spa_ffmpeg_enc_node_port_get_info (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t index,
|
||||
struct spa_param **param)
|
||||
uint32_t port_id, uint32_t index, struct spa_param **param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -335,8 +318,7 @@ spa_ffmpeg_enc_node_port_enum_params (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_port_set_param(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_param *param)
|
||||
uint32_t port_id, const struct spa_param *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -345,8 +327,7 @@ static int
|
|||
spa_ffmpeg_enc_node_port_use_buffers(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_buffer **buffers,
|
||||
uint32_t n_buffers)
|
||||
struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -363,8 +344,7 @@ spa_ffmpeg_enc_node_port_alloc_buffers (struct spa_node *node,
|
|||
uint32_t port_id,
|
||||
struct spa_param **params,
|
||||
uint32_t n_params,
|
||||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
struct spa_buffer **buffers, uint32_t * n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -372,8 +352,7 @@ spa_ffmpeg_enc_node_port_alloc_buffers (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_port_io *io)
|
||||
uint32_t port_id, struct spa_port_io *io)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -386,16 +365,15 @@ spa_ffmpeg_enc_node_port_set_io (struct spa_node *node,
|
|||
if (!IS_VALID_PORT(this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
spa_ffmpeg_enc_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -409,20 +387,17 @@ spa_ffmpeg_enc_node_port_reuse_buffer (struct spa_node *node,
|
|||
static int
|
||||
spa_ffmpeg_enc_node_port_send_command(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_command *command)
|
||||
uint32_t port_id, struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_process_input (struct spa_node *node)
|
||||
static int spa_ffmpeg_enc_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_node_process_output (struct spa_node *node)
|
||||
static int spa_ffmpeg_enc_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -474,9 +449,7 @@ static const struct spa_node ffmpeg_enc_node = {
|
|||
};
|
||||
|
||||
static int
|
||||
spa_ffmpeg_enc_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
spa_ffmpeg_enc_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -496,8 +469,7 @@ spa_ffmpeg_enc_get_interface (struct spa_handle *handle,
|
|||
int
|
||||
spa_ffmpeg_enc_init(struct spa_handle *handle,
|
||||
const struct spa_dict *info,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support)
|
||||
const struct spa_support *support, uint32_t n_support)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,10 @@
|
|||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
int spa_ffmpeg_dec_init (struct spa_handle *handle, const struct spa_dict *info, const struct spa_support *support, uint32_t n_support);
|
||||
int spa_ffmpeg_enc_init (struct spa_handle *handle, const struct spa_dict *info, const struct spa_support *support, uint32_t n_support);
|
||||
int spa_ffmpeg_dec_init(struct spa_handle *handle, const struct spa_dict *info,
|
||||
const struct spa_support *support, uint32_t n_support);
|
||||
int spa_ffmpeg_enc_init(struct spa_handle *handle, const struct spa_dict *info,
|
||||
const struct spa_support *support, uint32_t n_support);
|
||||
|
||||
static int
|
||||
ffmpeg_dec_init(const struct spa_handle_factory *factory,
|
||||
|
|
@ -54,10 +56,8 @@ ffmpeg_enc_init (const struct spa_handle_factory *factory,
|
|||
return spa_ffmpeg_enc_init(handle, info, support, n_support);
|
||||
}
|
||||
|
||||
static const struct spa_interface_info ffmpeg_interfaces[] =
|
||||
{
|
||||
{ SPA_TYPE__Node,
|
||||
},
|
||||
static const struct spa_interface_info ffmpeg_interfaces[] = {
|
||||
{SPA_TYPE__Node, },
|
||||
};
|
||||
|
||||
static int
|
||||
|
|
@ -76,9 +76,7 @@ ffmpeg_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
int
|
||||
spa_handle_factory_enum (const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
{
|
||||
static const AVCodec *c = NULL;
|
||||
static int ci = 0;
|
||||
|
|
@ -101,8 +99,7 @@ spa_handle_factory_enum (const struct spa_handle_factory **factory,
|
|||
if (av_codec_is_encoder(c)) {
|
||||
snprintf(name, 128, "ffenc_%s", c->name);
|
||||
f.init = ffmpeg_enc_init;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
snprintf(name, 128, "ffdec_%s", c->name);
|
||||
f.init = ffmpeg_dec_init;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,528 +0,0 @@
|
|||
/* Spa Libva Decoder
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
|
||||
typedef struct _SpaLibvaDec SpaLibvaDec;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
} SpaLibvaDecProps;
|
||||
|
||||
static void
|
||||
reset_libva_dec_props (SpaLibvaDecProps *props)
|
||||
{
|
||||
}
|
||||
|
||||
#define INPUT_PORT_ID 0
|
||||
#define OUTPUT_PORT_ID 1
|
||||
#define IS_VALID_PORT(id) ((id) < 2)
|
||||
#define MAX_BUFFERS 32
|
||||
|
||||
typedef struct _LibvaBuffer LibvaBuffer;
|
||||
|
||||
struct _LibvaBuffer {
|
||||
SpaBuffer buffer;
|
||||
SpaMeta metas[1];
|
||||
SpaMetaHeader header;
|
||||
SpaData datas[1];
|
||||
SpaLibvaDec *dec;
|
||||
SpaBuffer *imported;
|
||||
bool outstanding;
|
||||
LibvaBuffer *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SpaVideoRawFormat raw_format[2];
|
||||
SpaFormat *current_format;
|
||||
bool have_buffers;
|
||||
LibvaBuffer buffers[MAX_BUFFERS];
|
||||
SpaPortInfo info;
|
||||
SpaPortStatus status;
|
||||
} SpaLibvaState;
|
||||
|
||||
struct _SpaLibvaDec {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaLibvaDecProps props[2];
|
||||
|
||||
SpaNodeEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
SpaLibvaState state[2];
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ 0, },
|
||||
};
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_get_props (SpaHandle *handle,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
|
||||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_set_props (SpaHandle *handle,
|
||||
const SpaProps *props)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
SpaLibvaDecProps *p = &this->props[1];
|
||||
int res;
|
||||
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (props == NULL) {
|
||||
reset_libva_dec_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
res = spa_props_copy_values (props, &p->props);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_send_command (SpaHandle *handle,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
|
||||
if (handle == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (command->type) {
|
||||
case SPA_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_COMMAND_START:
|
||||
if (this->event_cb) {
|
||||
SpaNodeEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_NODE_EVENT_TYPE_STARTED;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
|
||||
this->event_cb (handle, &event, this->user_data);
|
||||
}
|
||||
break;
|
||||
case SPA_COMMAND_STOP:
|
||||
if (this->event_cb) {
|
||||
SpaNodeEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_NODE_EVENT_TYPE_STOPPED;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
|
||||
this->event_cb (handle, &event, this->user_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case SPA_COMMAND_FLUSH:
|
||||
case SPA_COMMAND_DRAIN:
|
||||
case SPA_COMMAND_MARKER:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_set_event_callback (SpaHandle *handle,
|
||||
SpaNodeEventCallback event,
|
||||
void *user_data)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this->event_cb = event;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_get_n_ports (SpaHandle *handle,
|
||||
uint32_t *n_input_ports,
|
||||
uint32_t *max_input_ports,
|
||||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_get_port_ids (SpaHandle *handle,
|
||||
uint32_t n_input_ports,
|
||||
uint32_t *input_ids,
|
||||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_add_port (SpaHandle *handle,
|
||||
SpaDirection direction,
|
||||
uint32_t *port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_remove_port (SpaHandle *handle,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
uint32_t index,
|
||||
SpaFormat **format)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
SpaLibvaState *state;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&state->raw_format[0]);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &state->raw_format[0].format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
SpaLibvaState *state;
|
||||
int res;
|
||||
SpaFormat *f, *tf;
|
||||
size_t fs;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
state->current_format = NULL;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if (format->media_type == SPA_MEDIA_TYPE_VIDEO) {
|
||||
if (format->media_subtype == SPA_MEDIA_SUBTYPE_RAW) {
|
||||
if ((res = spa_video_raw_format_parse (format, &state->raw_format[0]) < 0))
|
||||
return res;
|
||||
|
||||
f = &state->raw_format[0].format;
|
||||
tf = &state->raw_format[1].format;
|
||||
fs = sizeof (SpaVideoRawFormat);
|
||||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
memcpy (tf, f, fs);
|
||||
state->current_format = tf;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_get_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaFormat **format)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
SpaLibvaState *state;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
|
||||
if (state->current_format == NULL)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*format = state->current_format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_get_info (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaPortInfo **info)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
|
||||
if (handle == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*info = &this->state[port_id].info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_get_props (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaProps **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_set_props (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaProps *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_get_status (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
|
||||
if (handle == NULL || status == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->state[port_id].status;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_use_buffers (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t n_buffers)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_alloc_buffers (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaParam **params,
|
||||
uint32_t n_params,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_push_input (SpaHandle *handle,
|
||||
uint32_t n_info,
|
||||
SpaInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_dec_node_port_pull_output (SpaHandle *handle,
|
||||
uint32_t n_info,
|
||||
SpaOutputInfo *info)
|
||||
{
|
||||
SpaLibvaDec *this = (SpaLibvaDec *) handle;
|
||||
SpaLibvaState *state;
|
||||
uint32_t i;
|
||||
bool have_error = false;
|
||||
|
||||
if (handle == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (info[i].port_id != OUTPUT_PORT_ID) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
state = &this->state[info[i].port_id];
|
||||
|
||||
if (state->current_format == NULL) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode libva_dec_node = {
|
||||
sizeof (SpaNode),
|
||||
spa_libva_dec_node_get_props,
|
||||
spa_libva_dec_node_set_props,
|
||||
spa_libva_dec_node_send_command,
|
||||
spa_libva_dec_node_set_event_callback,
|
||||
spa_libva_dec_node_get_n_ports,
|
||||
spa_libva_dec_node_get_port_ids,
|
||||
spa_libva_dec_node_add_port,
|
||||
spa_libva_dec_node_remove_port,
|
||||
spa_libva_dec_node_port_enum_formats,
|
||||
spa_libva_dec_node_port_set_format,
|
||||
spa_libva_dec_node_port_get_format,
|
||||
spa_libva_dec_node_port_get_info,
|
||||
spa_libva_dec_node_port_get_props,
|
||||
spa_libva_dec_node_port_set_props,
|
||||
spa_libva_dec_node_port_use_buffers,
|
||||
spa_libva_dec_node_port_alloc_buffers,
|
||||
spa_libva_dec_node_port_get_status,
|
||||
spa_libva_dec_node_port_push_input,
|
||||
spa_libva_dec_node_port_pull_output,
|
||||
};
|
||||
|
||||
static int
|
||||
spa_libva_dec_get_interface (SpaHandle *handle,
|
||||
uint32_t interface_id,
|
||||
const void **interface)
|
||||
{
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &libva_dec_node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaHandle *
|
||||
spa_libva_dec_new (void)
|
||||
{
|
||||
SpaHandle *handle;
|
||||
SpaLibvaDec *this;
|
||||
|
||||
handle = calloc (1, sizeof (SpaLibvaDec));
|
||||
handle->get_interface = spa_libva_dec_get_interface;
|
||||
|
||||
this = (SpaLibvaDec *) handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_libva_dec_props (&this->props[1]);
|
||||
|
||||
this->state[INPUT_PORT_ID].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->state[INPUT_PORT_ID].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->state[OUTPUT_PORT_ID].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->state[OUTPUT_PORT_ID].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
return handle;
|
||||
}
|
||||
|
|
@ -1,530 +0,0 @@
|
|||
/* Spa Libva Encoder
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format.h>
|
||||
|
||||
typedef struct _SpaLibvaEnc SpaLibvaEnc;
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
} SpaLibvaEncProps;
|
||||
|
||||
static void
|
||||
reset_libva_enc_props (SpaLibvaEncProps *props)
|
||||
{
|
||||
}
|
||||
|
||||
#define INPUT_PORT_ID 0
|
||||
#define OUTPUT_PORT_ID 1
|
||||
#define IS_VALID_PORT(id) ((id) < 2)
|
||||
#define MAX_BUFFERS 32
|
||||
|
||||
typedef struct _LibvaBuffer LibvaBuffer;
|
||||
|
||||
struct _LibvaBuffer {
|
||||
SpaBuffer buffer;
|
||||
SpaMeta metas[1];
|
||||
SpaMetaHeader header;
|
||||
SpaData datas[1];
|
||||
SpaLibvaEnc *enc;
|
||||
SpaBuffer *imported;
|
||||
bool outstanding;
|
||||
LibvaBuffer *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SpaVideoRawFormat raw_format[2];
|
||||
SpaFormat *current_format;
|
||||
bool have_buffers;
|
||||
LibvaBuffer buffers[MAX_BUFFERS];
|
||||
SpaPortInfo info;
|
||||
SpaAllocParam *params[1];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaPortStatus status;
|
||||
} SpaLibvaState;
|
||||
|
||||
struct _SpaLibvaEnc {
|
||||
SpaHandle handle;
|
||||
|
||||
SpaLibvaEncProps props[2];
|
||||
|
||||
SpaEventCallback event_cb;
|
||||
void *user_data;
|
||||
|
||||
SpaLibvaState state[2];
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
static const SpaPropInfo prop_info[] =
|
||||
{
|
||||
{ 0, },
|
||||
};
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_get_props (SpaHandle *handle,
|
||||
SpaProps **props)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
|
||||
if (handle == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
memcpy (&this->props[0], &this->props[1], sizeof (this->props[1]));
|
||||
*props = &this->props[0].props;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_set_props (SpaHandle *handle,
|
||||
const SpaProps *props)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
SpaLibvaEncProps *p = &this->props[1];
|
||||
int res;
|
||||
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (props == NULL) {
|
||||
reset_libva_enc_props (p);
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
res = spa_props_copy_values (props, &p->props);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_send_command (SpaHandle *handle,
|
||||
SpaCommand *command)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
|
||||
if (handle == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (command->type) {
|
||||
case SPA_COMMAND_INVALID:
|
||||
return SPA_RESULT_INVALID_COMMAND;
|
||||
|
||||
case SPA_COMMAND_START:
|
||||
if (this->event_cb) {
|
||||
SpaEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_STARTED;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
|
||||
this->event_cb (handle, &event, this->user_data);
|
||||
}
|
||||
break;
|
||||
case SPA_COMMAND_STOP:
|
||||
if (this->event_cb) {
|
||||
SpaEvent event;
|
||||
|
||||
event.refcount = 1;
|
||||
event.notify = NULL;
|
||||
event.type = SPA_EVENT_TYPE_STOPPED;
|
||||
event.port_id = -1;
|
||||
event.data = NULL;
|
||||
event.size = 0;
|
||||
|
||||
this->event_cb (handle, &event, this->user_data);
|
||||
}
|
||||
break;
|
||||
|
||||
case SPA_COMMAND_FLUSH:
|
||||
case SPA_COMMAND_DRAIN:
|
||||
case SPA_COMMAND_MARKER:
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_set_event_callback (SpaHandle *handle,
|
||||
SpaEventCallback event,
|
||||
void *user_data)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this->event_cb = event;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_get_n_ports (SpaHandle *handle,
|
||||
uint32_t *n_input_ports,
|
||||
uint32_t *max_input_ports,
|
||||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 1;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 1;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_get_port_ids (SpaHandle *handle,
|
||||
uint32_t n_input_ports,
|
||||
uint32_t *input_ids,
|
||||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_input_ports > 0 && input_ids != NULL)
|
||||
input_ids[0] = 0;
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_add_port (SpaHandle *handle,
|
||||
SpaDirection direction,
|
||||
uint32_t *port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_remove_port (SpaHandle *handle,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
uint32_t index,
|
||||
SpaFormat **format)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
SpaLibvaState *state;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&state->raw_format[0]);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &state->raw_format[0].format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_set_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
bool test_only,
|
||||
const SpaFormat *format)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
SpaLibvaState *state;
|
||||
int res;
|
||||
SpaFormat *f, *tf;
|
||||
size_t fs;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
state->current_format = NULL;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
if (format->media_type == SPA_MEDIA_TYPE_VIDEO) {
|
||||
if (format->media_subtype == SPA_MEDIA_SUBTYPE_RAW) {
|
||||
if ((res = spa_video_raw_format_parse (format, &state->raw_format[0]) < 0))
|
||||
return res;
|
||||
|
||||
f = &state->raw_format[0].format;
|
||||
tf = &state->raw_format[1].format;
|
||||
fs = sizeof (SpaVideoRawFormat);
|
||||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
} else
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!test_only) {
|
||||
memcpy (tf, f, fs);
|
||||
state->current_format = tf;
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_get_format (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaFormat **format)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
SpaLibvaState *state;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
|
||||
if (state->current_format == NULL)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*format = state->current_format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_get_info (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaPortInfo **info)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
|
||||
if (handle == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*info = &this->state[port_id].info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_get_props (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaProps **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_set_props (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaProps *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_get_status (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
const SpaPortStatus **status)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
|
||||
if (handle == NULL || status == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
*status = &this->state[port_id].status;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_use_buffers (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t n_buffers)
|
||||
{
|
||||
if (handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_alloc_buffers (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaAllocParam **params,
|
||||
uint32_t n_params,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_push_input (SpaHandle *handle,
|
||||
uint32_t n_info,
|
||||
SpaInputInfo *info)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_libva_enc_node_port_pull_output (SpaHandle *handle,
|
||||
uint32_t n_info,
|
||||
SpaOutputInfo *info)
|
||||
{
|
||||
SpaLibvaEnc *this = (SpaLibvaEnc *) handle;
|
||||
SpaLibvaState *state;
|
||||
uint32_t i;
|
||||
bool have_error = false;
|
||||
|
||||
if (handle == NULL || n_info == 0 || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
|
||||
for (i = 0; i < n_info; i++) {
|
||||
if (info[i].port_id != OUTPUT_PORT_ID) {
|
||||
info[i].status = SPA_RESULT_INVALID_PORT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
state = &this->state[info[i].port_id];
|
||||
|
||||
if (state->current_format == NULL) {
|
||||
info[i].status = SPA_RESULT_NO_FORMAT;
|
||||
have_error = true;
|
||||
continue;
|
||||
}
|
||||
info[i].status = SPA_RESULT_OK;
|
||||
}
|
||||
if (have_error)
|
||||
return SPA_RESULT_ERROR;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaNode libva_enc_node = {
|
||||
sizeof (SpaNode),
|
||||
spa_libva_enc_node_get_props,
|
||||
spa_libva_enc_node_set_props,
|
||||
spa_libva_enc_node_send_command,
|
||||
spa_libva_enc_node_set_event_callback,
|
||||
spa_libva_enc_node_get_n_ports,
|
||||
spa_libva_enc_node_get_port_ids,
|
||||
spa_libva_enc_node_add_port,
|
||||
spa_libva_enc_node_remove_port,
|
||||
spa_libva_enc_node_port_enum_formats,
|
||||
spa_libva_enc_node_port_set_format,
|
||||
spa_libva_enc_node_port_get_format,
|
||||
spa_libva_enc_node_port_get_info,
|
||||
spa_libva_enc_node_port_get_props,
|
||||
spa_libva_enc_node_port_set_props,
|
||||
spa_libva_enc_node_port_use_buffers,
|
||||
spa_libva_enc_node_port_alloc_buffers,
|
||||
spa_libva_enc_node_port_get_status,
|
||||
spa_libva_enc_node_port_push_input,
|
||||
spa_libva_enc_node_port_pull_output,
|
||||
};
|
||||
|
||||
static int
|
||||
spa_libva_enc_get_interface (SpaHandle *handle,
|
||||
uint32_t interface_id,
|
||||
const void **interface)
|
||||
{
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (interface_id) {
|
||||
case SPA_INTERFACE_ID_NODE:
|
||||
*interface = &libva_enc_node;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaHandle *
|
||||
spa_libva_enc_new (void)
|
||||
{
|
||||
SpaHandle *handle;
|
||||
SpaLibvaEnc *this;
|
||||
|
||||
handle = calloc (1, sizeof (SpaLibvaEnc));
|
||||
handle->get_interface = spa_libva_enc_get_interface;
|
||||
|
||||
this = (SpaLibvaEnc *) handle;
|
||||
this->props[1].props.n_prop_info = PROP_ID_LAST;
|
||||
this->props[1].props.prop_info = prop_info;
|
||||
this->props[1].props.set_prop = spa_props_generic_set_prop;
|
||||
this->props[1].props.get_prop = spa_props_generic_get_prop;
|
||||
reset_libva_enc_props (&this->props[1]);
|
||||
|
||||
this->state[INPUT_PORT_ID].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->state[INPUT_PORT_ID].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->state[OUTPUT_PORT_ID].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->state[OUTPUT_PORT_ID].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
return handle;
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* Spa V4l2 support
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <spa/plugin.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
SpaHandle * spa_libva_dec_new (void);
|
||||
SpaHandle * spa_libva_enc_new (void);
|
||||
|
||||
static int
|
||||
libva_dec_instantiate (const struct spa_handle_factory *factory,
|
||||
SpaHandle **handle)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
*handle = spa_libva_dec_new ();
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
libva_enc_instantiate (const struct spa_handle_factory *factory,
|
||||
SpaHandle **handle)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
*handle = spa_libva_enc_new ();
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static const struct spa_interface_info libva_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
};
|
||||
|
||||
static int
|
||||
libva_enum_interface_info (const struct spa_handle_factory *factory,
|
||||
uint32_t index,
|
||||
const struct spa_interface_info **info)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &libva_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_handle_factory factories[] =
|
||||
{
|
||||
{ "libva-dec",
|
||||
NULL,
|
||||
libva_dec_instantiate,
|
||||
libva_enum_interface_info,
|
||||
},
|
||||
{ "libva-enc",
|
||||
NULL,
|
||||
libva_enc_instantiate,
|
||||
libva_enum_interface_info,
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
spa_handle_factory_enum (uint32_t index,
|
||||
const struct spa_handle_factory **factory)
|
||||
{
|
||||
if (index >= 2)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*factory = &factories[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
libva_sources = ['libva.c',
|
||||
'libva-dec.c',
|
||||
'libva-enc.c']
|
||||
|
||||
libvalib = shared_library('spa-libva',
|
||||
libva_sources,
|
||||
include_directories : inc,
|
||||
dependencies : libva_dep,
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2013 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _VAAPI_RECORDER_H_
|
||||
#define _VAAPI_RECORDER_H_
|
||||
|
||||
struct vaapi_recorder;
|
||||
|
||||
struct vaapi_recorder *
|
||||
vaapi_recorder_create(int drm_fd, int width, int height, const char *filename);
|
||||
void
|
||||
vaapi_recorder_destroy(struct vaapi_recorder *r);
|
||||
int
|
||||
vaapi_recorder_frame(struct vaapi_recorder *r, int fd, int stride);
|
||||
|
||||
#endif /* _VAAPI_RECORDER_H_ */
|
||||
|
|
@ -3,8 +3,6 @@ subdir('audiomixer')
|
|||
subdir('audiotestsrc')
|
||||
subdir('ffmpeg')
|
||||
subdir('test')
|
||||
#subdir('libva')
|
||||
subdir('videotestsrc')
|
||||
subdir('volume')
|
||||
subdir('v4l2')
|
||||
subdir('xv')
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ struct type {
|
|||
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
|
||||
|
|
@ -121,8 +120,7 @@ struct impl {
|
|||
|
||||
#define DEFAULT_LIVE false
|
||||
|
||||
static void
|
||||
reset_props (struct impl *this, struct props *props)
|
||||
static void reset_props(struct impl *this, struct props *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
}
|
||||
|
|
@ -140,9 +138,7 @@ reset_props (struct impl *this, struct props *props)
|
|||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
|
||||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -155,15 +151,14 @@ impl_node_get_props (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
|
||||
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(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
|
||||
this->props.live));
|
||||
*props = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_props);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -175,8 +170,7 @@ impl_node_set_props (struct spa_node *node,
|
|||
reset_props(this, &this->props);
|
||||
} else {
|
||||
spa_props_query(props,
|
||||
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
0);
|
||||
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, 0);
|
||||
}
|
||||
|
||||
if (this->props.live)
|
||||
|
|
@ -187,8 +181,7 @@ impl_node_set_props (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
set_timer (struct impl *this, bool enabled)
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.need_input || this->props.live) {
|
||||
if (enabled) {
|
||||
|
|
@ -208,8 +201,7 @@ set_timer (struct impl *this, bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
read_timer (struct impl *this)
|
||||
static inline void read_timer(struct impl *this)
|
||||
{
|
||||
uint64_t expirations;
|
||||
|
||||
|
|
@ -219,13 +211,11 @@ read_timer (struct impl *this)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
render_buffer (struct impl *this, struct buffer *b)
|
||||
static void render_buffer(struct impl *this, struct buffer *b)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
consume_buffer (struct impl *this)
|
||||
static int consume_buffer(struct impl *this)
|
||||
{
|
||||
struct buffer *b;
|
||||
struct spa_port_io *io = this->io;
|
||||
|
|
@ -273,17 +263,14 @@ consume_buffer (struct impl *this)
|
|||
return SPA_RESULT_NEED_BUFFER;
|
||||
}
|
||||
|
||||
static void
|
||||
on_input (struct spa_source *source)
|
||||
static void on_input(struct spa_source *source)
|
||||
{
|
||||
struct impl *this = source->data;
|
||||
|
||||
consume_buffer(this);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -314,8 +301,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = true;
|
||||
set_timer(this, true);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -327,8 +313,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -392,18 +377,13 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -413,8 +393,7 @@ impl_node_port_enum_formats (struct spa_node *node,
|
|||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_format **format,
|
||||
const struct spa_format *filter,
|
||||
uint32_t index)
|
||||
const struct spa_format *filter, uint32_t index)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -428,8 +407,7 @@ impl_node_port_enum_formats (struct spa_node *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
static int
|
||||
clear_buffers (struct impl *this)
|
||||
static int clear_buffers(struct impl *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
spa_log_info(this->log, NAME " %p: clear buffers", this);
|
||||
|
|
@ -534,16 +512,23 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
switch (index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
|
||||
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 128),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 1),
|
||||
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
|
||||
128),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
|
||||
1),
|
||||
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
|
||||
32,
|
||||
2, 32),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
|
||||
16));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
|
||||
this->type.meta.Header),
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
|
||||
sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -595,9 +580,9 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
if ((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd ||
|
||||
d[0].type == this->type.data.DmaBuf) &&
|
||||
d[0].data == NULL) {
|
||||
spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]);
|
||||
d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
}
|
||||
}
|
||||
this->n_buffers = n_buffers;
|
||||
|
|
@ -647,10 +632,7 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -664,8 +646,7 @@ impl_node_port_send_command (struct spa_node *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *input;
|
||||
|
|
@ -676,12 +657,12 @@ impl_node_process_input (struct spa_node *node)
|
|||
input = this->io;
|
||||
spa_return_val_if_fail(input != NULL, SPA_RESULT_WRONG_STATE);
|
||||
|
||||
if (input->status == SPA_RESULT_HAVE_BUFFER &&
|
||||
input->buffer_id != SPA_ID_INVALID) {
|
||||
if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) {
|
||||
struct buffer *b = &this->buffers[input->buffer_id];
|
||||
|
||||
if (!b->outstanding) {
|
||||
spa_log_warn (this->log, NAME " %p: buffer %u in use", this, input->buffer_id);
|
||||
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
|
||||
input->buffer_id);
|
||||
input->status = SPA_RESULT_INVALID_BUFFER_ID;
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
|
|
@ -700,8 +681,7 @@ impl_node_process_input (struct spa_node *node)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -732,16 +712,12 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_clock_get_props (struct spa_clock *clock,
|
||||
struct spa_props **props)
|
||||
static int impl_clock_get_props(struct spa_clock *clock, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clock_set_props (struct spa_clock *clock,
|
||||
const struct spa_props *props)
|
||||
static int impl_clock_set_props(struct spa_clock *clock, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -780,10 +756,7 @@ static const struct spa_clock impl_clock = {
|
|||
impl_clock_get_time,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -802,8 +775,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -869,8 +841,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
|
|
@ -879,8 +850,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Node,},
|
||||
{SPA_TYPE__Clock,},
|
||||
};
|
||||
|
|
@ -903,8 +873,8 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesink_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_fakesink_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ struct type {
|
|||
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
|
||||
|
|
@ -126,8 +125,7 @@ struct impl {
|
|||
#define DEFAULT_LIVE false
|
||||
#define DEFAULT_PATTERN 0
|
||||
|
||||
static void
|
||||
reset_props (struct impl *this, struct props *props)
|
||||
static void reset_props(struct impl *this, struct props *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->pattern = DEFAULT_PATTERN;
|
||||
|
|
@ -146,9 +144,7 @@ reset_props (struct impl *this, struct props *props)
|
|||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
|
||||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -161,7 +157,8 @@ impl_node_get_props (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
|
||||
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(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
|
||||
this->props.live),
|
||||
PROP_EN(&f[1], this->type.prop_pattern, SPA_POD_TYPE_ID, 1,
|
||||
this->props.pattern,
|
||||
this->props.pattern));
|
||||
|
|
@ -171,9 +168,7 @@ impl_node_get_props (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -186,8 +181,7 @@ impl_node_set_props (struct spa_node *node,
|
|||
} else {
|
||||
spa_props_query(props,
|
||||
this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live,
|
||||
this->type.prop_pattern, SPA_POD_TYPE_ID, &this->props.pattern,
|
||||
0);
|
||||
this->type.prop_pattern, SPA_POD_TYPE_ID, &this->props.pattern, 0);
|
||||
}
|
||||
|
||||
if (this->props.live)
|
||||
|
|
@ -198,14 +192,12 @@ impl_node_set_props (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
fill_buffer (struct impl *this, struct buffer *b)
|
||||
static int fill_buffer(struct impl *this, struct buffer *b)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
set_timer (struct impl *this, bool enabled)
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if (enabled) {
|
||||
|
|
@ -225,8 +217,7 @@ set_timer (struct impl *this, bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
read_timer (struct impl *this)
|
||||
static inline void read_timer(struct impl *this)
|
||||
{
|
||||
uint64_t expirations;
|
||||
|
||||
|
|
@ -236,8 +227,7 @@ read_timer (struct impl *this)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
make_buffer (struct impl *this)
|
||||
static int make_buffer(struct impl *this)
|
||||
{
|
||||
struct buffer *b;
|
||||
struct spa_port_io *io = this->io;
|
||||
|
|
@ -281,8 +271,7 @@ make_buffer (struct impl *this)
|
|||
return SPA_RESULT_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static void
|
||||
on_output (struct spa_source *source)
|
||||
static void on_output(struct spa_source *source)
|
||||
{
|
||||
struct impl *this = source->data;
|
||||
int res;
|
||||
|
|
@ -293,9 +282,7 @@ on_output (struct spa_source *source)
|
|||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -326,8 +313,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = true;
|
||||
set_timer(this, true);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -339,8 +325,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -404,18 +389,13 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -440,8 +420,7 @@ impl_node_port_enum_formats (struct spa_node *node,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
static int
|
||||
clear_buffers (struct impl *this)
|
||||
static int clear_buffers(struct impl *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
spa_log_info(this->log, NAME " %p: clear buffers", this);
|
||||
|
|
@ -550,16 +529,23 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
switch (index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
|
||||
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 128),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 1),
|
||||
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
|
||||
128),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
|
||||
1),
|
||||
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
|
||||
32,
|
||||
2, 32),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
|
||||
16));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
|
||||
this->type.meta.Header),
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
|
||||
sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -611,9 +597,9 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
if ((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd ||
|
||||
d[0].type == this->type.data.DmaBuf) &&
|
||||
d[0].data == NULL) {
|
||||
spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]);
|
||||
d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
}
|
||||
spa_list_insert(this->empty.prev, &b->link);
|
||||
}
|
||||
|
|
@ -665,8 +651,7 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static inline void
|
||||
reuse_buffer (struct impl *this, uint32_t id)
|
||||
static inline void reuse_buffer(struct impl *this, uint32_t id)
|
||||
{
|
||||
struct buffer *b = &this->buffers[id];
|
||||
spa_return_if_fail(b->outstanding);
|
||||
|
|
@ -682,10 +667,7 @@ reuse_buffer (struct impl *this, uint32_t id)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -711,14 +693,12 @@ impl_node_port_send_command (struct spa_node *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
|
@ -769,16 +749,12 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_clock_get_props (struct spa_clock *clock,
|
||||
struct spa_props **props)
|
||||
static int impl_clock_get_props(struct spa_clock *clock, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clock_set_props (struct spa_clock *clock,
|
||||
const struct spa_props *props)
|
||||
static int impl_clock_set_props(struct spa_clock *clock, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -817,10 +793,7 @@ static const struct spa_clock impl_clock = {
|
|||
impl_clock_get_time,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -839,8 +812,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -906,8 +878,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
|
|
@ -916,8 +887,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Node,},
|
||||
{SPA_TYPE__Clock,},
|
||||
};
|
||||
|
|
@ -940,8 +910,8 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_fakesrc_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_fakesrc_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -24,11 +24,9 @@ extern const struct spa_handle_factory spa_fakesrc_factory;
|
|||
extern const struct spa_handle_factory spa_fakesink_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ struct type {
|
|||
struct spa_type_monitor monitor;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->handle_factory = spa_type_map_get_id(map, SPA_TYPE__HandleFactory);
|
||||
spa_type_monitor_map(map, &type->monitor);
|
||||
|
|
@ -76,8 +75,7 @@ struct impl {
|
|||
struct spa_source source;
|
||||
};
|
||||
|
||||
static int
|
||||
impl_udev_open (struct impl *this)
|
||||
static int impl_udev_open(struct impl *this)
|
||||
{
|
||||
if (this->udev != NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -87,8 +85,7 @@ impl_udev_open (struct impl *this)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
fill_item (struct impl *this, struct item *item, struct udev_device *udevice)
|
||||
static void fill_item(struct impl *this, struct item *item, struct udev_device *udevice)
|
||||
{
|
||||
const char *str, *name;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -118,15 +115,19 @@ fill_item (struct impl *this, struct item *item, struct udev_device *udevice)
|
|||
spa_pod_builder_push_object(&b, &f[0], 0, this->type.monitor.MonitorItem);
|
||||
|
||||
spa_pod_builder_add(&b,
|
||||
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),
|
||||
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->type.monitor.info, 0,
|
||||
SPA_POD_TYPE_STRUCT, 1, &f[2], 0);
|
||||
|
|
@ -135,29 +136,35 @@ fill_item (struct impl *this, struct item *item, struct udev_device *udevice)
|
|||
spa_pod_builder_add(&b,
|
||||
SPA_POD_TYPE_STRING, "udev-probed", SPA_POD_TYPE_STRING, "1",
|
||||
SPA_POD_TYPE_STRING, "device.api", SPA_POD_TYPE_STRING, "v4l2",
|
||||
SPA_POD_TYPE_STRING, "device.path", SPA_POD_TYPE_STRING, udev_device_get_devnode (item->udevice),
|
||||
0);
|
||||
SPA_POD_TYPE_STRING, "device.path", SPA_POD_TYPE_STRING,
|
||||
udev_device_get_devnode(item->udevice), 0);
|
||||
|
||||
str = udev_device_get_property_value(item->udevice, "ID_PATH");
|
||||
if (!(str && *str))
|
||||
str = udev_device_get_syspath(item->udevice);
|
||||
if (str && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.bus_path", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.bus_path", SPA_POD_TYPE_STRING,
|
||||
str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_syspath(item->udevice)) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "sysfs.path", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "sysfs.path", SPA_POD_TYPE_STRING,
|
||||
str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(item->udevice, "ID_ID")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "udev.id", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "udev.id", SPA_POD_TYPE_STRING,
|
||||
str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(item->udevice, "ID_BUS")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.bus", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.bus", SPA_POD_TYPE_STRING,
|
||||
str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(item->udevice, "SUBSYSTEM")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.subsystem", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.subsystem",
|
||||
SPA_POD_TYPE_STRING, str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(item->udevice, "ID_VENDOR_ID")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.vendor.id", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.vendor.id",
|
||||
SPA_POD_TYPE_STRING, str, 0);
|
||||
}
|
||||
str = udev_device_get_property_value(item->udevice, "ID_VENDOR_FROM_DATABASE");
|
||||
if (!(str && *str)) {
|
||||
|
|
@ -167,31 +174,32 @@ fill_item (struct impl *this, struct item *item, struct udev_device *udevice)
|
|||
}
|
||||
}
|
||||
if (str && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.vendor.name", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.vendor.name",
|
||||
SPA_POD_TYPE_STRING, str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(item->udevice, "ID_MODEL_ID")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.product.id", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.product.id",
|
||||
SPA_POD_TYPE_STRING, str, 0);
|
||||
}
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.product.name", SPA_POD_TYPE_STRING, name, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.product.name", SPA_POD_TYPE_STRING,
|
||||
name, 0);
|
||||
if ((str = udev_device_get_property_value(item->udevice, "ID_SERIAL")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.serial", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.serial", SPA_POD_TYPE_STRING,
|
||||
str, 0);
|
||||
}
|
||||
if ((str = udev_device_get_property_value(item->udevice, "ID_V4L_CAPABILITIES")) && *str) {
|
||||
spa_pod_builder_add (&b, SPA_POD_TYPE_STRING, "device.capabilities", SPA_POD_TYPE_STRING, str, 0);
|
||||
spa_pod_builder_add(&b, SPA_POD_TYPE_STRING, "device.capabilities",
|
||||
SPA_POD_TYPE_STRING, str, 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
-SPA_POD_TYPE_STRUCT, &f[2],
|
||||
-SPA_POD_TYPE_PROP, &f[1],
|
||||
0);
|
||||
spa_pod_builder_add(&b, -SPA_POD_TYPE_STRUCT, &f[2], -SPA_POD_TYPE_PROP, &f[1], 0);
|
||||
|
||||
spa_pod_builder_pop(&b, &f[0]);
|
||||
|
||||
item->item = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_monitor_item);
|
||||
}
|
||||
|
||||
static void
|
||||
impl_on_fd_events (struct spa_source *source)
|
||||
static void impl_on_fd_events(struct spa_source *source)
|
||||
{
|
||||
struct impl *this = source->data;
|
||||
struct udev_device *dev;
|
||||
|
|
@ -220,8 +228,7 @@ impl_on_fd_events (struct spa_source *source)
|
|||
return;
|
||||
|
||||
spa_pod_builder_init(&b, buffer, sizeof(buffer));
|
||||
spa_pod_builder_object (&b, &f[0], 0, type,
|
||||
SPA_POD_TYPE_POD, this->uitem.item);
|
||||
spa_pod_builder_object(&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->uitem.item);
|
||||
|
||||
event = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_event);
|
||||
this->callbacks.event(&this->monitor, event, this->user_data);
|
||||
|
|
@ -230,8 +237,7 @@ impl_on_fd_events (struct spa_source *source)
|
|||
static int
|
||||
impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
||||
const struct spa_monitor_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
size_t callbacks_size, void *user_data)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -252,8 +258,7 @@ impl_monitor_set_callbacks (struct spa_monitor *monitor,
|
|||
return SPA_RESULT_ERROR;
|
||||
|
||||
udev_monitor_filter_add_match_subsystem_devtype(this->umonitor,
|
||||
"video4linux",
|
||||
NULL);
|
||||
"video4linux", NULL);
|
||||
|
||||
udev_monitor_enable_receiving(this->umonitor);
|
||||
this->source.func = impl_on_fd_events;
|
||||
|
|
@ -271,9 +276,7 @@ impl_monitor_set_callbacks (struct spa_monitor *monitor,
|
|||
}
|
||||
|
||||
static int
|
||||
impl_monitor_enum_items (struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item,
|
||||
uint32_t index)
|
||||
impl_monitor_enum_items(struct spa_monitor *monitor, struct spa_monitor_item **item, uint32_t index)
|
||||
{
|
||||
int res;
|
||||
struct impl *this;
|
||||
|
|
@ -307,8 +310,7 @@ impl_monitor_enum_items (struct spa_monitor *monitor,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
dev = udev_device_new_from_syspath (this->udev,
|
||||
udev_list_entry_get_name (this->devices));
|
||||
dev = udev_device_new_from_syspath(this->udev, udev_list_entry_get_name(this->devices));
|
||||
|
||||
fill_item(this, &this->uitem, dev);
|
||||
if (dev == NULL)
|
||||
|
|
@ -329,10 +331,7 @@ static const struct spa_monitor impl_monitor = {
|
|||
impl_monitor_enum_items,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -349,8 +348,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -369,9 +367,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear,
|
||||
|
||||
this = (struct impl *) handle;
|
||||
handle->clear = impl_clear, this = (struct impl *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
|
|
@ -396,8 +392,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Monitor,},
|
||||
};
|
||||
|
||||
|
|
@ -413,11 +408,12 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_monitor_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_v4l2_monitor_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ struct props {
|
|||
int device_fd;
|
||||
};
|
||||
|
||||
static void
|
||||
reset_props (struct props *props)
|
||||
static void reset_props(struct props *props)
|
||||
{
|
||||
strncpy(props->device, default_device, 64);
|
||||
}
|
||||
|
|
@ -83,8 +82,7 @@ struct type {
|
|||
struct spa_type_data data;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
|
||||
|
|
@ -184,9 +182,7 @@ struct impl {
|
|||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
#include "v4l2-utils.c"
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -199,17 +195,18 @@ impl_node_get_props (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
|
||||
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));
|
||||
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, struct spa_props);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -221,15 +218,13 @@ impl_node_set_props (struct spa_node *node,
|
|||
reset_props(&this->props);
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
0);
|
||||
spa_props_query(props, this->type.prop_device, -SPA_POD_TYPE_STRING,
|
||||
this->props.device, sizeof(this->props.device), 0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
do_pause_done (struct spa_loop *loop,
|
||||
static int do_pause_done(struct spa_loop *loop,
|
||||
bool async,
|
||||
uint32_t seq,
|
||||
size_t size,
|
||||
|
|
@ -247,8 +242,7 @@ do_pause_done (struct spa_loop *loop,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
do_pause (struct spa_loop *loop,
|
||||
static int do_pause(struct spa_loop *loop,
|
||||
bool async,
|
||||
uint32_t seq,
|
||||
size_t size,
|
||||
|
|
@ -259,10 +253,7 @@ do_pause (struct spa_loop *loop,
|
|||
int res;
|
||||
struct spa_command *cmd = data;
|
||||
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
0,
|
||||
cmd);
|
||||
res = spa_node_port_send_command(&this->node, SPA_DIRECTION_OUTPUT, 0, cmd);
|
||||
|
||||
if (async) {
|
||||
spa_loop_invoke(this->out_ports[0].main_loop,
|
||||
|
|
@ -276,8 +267,7 @@ do_pause (struct spa_loop *loop,
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
do_start_done (struct spa_loop *loop,
|
||||
static int do_start_done(struct spa_loop *loop,
|
||||
bool async,
|
||||
uint32_t seq,
|
||||
size_t size,
|
||||
|
|
@ -292,8 +282,7 @@ do_start_done (struct spa_loop *loop,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
do_start (struct spa_loop *loop,
|
||||
static int do_start(struct spa_loop *loop,
|
||||
bool async,
|
||||
uint32_t seq,
|
||||
size_t size,
|
||||
|
|
@ -304,10 +293,7 @@ do_start (struct spa_loop *loop,
|
|||
int res;
|
||||
struct spa_command *cmd = data;
|
||||
|
||||
res = spa_node_port_send_command (&this->node,
|
||||
SPA_DIRECTION_OUTPUT,
|
||||
0,
|
||||
cmd);
|
||||
res = spa_node_port_send_command(&this->node, SPA_DIRECTION_OUTPUT, 0, cmd);
|
||||
|
||||
if (async) {
|
||||
spa_loop_invoke(this->out_ports[0].main_loop,
|
||||
|
|
@ -318,13 +304,10 @@ do_start (struct spa_loop *loop,
|
|||
seq, res),
|
||||
this);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -352,8 +335,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
SPA_POD_SIZE(command),
|
||||
command,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
struct port *state = &this->out_ports[0];
|
||||
|
||||
if (!state->have_format)
|
||||
|
|
@ -368,16 +350,13 @@ impl_node_send_command (struct spa_node *node,
|
|||
SPA_POD_SIZE(command),
|
||||
command,
|
||||
this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.ClockUpdate) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.ClockUpdate) {
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_callbacks (struct spa_node *node,
|
||||
static int impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
|
|
@ -415,8 +394,7 @@ impl_node_get_n_ports (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_get_port_ids (struct spa_node *node,
|
||||
static int impl_node_get_port_ids(struct spa_node *node,
|
||||
uint32_t n_input_ports,
|
||||
uint32_t *input_ids,
|
||||
uint32_t n_output_ports,
|
||||
|
|
@ -431,16 +409,14 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
static int impl_node_add_port(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
static int impl_node_remove_port(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
|
|
@ -470,8 +446,7 @@ impl_node_port_enum_formats (struct spa_node *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_format (struct spa_node *node,
|
||||
static int impl_node_port_set_format(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
|
|
@ -516,8 +491,7 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
info.info.raw.size.width == state->current_format.info.raw.size.width &&
|
||||
info.info.raw.size.height == state->current_format.info.raw.size.height)
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
else if (info.media_subtype == this->type.media_subtype_video.mjpg) {
|
||||
} else if (info.media_subtype == this->type.media_subtype_video.mjpg) {
|
||||
if (!spa_format_video_mjpg_parse(format, &info.info.mjpg, &this->type.format_video))
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
|
|
@ -526,8 +500,7 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
info.info.mjpg.size.width == state->current_format.info.mjpg.size.width &&
|
||||
info.info.mjpg.size.height == state->current_format.info.mjpg.size.height)
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
else if (info.media_subtype == this->type.media_subtype_video.h264) {
|
||||
} else if (info.media_subtype == this->type.media_subtype_video.h264) {
|
||||
if (!spa_format_video_h264_parse(format, &info.info.h264, &this->type.format_video))
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
|
|
@ -555,8 +528,7 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_format (struct spa_node *node,
|
||||
static int impl_node_port_get_format(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_format **format)
|
||||
|
|
@ -587,23 +559,25 @@ impl_node_port_get_format (struct spa_node *node,
|
|||
|
||||
if (state->current_format.media_subtype == this->type.media_subtype.raw) {
|
||||
spa_pod_builder_add(&b,
|
||||
PROP (&f[1], this->type.format_video.format, SPA_POD_TYPE_ID, state->current_format.info.raw.format),
|
||||
PROP (&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.raw.size),
|
||||
PROP (&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.raw.framerate),
|
||||
0);
|
||||
}
|
||||
else if (state->current_format.media_subtype == this->type.media_subtype_video.mjpg ||
|
||||
PROP(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID,
|
||||
state->current_format.info.raw.format),
|
||||
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
|
||||
&state->current_format.info.raw.size),
|
||||
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
|
||||
&state->current_format.info.raw.framerate), 0);
|
||||
} 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->type.format_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.mjpg.size),
|
||||
PROP (&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.mjpg.framerate),
|
||||
0);
|
||||
}
|
||||
else if (state->current_format.media_subtype == this->type.media_subtype_video.h264) {
|
||||
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
|
||||
&state->current_format.info.mjpg.size),
|
||||
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
|
||||
&state->current_format.info.mjpg.framerate), 0);
|
||||
} else if (state->current_format.media_subtype == this->type.media_subtype_video.h264) {
|
||||
spa_pod_builder_add(&b,
|
||||
PROP (&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE, &state->current_format.info.h264.size),
|
||||
PROP (&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION, &state->current_format.info.h264.framerate),
|
||||
0);
|
||||
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
|
||||
&state->current_format.info.h264.size),
|
||||
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
|
||||
&state->current_format.info.h264.framerate), 0);
|
||||
} else
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -614,8 +588,7 @@ impl_node_port_get_format (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_get_info (struct spa_node *node,
|
||||
static int impl_node_port_get_info(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
|
|
@ -634,8 +607,7 @@ impl_node_port_get_info (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_enum_params (struct spa_node *node,
|
||||
static int impl_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t index,
|
||||
|
|
@ -661,16 +633,21 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
switch (index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
|
||||
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, state->fmt.fmt.pix.sizeimage),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, state->fmt.fmt.pix.bytesperline),
|
||||
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
|
||||
state->fmt.fmt.pix.sizeimage),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
|
||||
state->fmt.fmt.pix.bytesperline),
|
||||
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
|
||||
MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
|
||||
this->type.meta.Header),
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
|
||||
sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -682,8 +659,7 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_param (struct spa_node *node,
|
||||
static int impl_node_port_set_param(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_param *param)
|
||||
|
|
@ -691,8 +667,7 @@ impl_node_port_set_param (struct spa_node *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_use_buffers (struct spa_node *node,
|
||||
static int impl_node_port_use_buffers(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_buffer **buffers,
|
||||
|
|
@ -755,8 +730,7 @@ impl_node_port_alloc_buffers (struct spa_node *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_set_io (struct spa_node *node,
|
||||
static int impl_node_port_set_io(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_port_io *io)
|
||||
|
|
@ -774,8 +748,7 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
|
|
@ -797,8 +770,7 @@ impl_node_port_reuse_buffer (struct spa_node *node,
|
|||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_send_command (struct spa_node *node,
|
||||
static int impl_node_port_send_command(struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_command *command)
|
||||
|
|
@ -814,24 +786,20 @@ impl_node_port_send_command (struct spa_node *node,
|
|||
|
||||
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->type.command_node.Start) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
res = spa_v4l2_port_set_enabled(this, true);
|
||||
}
|
||||
else
|
||||
} else
|
||||
res = SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
int res = SPA_RESULT_OK;
|
||||
|
|
@ -840,6 +808,7 @@ impl_node_process_output (struct spa_node *node)
|
|||
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
io = this->out_ports[0].io;
|
||||
spa_return_val_if_fail(io != NULL, SPA_RESULT_WRONG_STATE);
|
||||
|
||||
|
|
@ -879,22 +848,17 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_clock_get_props (struct spa_clock *clock,
|
||||
struct spa_props **props)
|
||||
static int impl_clock_get_props(struct spa_clock *clock, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clock_set_props (struct spa_clock *clock,
|
||||
const struct spa_props *props)
|
||||
static int impl_clock_set_props(struct spa_clock *clock, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clock_get_time (struct spa_clock *clock,
|
||||
static int impl_clock_get_time(struct spa_clock *clock,
|
||||
int32_t *rate,
|
||||
int64_t *ticks,
|
||||
int64_t *monotonic_time)
|
||||
|
|
@ -926,10 +890,7 @@ static const struct spa_clock impl_clock = {
|
|||
impl_clock_get_time,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -948,8 +909,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -969,9 +929,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
spa_return_val_if_fail(handle != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear,
|
||||
|
||||
this = (struct impl *) handle;
|
||||
handle->clear = impl_clear, this = (struct impl *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp(support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
|
|
@ -1014,14 +972,12 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Node,},
|
||||
{SPA_TYPE__Clock,},
|
||||
};
|
||||
|
||||
static int
|
||||
impl_enum_interface_info (const struct spa_handle_factory *factory,
|
||||
static int impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
{
|
||||
|
|
@ -1032,11 +988,12 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_v4l2_source_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_v4l2_source_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,21 @@
|
|||
/* Spa
|
||||
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -7,12 +25,9 @@
|
|||
#include <sys/mman.h>
|
||||
#include <poll.h>
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
|
||||
static void v4l2_on_fd_events(struct spa_source *source);
|
||||
|
||||
static int
|
||||
xioctl (int fd, int request, void *arg)
|
||||
static int xioctl(int fd, int request, void *arg)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
|
@ -23,8 +38,7 @@ xioctl (int fd, int request, void *arg)
|
|||
return err;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_open (struct impl *this)
|
||||
static int spa_v4l2_open(struct impl *this)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
struct stat st;
|
||||
|
|
@ -80,8 +94,7 @@ spa_v4l2_open (struct impl *this)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_buffer_recycle (struct impl *this, uint32_t buffer_id)
|
||||
static int spa_v4l2_buffer_recycle(struct impl *this, uint32_t buffer_id)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
struct buffer *b = &state->buffers[buffer_id];
|
||||
|
|
@ -98,8 +111,7 @@ spa_v4l2_buffer_recycle (struct impl *this, uint32_t buffer_id)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_clear_buffers (struct impl *this)
|
||||
static int spa_v4l2_clear_buffers(struct impl *this)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
struct v4l2_requestbuffers reqbuf;
|
||||
|
|
@ -125,7 +137,7 @@ spa_v4l2_clear_buffers (struct impl *this)
|
|||
}
|
||||
}
|
||||
|
||||
CLEAR(reqbuf);
|
||||
spa_zero(reqbuf);
|
||||
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
reqbuf.memory = state->memtype;
|
||||
reqbuf.count = 0;
|
||||
|
|
@ -138,8 +150,7 @@ spa_v4l2_clear_buffers (struct impl *this)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_port_set_enabled (struct impl *this, bool enabled)
|
||||
static int spa_v4l2_port_set_enabled(struct impl *this, bool enabled)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
if (state->source_enabled != enabled) {
|
||||
|
|
@ -153,8 +164,7 @@ spa_v4l2_port_set_enabled (struct impl *this, bool enabled)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_close (struct impl *this)
|
||||
static int spa_v4l2_close(struct impl *this)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
|
||||
|
|
@ -233,8 +243,7 @@ struct format_info {
|
|||
#define FORMAT_NV61 offsetof(struct type, video_format.NV61)
|
||||
#define FORMAT_NV24 offsetof(struct type, video_format.NV24)
|
||||
|
||||
static const struct format_info format_info[] =
|
||||
{
|
||||
static const struct format_info format_info[] = {
|
||||
/* RGB formats */
|
||||
{V4L2_PIX_FMT_RGB332, FORMAT_UNKNOWN, VIDEO, RAW},
|
||||
{V4L2_PIX_FMT_ARGB555, FORMAT_UNKNOWN, VIDEO, RAW},
|
||||
|
|
@ -342,8 +351,7 @@ static const struct format_info format_info[] =
|
|||
{V4L2_PIX_FMT_PWC2, FORMAT_UNKNOWN, VIDEO, RAW},
|
||||
};
|
||||
|
||||
static const struct format_info *
|
||||
fourcc_to_format_info (uint32_t fourcc)
|
||||
static const struct format_info *fourcc_to_format_info(uint32_t fourcc)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -355,8 +363,7 @@ fourcc_to_format_info (uint32_t fourcc)
|
|||
}
|
||||
|
||||
#if 0
|
||||
static const struct format_info *
|
||||
video_format_to_format_info (uint32_t format)
|
||||
static const struct format_info *video_format_to_format_info(uint32_t format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -368,8 +375,7 @@ video_format_to_format_info (uint32_t format)
|
|||
}
|
||||
#endif
|
||||
|
||||
static const struct format_info *
|
||||
find_format_info_by_media_type (struct type *types,
|
||||
static const struct format_info *find_format_info_by_media_type(struct type *types,
|
||||
uint32_t type,
|
||||
uint32_t subtype,
|
||||
uint32_t format,
|
||||
|
|
@ -385,8 +391,7 @@ find_format_info_by_media_type (struct type *types,
|
|||
media_format = *SPA_MEMBER(types, format_info[i].format_offset, uint32_t);
|
||||
|
||||
if ((media_type == type) &&
|
||||
(media_subtype == subtype) &&
|
||||
(format == 0 || media_format == format))
|
||||
(media_subtype == subtype) && (format == 0 || media_format == format))
|
||||
return &format_info[i];
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -463,8 +468,7 @@ filter_framesize (struct v4l2_frmsizeenum *frmsize,
|
|||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
compare_fraction (struct v4l2_fract *f1, const struct spa_fraction *f2)
|
||||
static int compare_fraction(struct v4l2_fract *f1, const struct spa_fraction *f2)
|
||||
{
|
||||
uint64_t n1, n2;
|
||||
|
||||
|
|
@ -536,13 +540,13 @@ spa_v4l2_enum_format (struct impl *this,
|
|||
*format = NULL;
|
||||
|
||||
if (index == 0) {
|
||||
CLEAR (state->fmtdesc);
|
||||
spa_zero(state->fmtdesc);
|
||||
state->fmtdesc.index = 0;
|
||||
state->fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
state->next_fmtdesc = true;
|
||||
CLEAR (state->frmsize);
|
||||
spa_zero(state->frmsize);
|
||||
state->next_frmsize = true;
|
||||
CLEAR (state->frmival);
|
||||
spa_zero(state->frmival);
|
||||
}
|
||||
|
||||
if (false) {
|
||||
|
|
@ -553,15 +557,15 @@ next_fmtdesc:
|
|||
|
||||
while (state->next_fmtdesc) {
|
||||
if (filter) {
|
||||
video_format = enum_filter_format (&this->type, filter, state->fmtdesc.index);
|
||||
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->type,
|
||||
filter->body.media_type.value,
|
||||
filter->body.media_subtype.value,
|
||||
video_format,
|
||||
0);
|
||||
video_format, 0);
|
||||
if (info == NULL)
|
||||
goto next_fmtdesc;
|
||||
|
||||
|
|
@ -594,7 +598,8 @@ next_frmsize:
|
|||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
if (!(p->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
|
||||
const struct spa_rectangle *values = SPA_POD_BODY_CONST (&p->body.value);
|
||||
const struct spa_rectangle *values =
|
||||
SPA_POD_BODY_CONST(&p->body.value);
|
||||
|
||||
if (state->frmsize.index > 0)
|
||||
goto next_fmtdesc;
|
||||
|
|
@ -628,20 +633,14 @@ do_frmsize:
|
|||
n_values = SPA_POD_PROP_N_VALUES(p);
|
||||
|
||||
if (range == SPA_POD_PROP_RANGE_MIN_MAX && n_values > 2) {
|
||||
if (filter_framesize (&state->frmsize, &values[1],
|
||||
&values[2],
|
||||
&step))
|
||||
if (filter_framesize(&state->frmsize, &values[1], &values[2], &step))
|
||||
goto have_size;
|
||||
} else if (range == SPA_POD_PROP_RANGE_STEP && n_values > 3) {
|
||||
if (filter_framesize (&state->frmsize, &values[1],
|
||||
&values[2],
|
||||
&values[3]))
|
||||
if (filter_framesize(&state->frmsize, &values[1], &values[2], &values[3]))
|
||||
goto have_size;
|
||||
} else if (range == SPA_POD_PROP_RANGE_ENUM) {
|
||||
for (i = 1; i < n_values; i++) {
|
||||
if (filter_framesize (&state->frmsize, &values[i],
|
||||
&values[i],
|
||||
&step))
|
||||
if (filter_framesize(&state->frmsize, &values[i], &values[i], &step))
|
||||
goto have_size;
|
||||
}
|
||||
}
|
||||
|
|
@ -658,8 +657,7 @@ have_size:
|
|||
state->frmival.width = state->frmsize.discrete.width;
|
||||
state->frmival.height = state->frmsize.discrete.height;
|
||||
state->next_frmsize = false;
|
||||
}
|
||||
else if (state->frmsize.type == V4L2_FRMSIZE_TYPE_CONTINUOUS ||
|
||||
} else if (state->frmsize.type == V4L2_FRMSIZE_TYPE_CONTINUOUS ||
|
||||
state->frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
|
||||
/* we have a non fixed size, fix to something sensible to get the
|
||||
* framerate */
|
||||
|
|
@ -678,24 +676,19 @@ have_size:
|
|||
video_format = *SPA_MEMBER(&this->type, info->format_offset, uint32_t);
|
||||
|
||||
spa_pod_builder_init(&b, state->format_buffer, sizeof(state->format_buffer));
|
||||
spa_pod_builder_push_format (&b, &f[0], this->type.format,
|
||||
media_type,
|
||||
media_subtype);
|
||||
spa_pod_builder_push_format(&b, &f[0], this->type.format, media_type, media_subtype);
|
||||
|
||||
if (media_subtype == this->type.media_subtype.raw) {
|
||||
spa_pod_builder_add(&b,
|
||||
PROP (&f[1], this->type.format_video.format, SPA_POD_TYPE_ID, video_format),
|
||||
0);
|
||||
PROP(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID,
|
||||
video_format), 0);
|
||||
}
|
||||
spa_pod_builder_add(&b,
|
||||
PROP (&f[1], this->type.format_video.size, SPA_POD_TYPE_RECTANGLE, state->frmsize.discrete.width,
|
||||
state->frmsize.discrete.height),
|
||||
0);
|
||||
PROP(&f[1], this->type.format_video.size, SPA_POD_TYPE_RECTANGLE,
|
||||
state->frmsize.discrete.width, state->frmsize.discrete.height), 0);
|
||||
|
||||
spa_pod_builder_push_prop (&b, &f[1],
|
||||
this->type.format_video.framerate,
|
||||
SPA_POD_PROP_RANGE_NONE |
|
||||
SPA_POD_PROP_FLAG_UNSET);
|
||||
spa_pod_builder_push_prop(&b, &f[1], this->type.format_video.framerate,
|
||||
SPA_POD_PROP_RANGE_NONE | SPA_POD_PROP_FLAG_UNSET);
|
||||
|
||||
prop = SPA_POD_BUILDER_DEREF(&b, f[1].ref, struct spa_pod_prop);
|
||||
n_fractions = 0;
|
||||
|
|
@ -731,25 +724,17 @@ have_size:
|
|||
n_values = SPA_POD_PROP_N_VALUES(p);
|
||||
|
||||
if (!(p->body.flags & SPA_POD_PROP_FLAG_UNSET)) {
|
||||
if (filter_framerate (&state->frmival, &values[0],
|
||||
&values[0],
|
||||
&step))
|
||||
if (filter_framerate(&state->frmival, &values[0], &values[0], &step))
|
||||
goto have_framerate;
|
||||
} else if (range == SPA_POD_PROP_RANGE_MIN_MAX && n_values > 2) {
|
||||
if (filter_framerate (&state->frmival, &values[1],
|
||||
&values[2],
|
||||
&step))
|
||||
if (filter_framerate(&state->frmival, &values[1], &values[2], &step))
|
||||
goto have_framerate;
|
||||
} else if (range == SPA_POD_PROP_RANGE_STEP && n_values > 3) {
|
||||
if (filter_framerate (&state->frmival, &values[1],
|
||||
&values[2],
|
||||
&values[3]))
|
||||
if (filter_framerate(&state->frmival, &values[1], &values[2], &values[3]))
|
||||
goto have_framerate;
|
||||
} else if (range == SPA_POD_PROP_RANGE_ENUM) {
|
||||
for (i = 1; i < n_values; i++) {
|
||||
if (filter_framerate (&state->frmival, &values[i],
|
||||
&values[i],
|
||||
&step))
|
||||
if (filter_framerate(&state->frmival, &values[i], &values[i], &step))
|
||||
goto have_framerate;
|
||||
}
|
||||
}
|
||||
|
|
@ -803,8 +788,7 @@ have_framerate:
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_set_format (struct impl *this, struct spa_video_info *format, bool try_only)
|
||||
static int spa_v4l2_set_format(struct impl *this, struct spa_video_info *format, bool try_only)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
int cmd;
|
||||
|
|
@ -815,8 +799,8 @@ spa_v4l2_set_format (struct impl *this, struct spa_video_info *format, bool try_
|
|||
struct spa_rectangle *size = NULL;
|
||||
struct spa_fraction *framerate = NULL;
|
||||
|
||||
CLEAR (fmt);
|
||||
CLEAR (streamparm);
|
||||
spa_zero(fmt);
|
||||
spa_zero(streamparm);
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
|
||||
|
|
@ -824,27 +808,22 @@ spa_v4l2_set_format (struct impl *this, struct spa_video_info *format, bool try_
|
|||
video_format = format->info.raw.format;
|
||||
size = &format->info.raw.size;
|
||||
framerate = &format->info.raw.framerate;
|
||||
}
|
||||
else if (format->media_subtype == this->type.media_subtype_video.mjpg ||
|
||||
} 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->type.media_subtype_video.h264) {
|
||||
} 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 {
|
||||
} else {
|
||||
video_format = this->type.video_format.ENCODED;
|
||||
}
|
||||
|
||||
info = find_format_info_by_media_type(&this->type,
|
||||
format->media_type,
|
||||
format->media_subtype,
|
||||
video_format,
|
||||
0);
|
||||
format->media_subtype, video_format, 0);
|
||||
if (info == NULL || size == NULL || framerate == NULL) {
|
||||
spa_log_error(state->log, "v4l2: unknown media type %d %d %d", format->media_type,
|
||||
format->media_subtype, video_format);
|
||||
|
|
@ -899,15 +878,13 @@ spa_v4l2_set_format (struct impl *this, struct spa_video_info *format, bool try_
|
|||
|
||||
state->fmt = fmt;
|
||||
state->info.flags = (state->export_buf ? SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS : 0) |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_LIVE;
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_LIVE;
|
||||
state->info.rate = streamparm.parm.capture.timeperframe.denominator;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mmap_read (struct impl *this)
|
||||
static int mmap_read(struct impl *this)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
struct v4l2_buffer buf;
|
||||
|
|
@ -916,7 +893,7 @@ mmap_read (struct impl *this)
|
|||
int64_t pts;
|
||||
struct spa_port_io *io = state->io;
|
||||
|
||||
CLEAR(buf);
|
||||
spa_zero(buf);
|
||||
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
buf.memory = state->memtype;
|
||||
|
||||
|
|
@ -931,7 +908,8 @@ mmap_read (struct impl *this)
|
|||
}
|
||||
}
|
||||
|
||||
state->last_ticks = (int64_t)buf.timestamp.tv_sec * SPA_USEC_PER_SEC + (uint64_t)buf.timestamp.tv_usec;
|
||||
state->last_ticks = (int64_t) buf.timestamp.tv_sec * SPA_USEC_PER_SEC +
|
||||
(uint64_t) buf.timestamp.tv_usec;
|
||||
pts = state->last_ticks * 1000;
|
||||
|
||||
if (buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC)
|
||||
|
|
@ -961,8 +939,7 @@ mmap_read (struct impl *this)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
v4l2_on_fd_events (struct spa_source *source)
|
||||
static void v4l2_on_fd_events(struct spa_source *source)
|
||||
{
|
||||
struct impl *this = source->data;
|
||||
|
||||
|
|
@ -976,8 +953,7 @@ v4l2_on_fd_events (struct spa_source *source)
|
|||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_use_buffers (struct impl *this, struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers, uint32_t n_buffers)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
struct v4l2_requestbuffers reqbuf;
|
||||
|
|
@ -988,20 +964,17 @@ spa_v4l2_use_buffers (struct impl *this, struct spa_buffer **buffers, uint32_t n
|
|||
d = buffers[0]->datas;
|
||||
|
||||
if ((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd) &&
|
||||
d[0].data != NULL) {
|
||||
d[0].type == this->type.data.MemFd) && d[0].data != NULL) {
|
||||
state->memtype = V4L2_MEMORY_USERPTR;
|
||||
}
|
||||
else if (d[0].type == this->type.data.DmaBuf) {
|
||||
} else if (d[0].type == this->type.data.DmaBuf) {
|
||||
state->memtype = V4L2_MEMORY_DMABUF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
spa_log_error(state->log, "v4l2: can't use buffers of type %d", d[0].type);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
CLEAR(reqbuf);
|
||||
spa_zero(reqbuf);
|
||||
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
reqbuf.memory = state->memtype;
|
||||
reqbuf.count = n_buffers;
|
||||
|
|
@ -1033,17 +1006,15 @@ spa_v4l2_use_buffers (struct impl *this, struct spa_buffer **buffers, uint32_t n
|
|||
}
|
||||
d = buffers[i]->datas;
|
||||
|
||||
CLEAR (b->v4l2_buffer);
|
||||
spa_zero(b->v4l2_buffer);
|
||||
b->v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
b->v4l2_buffer.memory = state->memtype;
|
||||
b->v4l2_buffer.index = i;
|
||||
|
||||
if (d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd) {
|
||||
if (d[0].type == this->type.data.MemPtr || d[0].type == this->type.data.MemFd) {
|
||||
b->v4l2_buffer.m.userptr = (unsigned long) d[0].data;
|
||||
b->v4l2_buffer.length = d[0].maxsize;
|
||||
}
|
||||
else if (d[0].type == this->type.data.DmaBuf) {
|
||||
} else if (d[0].type == this->type.data.DmaBuf) {
|
||||
b->v4l2_buffer.m.fd = d[0].fd;
|
||||
}
|
||||
spa_v4l2_buffer_recycle(this, buffers[i]->id);
|
||||
|
|
@ -1066,7 +1037,7 @@ mmap_init (struct impl *this,
|
|||
|
||||
state->memtype = V4L2_MEMORY_MMAP;
|
||||
|
||||
CLEAR(reqbuf);
|
||||
spa_zero(reqbuf);
|
||||
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
reqbuf.memory = state->memtype;
|
||||
reqbuf.count = *n_buffers;
|
||||
|
|
@ -1101,7 +1072,7 @@ mmap_init (struct impl *this,
|
|||
b->allocated = true;
|
||||
b->h = spa_buffer_find_meta(b->outbuf, this->type.meta.Header);
|
||||
|
||||
CLEAR (b->v4l2_buffer);
|
||||
spa_zero(b->v4l2_buffer);
|
||||
b->v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
b->v4l2_buffer.memory = state->memtype;
|
||||
b->v4l2_buffer.index = i;
|
||||
|
|
@ -1121,7 +1092,7 @@ mmap_init (struct impl *this,
|
|||
if (state->export_buf) {
|
||||
struct v4l2_exportbuffer expbuf;
|
||||
|
||||
CLEAR (expbuf);
|
||||
spa_zero(expbuf);
|
||||
expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
expbuf.index = i;
|
||||
expbuf.flags = O_CLOEXEC | O_RDONLY;
|
||||
|
|
@ -1137,8 +1108,7 @@ mmap_init (struct impl *this,
|
|||
d[0].fd = -1;
|
||||
d[0].data = mmap(NULL,
|
||||
b->v4l2_buffer.length,
|
||||
PROT_READ,
|
||||
MAP_SHARED,
|
||||
PROT_READ, MAP_SHARED,
|
||||
state->fd,
|
||||
b->v4l2_buffer.m.offset);
|
||||
if (d[0].data == MAP_FAILED) {
|
||||
|
|
@ -1153,14 +1123,12 @@ mmap_init (struct impl *this,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
userptr_init (struct impl *this)
|
||||
static int userptr_init(struct impl *this)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
read_init (struct impl *this)
|
||||
static int read_init(struct impl *this)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -1191,8 +1159,7 @@ spa_v4l2_alloc_buffers (struct impl *this,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_stream_on (struct impl *this)
|
||||
static int spa_v4l2_stream_on(struct impl *this)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
enum v4l2_buf_type type;
|
||||
|
|
@ -1210,8 +1177,7 @@ spa_v4l2_stream_on (struct impl *this)
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_v4l2_stream_off (struct impl *this)
|
||||
static int spa_v4l2_stream_off(struct impl *this)
|
||||
{
|
||||
struct port *state = &this->out_ports[0];
|
||||
enum v4l2_buf_type type;
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@
|
|||
extern const struct spa_handle_factory spa_videotestsrc_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ struct type {
|
|||
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->clock = spa_type_map_get_id(map, SPA_TYPE__Clock);
|
||||
|
|
@ -145,8 +144,7 @@ struct impl {
|
|||
#define DEFAULT_LIVE true
|
||||
#define DEFAULT_PATTERN pattern_smpte_snow
|
||||
|
||||
static void
|
||||
reset_props (struct impl *this, struct props *props)
|
||||
static void reset_props(struct impl *this, struct props *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->pattern = this->type.DEFAULT_PATTERN;
|
||||
|
|
@ -165,9 +163,7 @@ reset_props (struct impl *this, struct props *props)
|
|||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
|
||||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -180,7 +176,8 @@ impl_node_get_props (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
|
||||
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(&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL,
|
||||
this->props.live),
|
||||
PROP_EN(&f[1], this->type.prop_pattern, SPA_POD_TYPE_ID, 3,
|
||||
this->props.pattern,
|
||||
this->type.pattern_smpte_snow,
|
||||
|
|
@ -191,9 +188,7 @@ impl_node_get_props (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -220,14 +215,12 @@ impl_node_set_props (struct spa_node *node,
|
|||
|
||||
#include "draw.c"
|
||||
|
||||
static int
|
||||
fill_buffer (struct impl *this, struct buffer *b)
|
||||
static int fill_buffer(struct impl *this, struct buffer *b)
|
||||
{
|
||||
return draw(this, b->outbuf->datas[0].data);
|
||||
}
|
||||
|
||||
static void
|
||||
set_timer (struct impl *this, bool enabled)
|
||||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.have_output || this->props.live) {
|
||||
if (enabled) {
|
||||
|
|
@ -247,8 +240,7 @@ set_timer (struct impl *this, bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
read_timer (struct impl *this)
|
||||
static void read_timer(struct impl *this)
|
||||
{
|
||||
uint64_t expirations;
|
||||
|
||||
|
|
@ -258,8 +250,7 @@ read_timer (struct impl *this)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
make_buffer (struct impl *this)
|
||||
static int make_buffer(struct impl *this)
|
||||
{
|
||||
struct buffer *b;
|
||||
struct spa_port_io *io = this->io;
|
||||
|
|
@ -299,11 +290,10 @@ make_buffer (struct impl *this)
|
|||
io->buffer_id = b->outbuf->id;
|
||||
io->status = SPA_RESULT_HAVE_BUFFER;
|
||||
|
||||
return SPA_RESULT_HAVE_BUFFER;
|
||||
return io->status;
|
||||
}
|
||||
|
||||
static void
|
||||
impl_on_output (struct spa_source *source)
|
||||
static void on_output(struct spa_source *source)
|
||||
{
|
||||
struct impl *this = source->data;
|
||||
int res;
|
||||
|
|
@ -314,9 +304,7 @@ impl_on_output (struct spa_source *source)
|
|||
this->callbacks.have_output(&this->node, this->user_data);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -347,8 +335,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = true;
|
||||
set_timer(this, true);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
if (!this->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
|
|
@ -360,8 +347,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
this->started = false;
|
||||
set_timer(this, false);
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -425,18 +411,13 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -452,7 +433,7 @@ impl_node_port_enum_formats (struct spa_node *node,
|
|||
struct impl *this;
|
||||
int res;
|
||||
struct spa_format *fmt;
|
||||
uint8_t buffer[1024];
|
||||
uint8_t buffer[256];
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
struct spa_pod_frame f[2];
|
||||
uint32_t count, match;
|
||||
|
|
@ -472,7 +453,8 @@ next:
|
|||
switch (count++) {
|
||||
case 0:
|
||||
spa_pod_builder_format(&b, &f[0], this->type.format,
|
||||
this->type.media_type.video, this->type.media_subtype.raw,
|
||||
this->type.media_type.video,
|
||||
this->type.media_subtype.raw,
|
||||
PROP_U_EN(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID, 3,
|
||||
this->type.video_format.RGB,
|
||||
this->type.video_format.RGB,
|
||||
|
|
@ -501,8 +483,7 @@ next:
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
clear_buffers (struct impl *this)
|
||||
static int clear_buffers(struct impl *this)
|
||||
{
|
||||
if (this->n_buffers > 0) {
|
||||
spa_log_info(this->log, NAME " %p: clear buffers", this);
|
||||
|
|
@ -534,7 +515,8 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
clear_buffers(this);
|
||||
} else {
|
||||
struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE(format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
SPA_FORMAT_MEDIA_SUBTYPE(format),
|
||||
};
|
||||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
|
|
@ -543,14 +525,12 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
if (!spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video))
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (info.info.raw.format == this->type.video_format.RGB) {
|
||||
if (info.info.raw.format == this->type.video_format.RGB)
|
||||
this->bpp = 3;
|
||||
}
|
||||
else if (info.info.raw.format == this->type.video_format.UYVY) {
|
||||
else if (info.info.raw.format == this->type.video_format.UYVY)
|
||||
this->bpp = 2;
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
this->current_format = info;
|
||||
this->have_format = true;
|
||||
|
|
@ -586,10 +566,15 @@ impl_node_port_get_format (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->format_buffer, sizeof(this->format_buffer));
|
||||
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.format_video.format, SPA_POD_TYPE_ID, this->current_format.info.raw.format),
|
||||
PROP (&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size),
|
||||
PROP (&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate));
|
||||
this->type.media_type.video,
|
||||
this->type.media_subtype.raw,
|
||||
PROP(&f[1], this->type.format_video.format, SPA_POD_TYPE_ID,
|
||||
this->current_format.info.raw.format),
|
||||
PROP(&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE,
|
||||
&this->current_format.info.raw.size),
|
||||
PROP(&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION,
|
||||
&this->current_format.info.raw.framerate));
|
||||
|
||||
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -636,21 +621,26 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
spa_pod_builder_init(&b, this->params_buffer, sizeof(this->params_buffer));
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
{
|
||||
case 0: {
|
||||
struct spa_video_info_raw *raw_info = &this->current_format.info.raw;
|
||||
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
|
||||
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, this->stride),
|
||||
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
|
||||
this->stride * raw_info->size.height),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
|
||||
this->stride),
|
||||
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
|
||||
32, 2, 32),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
|
||||
16));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
|
||||
this->type.meta.Header),
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
|
||||
sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -703,9 +693,9 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
if ((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd ||
|
||||
d[0].type == this->type.data.DmaBuf) &&
|
||||
d[0].data == NULL) {
|
||||
spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]);
|
||||
d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
}
|
||||
spa_list_insert(this->empty.prev, &b->link);
|
||||
}
|
||||
|
|
@ -756,8 +746,7 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static inline void
|
||||
reuse_buffer (struct impl *this, uint32_t id)
|
||||
static inline void reuse_buffer(struct impl *this, uint32_t id)
|
||||
{
|
||||
struct buffer *b = &this->buffers[id];
|
||||
spa_return_if_fail(b->outstanding);
|
||||
|
|
@ -771,10 +760,7 @@ reuse_buffer (struct impl *this, uint32_t id)
|
|||
set_timer(this, true);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -800,14 +786,12 @@ impl_node_port_send_command (struct spa_node *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *io;
|
||||
|
|
@ -858,16 +842,12 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_clock_get_props (struct spa_clock *clock,
|
||||
struct spa_props **props)
|
||||
static int impl_clock_get_props(struct spa_clock *clock, struct spa_props **props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clock_set_props (struct spa_clock *clock,
|
||||
const struct spa_props *props)
|
||||
static int impl_clock_set_props(struct spa_clock *clock, const struct spa_props *props)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -906,10 +886,7 @@ static const struct spa_clock impl_clock = {
|
|||
impl_clock_get_time,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -928,8 +905,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -982,7 +958,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
|
||||
spa_list_init(&this->empty);
|
||||
|
||||
this->timer_source.func = impl_on_output;
|
||||
this->timer_source.func = on_output;
|
||||
this->timer_source.data = this;
|
||||
this->timer_source.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
|
|
@ -995,8 +971,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_NO_REF;
|
||||
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF;
|
||||
if (this->props.live)
|
||||
this->info.flags |= SPA_PORT_INFO_FLAG_LIVE;
|
||||
|
||||
|
|
@ -1005,8 +980,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Node,},
|
||||
{SPA_TYPE__Clock,},
|
||||
};
|
||||
|
|
@ -1029,8 +1003,8 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_videotestsrc_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_videotestsrc_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -22,12 +22,9 @@
|
|||
|
||||
extern const struct spa_handle_factory spa_volume_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(factory != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ struct type {
|
|||
struct spa_type_param_alloc_meta_enable param_alloc_meta_enable;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
static inline void init_type(struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
type->node = spa_type_map_get_id(map, SPA_TYPE__Node);
|
||||
type->format = spa_type_map_get_id(map, SPA_TYPE__Format);
|
||||
|
|
@ -128,8 +127,7 @@ struct impl {
|
|||
#define DEFAULT_VOLUME 1.0
|
||||
#define DEFAULT_MUTE false
|
||||
|
||||
static void
|
||||
reset_props (struct props *props)
|
||||
static void reset_props(struct props *props)
|
||||
{
|
||||
props->volume = DEFAULT_VOLUME;
|
||||
props->mute = DEFAULT_MUTE;
|
||||
|
|
@ -147,9 +145,7 @@ reset_props (struct props *props)
|
|||
SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__)
|
||||
|
||||
|
||||
static int
|
||||
impl_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
|
|
@ -162,17 +158,18 @@ impl_node_get_props (struct spa_node *node,
|
|||
|
||||
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
|
||||
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));
|
||||
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, struct spa_props);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -185,15 +182,12 @@ impl_node_set_props (struct spa_node *node,
|
|||
} else {
|
||||
spa_props_query(props,
|
||||
this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume,
|
||||
this->type.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute,
|
||||
0);
|
||||
this->type.prop_mute, SPA_POD_TYPE_BOOL, &this->props.mute, 0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
static int impl_node_send_command(struct spa_node *node, struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -204,11 +198,9 @@ impl_node_send_command (struct spa_node *node,
|
|||
|
||||
if (SPA_COMMAND_TYPE(command) == this->type.command_node.Start) {
|
||||
this->started = true;
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
} else if (SPA_COMMAND_TYPE(command) == this->type.command_node.Pause) {
|
||||
this->started = false;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -217,8 +209,7 @@ impl_node_send_command (struct spa_node *node,
|
|||
static int
|
||||
impl_node_set_callbacks(struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
size_t callbacks_size, void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -271,18 +262,13 @@ impl_node_get_port_ids (struct spa_node *node,
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
impl_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
static int impl_node_add_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
impl_node_remove_port(struct spa_node *node, enum spa_direction direction, uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
@ -318,13 +304,18 @@ next:
|
|||
switch (count++) {
|
||||
case 0:
|
||||
spa_pod_builder_format(&b, &f[0], this->type.format,
|
||||
this->type.media_type.audio, this->type.media_subtype.raw,
|
||||
this->type.media_type.audio,
|
||||
this->type.media_subtype.raw,
|
||||
PROP_U_EN(&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID, 3,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S16,
|
||||
this->type.audio_format.S32),
|
||||
PROP_U_MM (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
|
||||
PROP_U_MM (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
|
||||
PROP_U_MM(&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT,
|
||||
44100,
|
||||
1, INT32_MAX),
|
||||
PROP_U_MM(&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT,
|
||||
2,
|
||||
1, INT32_MAX));
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
@ -341,8 +332,7 @@ next:
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
clear_buffers (struct impl *this, struct port *port)
|
||||
static int clear_buffers(struct impl *this, struct port *port)
|
||||
{
|
||||
if (port->n_buffers > 0) {
|
||||
spa_log_info(this->log, NAME " %p: clear buffers", this);
|
||||
|
|
@ -368,14 +358,16 @@ impl_node_port_set_format (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
clear_buffers(this, port);
|
||||
} else {
|
||||
struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE(format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
SPA_FORMAT_MEDIA_SUBTYPE(format),
|
||||
};
|
||||
|
||||
if (info.media_type != this->type.media_type.audio ||
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
|
|
@ -407,7 +399,8 @@ impl_node_port_get_format (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
|
@ -433,7 +426,8 @@ impl_node_port_get_info (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
@ -458,23 +452,31 @@ impl_node_port_enum_params (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
spa_pod_builder_init(&b, port->params_buffer, sizeof(port->params_buffer));
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
|
||||
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 16),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 16),
|
||||
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
|
||||
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
|
||||
PROP(&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
|
||||
16),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT,
|
||||
16),
|
||||
PROP_U_MM(&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT,
|
||||
MAX_BUFFERS,
|
||||
2, MAX_BUFFERS),
|
||||
PROP(&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT,
|
||||
16));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
spa_pod_builder_object(&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
|
||||
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header)));
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID,
|
||||
this->type.meta.Header),
|
||||
PROP(&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT,
|
||||
sizeof(struct spa_meta_header)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -512,7 +514,8 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
|
@ -530,13 +533,12 @@ impl_node_port_use_buffers (struct spa_node *node,
|
|||
|
||||
if ((d[0].type == this->type.data.MemPtr ||
|
||||
d[0].type == this->type.data.MemFd ||
|
||||
d[0].type == this->type.data.DmaBuf) &&
|
||||
d[0].data != NULL) {
|
||||
d[0].type == this->type.data.DmaBuf) && d[0].data != NULL) {
|
||||
b->ptr = d[0].data;
|
||||
b->size = d[0].maxsize;
|
||||
}
|
||||
else {
|
||||
spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]);
|
||||
} else {
|
||||
spa_log_error(this->log, NAME " %p: invalid memory on buffer %p", this,
|
||||
buffers[i]);
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
spa_list_insert(port->empty.prev, &b->link);
|
||||
|
|
@ -573,14 +575,14 @@ impl_node_port_set_io (struct spa_node *node,
|
|||
|
||||
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
recycle_buffer (struct impl *this, uint32_t id)
|
||||
static void recycle_buffer(struct impl *this, uint32_t id)
|
||||
{
|
||||
struct port *port = &this->out_ports[0];
|
||||
struct buffer *b = &port->buffers[id];
|
||||
|
|
@ -595,10 +597,7 @@ recycle_buffer (struct impl *this, uint32_t id)
|
|||
spa_log_trace(this->log, NAME " %p: recycle buffer %d", this, id);
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
static int impl_node_port_reuse_buffer(struct spa_node *node, uint32_t port_id, uint32_t buffer_id)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
|
@ -607,7 +606,8 @@ impl_node_port_reuse_buffer (struct spa_node *node,
|
|||
|
||||
this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
|
||||
spa_return_val_if_fail (CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id), SPA_RESULT_INVALID_PORT);
|
||||
spa_return_val_if_fail(CHECK_PORT(this, SPA_DIRECTION_OUTPUT, port_id),
|
||||
SPA_RESULT_INVALID_PORT);
|
||||
|
||||
port = &this->out_ports[port_id];
|
||||
|
||||
|
|
@ -631,8 +631,7 @@ impl_node_port_send_command (struct spa_node *node,
|
|||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static struct spa_buffer *
|
||||
find_free_buffer (struct impl *this, struct port *port)
|
||||
static struct spa_buffer *find_free_buffer(struct impl *this, struct port *port)
|
||||
{
|
||||
struct buffer *b;
|
||||
|
||||
|
|
@ -646,15 +645,13 @@ find_free_buffer (struct impl *this, struct port *port)
|
|||
return b->outbuf;
|
||||
}
|
||||
|
||||
static inline void
|
||||
release_buffer (struct impl *this, struct spa_buffer *buffer)
|
||||
static inline void release_buffer(struct impl *this, struct spa_buffer *buffer)
|
||||
{
|
||||
if (this->callbacks.reuse_buffer)
|
||||
this->callbacks.reuse_buffer(&this->node, 0, buffer->id, this->user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
do_volume (struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)
|
||||
static void do_volume(struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)
|
||||
{
|
||||
uint32_t si, di, i, n_samples, n_bytes, soff, doff;
|
||||
struct spa_data *sd, *dd;
|
||||
|
|
@ -696,8 +693,7 @@ do_volume (struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_input (struct spa_node *node)
|
||||
static int impl_node_process_input(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_port_io *input;
|
||||
|
|
@ -735,8 +731,7 @@ impl_node_process_input (struct spa_node *node)
|
|||
return SPA_RESULT_HAVE_BUFFER;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_node_process_output (struct spa_node *node)
|
||||
static int impl_node_process_output(struct spa_node *node)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *in_port, *out_port;
|
||||
|
|
@ -795,10 +790,7 @@ static const struct spa_node impl_node = {
|
|||
impl_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
impl_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id, void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
|
|
@ -815,8 +807,7 @@ impl_get_interface (struct spa_handle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_clear (struct spa_handle *handle)
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -865,8 +856,7 @@ impl_init (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] =
|
||||
{
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
{SPA_TYPE__Node,},
|
||||
};
|
||||
|
||||
|
|
@ -888,8 +878,8 @@ impl_enum_interface_info (const struct spa_handle_factory *factory,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_volume_factory =
|
||||
{ NAME,
|
||||
const struct spa_handle_factory spa_volume_factory = {
|
||||
NAME,
|
||||
NULL,
|
||||
sizeof(struct impl),
|
||||
impl_init,
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
xv_sources = ['xv.c',
|
||||
'xv-sink.c']
|
||||
|
||||
xvlib = shared_library('spa-xv',
|
||||
xv_sources,
|
||||
include_directories : [spa_inc, spa_libinc],
|
||||
dependencies : xv_dep,
|
||||
link_with : spalib,
|
||||
install : true,
|
||||
install_dir : '@0@/spa'.format(get_option('libdir')))
|
||||
|
|
@ -1,605 +0,0 @@
|
|||
/* Spa Xv Sink
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <spa/type-map.h>
|
||||
#include <spa/log.h>
|
||||
#include <spa/list.h>
|
||||
#include <spa/node.h>
|
||||
#include <spa/video/format-utils.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
static const char default_device[] = "/dev/video0";
|
||||
|
||||
struct props {
|
||||
char device[64];
|
||||
char device_name[128];
|
||||
int device_fd;
|
||||
};
|
||||
|
||||
static void
|
||||
reset_props (struct props *props)
|
||||
{
|
||||
strncpy (props->device, default_device, 64);
|
||||
}
|
||||
|
||||
#define MAX_BUFFERS 32
|
||||
|
||||
struct buffer {
|
||||
struct spa_buffer buffer;
|
||||
struct spa_meta meta[1];
|
||||
struct spa_meta_header header;
|
||||
struct spa_data data[1];
|
||||
struct spa_list link;
|
||||
bool outstanding;
|
||||
};
|
||||
|
||||
struct port {
|
||||
bool opened;
|
||||
int fd;
|
||||
|
||||
struct spa_port_io *io;
|
||||
|
||||
bool have_format;
|
||||
uint8_t format_buffer[1024];
|
||||
struct spa_video_info current_format;
|
||||
struct spa_port_info info;
|
||||
|
||||
struct buffer buffers[MAX_BUFFERS];
|
||||
struct spa_list ready;
|
||||
};
|
||||
|
||||
struct type {
|
||||
uint32_t node;
|
||||
uint32_t props;
|
||||
uint32_t prop_device;
|
||||
uint32_t prop_device_name;
|
||||
uint32_t prop_device_fd;
|
||||
struct spa_type_media_type media_type;
|
||||
struct spa_type_media_subtype media_subtype;
|
||||
struct spa_type_format_video format_video;
|
||||
struct spa_type_command_node command_node;
|
||||
};
|
||||
|
||||
static inline void
|
||||
init_type (struct type *type, struct spa_type_map *map)
|
||||
{
|
||||
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_format_video_map (map, &type->format_video);
|
||||
spa_type_command_node_map (map, &type->command_node);
|
||||
}
|
||||
|
||||
struct impl {
|
||||
struct spa_handle handle;
|
||||
struct spa_node node;
|
||||
|
||||
struct type type;
|
||||
struct spa_type_map *map;
|
||||
struct spa_log *log;
|
||||
|
||||
uint8_t props_buffer[512];
|
||||
struct props props;
|
||||
|
||||
struct spa_node_callbacks callbacks;
|
||||
void *user_data;
|
||||
|
||||
struct port in_ports[1];
|
||||
};
|
||||
|
||||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0)
|
||||
|
||||
#include "xv-utils.c"
|
||||
|
||||
#define PROP(f,key,type,...) \
|
||||
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
|
||||
#define PROP_R(f,key,type,...) \
|
||||
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_READONLY,type,1,__VA_ARGS__)
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_get_props (struct spa_node *node,
|
||||
struct spa_props **props)
|
||||
{
|
||||
struct impl *this;
|
||||
struct spa_pod_builder b = { NULL, };
|
||||
struct spa_pod_frame f[2];
|
||||
|
||||
if (node == NULL || props == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer));
|
||||
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, struct spa_props);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_set_props (struct spa_node *node,
|
||||
const struct spa_props *props)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (props == NULL) {
|
||||
reset_props (&this->props);
|
||||
} else {
|
||||
spa_props_query (props,
|
||||
this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device),
|
||||
0);
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_send_command (struct spa_node *node,
|
||||
struct spa_command *command)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
if (node == NULL || command == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) {
|
||||
spa_xv_start (this);
|
||||
}
|
||||
else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) {
|
||||
spa_xv_stop (this);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_set_callbacks (struct spa_node *node,
|
||||
const struct spa_node_callbacks *callbacks,
|
||||
size_t callbacks_size,
|
||||
void *user_data)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
this->callbacks = *callbacks;
|
||||
this->user_data = user_data;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_get_n_ports (struct spa_node *node,
|
||||
uint32_t *n_input_ports,
|
||||
uint32_t *max_input_ports,
|
||||
uint32_t *n_output_ports,
|
||||
uint32_t *max_output_ports)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_input_ports)
|
||||
*n_input_ports = 0;
|
||||
if (n_output_ports)
|
||||
*n_output_ports = 1;
|
||||
if (max_input_ports)
|
||||
*max_input_ports = 0;
|
||||
if (max_output_ports)
|
||||
*max_output_ports = 1;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_get_port_ids (struct spa_node *node,
|
||||
uint32_t n_input_ports,
|
||||
uint32_t *input_ids,
|
||||
uint32_t n_output_ports,
|
||||
uint32_t *output_ids)
|
||||
{
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (n_output_ports > 0 && output_ids != NULL)
|
||||
output_ids[0] = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_add_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_remove_port (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_enum_formats (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_format **format,
|
||||
const struct spa_format *filter,
|
||||
uint32_t index)
|
||||
{
|
||||
//struct impl *this;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
//this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_set_format (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
const struct spa_format *format)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = &this->in_ports[0];
|
||||
|
||||
if (format == NULL) {
|
||||
port->have_format = false;
|
||||
return SPA_RESULT_OK;
|
||||
} else {
|
||||
struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE (format),
|
||||
SPA_FORMAT_MEDIA_SUBTYPE (format), };
|
||||
|
||||
|
||||
if (info.media_type != this->type.media_type.video &&
|
||||
info.media_subtype != this->type.media_subtype.raw)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!spa_format_video_raw_parse (format, &info.info.raw, &this->type.format_video))
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (spa_xv_set_format (this, &info, flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY) < 0)
|
||||
return SPA_RESULT_INVALID_MEDIA_TYPE;
|
||||
|
||||
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
|
||||
port->current_format = info;
|
||||
port->have_format = true;
|
||||
}
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_get_format (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_format **format)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = &this->in_ports[0];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
*format = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_get_info (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
if (node == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = &this->in_ports[0];
|
||||
|
||||
*info = &port->info;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_enum_params (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t index,
|
||||
struct spa_param **param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_set_param (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_param *param)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_use_buffers (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_buffer **buffers,
|
||||
uint32_t n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_alloc_buffers (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_param **params,
|
||||
uint32_t n_params,
|
||||
struct spa_buffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_set_io (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_port_io *io)
|
||||
{
|
||||
struct impl *this;
|
||||
struct port *port;
|
||||
|
||||
if (node == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = SPA_CONTAINER_OF (node, struct impl, node);
|
||||
|
||||
if (!CHECK_PORT (this, direction, port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
port = &this->in_ports[0];
|
||||
port->io = io;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_reuse_buffer (struct spa_node *node,
|
||||
uint32_t port_id,
|
||||
uint32_t buffer_id)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_port_send_command (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
struct spa_command *command)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_process_input (struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_sink_node_process_output (struct spa_node *node)
|
||||
{
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
}
|
||||
|
||||
static const struct spa_node xvsink_node = {
|
||||
sizeof (struct spa_node),
|
||||
NULL,
|
||||
spa_xv_sink_node_get_props,
|
||||
spa_xv_sink_node_set_props,
|
||||
spa_xv_sink_node_send_command,
|
||||
spa_xv_sink_node_set_callbacks,
|
||||
spa_xv_sink_node_get_n_ports,
|
||||
spa_xv_sink_node_get_port_ids,
|
||||
spa_xv_sink_node_add_port,
|
||||
spa_xv_sink_node_remove_port,
|
||||
spa_xv_sink_node_port_enum_formats,
|
||||
spa_xv_sink_node_port_set_format,
|
||||
spa_xv_sink_node_port_get_format,
|
||||
spa_xv_sink_node_port_get_info,
|
||||
spa_xv_sink_node_port_enum_params,
|
||||
spa_xv_sink_node_port_set_param,
|
||||
spa_xv_sink_node_port_use_buffers,
|
||||
spa_xv_sink_node_port_alloc_buffers,
|
||||
spa_xv_sink_node_port_set_io,
|
||||
spa_xv_sink_node_port_reuse_buffer,
|
||||
spa_xv_sink_node_port_send_command,
|
||||
spa_xv_sink_node_process_input,
|
||||
spa_xv_sink_node_process_output,
|
||||
};
|
||||
|
||||
static int
|
||||
spa_xv_sink_get_interface (struct spa_handle *handle,
|
||||
uint32_t interface_id,
|
||||
void **interface)
|
||||
{
|
||||
struct impl *this;
|
||||
|
||||
if (handle == NULL || interface == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.node)
|
||||
*interface = &this->node;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
xv_sink_clear (struct spa_handle *handle)
|
||||
{
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
xv_sink_init (const struct spa_handle_factory *factory,
|
||||
struct spa_handle *handle,
|
||||
const struct spa_dict *info,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support)
|
||||
{
|
||||
struct impl *this;
|
||||
uint32_t i;
|
||||
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
handle->get_interface = spa_xv_sink_get_interface;
|
||||
handle->clear = xv_sink_clear;
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0)
|
||||
this->map = support[i].data;
|
||||
else if (strcmp (support[i].type, SPA_TYPE__Log) == 0)
|
||||
this->log = support[i].data;
|
||||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error (this->log, "a type-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
}
|
||||
init_type (&this->type, this->map);
|
||||
|
||||
this->node = xvsink_node;
|
||||
reset_props (&this->props);
|
||||
|
||||
this->in_ports[0].info.flags = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info xv_sink_interfaces[] =
|
||||
{
|
||||
{ SPA_TYPE__Node, },
|
||||
};
|
||||
|
||||
static int
|
||||
xv_sink_enum_interface_info (const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
{
|
||||
if (factory == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &xv_sink_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_xv_sink_factory =
|
||||
{
|
||||
"xv-sink",
|
||||
NULL,
|
||||
sizeof (struct impl),
|
||||
xv_sink_init,
|
||||
xv_sink_enum_interface_info,
|
||||
};
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sched.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <poll.h>
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
|
||||
static int
|
||||
spa_xv_open (struct impl *this)
|
||||
{
|
||||
struct port *port = &this->in_ports[0];
|
||||
|
||||
if (port->opened)
|
||||
return 0;
|
||||
|
||||
port->opened = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_set_format (struct impl *this, struct spa_video_info *info, bool try_only)
|
||||
{
|
||||
if (spa_xv_open (this) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_close (struct impl *this)
|
||||
{
|
||||
struct port *port = &this->in_ports[0];
|
||||
|
||||
if (!port->opened)
|
||||
return 0;
|
||||
|
||||
port->opened = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_start (struct impl *this)
|
||||
{
|
||||
if (spa_xv_open (this) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_xv_stop (struct impl *this)
|
||||
{
|
||||
spa_xv_close (this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/* Spa Xv support
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <spa/plugin.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
extern const struct spa_handle_factory spa_xv_sink_factory;
|
||||
|
||||
int
|
||||
spa_handle_factory_enum(const struct spa_handle_factory **factory,
|
||||
uint32_t index)
|
||||
{
|
||||
spa_return_val_if_fail(factory != NULL,
|
||||
SPA_RESULT_INVALID_ARGUMENTS);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_xv_sink_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue