Assistance with editing links via WirePlumber

George Kiagiadakis mail at gkiagia.gr
Fri Feb 9 08:00:10 UTC 2024


Yes, you can use the metadata object without the PA API.


> On 8 Feb 2024, at 20:01, Louis DeLosSantos <louis.delos at gmail.com> wrote:
> 
> Thanks a ton for the info. 
> 
> I dug at this for awhile and yes, I wound up just calling into the pulse audio api to switch sink inputs. 
> 
> I dug enough to find that this file: 
> https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/modules/module-protocol-pulse/modules/module-stream-restore.c?ref_type=heads
> 
> Is writing to metadata. I kinda quit there, because I couldnt tell if the metadata it was writing was "stuck" in the pulse audio module or was made available to the pipewire api proper. 
> 
> Sounds like from your response that the state that the pa stream restore module stashes on metadata is indeed available at the "default-metadata" object that I can retrieve on the registry? 
> 
> If so, thats great, i can remove the call into pulse-audio library and just use wireplumber/pipewire.  
> 
> On Thu, Feb 8, 2024 at 3:46 PM George Kiagiadakis <mail at gkiagia.gr <mailto:mail at gkiagia.gr>> wrote:
>> Hi,
>> 
>> Yes, it is easy to re-link streams to different sinks, similar to pavucontrol.
>> 
>> You can do this by setting the “target.object” property in the “default” metadata object. The value may be the “node.name <http://node.name/>" or the “object.serial” of the target sink/source that you want to link your stream with.
>> 
>> On the command line:
>> 
>> pw-metadata -n default <ID of the stream> “target.object” “<name of the sink>” “Spa:String"
>> 
>> For example:
>> 
>> pw-metadata -n default 45 “target.object” “alsa_output.pci-0000_00_1f.3.analog-stereo” “Spa:String"
>> 
>> Using the WirePlumber C API, you need to find the WpMetadata object first, using an object manager (use a constraint on “metadata.name <http://metadata.name/>” to match “default”) and then set the value with:
>> 
>> wp_metadata_set (metadata, stream_node_id, PW_KEY_TARGET_OBJECT, “Spa:String”, target_node_name);
>> 
>> PS: If you set the “object.serial” instead of the name, then the type should be “Spa:Id” instead.
>> 
>> This is the same mechanism that is used by existing tools like pavucontrol. You can also use pavucontrol to see this in action. Use “pw-metadata -n default” to print the existing metadata values for inspection.
>> 
>> I hope this helps.
>> 
>> Best regards,
>> George
>> 
>> 
>> > On 26 Jan 2024, at 18:09, Louis DeLosSantos <louis.delos at gmail.com <mailto:louis.delos at gmail.com>> wrote:
>> > 
>> > Hey all,
>> > 
>> > I'm writing a Linux desktop shell which will have a built in audio mixer.
>> > I'm trying to isolate the API usage to the WirePlumber C API.
>> > 
>> > Is it currently possible to "re-link" input or output streams to a
>> > different sink/source via WirePlumber?
>> > 
>> > Is anyone able to point me to examples of doing this? I'm a bit
>> > confused about whether I need to delete the existing link and create a
>> > new one, or if I can update the existing link with new input/output
>> > ports.
>> > 
>> > Thanks a lot.
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pipewire-devel/attachments/20240209/6745aa1e/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 509 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/pipewire-devel/attachments/20240209/6745aa1e/attachment-0001.sig>


More information about the Pipewire-devel mailing list