mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
More hacking
Add spa based v4l2 pinos module Add allocation params to port_alloc_buffers Let the app do allocation for handles.
This commit is contained in:
parent
4c7cee6b28
commit
6ab8af91e0
41 changed files with 4733 additions and 351 deletions
|
|
@ -77,6 +77,8 @@ typedef struct {
|
|||
SpaPollFd fds[1];
|
||||
SpaPollItem poll;
|
||||
SpaPortInfo info;
|
||||
SpaAllocParam *params[1];
|
||||
SpaAllocParamBuffers param_buffers;
|
||||
SpaPortStatus status;
|
||||
} SpaV4l2State;
|
||||
|
||||
|
|
@ -467,6 +469,8 @@ spa_v4l2_source_node_port_use_buffers (SpaHandle *handle,
|
|||
static SpaResult
|
||||
spa_v4l2_source_node_port_alloc_buffers (SpaHandle *handle,
|
||||
uint32_t port_id,
|
||||
SpaAllocParam **params,
|
||||
uint32_t n_params,
|
||||
SpaBuffer **buffers,
|
||||
uint32_t *n_buffers)
|
||||
{
|
||||
|
|
@ -573,13 +577,15 @@ spa_v4l2_source_get_interface (SpaHandle *handle,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
SpaHandle *
|
||||
spa_v4l2_source_new (void)
|
||||
static SpaResult
|
||||
v4l2_source_init (const SpaHandleFactory *factory,
|
||||
SpaHandle *handle)
|
||||
{
|
||||
SpaHandle *handle;
|
||||
SpaV4l2Source *this;
|
||||
|
||||
handle = calloc (1, sizeof (SpaV4l2Source));
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
handle->get_interface = spa_v4l2_source_get_interface;
|
||||
|
||||
this = (SpaV4l2Source *) handle;
|
||||
|
|
@ -591,5 +597,35 @@ spa_v4l2_source_new (void)
|
|||
|
||||
this->state[0].info.flags = SPA_PORT_INFO_FLAG_NONE;
|
||||
this->state[0].status.flags = SPA_PORT_STATUS_FLAG_NONE;
|
||||
return handle;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaInterfaceInfo v4l2_source_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
v4l2_source_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &v4l2_source_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
const SpaHandleFactory spa_v4l2_source_factory =
|
||||
{ "v4l2-source",
|
||||
NULL,
|
||||
sizeof (SpaV4l2Source),
|
||||
v4l2_source_init,
|
||||
v4l2_source_enum_interface_info,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -314,13 +314,19 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaFormat *format, bool try_only)
|
|||
|
||||
state->fmt = fmt;
|
||||
state->info.flags = SPA_PORT_INFO_FLAG_CAN_GIVE_BUFFER;
|
||||
state->info.minsize = fmt.fmt.pix.sizeimage;
|
||||
state->info.stride = fmt.fmt.pix.bytesperline;
|
||||
state->info.min_buffers = 2;
|
||||
state->info.max_buffers = MAX_BUFFERS;
|
||||
state->info.align = 16;
|
||||
state->info.maxbuffering = -1;
|
||||
state->info.latency = -1;
|
||||
|
||||
state->info.n_params = 1;
|
||||
state->info.params = state->params;
|
||||
state->params[0] = &state->param_buffers.param;
|
||||
state->param_buffers.param.type = SPA_ALLOC_PARAM_TYPE_BUFFERS;
|
||||
state->param_buffers.param.size = sizeof (&state->buffers);
|
||||
state->param_buffers.minsize = fmt.fmt.pix.sizeimage;
|
||||
state->param_buffers.stride = fmt.fmt.pix.bytesperline;
|
||||
state->param_buffers.min_buffers = 2;
|
||||
state->param_buffers.max_buffers = MAX_BUFFERS;
|
||||
state->param_buffers.align = 16;
|
||||
state->info.features = NULL;
|
||||
|
||||
return 0;
|
||||
|
|
@ -334,6 +340,7 @@ spa_v4l2_close (SpaV4l2Source *this)
|
|||
if (!state->opened)
|
||||
return 0;
|
||||
|
||||
fprintf (stderr, "close\n");
|
||||
if (close(state->fd))
|
||||
perror ("close");
|
||||
|
||||
|
|
|
|||
|
|
@ -20,59 +20,21 @@
|
|||
#include <spa/plugin.h>
|
||||
#include <spa/node.h>
|
||||
|
||||
SpaHandle * spa_v4l2_source_new (void);
|
||||
|
||||
static SpaResult
|
||||
v4l2_source_instantiate (const SpaHandleFactory *factory,
|
||||
SpaHandle **handle)
|
||||
{
|
||||
if (factory == NULL || handle == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
*handle = spa_v4l2_source_new ();
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaInterfaceInfo v4l2_source_interfaces[] =
|
||||
{
|
||||
{ SPA_INTERFACE_ID_NODE,
|
||||
SPA_INTERFACE_ID_NODE_NAME,
|
||||
SPA_INTERFACE_ID_NODE_DESCRIPTION,
|
||||
},
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
v4l2_source_enum_interface_info (const SpaHandleFactory *factory,
|
||||
unsigned int index,
|
||||
const SpaInterfaceInfo **info)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*info = &v4l2_source_interfaces[index];
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static const SpaHandleFactory factories[] =
|
||||
{
|
||||
{ "v4l2-source",
|
||||
NULL,
|
||||
v4l2_source_instantiate,
|
||||
v4l2_source_enum_interface_info,
|
||||
},
|
||||
};
|
||||
|
||||
extern const SpaHandleFactory spa_v4l2_source_factory;
|
||||
|
||||
SpaResult
|
||||
spa_enum_handle_factory (unsigned int index,
|
||||
const SpaHandleFactory **factory)
|
||||
{
|
||||
if (index >= 1)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*factory = &factories[index];
|
||||
if (factory == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
*factory = &spa_v4l2_source_factory;
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue