Commit graph

67 commits

Author SHA1 Message Date
Thibault Saunier
019971a3c7 Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir 2021-09-24 16:14:36 -03:00
Zhao Zhili
57d8de68d1 srtobject: fix optlen of srt_getsockflag
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2149>
2021-04-08 20:30:20 +08:00
Jakub Adam
9c00d261c3 srt: preserve ABI compatibility
Reintroduce socket descriptor parameter removed in 327ad84e to
"caller-added" and "caller-removed" signals, just set it always to zero.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2004>
2021-02-03 23:39:00 +01:00
Jakub Adam
327ad84e35 srt: don't pass SRT socket ID to "caller-added,removed" signals
The caller's IP and port is enough for unique identification. Don't leak
the socket handle since using it in unadvised libsrt calls from the
application could break the SRT element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1772>
2021-02-03 16:23:33 +00:00
Jakub Adam
4a58af4352 srtobject: add caller address to stats structure
In listener mode, gst_stats() returns an independent set of
statistics for every connected caller. Having the caller's IP and port
present in each structure allows to correlate the statistics with a
particular caller that has been announced by "caller-added" signal.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1772>
2021-02-03 16:23:33 +00:00
Edward Hervey
4e7f7871db srt: Define options added in later revisions
Allows compiling the plugin against old headers.

For SRTO_BINDTODEVICE there's nothing we can do, since the value depends on
configuration options of the library. Nice.

Fixes build with libsrt < 1.4.2

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1945>
2021-01-07 09:23:28 +01:00
Jakub Adam
6c35222973 srtobject: distinguish authentication error messages
Use GST_RESOURCE_ERROR_NOT_AUTHORIZED code in posted error messages
related to SRT authentication (e.g. incorrect or missing password) so
that the application can recognize them more easily.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1943>
2021-01-06 23:35:20 +00:00
Jakub Adam
ef118f3d0a srtobject: detect socket errors from srt_epoll_wait()
On an error event, epoll wait puts the failed socket in both readfds and
writefds. We can take advantage of this and avoid explicitly checking
socket state before every read or write attempt.

In addition, srt_getrejectreason() will give us more detailed
description of the connection failure.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1943>
2021-01-06 23:35:20 +00:00
Jakub Adam
3c3e89304e srtobject: make possible to specify more sockopts in SRT URI
Any socket option that can be passed to libsrt's srt-live-transmit
through SRT URI query string is now recognized.

Also make the code that applies options to SRT sockets more generic.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1842>
2021-01-06 22:28:02 +00:00
Jakub Adam
d540012091 srtobject: obey "wait-for-connection" in caller mode
The pipeline now gets stuck in gst_srt_object_write_one() until the
receiver comes online, which may or may not be desired based on the use
case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1836>
2021-01-06 18:55:37 +00:00
Jakub Adam
00e44e8ed7 srtobject: post a message on the bus when broken socket is detected
So that the application gets notified may react to it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1935>
2021-01-05 16:50:01 +00:00
Raghavendra
08b1485862 srt: Add authentication to srtsink and srtsrc elements
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1725>
2021-01-04 00:03:47 +05:30
Jan Alexander Steffens (heftig)
470e6989d2 srt: Don't take object lock calling gst_srt_object_get_stats
This function takes the sock lock. This can result in a deadlock when
another thread holding the sock lock is trying to take the object lock.

Thread A (Holds object lock, wants sock lock):

    #2  gst_srt_object_get_stats at gst-plugins-bad/ext/srt/gstsrtobject.c:1753
    #3  gst_srt_object_get_property_helper at gst-plugins-bad/ext/srt/gstsrtobject.c:409
    #4  gst_srt_sink_get_property at gst-plugins-bad/ext/srt/gstsrtsink.c:95
    #5  g_object_get_property from libgobject-2.0.so.0

Thread B (Holds sock lock, wants object lock):

    #2  gst_element_post_message_default at gstreamer/gst/gstelement.c:2069
    #3  gst_element_post_message at gstreamer/gst/gstelement.c:2123
    #4  gst_element_message_full_with_details at gstreamer/gst/gstelement.c:2259
    #5  gst_element_message_full at gstreamer/gst/gstelement.c:2298
    #6  gst_srt_object_send_headers at gst-plugins-bad/ext/srt/gstsrtobject.c:1407
    #7  gst_srt_object_send_headers at gst-plugins-bad/ext/srt/gstsrtobject.c:1444
    #8  gst_srt_object_write_to_callers at gst-plugins-bad/ext/srt/gstsrtobject.c:1444
    #9  gst_srt_object_write at gst-plugins-bad/ext/srt/gstsrtobject.c:1598
    #10 gst_srt_sink_render at gst-plugins-bad/ext/srt/gstsrtsink.c:179

Fixes d2d00e07ac.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1861>
2020-12-07 17:59:09 +00:00
Jan Alexander Steffens (heftig)
2a7fa67693 srt: Check socket state before retrieving payload size
The connection might be broken, which we should detect instead of just
aborting the write.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1669>
2020-10-09 07:12:04 +00:00
Edward Hervey
dd11e91c3b srtsrc: Fix timestamping
SRT provides the original timestamp of a packet (with drift/skew corrected for
local clock), which is what should be used for timestamping the outgoing
buffers. This ensures that we output the packets with the same timestamp (and by
extension rate) as the original feed.

Also detect if packets were dropped (by checking the sequence number) and
properly set DISCONT flag on the outgoing buffer.

Finally answer the latency queries

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1658>
2020-10-08 21:12:17 +00:00
Jan Alexander Steffens (heftig)
92dc2f4192 srt: Remove unused sa_family tracking
Now that SRT no longer needs the family when creating the socket, this
code has become useless.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1659>
2020-10-06 13:56:32 +02:00
Niklas Hambüchen
13c8bda531 srt: Move off deprecated srt_socket().
See 73ee1e1a3e/docs/API-functions.md (srt_socket)

`srt_create_socket()` was added in
4b897ba92d
and srt `v1.3.0` is the first release that has it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1659>
2020-10-06 13:56:32 +02:00
Jan Alexander Steffens (heftig)
936f422764 srt: Avoid removing invalid sockets from the polls
This would provoke error messages from SRT.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1659>
2020-10-06 12:39:00 +02:00
Jan Alexander Steffens (heftig)
fda4cfd15e srt: Fix use of srt_startup
`srt_startup` can also return 1 if it was successful. Avoid warning in
this case.

Avoid a race when checking whether we need to call it at all.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1659>
2020-10-06 12:38:57 +02:00
Jan Alexander Steffens (heftig)
6b8c4a5f34 srt: Fix parameter types used for socket options
The [SRT documentation][1] specifies exact types for the socket options.
Make sure we match these.

This reverts the linger workaround in commit 84f8dbd932
and extends srt_constant_params to support other types than int.

[1]: https://github.com/Haivision/srt/blob/master/docs/APISocketOptions.md

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1659>
2020-10-06 12:36:40 +02:00
raghavendra
84f8dbd932 srtobject: typecast SRTO_LINGER to linger
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1615>
2020-09-25 22:00:26 +05:30
J. Kim
8e9f8c7f2c srtobject: set error when canceled waiting for a caller
To propagate error, this commit sets a reason. Otherwise, the function
caller should check if `error` is NULL when the return value is not normal.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1522>
2020-08-19 12:01:37 +00:00
J. Kim
ebdb3447ce srtobject: fix typo, s/errorj/error
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1522>
2020-08-19 11:31:41 +00:00
Sebastian Dröge
e70ec38000 srt: Add support for using hostnames instead of IP addresses
If an address can't be parsed as IP address, try resolving it via
GResolver instead. SRT URIs more often than not contain hostnames and
without trying to resolve them we won't be able to handle such URIs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1493>
2020-08-06 07:29:14 +00:00
Francisco Javier Velázquez-García
97b5951d25 srtobject: Add support for IPv6
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1477>
2020-08-03 21:46:04 +00:00
Francisco Javier Velázquez-García
1ba379ded0 srtobject: Reset parameters before setting URI
This makes `gst_srt_object_validate_parameters` work properly since
`localaddress` and `localport` will be missing if the URL did not
provide them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1477>
2020-08-03 21:46:04 +00:00
Francisco Javier Velázquez-García
096c60f9c5 srtobject: Simplify gst_srt_object_set_*_value
This fixes `gst_srt_object_set_string_value` in particular because the
value might not be a static string.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1477>
2020-08-03 21:46:04 +00:00
Francisco Javier Velázquez-García
1a8e2cf981 srtobject: Store passphrase like other parameters
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1477>
2020-08-03 21:46:04 +00:00
Thibault Saunier
ebababae03 srt: doc: Add missing gst_type_mark_as_plugin_api 2020-06-09 12:28:13 -04:00
Peter Workman
b98712c44a srtobject: continue polling or report error on failed receive
fixes #1277

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1260>
2020-06-03 09:31:42 +00:00
Jan Alexander Steffens (heftig)
a1bc9d4319 srt: Make logging regarding callers more useful
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1273>
2020-06-03 04:23:14 +00:00
Jan Schmidt
918ed75944 srt: Don't leak the connection_poll_id on close()
Attempting to reach an inactive SRT peer in caller mode
was leaking an fd every few seconds in the gst_srt_object_close()/open()
loop.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1293>
2020-05-24 10:47:59 +00:00
J. Kim
4ccaa1ebbb srtobject: add streamid property
The stream id starts with '#!::' according to SRT Access Control[1],
but GstURI requires URI encoded string.This commit introduces additional
property to set the id by normal string.

[1] https://github.com/Haivision/srt/blob/master/docs/AccessControl.md
2020-05-13 14:13:48 +00:00
krivoguzovVlad
b769af0c4f Update gstsrtobject.c
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/999>
2020-04-30 18:57:13 +00:00
Jan Alexander Steffens (heftig)
97c05d3f4b
srt: Accumulate total bytes sent/received over all connections/callers
So we don't lose them. Split gst_srt_object_open_internal for internal
reconnections that don't reset the accumulated bytes.
2020-04-15 10:42:48 +02:00
Jan Alexander Steffens (heftig)
d19b3fccb5
srt: Fix type of bytes-received-lost
The field is a uint64_t.
2020-04-15 10:42:47 +02:00
Jan Alexander Steffens (heftig)
132e3a1af9
srt: Remove use of closures for signal emission
It seems overly complicated.
2020-04-15 10:42:47 +02:00
Jan Alexander Steffens (heftig)
d2d00e07ac
srt: Clean up locking
Use GST_OBJECT_LOCK (srtobject->element) to protect only the fields
involved in property access.

Introduce a new mutex srtobject->sock_lock to go with
srtobject->sock_cond and protect the list of callers from concurrent
access.
2020-04-15 10:42:47 +02:00
Jan Alexander Steffens (heftig)
37ee389913
srt: Remove trailing whitespace 2020-04-15 10:42:47 +02:00
J. Kim
04f3f4be4f srtobject: fix mutex lock target
GstSRTObject is a structure that has an actual GstElement
which is extended to srt{src,sink}.
2020-04-13 15:23:46 +09:00
Francisco Javier Velázquez-García (francisv)
c7fe1e8164 gstsrtsink: Add wait-for-connection property to srtsink
Add `wait-for-connection` property to `srtsink` element.  This
property allows the element to process packets even when no clients
are connected.
2019-12-19 19:46:47 +00:00
Jakub Adam
19391ae4c7 srtobject: allow passing SRT Stream ID in stream URI
Based on Stream ID, the application can accept or reject the connection,
select the desired data stream, or set an appropriate passphrase for the
connection. Example usage:

  srt://127.0.0.1:1234?streamid=mystream
2019-11-20 17:09:34 +00:00
Justin Kim
e6847b6d29 srt: split incoming buffer up into srt chunk 2019-11-06 13:14:26 +00:00
Aaron Boxer
6d3429af34 documentation: fixed a heap o' typos 2019-11-05 09:11:25 -05:00
Olivier Crête
fa842f2156 srt: Set latency property on SRT socket 2019-08-27 22:31:50 +00:00
Olivier Crête
177f1f95e1 srt: Add sender side statistics 2019-08-27 22:31:50 +00:00
Olivier Crête
54dc0b5579 srtobject: Remove pointless GMainLoop
Just use srt's blocking epoll function and fix locking while we're at it.
2019-08-27 22:31:50 +00:00
Olivier Crête
15f2cdd750 srt: Remove msg-size property
Remove the now unused property
2019-07-08 16:00:51 -04:00
Olivier Crête
42fa4cb2ad srtsrc: Receive one frame per gstbuffer
Don't aggregate the received data, just receive it one packet at a
time. So it keeps the packetization boundaries
2019-07-08 16:00:51 -04:00
Nicolas Dufresne
1acd9c726a srt: Fix listener crash if no URI is specified 2019-07-08 13:52:48 -04:00