mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
improve format filters
This commit is contained in:
parent
4bdbb58276
commit
22070ecbf8
4 changed files with 34 additions and 8 deletions
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
|
|
||||||
|
|
||||||
#include "pinos/client/pinos.h"
|
#include "pinos/client/pinos.h"
|
||||||
#include "pinos/client/interfaces.h"
|
#include "pinos/client/interfaces.h"
|
||||||
#include "pinos/client/transport.h"
|
#include "pinos/client/transport.h"
|
||||||
|
|
@ -36,6 +37,7 @@
|
||||||
#include "pinos/server/client-node.h"
|
#include "pinos/server/client-node.h"
|
||||||
|
|
||||||
#include "spa/include/spa/node.h"
|
#include "spa/include/spa/node.h"
|
||||||
|
#include "spa/include/spa/format-builder.h"
|
||||||
|
|
||||||
#define MAX_INPUTS 64
|
#define MAX_INPUTS 64
|
||||||
#define MAX_OUTPUTS 64
|
#define MAX_OUTPUTS 64
|
||||||
|
|
@ -107,6 +109,7 @@ struct _SpaProxy
|
||||||
SpaProxyPort in_ports[MAX_INPUTS];
|
SpaProxyPort in_ports[MAX_INPUTS];
|
||||||
SpaProxyPort out_ports[MAX_OUTPUTS];
|
SpaProxyPort out_ports[MAX_OUTPUTS];
|
||||||
|
|
||||||
|
uint8_t format_buffer[1024];
|
||||||
uint32_t seq;
|
uint32_t seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -446,6 +449,10 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
|
||||||
{
|
{
|
||||||
SpaProxy *this;
|
SpaProxy *this;
|
||||||
SpaProxyPort *port;
|
SpaProxyPort *port;
|
||||||
|
SpaFormat *fmt;
|
||||||
|
SpaPODBuilder b = { NULL, };
|
||||||
|
SpaResult res;
|
||||||
|
uint32_t count, match = 0;
|
||||||
|
|
||||||
if (node == NULL || format == NULL)
|
if (node == NULL || format == NULL)
|
||||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||||
|
|
@ -457,10 +464,20 @@ spa_proxy_node_port_enum_formats (SpaNode *node,
|
||||||
|
|
||||||
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 (index >= port->n_formats)
|
count = match = filter ? 0 : index;
|
||||||
|
|
||||||
|
next:
|
||||||
|
if (count >= port->n_formats)
|
||||||
return SPA_RESULT_ENUM_END;
|
return SPA_RESULT_ENUM_END;
|
||||||
|
|
||||||
*format = port->formats[index];
|
fmt = port->formats[count++];
|
||||||
|
|
||||||
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
|
|
||||||
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
|
||||||
|
goto next;
|
||||||
|
|
||||||
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
||||||
return SPA_RESULT_OK;
|
return SPA_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -480,6 +480,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
uint8_t buffer[256];
|
uint8_t buffer[256];
|
||||||
SpaPODBuilder b = { NULL, };
|
SpaPODBuilder b = { NULL, };
|
||||||
SpaPODFrame f[2];
|
SpaPODFrame f[2];
|
||||||
|
uint32_t count, match;
|
||||||
|
|
||||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||||
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||||
|
|
@ -488,10 +489,12 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
|
|
||||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||||
|
|
||||||
|
count = match = filter ? 0 : index;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
switch (index++) {
|
switch (count++) {
|
||||||
case 0:
|
case 0:
|
||||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
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,
|
||||||
|
|
@ -510,7 +513,7 @@ next:
|
||||||
|
|
||||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
|
||||||
|
|
@ -465,6 +465,7 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
SpaPODBuilder b = { NULL, };
|
SpaPODBuilder b = { NULL, };
|
||||||
SpaPODFrame f[2];
|
SpaPODFrame f[2];
|
||||||
|
uint32_t count, match;
|
||||||
|
|
||||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||||
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||||
|
|
@ -473,10 +474,12 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
||||||
|
|
||||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||||
|
|
||||||
|
count = match = filter ? 0 : index;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
switch (index++) {
|
switch (count++) {
|
||||||
case 0:
|
case 0:
|
||||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
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,
|
||||||
|
|
@ -500,7 +503,7 @@ next:
|
||||||
|
|
||||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
|
||||||
|
|
@ -300,6 +300,7 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
SpaPODBuilder b = { NULL, };
|
SpaPODBuilder b = { NULL, };
|
||||||
SpaPODFrame f[2];
|
SpaPODFrame f[2];
|
||||||
|
uint32_t count, match;
|
||||||
|
|
||||||
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||||
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||||
|
|
@ -308,10 +309,12 @@ spa_volume_node_port_enum_formats (SpaNode *node,
|
||||||
|
|
||||||
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
|
||||||
|
|
||||||
|
count = match = filter ? 0 : index;
|
||||||
|
|
||||||
next:
|
next:
|
||||||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||||
|
|
||||||
switch (index++) {
|
switch (count++) {
|
||||||
case 0:
|
case 0:
|
||||||
spa_pod_builder_format (&b, &f[0], this->type.format,
|
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,
|
||||||
|
|
@ -329,7 +332,7 @@ next:
|
||||||
fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
|
fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat);
|
||||||
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer));
|
||||||
|
|
||||||
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK)
|
if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
*format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue