Commit graph

92 commits

Author SHA1 Message Date
Wim Taymans
13b8c23767 Don't use SPA_AUDIO_MAX_CHANNELS directly
Make a MAX_CHANNELS define and use that one in code. This makes it
easier to change the constant later.
2025-10-21 09:43:06 +02:00
Wim Taymans
a75cea96fb modules: port modules to timer-queue
Instead of using timerfd, use the context timer-queue to schedule
timeouts. This saves fds and removes some redundant code.

Make the rtp-source timeout and standby code a bit better by using
atomic operations.
2025-10-15 16:57:24 +02:00
Wim Taymans
b220f85790 module-rtp-sap: reorganize generation of SDP
Move the code to recalculate the hash and version into make_sdp. Add a
boolean argument to the make_sdp function. Recalculate the hash and
version when we are making a new SDP and leave the old values if we
are making an SDP to compare against the current one.
2025-10-15 14:08:24 +02:00
Wim Taymans
c40e0d1d98 module-rtp: unset ptp_fd or else we might close it 2025-10-15 14:05:29 +02:00
Carlos Rafael Giani
97996a6e20 module-rtp-sap: Take RTP dest port into account when matching sessions
This is important if several sessions use the same multicast IP address.
2025-07-18 10:54:04 +02:00
Melvin Manninen
f4f548fbe6 module-rtp-sap: Fix Message Identifier Hash generation for first session and update SDP on grandmaster change 2025-07-17 16:00:32 +00:00
Pauli Virtanen
dc618d37c6 modules: fix missing free/close and length checks
Fix some missing free and close.

Fix not checking length of received netjack data.
2025-06-14 15:24:05 +03:00
Wim Taymans
74035f0a34 rtp-sdp: format ptime in the C locale
Don't place locale dependent strings in the SDP.

Fixes #4615
2025-03-19 17:53:04 +01:00
Arun Raghavan
5e295815bf module-rtp-sap: Add a couple of SDP parsing validations 2025-02-15 22:42:46 -05:00
Arun Raghavan
25e58995f5 module-rtp-sap: Silently ignore other SSRCs if we know the receiver SSRC
If we know the receiver SSRC from the SAP, we can happily ignore packets
on other SSRCs.
2025-02-15 22:32:12 -05:00
Arun Raghavan
13e3918f81 module-rtp-sap: Publish sender SSRC if we have it
Can be handy on the receiver side.
2025-02-15 17:58:34 -05:00
Arun Raghavan
dbf0442c7e module-rtp-sap: Fix sending first session SDP
We don't initially have the SAP socket open, so we can't generate an SDP
(because we don't have the interface address). So in addition to the
regular flow, also trigger SDP creation after opening the SAP socket, so
we can have a valid SDP for the announcement.

The sending was broken in commit a44afd84. We delay the SAP fd openeing
for reasons explained in commit f2f204d6).
2025-02-15 17:58:34 -05:00
Wim Taymans
a44afd84ff sap: only send bye + new SAP when SDP changed
Reorganize some code to separate the creation and sending of the SAP
message.

Check if when the node changed, we have an actual change in the SDP
before we send BYE and the new SAP message. It's possible that nothing
changed, for example when the node simply changed state or an unrelated
property.
2025-01-21 15:43:10 +01:00
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