Centricular

Expertise, Straight from the Source



« Back

Devlog

Posts tagged with #sdp

New udpsink2 & multiudpsink2 elements

Following the new udpsrc2 element I wrote about earlier this year in spring, there's now also a new version of udpsink and multiudpsink in gst-plugins-rs in the same plugin. All three new elements will be included in gst-plugins-rs 0.16 which is scheduled to be released together with GStreamer 1.30 in the coming weeks.

Just like udpsrc2, these new elements don't use GIO anymore but use the socket APIs directly which leads to less overhead. As a bonus, on Windows this now also uses WSASendMsg() instead of the slower WSASendTo path that is the only available code path in GIO on Windows. This should improve performance in situations where a datagram made of multiple chunks of memory has to be sent, e.g. when an upstream RTP payloader produces a buffer with multiple memories.

The new elements should be approximately a drop-in replacement. The only API difference between the old C elements and the new ones is a bit of API cleanup: multiudpsink2 is not a base class of udpsink2 so the confusing existence of the multi-destination API in udpsink is no longer a problem.

The full documentation of the three elements can be found here.

Improvements to udpsrc2 and socket sharing between source and sink

In addition, a couple of improvements to udpsrc2, also in relation to the sinks, were merged over the last months.

Apart from fixes, the most important and noteworthy one is probably the more consistent handling of socket configuration with externally provided sockets. This was originally reported against the C versions of the elements but the Rust versions were equally affected. The C versions are not fixed yet.

The main problem here was that when providing sockets externally via the properties, it was not consistent between the elements which socket configurations were applied, and this could lead to all kinds of problems when sharing sockets between the source and sink element. For example, a socket created by the sink would not have IP_MULTICAST_ALL disabled so when passing it to a source element later it might have lots of unrelated packets queued up.

The solution now is that each element always configures all the socket configurations that are relevant to its direction (send vs. receive).

As part of this, the loop property was also removed from udpsrc2 as setting multicast loopback is decided for the sending side and not the receiving side.

The only socket configuration that needs special consideration now when sharing a socket between the source and sink element is which multicast groups to join and which element should be responsible for that. Joining the same multicast group twice is generally an error. For that reason the auto-multicast property exists on both elements and usually this should be disabled on one of the two elements (or both) when sharing sockets.

Socket sharing between the source and sink element is usually used for bidirectional RTP/RTCP sessions, and for example the SDP/SAP elements and the RTSP source element and server is making use of it.