Skip to content

Conversation

pobrn
Copy link
Contributor

@pobrn pobrn commented Aug 15, 2025

Description + Motivation and Context

A node might choose to use an enumerated choice pod to report the set of
supported sizes. Currently that is not supported. And what's worse, since
SPA_POD_OPT_Rectangle() is used, if the node uses an enum choice, then
{,this_}resolution stays uninitialized but spa_pod_parse_object() will
not report errors because the field is considered optional.

Fix this by using spa_pod_get_values(), which can be used for concrete
values, and both SPA_CHOICE_{None,Enum}.

Since the resolutions are parsed in two separate places, and since the
frame rates require essentially the same treatment a new function is
introduced to handle the common parts.

How Has This Been Tested?

With the current pipewire master branch, with a video node that uses enumerated choice for size, as well as nodes that don't use enumerated choices.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@pobrn pobrn force-pushed the pw_cam_size_choice branch 2 times, most recently from 2111490 to aca61e3 Compare August 15, 2025 18:07
@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Aug 16, 2025
@PatTheMav
Copy link
Member

Why is this PR opened as a Draft PR? In general we want to keep the amount of Draft PRs to a minimum (ideally zero) as those clutter the already-growing list of open PRs.

If this PR is ready for production, it should also be ready for review. If it is not ready for review, it should not have been opened.

@pobrn pobrn force-pushed the pw_cam_size_choice branch from aca61e3 to b830979 Compare August 21, 2025 16:58
@pobrn
Copy link
Contributor Author

pobrn commented Aug 21, 2025

Oh, okay.

@pobrn pobrn marked this pull request as ready for review August 21, 2025 17:00
pobrn added 2 commits August 28, 2025 17:54
Add a new function `get_values_from_pod()` to provide a wrapper around
`spa_pod_get_values()` with extra checks, and that ignores the default
value for `SPA_CHOICE_Enum`.
The refactor in obsproject#11741 made it so that if an offered format of a node
does not have a frame rate, then that is ignored. Instead of ignoring
those formats, just skip those parts from the format description.
@pobrn pobrn force-pushed the pw_cam_size_choice branch from b830979 to 7db3dab Compare August 28, 2025 16:13
A node might choose to use an enumerated choice pod to report the set of
supported sizes. Currently that is not supported. And what's worse, since
`SPA_POD_OPT_Rectangle()` is used, if the node uses an enum choice, then
`{,this_}resolution` stays uninitialized but `spa_pod_parse_object()` will
not report errors because the field is considered optional.

Fix this by handling `SPA_CHOICE_Enum` as well, and ignoring the unsupported
choice types.
@pobrn pobrn force-pushed the pw_cam_size_choice branch from 7db3dab to c6c927e Compare August 28, 2025 16:21
@pobrn
Copy link
Contributor Author

pobrn commented Aug 28, 2025

Rebased after #11741.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants