mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
inspect: improve output
Keep state variable to enumerate things. This allows us to remove the expectation that the same index will give the same item. Use a new rectangle type for video size. When enumerating sizes, this allows us to specify relations between width and height more easily. Remove the struct and bytes type, they are like pointer. Add filter to enum_formats to speed up enumerations.
This commit is contained in:
parent
77bc2a1793
commit
b9320c67c2
27 changed files with 414 additions and 287 deletions
|
|
@ -333,17 +333,21 @@ spa_alsa_sink_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_alsa_sink_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaALSASink *this = (SpaALSASink *) handle;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_audio_raw_format_init (&this->query_format);
|
||||
|
|
@ -355,6 +359,7 @@ spa_alsa_sink_node_port_enum_formats (SpaHandle *handle,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -608,13 +613,24 @@ static const SpaInterfaceInfo alsa_sink_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
alsa_sink_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
int index;
|
||||
|
||||
*info = &alsa_sink_interfaces[index];
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &alsa_sink_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@
|
|||
extern const SpaHandleFactory spa_alsa_sink_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
if (factory == NULL)
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_alsa_sink_factory;
|
||||
|
|
@ -36,5 +40,6 @@ spa_enum_handle_factory (unsigned int index,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = index++;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,17 +301,21 @@ spa_audiomixer_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_audiomixer_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaAudioMixer *this = (SpaAudioMixer *) handle;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id > MAX_PORTS)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_audio_raw_format_init (&this->query_format);
|
||||
|
|
@ -320,6 +324,7 @@ spa_audiomixer_node_port_enum_formats (SpaHandle *handle,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = index++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -771,14 +776,24 @@ static const SpaInterfaceInfo audiomixer_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
audiomixer_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
int index;
|
||||
|
||||
*info = &audiomixer_interfaces[index];
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &audiomixer_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@
|
|||
extern const SpaHandleFactory spa_audiomixer_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
if (factory == NULL)
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_audiomixer_factory;
|
||||
|
|
@ -36,5 +40,6 @@ spa_enum_handle_factory (unsigned int index,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,17 +278,21 @@ spa_audiotestsrc_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_audiotestsrc_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaAudioTestSrc *this = (SpaAudioTestSrc *) handle;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_audio_raw_format_init (&this->query_format);
|
||||
|
|
@ -297,6 +301,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaHandle *handle,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -557,14 +562,24 @@ static const SpaInterfaceInfo audiotestsrc_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
audiotestsrc_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
int index;
|
||||
|
||||
*info = &audiotestsrc_interfaces[index];
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &audiotestsrc_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@
|
|||
extern const SpaHandleFactory spa_audiotestsrc_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
if (factory == NULL)
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_audiotestsrc_factory;
|
||||
|
|
@ -36,5 +40,6 @@ spa_enum_handle_factory (unsigned int index,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,28 +246,33 @@ spa_ffmpeg_dec_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_ffmpeg_dec_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaFFMpegDec *this = (SpaFFMpegDec *) handle;
|
||||
SpaFFMpegState *state;
|
||||
SpaFFMpegState *s;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
s = &this->state[port_id];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&state->raw_format[0]);
|
||||
spa_video_raw_format_init (&s->raw_format[0]);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &state->raw_format[0].format;
|
||||
*format = &s->raw_format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,11 +246,13 @@ spa_ffmpeg_enc_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_ffmpeg_enc_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaFFMpegEnc *this = (SpaFFMpegEnc *) handle;
|
||||
SpaFFMpegState *state;
|
||||
SpaFFMpegState *s;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -258,16 +260,19 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaHandle *handle,
|
|||
if (!IS_VALID_PORT (port_id))
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
s = &this->state[port_id];
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&state->raw_format[0]);
|
||||
spa_video_raw_format_init (&s->raw_format[0]);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &state->raw_format[0].format;
|
||||
*format = &s->raw_format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,25 +58,36 @@ static const SpaInterfaceInfo ffmpeg_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
ffmpeg_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL || info == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &ffmpeg_interfaces[index];
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
static const AVCodec *c = NULL;
|
||||
static int ci = 0;
|
||||
static SpaHandleFactory f;
|
||||
static char name[128];
|
||||
int index;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
av_register_all();
|
||||
|
||||
|
|
@ -91,6 +102,8 @@ spa_enum_handle_factory (unsigned int index,
|
|||
if (c == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*(int*)state = ++index;
|
||||
|
||||
if (av_codec_is_encoder (c)) {
|
||||
snprintf (name, 128, "ffenc_%s", c->name);
|
||||
f.init = ffmpeg_enc_init;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
typedef struct _SpaV4l2Source SpaV4l2Source;
|
||||
|
||||
static const char default_device[] = "/dev/video0";
|
||||
static const char default_device[] = "/dev/video1";
|
||||
|
||||
typedef struct {
|
||||
SpaProps props;
|
||||
|
|
@ -312,32 +312,22 @@ spa_v4l2_source_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_v4l2_source_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaV4l2Source *this = (SpaV4l2Source *) handle;
|
||||
SpaV4l2State *state;
|
||||
SpaResult res;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
state = &this->state[port_id];
|
||||
res = spa_v4l2_enum_format (this, format, state);
|
||||
|
||||
/*
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&state->raw_format[0]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*format = &state->raw_format[0].format;
|
||||
*/
|
||||
|
||||
return spa_v4l2_enum_format (this, format, &state->cookie);
|
||||
return res;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
|
|
@ -616,7 +606,7 @@ v4l2_source_init (const SpaHandleFactory *factory,
|
|||
this->state[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->state[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
|
||||
this->state[0].export_buf = true;
|
||||
this->state[0].export_buf = false;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -631,14 +621,24 @@ static const SpaInterfaceInfo v4l2_source_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
v4l2_source_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
int index;
|
||||
|
||||
*info = &v4l2_source_interfaces[index];
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &v4l2_source_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@ spa_v4l2_open (SpaV4l2Source *this)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static SpaVideoFormat
|
||||
fourcc_to_video_format (uint32_t fourcc)
|
||||
{
|
||||
|
|
@ -169,7 +168,6 @@ fourcc_to_video_format (uint32_t fourcc)
|
|||
}
|
||||
return format;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint32_t
|
||||
video_format_to_fourcc (SpaVideoFormat format)
|
||||
|
|
@ -329,37 +327,17 @@ again:
|
|||
}
|
||||
state->frmival.index++;
|
||||
}
|
||||
fprintf (stderr, "format %c%c%c%c\n", FOURCC_ARGS (state->fmtdesc.pixelformat));
|
||||
if (state->frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
|
||||
fprintf (stderr, "size %dx%d\n", state->frmsize.discrete.width, state->frmsize.discrete.height);
|
||||
} else if (state->frmsize.type == V4L2_FRMSIZE_TYPE_STEPWISE) {
|
||||
fprintf (stderr, "size %dx%d - %dx%d with step %d/%d\n",
|
||||
state->frmsize.stepwise.min_width,
|
||||
state->frmsize.stepwise.min_height,
|
||||
state->frmsize.stepwise.max_width,
|
||||
state->frmsize.stepwise.max_height,
|
||||
state->frmsize.stepwise.step_width,
|
||||
state->frmsize.stepwise.step_height);
|
||||
}
|
||||
if (state->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
|
||||
fprintf (stderr, "framerate %u/%u\n",
|
||||
state->frmival.discrete.numerator,
|
||||
state->frmival.discrete.denominator);
|
||||
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
|
||||
fprintf (stderr, "framerate %u/%u - %u/%u\n",
|
||||
state->frmival.stepwise.min.numerator,
|
||||
state->frmival.stepwise.min.denominator,
|
||||
state->frmival.stepwise.max.numerator,
|
||||
state->frmival.stepwise.max.denominator);
|
||||
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
|
||||
fprintf (stderr, "framerate %u/%u - %u/%u step %u/%u\n",
|
||||
state->frmival.stepwise.min.numerator,
|
||||
state->frmival.stepwise.min.denominator,
|
||||
state->frmival.stepwise.max.numerator,
|
||||
state->frmival.stepwise.max.denominator,
|
||||
state->frmival.stepwise.step.numerator,
|
||||
state->frmival.stepwise.step.denominator);
|
||||
}
|
||||
|
||||
spa_video_raw_format_init (&state->raw_format[0]);
|
||||
state->raw_format[0].info.format = fourcc_to_video_format (state->fmtdesc.pixelformat);
|
||||
state->raw_format[0].info.size.width = state->frmsize.discrete.width;
|
||||
state->raw_format[0].info.size.height = state->frmsize.discrete.height;
|
||||
state->raw_format[0].info.framerate.num = state->frmival.discrete.numerator;
|
||||
state->raw_format[0].info.framerate.denom = state->frmival.discrete.denominator;
|
||||
state->raw_format[0].unset_mask &= ~((1<<0)|(1<<1)|(1<<2));
|
||||
|
||||
*format = &state->raw_format[0].format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
@ -381,8 +359,8 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaFormat *format, bool try_only)
|
|||
SpaVideoRawFormat *f = (SpaVideoRawFormat *) format;
|
||||
|
||||
fmt.fmt.pix.pixelformat = video_format_to_fourcc (f->info.format);
|
||||
fmt.fmt.pix.width = f->info.width;
|
||||
fmt.fmt.pix.height = f->info.height;
|
||||
fmt.fmt.pix.width = f->info.size.width;
|
||||
fmt.fmt.pix.height = f->info.size.height;
|
||||
fmt.fmt.pix.field = V4L2_FIELD_ANY;
|
||||
streamparm.parm.capture.timeperframe.numerator = f->info.framerate.denom;
|
||||
streamparm.parm.capture.timeperframe.denominator = f->info.framerate.num;
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@
|
|||
extern const SpaHandleFactory spa_v4l2_source_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
if (factory == NULL)
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_v4l2_source_factory;
|
||||
|
|
@ -36,5 +40,7 @@ spa_enum_handle_factory (unsigned int index,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,18 +23,24 @@
|
|||
extern const SpaHandleFactory spa_volume_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
if (factory == NULL)
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_volume_factory;
|
||||
*factory = &spa_volume_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,17 +259,21 @@ spa_volume_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_volume_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaVolume *this = (SpaVolume *) handle;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_audio_raw_format_init (&this->query_format);
|
||||
|
|
@ -278,6 +282,7 @@ spa_volume_node_port_enum_formats (SpaHandle *handle,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->query_format.format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -636,13 +641,24 @@ static const SpaInterfaceInfo volume_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
volume_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
int index;
|
||||
|
||||
*info = &volume_interfaces[index];
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &volume_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,17 +288,21 @@ spa_xv_sink_node_remove_port (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_xv_sink_node_port_enum_formats (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
unsigned int index,
|
||||
SpaFormat **format)
|
||||
SpaFormat **format,
|
||||
const SpaFormat *filter,
|
||||
void **state)
|
||||
{
|
||||
SpaXvSink *this = (SpaXvSink *) handle;
|
||||
int index;
|
||||
|
||||
if (handle == NULL || format == NULL)
|
||||
if (handle == NULL || format == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
if (port_id != 0)
|
||||
return SPA_RESULT_INVALID_PORT;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
spa_video_raw_format_init (&this->raw_format[0]);
|
||||
|
|
@ -307,6 +311,7 @@ spa_xv_sink_node_port_enum_formats (SpaHandle *handle,
|
|||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*format = &this->raw_format[0].format;
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
@ -582,14 +587,24 @@ static const SpaInterfaceInfo xv_sink_interfaces[] =
|
|||
|
||||
static SpaResult
|
||||
xv_sink_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
const SpaInterfaceInfo **info,
|
||||
void **state)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
int index;
|
||||
|
||||
*info = &xv_sink_interfaces[index];
|
||||
if (factory == NULL || info == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*info = &xv_sink_interfaces[index];
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,16 @@
|
|||
extern const SpaHandleFactory spa_xv_sink_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
spa_enum_handle_factory (const SpaHandleFactory **factory,
|
||||
void **state)
|
||||
{
|
||||
if (factory == NULL)
|
||||
int index;
|
||||
|
||||
if (factory == NULL || state == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
index = (*state == NULL ? 0 : *(int*)state);
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_xv_sink_factory;
|
||||
|
|
@ -36,5 +40,7 @@ spa_enum_handle_factory (unsigned int index,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
*(int*)state = ++index;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue