Commit graph

327 commits

Author SHA1 Message Date
Göran Jönsson
16bc937ed9 Use complete streams for scale and speed.
Without this patch it's always stream0 that is used to get segment event
that is used to set scale and speed. This even if client not doing SETUP
for stream0. At least in suspend mode reset this not working since then
it's just random if send_rtp_sink have got any segment event. There are
no check if send_rtp_sink for stream0 got any data before media is
prerolled after PLAY request.
2019-08-29 07:15:37 +02:00
Mathieu Duponchelle
7073ade1a6 rtsp-media: add missing Since tag 2019-08-12 16:09:02 +00:00
Mathieu Duponchelle
72504eee99 rtsp-client: define all seek accuracy flags from setup_play_mode
We then pass those to adjust_play_mode, which needs to operate
on the "final" seek flags, as previously the code in rtsp-media
was assuming that accuracy seek flags (accurate / key_unit) should
not be set if the flags passed to the seek method were already set.
2019-08-07 18:04:03 +02:00
Sebastian Dröge
446315b36c rtsp-media: Try to get dynamic payloaders by name from their bin first
First try "pay", then "pay_%s" (where %s == pad name). And only then
fall back to the code that simply takes the first payloader that is
found.

The current code usually works (but is racy) because it will always take
the payloader that was last added (due to g_list_prepend() when adding
elements) in pad-added and that's usually the correct one. But if a new
payloader is added between pad-added and us trying to get it, we would
get the wrong payloader.
2019-07-22 19:44:28 +03:00
Mathieu Duponchelle
ab37286300 rtsp-media: make sure streams are blocked when sending seek
The recent ONVIF work exposed a race condition when dealing with
multiple streams: one of the sinks may preroll before other streams
have started flushing. This led to the pipeline posting async-done
prematurely, when some streams were actually still in the middle
of performing a flushing seek. The newly-added code looks up a
sticky segment event on the first stream in order to respond to
the PLAY request with accurate Scale and Speed headers. In the
failure condition, the first stream was flushing, and thus had
no sticky segment event, leading to the PLAY request failing,
and in turn the test.
2019-06-12 22:19:27 +02:00
Mathieu Duponchelle
0f498eabf4 onvif: Implement and test the Streaming Specification
https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf
2019-06-06 18:45:17 +02:00
Nikita Bobkov
f31f79f60e Reverse playback support
GStreamer plays segment from stop to start when doing reverse playback.
RTSP implies that media should be played from start of Range header to
its stop. Hence we swap start and stop times before passing them to
gst_element_seek.

Also make gst_rtsp_stream_query_stop always return value that can be
used as stop time of Range header.
2019-06-04 14:32:51 +02:00
Branko Subasic
bc74589601 rtsp-client: add support for Scale and Speed header
Add support for the RTSP Scale and Speed headers by setting the rate in
the seek to (scale*speed). We then check the resulting segment for rate
and applied rate, and use them as values for the Speed and Scale headers
respectively.

https://bugzilla.gnome.org/show_bug.cgi?id=754575
2019-06-04 14:32:51 +02:00
Branko Subasic
421ac85150 rtsp-media: allow specifying rate when seeking
Add new function gst_rtsp_media_seek_full_with_rate() which allows the
caller to specify the rate for the seek. Also added functions in
rtsp-stream and rtsp-media for retreiving current rate and applied rate.

https://bugzilla.gnome.org/show_bug.cgi?id=754575
2019-06-04 14:32:51 +02:00
Sebastian Dröge
8d3bef4c1e rtsp-server: Add various Since: 1.14 markers 2019-04-23 15:01:32 +03:00
Sebastian Dröge
802a648723 rtsp-server: Add various missing Since: 1.16 markers 2019-04-23 14:56:42 +03:00
Göran Jönsson
1fd49d36d1 rtsp-media: Handle set state when preparing.
Handle the situation when  a call to gst_rtsp_media_set_state is done
when media status is preparing.

Also add unit test for this scenario.

The unit test simulate on a media level when two clients share a (live)
media.
Both clients have done SETUP and got responses. Now client 1 is doing
play and client 2 is just closing the connection.

Then without patch there are a problem when
client1 is calling gst_rtsp_media_unsuspend in handle_play_request.
And client2 is doing closing connection we can end up in a call
to gst_rtsp_media_set_state when
priv->status == GST_RTSP_MEDIA_STATUS_PREPARING and all the logic for
shut down media is jumped over .

With this patch and this scenario we wait until
priv->status == GST_RTSP_MEDIA_STATUS_PREPARED and then continue to
execute after that and now we will execute the logic for
shut down media.
2019-03-20 12:26:50 +01:00
Göran Jönsson
7e01dfd151 rtsp-media: Fix multicast use case with common media
Use case
client 1: SETUP
client 1: PLAY
client 2: SETUP
client 1: TEARDOWN
client 2: PLAY
client 2: TEARDOWN
2019-02-19 12:12:34 +01:00
Sebastian Dröge
d708f9736b rtsp-server: Add support for buffer lists
This adds new functions for passing buffer lists through the different
layers without breaking API/ABI, and enables the appsink to actually
provide buffer lists.

This should already reduce CPU usage and potentially context switches a
bit by passing a whole buffer list from the appsink instead of
individual buffers. As a next step it would be necessary to
  a) Add support for a vector of data for the GstRTSPMessage body
  b) Add support for sending multiple messages at once to the
    GstRTSPWatch and let it be handled internally
  c) Adding API to GOutputStream that works like writev()

Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/issues/29
2019-01-30 14:39:50 +02:00
Lars Wiréen
ae32203cb0 rtsp-media: Fix race codition in finish_unprepare
The previous fix for race condition around finish_unprepare where the
function could be called twice assumed that the status wouldn't change
during execution of the function. This assumption is incorrect as the
state may change, for example if an error message arrives from the
pipeline bus.

Instead a flag keeping track on whether the finish_unprepare function
is currently executing is introduced and checked.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/issues/59
2019-01-25 12:44:23 +00:00
Patricia Muscalu
4370f3a901 rtsp-media: Update priv->blocked when linked streams are unblocked.
Media is considered to be blocked when all streams that belong to
that media are blocked.
This patch solves the problem of inconsistent updates of
priv->blocked that are not synchronized with the media state.
2018-11-19 11:35:26 +00:00
Patricia Muscalu
146b3da174 rtsp-media: Don't block streams before seeking
Before the seek operation is performed on media, it's required that
its pipeline is prepared <=> the pipeline is in the PAUSED state.
At this stage, all transport parts (transport sinks) have been successfully
added to the pipeline and there is no need for blocking the streams.
2018-11-19 11:35:26 +00:00
Patricia Muscalu
c394de2348 New property for socket binding to mcast addresses
By default the multicast sockets are bound to INADDR_ANY,
as it's not allowed to bind sockets to multicast addresses
in Windows. This default behaviour can be changed by setting
bind-mcast-address property on the media-factory object.

https://bugzilla.gnome.org/show_bug.cgi?id=797059
2018-09-28 13:27:48 +03:00
Tim-Philipp Müller
62d4c0b179 libs: fix API export/import and 'inconsistent linkage' on MSVC
Export rtsp-server library API in headers when we're building the
library itself, otherwise import the API from the headers.

This fixes linker warnings on Windows when building with MSVC.

Fix up some missing config.h includes when building the lib which
is needed to get the export api define from config.h

https://bugzilla.gnome.org/show_bug.cgi?id=797185
2018-09-24 09:36:21 +01:00
Patricia Muscalu
a7bb684e9b Add new API for setting/getting maximum multicast ttl value
Change-Id: I5ef4758188c14785e17fb8fbf42a3dc0cb054233

https://bugzilla.gnome.org/show_bug.cgi?id=793441
2018-08-14 14:31:41 +03:00
Sebastian Dröge
443c2b73e5 Revert "Add new API for setting/getting maximum multicast ttl value"
This reverts commit 7f0ae77e40.

Commits where accidentially squashed together
2018-08-14 14:25:42 +03:00
Patricia Muscalu
7f0ae77e40 Add new API for setting/getting maximum multicast ttl value
https://bugzilla.gnome.org/show_bug.cgi?id=793441
2018-08-14 14:10:20 +03:00
Carlos Rafael Giani
12c2dd6e1c rtsp-media: unref clock (if set) when finalizing
https://bugzilla.gnome.org/show_bug.cgi?id=796814
2018-07-16 23:56:09 +01:00
Tim-Philipp Müller
2eb4d1b810 Update for g_type_class_add_private() deprecation in recent GLib 2018-06-24 12:48:11 +02:00
Tim-Philipp Müller
e82ba1e52f Fix indentation 2018-06-24 12:45:49 +02:00
Patricia Muscalu
768fb5695c Get payloader stats only for the sending streams
Get/set payloader properties only for streams that actually
contain a payloader element.

https://bugzilla.gnome.org/show_bug.cgi?id=796523
2018-06-13 10:13:12 +03:00
Mathieu Duponchelle
bfc35ae1ae Implement support for ULP Forward Error Correction
In this initial commit, interface is only exposed for RECORD,
further work will be needed in rtspsrc to support this for
PLAY.

https://bugzilla.gnome.org/show_bug.cgi?id=794911
2018-04-19 18:25:31 +02:00
Sebastian Dröge
ef878da703 gst: Run everything through gst-indent again 2018-04-04 10:06:06 +03:00
Branko Subasic
48ad01beba rtsp-media: query the position on active streams if media is complete
If the media is complete, i.e. one or more streams have been configured
with sinks, then we want to query the position on those streams only.
A query on an incomplete stream may return a position that originates from
an earlier preroll.

https://bugzilla.gnome.org/show_bug.cgi?id=794964
2018-04-04 10:05:38 +03:00
Mathieu Duponchelle
988db52016 rtsp-server: add API to enable retransmission requests
"do-retransmission" was previously set when rtx-time != 0,
which made no sense as do-retransmission is used to enable
the sending of retransmission requests, where as rtx-time
is used by the peer to enable storing of buffers in order
to respond to retransmission requests.

rtsp-media now also provides a callback for the
request-aux-receiver signal.

https://bugzilla.gnome.org/show_bug.cgi?id=794822
2018-03-30 17:55:32 +02:00
Carlos Rafael Giani
5f29712243 rtsp-media: Replace g_print() log line
https://bugzilla.gnome.org/show_bug.cgi?id=793838
2018-02-26 15:26:29 +02:00
Mathieu Duponchelle
ddb0d83844 rtsp-media: fix RECORD getting stuck
The test_record case was working because async=false had
been added in https://bugzilla.gnome.org/show_bug.cgi?id=757488
but that was incorrect, as it should not be needed.

Removing async=false made the test fail as expected, this is
fixed by not trying to preroll when preparing the media for
RECORD, as start_prepare is called upon receiving ANNOUNCE,
and our peer will not start sending media until it has received
a response to that request, and sent and received a response
to RECORD as well, thus obviously preventing preroll.

https://bugzilla.gnome.org/show_bug.cgi?id=793738
2018-02-23 16:13:56 +01:00
Ognyan Tonchev
14c511ae62 stream: Add functions for checking if stream is receiver or sender
...and replace all checks for RECORD in GstRTSPMedia which are really
for "sender-only". This way the code becomes more generic and introducing
support for onvif-backchannel later on will require no changes in
GstRTSPMedia.
2018-02-16 11:04:53 +02:00
Sebastian Dröge
231700b2bb rtsp-media: Add support for sending+receiving medias
We need to add an appsrc/appsink in that case because otherwise the
media bin will be a sink and a source for rtpbin, causing a pipeline
loop.

https://bugzilla.gnome.org/show_bug.cgi?id=788950
2018-02-16 11:04:53 +02:00
Mathieu Duponchelle
ee44f38051 set_clock functions: Add nullable annotations 2018-02-13 18:59:49 +01:00
Mathieu Duponchelle
c725ef01a4 All around: add annotations and API guards 2018-02-12 19:16:11 +01:00
Edward Hervey
64a46d47ba rtsp-server: Minor doc fixes
Mostly for g-i
2017-12-07 16:08:50 +01:00
Patricia Muscalu
0015791f8f rtsp-media: Fix missing lock in gst_rtsp_media_seekable()
https://bugzilla.gnome.org/show_bug.cgi?id=790674
2017-11-27 07:58:42 +01:00
Edward Hervey
9514f2d354 rtsp-media: Enable seeking query before pipeline is complete
SDP are now provided *before* the pipeline is fully complete. In order
to know whether a media is seekable or not therefore requires asking
the invididual streams.

API: gst_rtsp_stream_seekable

https://bugzilla.gnome.org/show_bug.cgi?id=790674
2017-11-25 07:53:11 +01:00
Patricia Muscalu
bb29d2e2ee rtsp-media: Fix handling in default_unsuspend()
Handle the case when streams are not blocked and media
is suspended from PAUSED.

Change-Id: I2f3d222ea7b9b20a0732ea5dc81a32d17ab75040

https://bugzilla.gnome.org/show_bug.cgi?id=790674
2017-11-24 10:52:36 +01:00
Patricia Muscalu
132e00adfd rtsp-media: Removed fakesink elements
There is not need of adding fakesink elements to the media
pipeline in the dynamic-payloader case.
The media pipeline itself is dynamically updated with
the receiver and sender parts that are based on the client
transport information known after SETUP has been received.

Change-Id: I4e88c9b500c04030669822f0d03b1842913f6cb9

https://bugzilla.gnome.org/show_bug.cgi?id=790674
2017-11-24 10:52:36 +01:00
Patricia Muscalu
ac6169d50a rtsp-media: Corrected ASYNC_DONE handling
Media is complete when all the transport based parts are
added to the media pipeline. At this point ASYNC_DONE is
posted by the media pipeline and media is ready to enter
the PREPARED state.

Change-Id: I50fb8dfed88ebaf057d9a35fca2d7f0a70e9d1fa

https://bugzilla.gnome.org/show_bug.cgi?id=790674
2017-11-24 10:52:36 +01:00
Edward Hervey
6371f2fc29 rtsp-media: Don't unblock with remaining dynamic payloaders
If we still have some dynamic paylaoders which haven't posted
no-more-pads yet, don't go to PREPARED if one of the streams
blocked.

The risk was that we would end up not exposing/using all specified
streams.

The downside is that if you have _multiple_ _live_ _dynamic_ payloaders
then it will take a bit more time to start. But only if those 3
conditions are present.

https://bugzilla.gnome.org/show_bug.cgi?id=769521
2017-11-21 07:59:15 +01:00
Edward Hervey
d1a6418fe2 rtsp-media: Fix doc 2017-11-21 07:59:15 +01:00
Edward Hervey
0dddaba9bb rtsp-media: Don't set float on a gint64 variable
Just use 0. Fixes 'undefined' behaviour from clang
2017-11-21 07:59:15 +01:00
Edward Hervey
27d256d4ca rtsp-media: Fix previous commit
We only want to count dynamic payloaders
2017-11-21 07:59:15 +01:00
Edward Hervey
2386e91c36 rtsp-media: Handle multiple dynamic elements
If we have more than one dynamic payloader in the pipeline, we need
to wait until the *last* one emits 'no-more-pads' before switching
to PREPARED.

Failure to do so would result in a race where some of the streams
wouldn't properly be prepared

https://bugzilla.gnome.org/show_bug.cgi?id=769521
2017-11-20 09:38:49 +01:00
Patricia Muscalu
efdb795c86 rtsp-media: seek on media pipelines that are complete
Make sure that a seek is performed on pipelines that
contain at least one sink element.

Change-Id: Icf398e10add3191d104b1289de612412da326819

https://bugzilla.gnome.org/show_bug.cgi?id=788340
2017-11-15 19:56:26 +02:00
Patricia Muscalu
a7732a68e8 Dynamically reconfigure pipeline in PLAY based on transports
The initial pipeline does not contain specific transport
elements. The receiver and the sender parts are added
after PLAY.
If the media is shared, the streams are dynamically
reconfigured after each PLAY.

https://bugzilla.gnome.org/show_bug.cgi?id=788340
2017-11-15 19:56:15 +02:00
Patricia Muscalu
b5c3ef8d53 rtsp-media: return minimum value in query position case
The minimum position should be returned as we are interested
in the whole interval.

Change-Id: I30e297fc040c995ae40c25dee8ff56321612fe2b

https://bugzilla.gnome.org/show_bug.cgi?id=788340
2017-11-15 17:46:00 +02:00