Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimidium Totius (in preparation for PipeWire camera and audio, part 1) #8153

Conversation

GeorgesStavracas
Copy link
Member

@GeorgesStavracas GeorgesStavracas commented Jan 26, 2023

Description

Various cleanups in preparation for making linux-pipewire handle cameras and audio. This pull request contains the "easy" half of #6669 and should not be controversial.

What is done here is:

  • Clean up a leftover object when the plugin is unloaded
  • Massage some functions to receive more parameters...
  • ... which then allow cleaning up the internal struct
  • Rename a struct to better represent its scope
  • Shuffle code around

Motivation and Context

Prepare the linux-pipewire plugin to receive support for cameras and audio. This is also an effort to get #6669 unstuck.

How Has This Been Tested?

  • Run OBS Studio on Linux + Wayland, and notice it continues to work

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

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.

@GeorgesStavracas GeorgesStavracas added Enhancement Improvement to existing functionality Linux Affects Linux labels Jan 26, 2023
@jp9000 jp9000 self-assigned this Jan 28, 2023
Copy link
Collaborator

@kkartaltepe kkartaltepe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine and works on my machine.

@jp9000 jp9000 removed their assignment Jan 29, 2023
plugins/linux-pipewire/pipewire.c Outdated Show resolved Hide resolved
Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message nits:

22b641c

Remove the pipewire_node field, and just create the stream directly
from the passed now.

Perhaps missing a word? I feel like something is amiss.

334927e

  • existance -> existence
  • prespective -> perspective
  • screencast -?> ScreenCast

3a76148

  • ying -> yin

Other than nits, and the previous review, I really don't have any items I'm worried about.

GeorgesStavracas and others added 8 commits February 12, 2023 14:29
Instead of returning an opaque void* pointer, return the leaf
C type obs_pipewire_data*.

This commit introduces no functional changes.
When the linux-pipewire plugin is unloaded, make sure to cleanup
the D-Bus proxy for the ScreenCast portal too. This effectively
doesn't change anything, but it's always good to keep up with the
code hygiene.
And let each portal pass the stream properties relevant to them.
This makes the pipewire.c more independent of the actual portal
by providing a wrapper to create a stream. This will be relevant
later, when linux-pipewire introduces more portals like the Camera
one.
This separation of obs_pipewire_create() and play_pipewire_stream()
was an artifact of how the original code was written, and there is
no reason to keep this separation anymore. Inlining it will help
future commits too.
We don't actually need to restore the node id anymore, since this
is handled by the screencast-portal.c code now.

Remove the pipewire_node field, and just create the stream directly
from the passed file descriptor now.
This commit introduces an important distinction in the initialization
process that is essential to future camera and audio work: it splits
creating and connecting to the PipeWire socket, from connecting to
specific PipeWire nodes.

Right now, for the only consumer in existence - the ScreenCast portal
code - this distinction is irrelevant, but from an API perspective it
just makes sense to model it this way.
Next commits will introduce new obs_pipewire_* types, so this
renaming will make it slightly easier to read the code with
different types.
A trivial cosmetic change. This groups the constructor and
destructor together. Two sides of the same coin, yin and yang,
bound by their nature, and linked by their position in code.
@GeorgesStavracas
Copy link
Member Author

Thanks for the review. The commit messages were adjusted.

Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@GeorgesStavracas GeorgesStavracas merged commit fad7420 into obsproject:master Feb 13, 2023
@GeorgesStavracas GeorgesStavracas deleted the gbsneto/linux-pipewire-cleanups branch February 13, 2023 15:28
@RytoEX RytoEX added this to the OBS Studio 29.1 milestone Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to existing functionality Linux Affects Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants