mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Improve negotiation
Try to link ports based on compatible formats Add methods to filter formats.
This commit is contained in:
parent
1370fafd5b
commit
df86fcec10
12 changed files with 229 additions and 95 deletions
|
|
@ -55,6 +55,8 @@ SpaResult spa_format_audio_init (SpaMediaType type,
|
|||
SpaFormatAudio *format);
|
||||
SpaResult spa_format_audio_parse (const SpaFormat *format,
|
||||
SpaFormatAudio *aformat);
|
||||
SpaResult spa_format_audio_filter (SpaFormatAudio *format,
|
||||
const SpaFormat *filter);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
|
|
@ -328,7 +328,9 @@ struct _SpaNode {
|
|||
* @index: an index variable, 0 to get the first item
|
||||
*
|
||||
* Enumerate all possible formats on @port_id of @node that are compatible
|
||||
* with @filter..
|
||||
* with @filter. When @port_id is #SPA_ID_INVALID, the enumeration will
|
||||
* list all the formats possible on a port that would be added with
|
||||
* add_port().
|
||||
*
|
||||
* Use @index to retrieve the formats one by one until the function
|
||||
* returns #SPA_RESULT_ENUM_END.
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ SpaResult spa_format_video_init (SpaMediaType type,
|
|||
SpaResult spa_format_video_parse (const SpaFormat *format,
|
||||
SpaFormatVideo *dest);
|
||||
|
||||
SpaResult spa_format_video_filter (SpaFormatVideo *format,
|
||||
const SpaFormat *filter);
|
||||
|
||||
struct _SpaFormatVideo {
|
||||
SpaFormat format;
|
||||
union {
|
||||
|
|
|
|||
|
|
@ -305,3 +305,19 @@ fallback:
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_format_audio_filter (SpaFormatAudio *format,
|
||||
const SpaFormat *filter)
|
||||
{
|
||||
SpaFormatAudio af;
|
||||
SpaResult res;
|
||||
|
||||
if (filter == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if ((res = spa_format_audio_parse (filter, &af)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -637,3 +637,19 @@ fallback:
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
SpaResult
|
||||
spa_format_video_filter (SpaFormatVideo *format,
|
||||
const SpaFormat *filter)
|
||||
{
|
||||
SpaFormatVideo vf;
|
||||
SpaResult res;
|
||||
|
||||
if (filter == NULL)
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
if ((res = spa_format_video_parse (filter, &vf)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,6 +366,7 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
unsigned int index)
|
||||
{
|
||||
SpaALSASource *this;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -389,6 +390,10 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node,
|
|||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
|
||||
if ((res = spa_format_audio_filter (&this->query_format, filter)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = &this->query_format.format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
|
|
@ -468,6 +468,7 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
unsigned int index)
|
||||
{
|
||||
SpaAudioTestSrc *this;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -479,16 +480,16 @@ spa_audiotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
switch (index) {
|
||||
case 0:
|
||||
if (filter)
|
||||
spa_format_audio_parse (filter, &this->query_format);
|
||||
else
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
SPA_MEDIA_SUBTYPE_RAW,
|
||||
&this->query_format);
|
||||
spa_format_audio_init (SPA_MEDIA_TYPE_AUDIO,
|
||||
SPA_MEDIA_SUBTYPE_RAW,
|
||||
&this->query_format);
|
||||
break;
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
if ((res = spa_format_audio_filter (&this->query_format, filter)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = &this->query_format.format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
|
|
@ -428,6 +428,7 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
unsigned int index)
|
||||
{
|
||||
SpaVideoTestSrc *this;
|
||||
SpaResult res;
|
||||
|
||||
if (node == NULL || format == NULL)
|
||||
return SPA_RESULT_INVALID_ARGUMENTS;
|
||||
|
|
@ -439,16 +440,34 @@ spa_videotestsrc_node_port_enum_formats (SpaNode *node,
|
|||
|
||||
switch (index) {
|
||||
case 0:
|
||||
if (filter)
|
||||
spa_format_video_parse (filter, &this->query_format);
|
||||
else
|
||||
spa_format_video_init (SPA_MEDIA_TYPE_VIDEO,
|
||||
SPA_MEDIA_SUBTYPE_RAW,
|
||||
&this->query_format);
|
||||
{
|
||||
int idx;
|
||||
static const uint32_t format_values[] = {
|
||||
SPA_VIDEO_FORMAT_RGB,
|
||||
SPA_VIDEO_FORMAT_UYVY,
|
||||
};
|
||||
static const SpaPropRangeInfo format_range[] = {
|
||||
{ "RGB", { sizeof (uint32_t), &format_values[0] } },
|
||||
{ "UYVY", { sizeof (uint32_t), &format_values[1] } },
|
||||
};
|
||||
SpaPropInfo *info;
|
||||
spa_format_video_init (SPA_MEDIA_TYPE_VIDEO,
|
||||
SPA_MEDIA_SUBTYPE_RAW,
|
||||
&this->query_format);
|
||||
|
||||
idx = spa_props_index_for_id (&this->query_format.format.props, SPA_PROP_ID_VIDEO_FORMAT);
|
||||
info = (SpaPropInfo *) &this->query_format.format.props.prop_info[idx];
|
||||
|
||||
info->n_range_values = SPA_N_ELEMENTS (format_range);
|
||||
info->range_values = format_range;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return SPA_RESULT_ENUM_END;
|
||||
}
|
||||
if ((res = spa_format_video_filter (&this->query_format, filter)) != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
*format = &this->query_format.format;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue