Commit graph

79 commits

Author SHA1 Message Date
George Kiagiadakis
fbbe983a05 rtp-sap: make the receive socket listen only to the configured sap.ip
In line also with da8e207de9,
make sure that the rtp-sap receive socket listens only to the configured
sap.ip in unicast mode, instead of accepting all packets on the port.

This additionally fixes breakage that was inadvertently introduced in
f2f204d604. Because the
`struct sockaddr_storage *sa` argument in `make_recv_socket` points
to `impl->sap_addr`, changing the address to INADDR_ANY in the unicast
code path would also silently cause the sender socket to try to
connect to INADDR_ANY and fail.
2024-09-25 10:55:28 +00:00
George Kiagiadakis
88dff1c021 rtp-sap: announce the source IP as the "connection" address in unicast
The "connection" address ("c=") is meant to be the address that the
RTP receiver will use to filter for incoming packets. In multicast,
it must be the multicast address, which is also the "destination"
address in this context. In unicast, however, it must be the sender's
address, i.e. the "source" in this context. The RTP receiver will
then call connect() on this address, effectively filtering the incoming
packets to the ones coming from that particular source.
2024-09-25 10:55:28 +00:00
Gleb Popov
aafe815556 Move the ifr_ifindex FreeBSD definition into a header file to reduce code duplication 2024-09-23 08:09:45 +00:00
Pauli Virtanen
ec5684302c doc: in user-facing config examples, indicate which file it goes into
Add suggestions for config fragments in config file examples, as
applicable.
2024-09-16 15:51:59 +00:00
Wim Taymans
cd81b5f39a spa: add spa_json_begin_array/object and relaxed versions
Add spa_json_begin_array/object to replace
spa_json_init+spa_json_begin_array/object

This function is better because it does not waste a useless spa_json
structure as an iterator. The relaxed versions also error out when the
container is mismatched because parsing a mismatched container is not
going to give any results anyway.
2024-09-16 09:50:33 +02:00
Arun Raghavan
d79b995e51 module-rtp-sap: Make sure we don't publish a null refclk
If the PTP refclk is not readable, we fallback to the stored ts_refclk,
which might be NULL. Make sure we check for this case.
2024-09-09 14:05:45 -04:00
Arun Raghavan
f2f204d604 module-rtp-sap: Initialise send fd when first needed
Avoids need for additional configuration to allow disabling send (which
in turn was needed to avoid errors when a network interface is not
available on start).
2024-08-20 05:24:31 -04:00
Wim Taymans
50be29ad18 modules-sap: fix uninitialized variable when close in error 2024-08-20 10:55:01 +02:00
George Kiagiadakis
242d75c6fc m-rtp-sap: add sap.announcer option to disable the send socket
In circumstances where the network interface is not ready yet,
creating a send socket will fail. This may be ok if we only
intend to use rtp-sap as a listener, therefore add an option for it.
2024-08-19 19:19:58 +03:00
Arun Raghavan
a3c68ef9cf module-rtp: Make max SAP sessions configurable
Keep the current limit, but allow for more if someone wants to track
more.
2024-07-16 08:45:50 -04:00
Arun Raghavan
9b33cea0f7 module-rtp: Minor robustness improvement to PTP socket reading
Mark socket as CLOEXEC like we do everything else, log when we flush
stale data, and check for errors in the while loop.
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
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
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
Diego Viola
7410755c03 Fix typos
found them with codespell.

Signed-off-by: Diego Viola <diego.viola@gmail.com>
2024-05-22 09:19:34 +02:00
Wim Taymans
f4e391dd41 stream: add pw_stream_get_nsec() to get current time
Make a method to get the current time to compare agains the pw_time-now
field. This is currently CLOCK_MONOTONIC but make this into a method
so that we can more easily change it later.
2024-03-04 12:59:26 +01:00
Wim Taymans
c0966f026a modules: prefix network-utils methods with pw_net 2024-02-26 15:17:48 +01:00
dsee
4888b35284 Support IPv6 link-local addresses
Use `getaddrinfo` in `parse_address` instead of `inet_pton`.
Display Ipv6 addresses with scope identifiers correctly in `get_ip`
functions using `if_indextoname`.
2024-02-25 18:20:54 +00:00
Wim Taymans
c37c6b0789 module-rtp: fix SAP header parsing for IPv6
If the originating source is IPv6, the A bit is set and the source is 16
bytes compared to 4 bytes for IPv4.

Fixes #3851
2024-02-16 12:53:54 +01:00
Wim Taymans
e15b9e7f71 module-rtp: fix debug log 2024-02-16 12:37:40 +01:00
Wim Taymans
09feb8a18c module-rtp: improve ipv5 support
Use the IPV6 versions for loop and ttl. Improve debug.
2024-02-16 09:54:09 +01:00
Wim Taymans
320eb935a3 module-rtp: handle ipv6 sap.ip
Make a socket of the same address family as the address we're going to
bind it to.

When the source.ip is not specified, use the default in the same address
family as the sap.ip.

Probe the interface for addresses of the same family as the sap.ip.

Makes pactl load-module module-rtp-recv sap_address=:: work.

See #3851
2024-02-15 15:18:13 +01:00
Gleb Popov
6b73cc15da FreeBSD compatibility for module-rtp-sap 2024-02-10 20:52:20 +03:00
Dmitry Sharshakov
bd5af4e573 module-rtp-sap: use autobind 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov
61db1f16e2 module-rtp-sap: sanity check PTP response 2024-01-22 16:41:06 +00:00
Barnabás Pőcze
1274ebe069 Apply 1 suggestion(s) to 1 file(s) 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov
44f1462711 module-rtp-sap: fix strncpy bounds 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov
9a0499b64d module-rtp-sap: fix fd leak 2024-01-22 16:41:06 +00:00
Dmitry Sharshakov
401df6e199 module-rtp-sap: review
Co-authored-by: Barnabás Pőcze <pobrn@protonmail.com>
2024-01-22 16:41:06 +00:00
Dmitry Sharshakov
7abb896aef module-rtp-sap: support PTP management protocol
Request current clock sync status to know the grandmaster identity for SAP announcements
2024-01-22 16:41:06 +00:00
Dmitry Sharshakov
a7410fe1bf module-rtp-sap: refactor channelmap generation 2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
aca4d93b31 module-rtp-sap: properly serialize custom channelmaps 2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
2e14f3d97a module-rtp-sap: only override NTP value in the timing line
That is indeed 0 for nearly any device. However the NTP value in the session identification part plays a crucial role for distinguishing between streams in some implementations, e.g. Dante.
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
420ab8ed89 module-rtp-sap: add session number to the NTP value
Dante Controller does not recognize next stream having the same NTP value. Work around that by adding current number of sessions to the time and the magic value.

Co-authored-by: Dewi Seignard <dewiweb@gmail.com>
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
57985e5aea module-rtp-sap: set source-filter up
Might enhance support for some devices or otherwise useful.

Co-authored-by: Dewi Seignard <dewiweb@gmail.com>
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
eab90d6029 module-rtp-sap: allow overriding NTP value
It seems like most devices use value 0 there, so for further enhanced compatibility it's preferred to do so as well
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
066e8e1c63 module-rtp-sap: add a way to add extra attributes to SDP
Useful for new device bringup without rebuilding PW
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
1fe6feac56 module-rtp: improve logging priorities
Previous state was useless for real debug at the current implementation level
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
c75f6219dc module-rtp-sap: add notices about different channelmap formats used by different hw 2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
873e6119b8 module-rtp: handle framecount attribute 2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
2525a99b97 module-rtp-sap: parse ptime from incoming streams 2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
6a64ec8b8f module-rtp-sap: send out a default channelmap if none specified
RAVENNA devices (at least Lawo) seem to error out on streams without this property

Co-authored-by: Dewi Seignard <dewiweb@gmail.com>
2023-12-20 09:35:22 +00:00
Dmitry Sharshakov
533161a766 module-rtp: add framecount to the SDP
Required for RAVENNA hardware.

Co-authored-by: Dewi Seignard <dewiweb@gmail.com>
2023-12-20 09:35:22 +00:00
Wim Taymans
5e750f6fb8 modules: place floats in properties in JSON format
Using %f will result in a locale dependent format and might not parse
with JSON parsers or even our own spa_atof() function.
2023-12-14 11:50:30 +01:00
Pauli Virtanen
fdcb02ed75 modules: add Module Name section to the module reference docs 2023-11-20 08:41:13 +00:00
Pauli Virtanen
eca773fc12 modules: strip "PipeWire Module:" from Doxygen page name
Make them appear nicer in the output.
2023-11-19 16:39:15 +00:00
Arun Raghavan
5617fa0501 module-rtp-sap/sink: try to bind sockets to an explicit interface 2023-10-24 07:17:21 +00:00
Wim Taymans
8dd294bf44 conf: support ! to negate the match
So that you can do "application.name" = "!pw-cat" to match anything
that is not pw-cat and "application.name" = "!~pw-cat$".

Fixes #3460
2023-08-25 11:39:28 +02:00