Commit graph

1771 commits

Author SHA1 Message Date
Thibault Saunier
11f4fe79d7 doc: Require hotdoc >= 0.11.0 2020-06-03 18:36:25 -04:00
Sebastian Dröge
6482651caf docs: Update gst_plugins_cache.json 2020-05-30 23:25:53 +03:00
Sebastian Dröge
1a99533be8 plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-05-30 23:25:53 +03:00
Tim-Philipp Müller
b61f1081b2 meson: gir: remove bogus sources_top_dir kwarg
Doesn't actually exist. Was fixed differently in Meson
so that the user doesn't have to specify it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/127>
2020-05-27 23:39:37 +01:00
Tim-Philipp Müller
a33e756d2c tests: put registry into tests/check not the gst/ subdir
Underscorify the test name before setting GST_REGISTRY,
so the registry actually ends up in the current build dir
and not some subdir.

For consistency with the other modules, but should also
avoid problems on windows.

Also fix indentation of environment block.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/126>
2020-05-27 17:40:38 +00:00
Tim-Philipp Müller
f9348a5e69 tests: fix meson test env setup to make sure we use the right gst-plugin-scanner
If core is built as a subproject (e.g. as in gst-build), make sure to use
the gst-plugin-scanner from the built subproject. Without this, gstreamer
might accidentally use the gst-plugin-scanner from the install prefix if
that exists, which in turn might drag in gst library versions we didn't
mean to drag in. Those gst library versions might then be older than
what our current build needs, and might cause our newly-built plugins
to get blacklisted in the test registry because they rely on a symbol
that the wrongly-pulled in gst lib doesn't have.

This should fix running of unit tests in gst-build when invoking
meson test or ninja test from outside the devenv for the case where
there is an older or different-version gst-plugin-scanner installed
in the install prefix.

In case no gst-plugin-scanner is installed in the install prefix, this
will fix "GStreamer-WARNING: External plugin loader failed. This most
likely means that the plugin loader helper binary was not found or
could not be run. You might need to set the GST_PLUGIN_SCANNER
environment variable if your setup is unusual." warnings when running
the unit tests.

In the case where we find GStreamer core via pkg-config we use
a newly-added pkg-config var "pluginscannerdir" to get the right
directory. This has the benefit of working transparently for both
installed and uninstalled pkg-config files/setups.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/126>
2020-05-27 17:40:38 +00:00
Tim-Philipp Müller
92215f2f37 tests: gst-plugins-base and -bad plugins are required for the unit tests
Make hard requirement until we have more fine-grained control
in the unit tests. Of course the presence of the .pc file doesn't
imply that the plugins we need are actually there, but it's at
least a step in the right direction.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/126>
2020-05-27 17:40:38 +00:00
Tim-Philipp Müller
fe5d29ee3f tests: pick up rtsp-server plugins from build directory only
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/126>
2020-05-27 17:40:38 +00:00
Ludvig Rappe
ae58f7d771 rtsp-media: wait for all GstRTSPStreamBlocking messages
Make sure rtsp-media have received a GstRTSPStreamBlocking message from
each active stream when checking if all streams are blocked.

Without this change there will be a race condition when using two or
more streams and rtsp-media receives a GstRTSPStreamBlocking message
from one of the streams. This is because rtsp-media then checks if all
streams are blocked by calling gst_rtsp_stream_is_blocking() for each
stream. This function call returns TRUE if the stream has sent a
GstRTSPStreamBlocking message, however, rtsp-media may have yet to
receive this message. This would then result in that rtsp-media
erroneously thinks it is blocking all streams which could result in
rtsp-media changing state, from PREPARING to PREPARED. In the case of a
preroll, this could result in that rtsp-media thinks that the pipeline
is prerolled even though that might not be the case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/124>
2020-05-27 16:35:49 +00:00
Ludvig Rappe
0526a5c9bb rtsp-media: update expected_async_done during suspend
Set expected_async_done to FALSE in default_suspend() if a state change
occurs and the return value from set_target_state() is something other
than GST_STATE_CHANGE_ASYNC.

Without this change there is a risk that expected_async_done will be
TRUE even though no asynchronous state change is taking place. This
could happen if the pipeline is set to PAUSED using
media_set_pipeline_state_locked(), an asynchronous state change starts
and then the media is suspended (which could result in a state change,
aborting the asynchronous state change). If the media is suspended
before the asynchronous state change ends then expected_async_done will
be TRUE but no asynchronous state change is taking place.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/123>
2020-05-27 15:23:04 +00:00
Kristofer Björkström
ba7d568bb3 rtsp-client: Fix race condition in rtsp ctrl timeout by WeakRef client
There was a race condition where client was being finalized and
concurrently in some other thread the rtsp ctrl timout was relying on
client data that was being freed.
When rtsp ctrl timeout is setup, a WeakRef on Client is set.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/121>
2020-05-27 15:31:34 +02:00
Gregor Boirie
6459a61e8f media-factory: complete DSCP QoS setting support
add dscp_qos setting support at factory and media level to setup IP DSCP
field of bounded UDP sinks.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/issues/6

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/120>
2020-05-18 11:12:00 +03:00
Sebastian Dröge
5d8abd9bfd rtsp-client: Fix some race conditions around timeout source removal
We always need to take the lock while accessing it as otherwise another
thread might've removed it in the meantime. Also when destroying and
creating a new one, ensure that the mutex is not shortly unlocked in
between as during that time another one might potentially be created
already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/119>
2020-05-14 11:07:46 +03:00
Sebastian Dröge
8052957c24 rtsp-media: Mark out parameters accordingly in gst_rtsp_media_get_rates()
And the same for gst_rtsp_stream_get_rates().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/118>
2020-05-03 13:31:37 +00:00
Tim-Philipp Müller
f0928c5c1f examples: test-onvif-server: fix compiler warnings on raspbian
Fix printf format for 64-bit variables.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/117>
2020-05-03 11:54:17 +01:00
Sebastian Dröge
65bfa84d7a rtsp-stream-transport: Fix accidental API/ABI breakage with message_sent callbacks
The old API is preserved now and new API was added that provides the
additional parameter to the callback.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/issues/104

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/116>
2020-05-01 10:45:45 +03:00
Sebastian Dröge
e7802c1be7 rtsp-client: Store the timeout source by pointer instead of id
That way we don't have to retrieve it again from the main context when
destroying it but can directly do so.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/115>
2020-04-28 23:33:49 +03:00
Sebastian Dröge
4188dbb99b rtsp-client: Clean up watch/watch context and related state consistently
And assert that it was cleaned up properly before the client is
finalized. If something is still around when the client is shut down
then something went very wrong before.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/115>
2020-04-28 23:16:18 +03:00
Sebastian Dröge
680ddb9fd3 rtsp-client: Combine the pre-session and post-session timeout
They previously used the same state but different mechanisms and
functions, which was difficult to follow, error prone and simply
confusing.

Also adjust the test for the post-session timeout a bit to be less racy
now that the timing has slightly changed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/115>
2020-04-28 11:12:30 +03:00
Sebastian Dröge
d33057a031 rtsp-client: Don't ever close the client connection directly when a session is torn down
There might be other sessions that are running over the same RTSP
connection and we should not simply close the client directly if one of
them is torn down.

By default the connection will be closed once the client closes it or
the OS does. This behaviour can be adjusted with the
post-session-timeout property, which allows to close it automatically
from the server side after all sessions are gone and the given timeout
is reached.

This reverts the previous commit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/115>
2020-04-28 11:12:30 +03:00
Sebastian Dröge
f2b82c28a3 rtsp-client: If the TEARDOWN response can be sent directly, directly close the client
Instead of closing it never at all. Previously there was only code that
closed the client asynchronously if sending the response happened
asynchrously at a later time.

Thanks to Christian M for debugging this issue.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/issues/102

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/114>
2020-04-27 13:53:22 +03:00
Michael Olbrich
a696d980b5 rtsp-stream: use mcast_udpsink[0] last-sample if available for rtpinfo
Otherwise no sink is found for multicast sreams and the less accurate
fallback is used to determine the current sequence number and timestamp.
2020-03-30 16:57:05 +02:00
Sebastian Dröge
44ccca3086 rtsp-auth: Fix NULL pointer dereference when handling an invalid basic Authorization header
When using the basic authentication scheme, we wouldn't validate that
the authorization field of the credentials is not NULL and pass it on
to g_hash_table_lookup(). g_str_hash() however is not NULL-safe and will
dereference the NULL pointer and crash.
A specially crafted (read: invalid) RTSP header can cause this to
happen.

As a solution, check for the authorization to be not NULL before
continuing processing it and if it is simply fail authentication.

This fixes CVE-2020-6095 and TALOS-2020-1018.

Discovered by Peter Wang of Cisco ASIG.
2020-03-23 16:06:43 +02:00
Göran Jönsson
daa18dc867 rtsp-client: Use watch_context before unref
Move the usage of priv->watch_context to beginning of function
gst_rtsp_client_finalize. Instead of use it after
g_main_context_unref (priv->watch_context).
2020-03-09 14:17:34 +01:00
Mathieu Duponchelle
8410c69da9 rtsp-stream: fix deadlock on transport removal
We cannot take the RTSPStream lock while holding a transport backlog
lock, as remove_transport may be called externally, which will
take first the RTSPStream lock then the transport backlog lock.
2020-02-24 20:24:29 +00:00
Mathieu Duponchelle
fa41cbe9a4 rtsp-stream: clear backlog when removing transport
This ensures we don't end up calling any of transports' callbacks
with a potentially unreffed user_data (in practice, a client that
may have been removed)
2020-02-24 20:24:29 +00:00
Mathieu Duponchelle
54b6b3bcab rtsp-stream: marshal calls to send_tcp_message to a single thread
In order to address the race condition pointed out at
https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/108#note_403579
we get rid of the send thread pool, and instead spawn and manage
a single thread to pull samples from app sinks and add them to
the transport's backlogs.

Additionally, we now also always go through the backlogs in order
to simplify the logic.
2020-02-24 20:24:29 +00:00
Mathieu Duponchelle
50ecbb1596 rtsp-stream: properly protect TCP backlog access
Fixes #97

We cannot hold stream->lock while pushing data, but need
to consistently check the state of the backlog both from
the send_tcp_message function and the on_message_sent function,
which may or may not be called from the same thread.

This commit introduces internal API to allow for potentially
recursive locking of transport streams, addressing a race
condition where the RTSP stream could push items out of order
when popping them from the backlog.
2020-02-24 20:24:29 +00:00
Sebastian Dröge
a2ba3639a5 rtsp-media: Sink pipeline in gst_rtsp_media_take_pipeline()
It's taken ownership of by the media, and returned with `transfer none`
from the GstRTSPMedia::create_pipeline() vfunc. If we don't sink it
first then any bindings will wrongly take ownership of the pipeline once
it arrives in bindings code.
2020-02-22 00:43:31 +02:00
Bastian Bouchardon
c1ca88cd34 Add initialization for context and params (gchar *)
Insert define (DEFAULT_*) into help to have to modify only the constants
2020-02-07 17:55:09 +01:00
Marc Leeman
7b5dbb0561 rtsp-media: fix default latency 2020-02-03 12:30:14 +00:00
Mathieu Duponchelle
90f7e851f4 rtsp-client: make closing more thread safe
+ Take the watch lock prior to using priv->watch
+ Flush both the watch and connection before closing / unreffing

gst_rtsp_connection_close() is not threadsafe on its own, this is
a workaround at the client level, where we control both the watch
and the connection
2020-01-23 18:08:21 +00:00
Jordan Petridis
b4948f69a0
rtsp-latency-bin: replace G_TYPE_INSTANCE_GET_PRIVATE as it's been deprecated
from glib
```
Deprecated: 2.58: Use %G_ADD_PRIVATE and the generated
  `your_type_get_instance_private()` function instead
```
2020-01-23 17:00:59 +02:00
Zoltán Imets
aa8126b239 rtsp-client: add property post-session-timeout
This is a TCP connection timeout for client connections, in seconds.
If a positive value is set for this property, the client connection
will be kept alive for this amount of seconds after the last session
timeout. For negative values of this property the connection timeout
handling is delegated to the system (just as it was before).

Fixes #83
2020-01-15 11:47:27 +00:00
Mark Nauwelaerts
0ed32e0d53 rtsp-stream: check for NULL transports prior to ref'ing 2020-01-11 22:58:48 +01:00
Mathieu Duponchelle
e0a4355d6b rtsp-stream: fix checking of TCP backpressure
The internal index of our appsinks, while it can be used to
determine whether a message is RTP or RTCP, is not necessarily
the same as the interleaved channel. Let the stream-transport
determine the channel to check backpressure for, the same way
it determines the channel according to whether it is sending
RTP or RTCP.
2020-01-09 14:10:44 +01:00
Olivier Crête
73b4929803 rtsp-session: Butcher the file to please gst-indent in the CI
This should be reverted once the CI has an updated gst-indent.
2019-12-18 19:48:31 +00:00
Olivier Crête
75b03ddf5e rtsp-session & client: Remove deprecated GTimeVal
GTimeVal won't work past 2038
2019-12-18 19:48:31 +00:00
Nicola Murino
a547e2b3c8 rtsp-auth: fix default token leak 2019-12-12 17:56:18 +01:00
Adam x Nilsson
8d4a9f37e5 gstrtspclientsink: unref transports when closing bin
Fixes #91
2019-12-10 10:27:07 +01:00
Kristofer Bjorkstrom
faf8f87a02 rtsp-media: Force seek when flush flag is set
The commit "rtsp-client: define all seek accuracy flags from
setup_play_mode" changed the behaviour of when doing a seek.

Before that commit, having the flush flag set would result in a seek
(forced seek).
Even if no seek was needed. One reason to force seek is to flush old buffers
created in Describe requests.

Thus adding force seek also for flush flag will result in play request
with fresh buffers.
2019-12-06 14:52:23 +01:00
Edward Hervey
8de843733d rtsp-client: Revitalize dead code
Leftover from 65d9aa327c

CID: 1455379
2019-12-02 10:46:40 +01:00
Edward Hervey
5ceb2cf83f rtsp-sdp: Don't try to use non-initialized values
Only attempt to use the various timing values iif gst_rtsp_stream_get_info()
returns TRUE. Also avoid the whole clock signalling block if we're not
dealing with senders.

CID: 1439524
CID: 1439536
CID: 1439520
2019-11-27 15:27:36 +01:00
Adam x Nilsson
9c5ca231a6 rtsp-stream: Removing invalid transports returns false
When removing transports an assertion was that the transports passed in
for removal are present in the list, however that can't be assumed.
As an example if a transport was removed from a thread running
send_tcp_message, the main thread can try to remove the same transport
again if it gets a handle_pause_request. This will not effect the
transport list but it will effect n_tcp_transports as it will be
decrement and then have the wrong value.
2019-11-25 19:12:10 +01:00
Zoltán Imets
c2d182de05 client test: add scale and speed negative tests
Negative tests for scale and speed should be done as well, verify that
the response code is "400 Bad request" when a bad request is done.
2019-11-12 09:56:39 +01:00
Niels De Graef
45e77ecdd7 Don't pass default GLib marshallers for signals
By passing NULL to `g_signal_new` instead of a marshaller, GLib will
actually internally optimize the signal (if the marshaller is available
in GLib itself) by also setting the valist marshaller. This makes the
signal emission a bit more performant than the regular marshalling,
which still needs to box into `GValue` and call libffi in case of a
generic marshaller.

Note that for custom marshallers, one would use
`g_signal_set_va_marshaller()` with the valist marshaller instead.
2019-11-04 14:16:10 +00:00
Xavier Claessens
f7bbd9dd86 GstRTSPMountPoints: Remove any existing factory before adding a new one
The documentation of gst_rtsp_mount_points_add_factory() says "Any
previous mount point will be freed" which was true when it was
implemented using a GHashTable. But in 2012 it got rewrote using a
GSequence and since then it could have 2 factories for the same path.
Which one gets used is random, depending on the sorting order of 2
identical items.
2019-11-04 12:01:09 +00:00
Mathieu Duponchelle
dd32924eb0 stream: refactor TCP backpressure handling
The previous implementation stopped sending TCP messages to
all clients when a single one stopped consuming them, which
obviously created problems for shared media.

Instead, we now manage a backlog in stream-transport, and slow
clients are removed once this backlog exceeds a maximum duration,
currently hardcoded.

Fixes #80
2019-10-21 13:49:54 +02:00
Tim-Philipp Müller
95ce953e34 meson: build gir even when cross-compiling if introspection was enabled explicitly
This can be made to work in certain circumstances when
cross-compiling, so default to not building g-i stuff
when cross-compiling, but allow it if introspection was
enabled explicitly via -Dintrospection=enabled.

See gstreamer/gstreamer#454 and gstreamer/gstreamer#381.
2019-10-18 08:30:59 +00:00
Göran Jönsson
d519f47402 rtsp-session: clean up comment extra-timeout 2019-10-18 09:19:59 +02:00