Commit graph

13651 commits

Author SHA1 Message Date
Wim Taymans
7d6e2a6417 impl-link: refactor format negotiation
Make a new port_info structure that holds the link port information for
input and output. We can use this in some places and remove some
redundant code.

We can also pass a reference to this port_info as the work-queue
object, which makes it more natural to find the associated port info in
the various work queue callbacks.

Move the private pw_context_find_format to the link implementation,
where is it actually used.

Rework the format negotiation code to use an array of 2 port_info
structures with the two ports to negotiate. The negiotiation will
always use the first port_info as higher priority.

Make sure a driver port has a lower priority than the other port. We want
to negotiate the source/sink to something close that what is
provided/requested by the client. The client can always adapt to the
driver port format fields by giving a "don't care" value for the format
property (either unspecified or with an out of range default value).
2025-04-24 11:17:49 +02:00
Wim Taymans
abfad78fb3 pod: swap inputs for filter when invalid default
We usualy want to prefer the filter default value. When this value is
not within the valid range/alternatives, swap the logic and prefer the
defaults of the other pod.

This way we can have a filter with an invalid default that will then use
the preference of the other pod but still enforce some bounds.
2025-04-24 11:14:51 +02:00
Wim Taymans
8b01fce2bc filter: remove unused function 2025-04-24 11:09:40 +02:00
Wim Taymans
19f6d83fa2 pod: move some filter functions to compare 2025-04-24 11:09:09 +02:00
Wim Taymans
1cca24c585 videoconvert: consume input buffer in all cases
Return the input buffer when we get some error so that the other side
can send new data.
2025-04-24 10:58:04 +02:00
Wim Taymans
bcf0c0cf89 v4l2: only skip buffer for raw formats
We don't want to skip the first buffer for encoded formats because it
can contain the encoding parameters, in the h264 case, for example.
2025-04-24 10:57:49 +02:00
Wim Taymans
d1d580cafa pod: move common check outside of the loop 2025-04-24 10:44:20 +02:00
Wim Taymans
4774178c68 pod: struct has spa_pod as the body 2025-04-24 10:42:20 +02:00
Wim Taymans
2f21b27397 filter: build result in separate builder and copy
Build the filtered result into a new separate builder and copy it into
the result builder afterwards. This ensures the memory of the old
builder does not suddenly change when it gets reallocated.
2025-04-24 10:41:05 +02:00
Wim Taymans
205ee5b6b0 dynamic: add _continue
The continue functions takes a builder as the argument and makes a new
builder that starts from the old builder memory. If the old builder was
dynamic, the new one will also be dynamic. Because it's a separate
builder, the memory of the old builder will not be reallocated when
extended.

This makes it possible to freely read the memory from the old builder
while we construct the result in a new builder without having to worry
about reallocating the memory of the old builder. When the new object is
completed, it can then be copied into the old builder.
2025-04-24 10:40:59 +02:00
Wim Taymans
336a5d1ded ump: fix program change 2.0 to 1.0 conversion
The program change byte should not be shifted an extra bit, unlike all
the other messages.

Fixes #4664
2025-04-24 10:25:39 +02:00
Anders Jonsson
14f55663bf po: Update Swedish translation 2025-04-23 00:03:23 +00:00
Philippe Normand
2e409c0237 gst: src: Attach video meta when receiving DMABufs from PipeWire
Fixes getDisplayMedia() in WebKitGTK after regression introduced by:
https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/2330
2025-04-22 10:48:00 +01:00
Pauli Virtanen
46c4261998 bluez5: fix cmsg align in spa_bt_recmsg & smaller buffer 2025-04-21 14:46:58 +03:00
Pauli Virtanen
0d61cc1b1d bluez5: use kernel-provided RX timestamps
Use kernel-provided packet reception timestamps to get less jitter in
packet timings. Mostly matters for ISO/SCO which have regular schedule.

A2DP (L2CAP) doesn't currently do RX timestamps in kernel, but we can as
well use the same mechanism for it.
2025-04-21 10:22:50 +00:00
Pauli Virtanen
081116906d bluez5: bap: allow configuring server locations/context
Add configuration options for the BAP/PACS sink and source endpoint
location (= channel positions) and context settings.

Although BlueZ associates these with individual endpoints, in the PACS
spec they are actually device-global, so configure directly in monitor
settings.
2025-04-20 20:34:35 +03:00
Arun Raghavan
a4148c80b4 Makefile: Fix up shell/run rules 2025-04-18 14:05:12 -04:00
Arun Raghavan
31069b2626 Don't log to systemd during development
Can get a bit spammy if we're doing verbose logging.
2025-04-18 12:28:23 -04:00
Arun Raghavan
ebe9381236 gst: handle blocks and size allocation for encoded format
In case of encoded video we get n_planes as 0 from the video info so
passing that as n_datas is failing during the buffer negotiation. Make
sure to use an appropriate value based on whether we have raw video or
not.

Co-authored-by: Taruntej Kanakamalla <taruntej@asymptotic.io>
2025-04-17 15:21:38 -04:00
Wim Taymans
55f71520db midifile: unpack the UMP SysRT bytes correctly
They are packed in a native endian uint32_t so read it like that and
then use shifts to get the right bytes.
2025-04-16 18:33:36 +02:00
Simon Ruderich
c4a88dfe6c midifile: decode UMP SysRT messages 2025-04-16 17:57:44 +02:00
Wim Taymans
57326d65d9 ebur128: work around libebur128 bug
Versions 1.2.5 and 1.2.6 don't scale the window in ms correctly, leading
to excessive memory allocation, so work around this here.
See https://github.com/jiixyj/libebur128/pull/132

Fixes #4646
2025-04-14 11:35:35 +02:00
Vinit Mehta
3140ede326 bluez5: Fix return status for parse_qos_settings 2025-04-14 07:26:28 +00:00
Pauli Virtanen
e9dae61cca bluez5: simplify BAP settings parsing and use device settings for them
Parse BAP settings in a single place, and simplify QoS customization a
bit.

Ensure the selected preset gets selected.

For all the BAP codec settings, use device settings instead of global
monitor ones.
2025-04-14 07:26:28 +00:00
Vinit Mehta
6e57510d6b doc: Add BAP QoS config & select option
This adds configuration options for BAP unicast QoS based on user
config parameters
2025-04-14 07:26:28 +00:00
Vinit Mehta
55372a41b1 bluez5: Add support to select BAP QoS config
The current BAP QoS configuration allows to register a sampling
frequency based on the configuration done using wireplumber configuration.
However, for a scenario were the user need to use a specific SDU framelength
it cannot be done as the select_bap_qos function selects the QOS based on
priority and hence it will use the best possible config rather than the user
configured.

This PR adds option to select the QoS set based on user configured value. If
the remote device doesn't have the user configured capabilities it will always
use the best priority config.

Further, this change also allows the user to set RTN, Latency, Delay QoS config
for certain use case to have controller use optimum bandwidth usage.

Below are the example configuration on setting LC3 capabilities in config file:

bluez5.bap.set_name = "48_2_1"
bluez5.bap.rtn = 5
bluez5.bap.latency = 20
bluez5.bap.delay = 40000
bluez5.framing = false
2025-04-14 07:26:28 +00:00
Vinit Mehta
d22a4d60b3 doc: Add BAP QoS config & select option
This adds configuration options for BAP unicast QoS based on user
config parameters
2025-04-14 07:26:28 +00:00
Vinit Mehta
6dfb164cab bluez5: Add support to configure & select BAP QoS config
The current BAP unicast QoS configuration allows to register a sampling
frequency based on the configuration done using wireplumber configuration.
However, for a scenario were the user need to use a specific SDU framelength
it cannot be done as the select_bap_qos function selects the QoS based on
priority and hence it will use the best possible config rather than the user
configured.

This PR adds option to select the QoS set based on user configured value. If
the remote device doesn't have the user configured capabilities it will always
use the best priority config.

Further, this change also allows the user to set RTN, Latency, Delay QoS config
for certain use case to have controller use optimum bandwidth usage.

Below is the example for the options that can be configured & selected
in config file:

bluez5.bap.set_name = "48_2_1"
bluez5.bap.rtn = 5
bluez5.bap.latency = 20
bluez5.bap.delay = 40000
bluez5.framing = false
2025-04-14 07:26:28 +00:00
Kenny Levinsen
558721efc2 audioconvert: Increase param length limit to 4096
Parameter values read into a 512 byte long buffer, which is insufficient
for medium to long filter-graph parameters.

Increase the buffer to 4096 bytes to give some wiggle-room.
2025-04-11 20:03:25 +00:00
Christian Glombek
9e3f9607a6 raop: Add fp_sap25 encryption type
Add support for FairPlay SAP v2.5 (encryption type 5) type devices such as Apple Home Pod Minis.

Apparently only these devices require the `POST /feedback` heartbeat, so fix that.
2025-04-10 23:13:46 +02:00
Pauli Virtanen
4c51e6518b bluez5: ldac decoding support
Add support for LDAC decoding, if libldac decoder is available.
2025-04-10 13:22:57 +00:00
Pauli Virtanen
bbe1587f71 bluez5: fix volume ids
Node ids don't map directly to volume ids. Fix the indexing.
2025-04-09 07:50:30 +00:00
fossdd
b15ec9bec9 doc: fix typo in pw-link(1) 2025-04-09 07:48:10 +00:00
Pauli Virtanen
42b92a3487 pw-loopback: add missing --channel-map long option 2025-04-09 07:47:32 +00:00
Sanchayan Maity
bb1bb07f6c gstpipewiresrc: Handle stream being disconnected
When PW source is used with something like Camera and the camera is
disconnected, all buffers are removed and stream will be paused.

When using PW sink with source, the sink side pipeline can go to EOS.
This again results in all the buffers being removed and stream being
paused on the source side. PW source side pipeline can also crash if
the sink was in the middle of frame copying a buffer to render which
got removed.

Handle this scenario by sending a flush-start event at the start of
buffer removal and flush-stop at the end followed by an end of stream
or pipeline error depending on user selection.
2025-04-09 07:45:27 +00:00
Pauli Virtanen
e9a2406314 CI: bump to Fedora 41
Fedora 40 EOL is next month, and newer Doxygen version is better for
docs.pipewire.org.
2025-04-06 12:12:59 +03:00
Pauli Virtanen
e3122a8555 doc: add links to docs of other versions 2025-04-05 14:36:43 +03:00
Pauli Virtanen
b8ad9acbc7 CI: build also 1.4 docs 2025-04-05 11:27:32 +00:00
Wim Taymans
e355df3785 channelmix: fix channel_mask bits iteration
Iterate the number of bits in the channel mask based on the number of
bits in the mask, not the max amount of channel positions.
2025-04-04 17:06:43 +02:00
Wim Taymans
a99ed4da2a raop: fix byte array initialization
Initialize the byte array with bytes instead of a string because the 0
byte at the end of the string does not fit in the array and causes a
compiler warning.
2025-04-04 16:12:41 +02:00
Wim Taymans
031014bbab acp: remove channel limit from API
Internally bump the channel limit and allocate the channel map
dynamically.
2025-04-04 15:46:03 +02:00
Wim Taymans
8205038ffb buffers: increase max datas limit
Increase the max amount of buffer datas allowed.
2025-04-04 15:46:03 +02:00
Wim Taymans
a9f12537d1 pulse: clamp channel numbers to right values
When converting between pipewire and pulse channelmaps, make sure we
clamp the channel numbers to the the right limit.
2025-04-04 15:46:03 +02:00
Wim Taymans
722776cf65 Remove some hardcoded channel number values
Mostly related to the number of channels.
2025-04-04 15:46:03 +02:00
Wim Taymans
5cfd461ba2 alsa: Use the configured max channels
Don't hardcode the max channels to 64 but use the globally configured
SPA_AUDIO_MAX_CHANNELS value.
2025-04-04 15:46:03 +02:00
Quentin
9d6098f8c6 Small changes, more natural sounding 2025-04-03 23:31:55 +00:00
Sanchayan Maity
77143e54d9 gstpipewiresrc: Fix re-linking for audio
For a pipeline like below, we might want to dynamically switch the audio
source.

gst-launch-1.0 -e pipewiresrc autoconnect=false ! queue ! audioconvert ! autoaudiosink

On switching to a different audio source, any one of driver, quantum
or clock rate might change which changes the return `result` value of
gst_pipewire_clock_get_internal_time.

This can result in the basesrc create function incorrectly waiting in
gst_clock_id_wait. We post clock lost message to fix this. In the case
of gst-launch, it will set the pipeline to PAUSED and then PLAYING to
to force a new clock and a new base_time distribution.

Without the clock lost message, the following can be seen

before re-linking to a different source
0:00:30.887602864 79499 0x7fffe8000d40 DEBUG              GST_CLOCK gstsystemclock.c:1158:gst_system_clock_id_wait_jitter_unlocked:<pipewireclock0> entry 0x7fffd803fad0 time 0:00:17.024565416 now 0:00:17.024109144 diff (time-now) 456272

after re-linking to a different source
0:00:45.790843245 79499 0x7fffe8000d40 DEBUG              GST_CLOCK gstsystemclock.c:1158:gst_system_clock_id_wait_jitter_unlocked:<pipewireclock0> entry 0x7fffd803fad0 time 0:00:31.927694059 now 0:00:17.066883864 diff (time-now) 14860810195

With the clock lost message, the following can be seen

before re-linking to a different source
0:01:09.336533552 89461 0x7fffe8000d40 DEBUG              GST_CLOCK gstsystemclock.c:1158:gst_system_clock_id_wait_jitter_unlocked:<pipewireclock0> entry 0x7fffd803fad0 time 0:00:58.198536772 now 0:00:58.197444926 diff (time-now) 1091846

after re-linking to a different source
0:01:21.659827958 89461 0x7fffe8000d40 DEBUG              GST_CLOCK gstsystemclock.c:1158:gst_system_clock_id_wait_jitter_unlocked:<pipewireclock0> entry 0x7fffd803fad0 time 0:28:24.853517646 now 0:28:24.853527204 diff (time-now) -9558

Note the difference in `time` and `now` fields of the above log message.

This is easy to reproduce by using a pipewiresink as the audio source
with a pipeline like below, as one of the sources during switching.

gst-launch-1.0 -e audiotestsrc wave=ticks ! audioconvert ! audio/x-raw,format=F32LE,rate=48000,channels=1 !
pipewiresink stream-properties="props,media.class=Audio/Source,node.description=pwsink" client-name=pwsink

Applications need to handle the GST_MESSAGE_CLOCK_LOST message in their
bus handlers.
2025-04-03 19:20:34 +05:30
Arun Raghavan
dd683176c2 gst: sink: Set provide clock flag if not in provide mode
Handle a theoretical corner case of an element that is first started
with mode=provide, and then restarted without mode=provide.
2025-04-03 06:59:31 -04:00
Wim Taymans
832c5a6d25 fix printf modifier for gsize
Fixes #4641
2025-04-02 13:25:31 +02:00
Wim Taymans
5c547d58d1 adapter: handle builder overflow 2025-04-02 10:39:34 +02:00