Commit graph

7124 commits

Author SHA1 Message Date
Arun Raghavan
858f534436 module-rtp: Allow setting session ID/version as parameters
This allows for externally setting the value at runtime, like we do with
the session name.
2024-07-06 22:45:56 +00:00
Arun Raghavan
6623eb8254 module-rtp: Allow overriding session version
This allows us to set an session version for the SAP externally. Also
the default is changed from 0 to an NTP timestamp, as recommended by the
spec[1].

[1] https://datatracker.ietf.org/doc/html/rfc4566#section-5.2
2024-07-06 22:45:56 +00:00
Arun Raghavan
7c8453f260 module-rtp: Allow overriding session ID
This allows us to specify a static session ID, so that (Dante) receivers
can uniquely identify us as a sender. This prevents duplicate streams in
Dante Controller, for example.
2024-07-06 22:45:56 +00:00
Wim Taymans
f5512e8b88 module-protocol-simple: use interface address as server address
Move the address:port parsing code to the net helper. Add a default
address option.

Pass the interface address to protocol-simple and use this as the
default address for listening.

This makes sure that when the user passes tcp:3400 that we don't end up
publishing 0.0.0.0:3400 but the actual address of the interface we are
listening on so that the snapcast discover can use this to notify the
snapcast server.

Fixes #4093
2024-07-06 10:12:27 +02:00
Pauli Virtanen
daef48b0eb conf: fix context.exec args parsing
The 'args' can be either JSON array, or a string.  If a string it should
not be parsed as JSON for a second time, but instead split at
whitespaces.
2024-07-04 20:54:51 +00:00
Arun Raghavan
35ba50f117 module-rtp: Update SAP session if stream properties change
This allows us to propagate changes to session name, destination IP,
etc.
2024-07-04 08:38:14 -04:00
Wim Taymans
2d0bc982bc impl-node: set INACTIVE state on server
Don't wait for the client to set the INACTIVE state, do it on the
server. We already decremented the target required so we don't want to
schedule the node anymore.

Fixes some xruns when removing nodes in a stress test.
2024-07-03 17:42:39 +02:00
Arun Raghavan
02fea0ba8f module-rtp: Allow updating sess.name from params
We might want to add more such properties to be dynamically updated, but
just adding this one for now.
2024-07-03 10:07:27 -04:00
Wim Taymans
59b9da9477 impl-node: disable async for driver nodes
Make it so that a driver node can never be scheduled async. It could
possibly make sense when the driver node is not currently driving the
graph but when it drives the graph it always needs to be sync. This
also simplifies the target activation because we can simply check the
async state and ignore if the node is driving or not.

Also make sure that we never make an async link with a driver output port.
This does not make sense because the driver node will always be
triggered sync first and before the async node so we can simply make
a sync link.

This fixes the modified (only generate 1 buffer) video-src -> video-play
case where the buffer never arrives in video-play because of the
useless async link.

Fixes #4092
2024-07-03 14:49:12 +02:00
Robert Mader
586e116f3c gst: stream: Destroy stream before clearing variable
`pw_stream_destroy()` chains up to `on_remove_buffer()` in
GstPipeWireSrc which again needs the stream to still be around to call
`pw_stream_queue_buffer()` on it. By using `g_clear_pointer()` it will
already have been cleared, causing crashes.

Revert to the behavior from before the commit mentioned below and add a
comment in order to avoid regressing in a future cleanup.

Fixes: 0c40c0147 (gst: factor out the stream management and some common variables in a new class)
2024-07-02 20:36:57 +02:00
Robert Mader
226440382b gst: src: Reset transform on stream stop
When a stream is stopped, chances are high that downstream elements
change or get reset, i.e. don't remember a previously send rotation
event. Thus reset the transform value in order to ensure we create a new
one on the next stream start.

In order to not regress the case when downstream *does* remember the
orientation and the buffer orientation changes from e.g.
`TRANSFORMATION_90` to `TRANSFORMATION_None` between stream
stop and restart, initialize the remembered transform to an invalid
value and ensure we always send a rotation event, even for
`TRANSFORMATION_None`.
2024-07-02 15:15:05 +02:00
David Coles
5d7624001d Add spa/utils/endian.h
This provides access to GNU C library-style endian and byteswap functions.

Windows doesn't provide pre-processor defines for endianness, but
all current Windows architectures (X32, X64, ARM) are little-endian.
2024-07-01 15:28:58 +00:00
Wim Taymans
29171cadb5 context: improve sync group handling some more
Keep track of the sync nodes we added to a driver and bring in the other
nodes from the same sync group, group or link groups. This makes it
possible to have disjoint sync groups each with their own driver.
2024-07-01 16:05:07 +02:00
Wim Taymans
070bcea63b context: Fix node collect with groups and sync enabled
When checking for the nodes to collect with a driver, don't just skip
checking the other nodes when the driver is not in the sync group.
Instead collect all nodes that have the same group and link group as
the driver first and then check the sync groups.

Fixes export in ardour8

Fixes #4083
2024-07-01 14:50:34 +02:00
Wim Taymans
dc5f441909 module-raop: only set softVolume when valid 2024-07-01 11:42:29 +02:00
Wim Taymans
b151b1f570 impl-node: fix required state for async driver nodes
When the node activation.required was incremented because it was a
driver, only decrement it in that case, regardless of the current driver
state of the node.

This fixes the case of KODI where the required field gets out of sync
and things become unschedulable.

Fixes #4087
2024-07-01 10:36:09 +02:00
Barnabás Pőcze
04450e14a4 treewide: fix more -Wformat issues
See !2057
2024-06-30 19:22:17 +00:00
Eli Schwartz
b5f031bc15 meson: fix conflicting use of feature-based dependency lookups
When spa-plugins is enabled, the gio-2.0 global dependency is
overwritten.

When bluez support is enabled, OR when gsettings is enabled, the gio-2.0
dependency is then detected as found. This means that
pipewire-module-protocol-pulse can end up enabling gsettings support
even if it has been forcibly turned off.

Rename the meson variables to ensure they are looked up separately.
2024-06-30 18:39:38 +00:00
Barnabás Pőcze
ec521ca870 meson.build: enable -Werror=format 2024-06-27 21:18:06 +00:00
Barnabás Pőcze
17fcc9fc51 pw-container: use smaller path for temporary file
The automatically deduced size is sufficient. This
prevents a -Wformat-overflow warning.
2024-06-27 21:18:06 +00:00
Wim Taymans
1e5d9cc635 impl-node: increment async driver nodes required field
A driver can't be async, we always need to be able to trigger it
to start it so increment the required field.

Fixes an issue with asunc drivers such as the video-src example or gnome
screen sharing.
2024-06-27 13:22:52 +02:00
Barnabás Pőcze
7732d0e3e5 pipewire: module-raop-sink: use uint32_t for sample rate
32 bits are enough, and additionally this also fixes an incorrect
format string, which caused the default `audio.rate` to be
incorrectly set on some platforms, such as 32-bit arm ones.

Fixes #4080
2024-06-27 09:46:45 +02:00
Christian Glombek
4067b3a985 module-rtp/stream: Fix setting marker_on_first prop for RAOP 2024-06-27 06:04:56 +02:00
Christian Glombek
34ae5ce649 module-raop-sink: Fix setting sess.ts-direct prop 2024-06-27 05:44:50 +02:00
Wim Taymans
9d1d1fcbef impl-port: add port.group property
Can be used to group ports together. Mostly because they are all from
the same stream and split into multiple ports by audioconvert/adapter.

Also useful for the alsa sequence to group client ports together.

Also interesting when pw-filter would be able to handle streams in the
future to find out what ports belong to what streams.
2024-06-24 13:38:09 +02:00
Arun Raghavan
92c9b27c94 pw-cli: Dump object info on events
This prints changed state, props and params when run with -m and running
the `info` command. We try to print only things that have changed. It
would probably be good to make the props (and params) print a diff of
what's changed as well.
2024-06-21 16:08:24 -04:00
Arun Raghavan
8cd857733b module-rtp: Check if packet receive works to track receiving state
If the sender is reset, the RTP stream may return, but may no longer
correspond to the stream for which we loaded this instance of
module-rtp-source. A power cycle or network reset on Dante devices
causes a new SDP and SSRC to be selected, for example.

So let's make sure we don't consider invalid receives while tracking our
"receiving" state. Arguable, we should bail entirely if this happens.
2024-06-21 15:39:47 -04:00
Michael Tretter
1b7cf61632 gst: pipewiresink: wait for activated buffer pool before updating buffers
PipeWire expects the SPA_TYPE_OBJECT_ParamBuffers to be valid after
setting SPA_PARAM_Format. The pipewiresink knows the final buffer size
only after the pipewirepool has been activated.

There is a race between PipeWire asking the pipewiresink for the buffers
and GStreamer activating the buffer pool. If GStreamer has not activated
the buffer pool before PipeWire asks for the Buffer params, PipeWire
won't allocate buffers with the correct type and size.

The chance of hitting this window increases, if the upstream GStreamer
element doesn't use the buffer pool. In this case the buffer pool is
activated by the first buffer that arrives at the pipewiresink, which
may take some time.

Instead of not updating the Buffer params when the buffer pool is not
active, wait for the buffer pool to become active.
2024-06-20 21:05:45 +00:00
Michael Tretter
21358526d5 gst: pipewiresink: extract gst_pipewire_sink_update_params
Add a helper function for updating the params instead of handling it in
the pool_activated callback. This allows to explicitly set the params
from the element.
2024-06-20 21:05:45 +00:00
Michael Tretter
6468e5338f gst: pipewirepool: print buffer type with numeric value
If the buffer type is invalid, the short_name will be (null). Printing
the numeric value helps the reader to understand the (null) type.
2024-06-20 21:05:45 +00:00
Barnabás Pőcze
6acfb53884 pipewire: module-roc-sink: explicity specify sender packet encoding
roc-toolkit commit 03d29eb97211ca87593566998c5087590c1bae38 [0]
("Add sample_format() and pcm_format() to SampleSpec") made
a change in how the packet encoding is determined. Specifically:

  This commit introduces small breaking change in C API:
  when we search for packet_encoding compatible with
  frame_encoding, we now take into account format too.

  It means that if you use ROC_FORMAT_PCM_FLOAT32 in frame_encoding,
  ROC_PACKET_ENCODING_AVP_L16_STEREO will not be selected automatically
  anymore, and you need to specify it manually via packet_encoding.

This causes module-roc-sink to fail to set up the ROC sender:

  roc_api: bad configuration: failed to select packet_encoding matching frame_encoding, set roc_sender_config.packet_encoding manually

So specify `ROC_PACKET_ENCODING_AVP_L16_STEREO` explicitly
as the packet encoding. This seems to work with roc-toolkit 0.3,
so the required version is not changed.

Fixes #4070

[0]: 03d29eb972
2024-06-20 21:04:40 +00:00
Wim Taymans
ea7e0e9152 spa: revert peer_enum_params node event again
It's not used anymore because it does work so well.

The problem is that while it transparently proxies param enums on
ports to peers, it fails to emit events when those peer
params change in a way that would make the enum result change as well.
This makes it quite hard to use this correctly.
2024-06-20 10:22:45 +02:00
Michael Tretter
7b8b6d92d9 gst: pipewiresink: decrease log level of on_process to LOG
on_process is called whenever a buffer may be queued. This happens for
every buffer. The correct log level is LOG.
2024-06-19 15:43:06 +00:00
Michael Tretter
3b581b2417 gst: pipewiresink: print stream state as string
Print the state of the stream not only as the numeric value, but also
print the name of the state to help the reader.

While at it, add the sink element to the log output to be able to
identify the sink that received the state change.
2024-06-19 15:43:06 +00:00
Arun Raghavan
4d14531444 module-rtp: Drop redundant include 2024-06-19 11:16:09 -04:00
Arun Raghavan
9559b9382b module-rtp: Propagate cleanup.sec to module-rtp-source
This might be specified on a `create-stream`, but then not actually
applied as a module argument, and thus be ignored.
2024-06-19 11:15:17 -04:00
Arun Raghavan
2c7272a13a module-rtp: Set receiving state on stream as a property
There isn't a good way to surface this information to the module owner
yet, so let's publish the information on the stream so we can try to
manage things in policy.
2024-06-19 10:49:51 -04:00
Wim Taymans
41691f8bc9 module-vban: fix some implicit float conversions 2024-06-18 16:05:36 +02:00
Wim Taymans
51bf143a77 module-rtp: fix fmodf usage 2024-06-18 16:01:41 +02:00
Wim Taymans
a76d262db6 modules: fix compilation 2024-06-18 15:47:02 +02:00
Wim Taymans
f7d59bcea7 fix compilation some more
The math M_*f symbols are GNU extensions.
2024-06-18 15:41:12 +02:00
Wim Taymans
1ae4374ccf Fix compilation with -Werror=float-conversion
Better make the conversions explicit so that we don't get any surprises.

Fixes #4065
2024-06-18 12:17:56 +02:00
Wim Taymans
50870aac57 impl-node: move node_peer functions to impl-node 2024-06-18 09:49:01 +02:00
Wim Taymans
33f1a713cd impl-node: set active_driver_id
This is the driver id that the client has received and is using right
now. We don't use this yet but it could be used in the future to check
if a client has the most up to date info.
2024-06-18 09:47:33 +02:00
Robert Rosengren
3cbda26f07 gst: src: disable active state when only going to PAUSED
The pipewiresrc starts the stream in active state but should be inactive
if only going to PAUSED state. This patch sets the stream to inactive
when wait_started has returned in the GStreamer state tranistions.

Also resets internal started state when going PAUSED -> READY.

Fixes #4049
2024-06-17 15:11:48 +02:00
Wim Taymans
a07f73ce82 impl-node: add more backwards compat
Make sure newer clients can work with an older server:

- Add client and server versions in the activation
- On older server, clients needs to trigger peers without CAS of status
- On older server, jack transport is started with command.
- Use client version to know when to set the INACTIVE/FINISHED
  state on the server instead.
- Async clients need to trigger peers on old server.
2024-06-17 12:07:09 +02:00
Wim Taymans
e045ef0e4c impl-node: add compat with old nodes 2024-06-14 12:41:03 +02:00
Wim Taymans
c89a68b0b4 impl-node: handle node <-> driver links with node_peer
Also handle the relation between a node and the driver with pw_node_peer,
like we do with the links.

Because these are refcounted, we only make one peer for a node that is
linked to another node that is also the driver (pw-play -> sink) and we
save some fds as well as some admin stuff and overhead for the refcounts.

This in return then results in less problems getting all the refcounts
right when adding/removing nodes.
2024-06-14 11:52:59 +02:00
Wim Taymans
b7af52e3fb impl-node: partially revert target rework
We can't let a client decrement the required state because if it crashes
or fails to decrement, the graph becomes unschedulable.
2024-06-13 17:40:55 +02:00
Wim Taymans
9592b0af2a examples: fix mapoffset in examples
The mapoffset should be using in the mmap call as the offset.

Mapping the whole memory before the offset and then ignoring the part
before it seems like it can work but it actually has some problems:

1. some drivers (v4l2) use the mapoffset to calculate the buffer to map
2. we waste resources for mapped but unused pages.

The problem with the mapoffset is that it needs to be page aligned and
that used to be a problem in the past. Nowadays PipeWire no longer set
the mapoffset for any of the memory that it allocates.
2024-06-13 10:11:29 +02:00