Commit graph

533 commits

Author SHA1 Message Date
Jan Schmidt
eb5b064145 splitmuxsink: Update tracked running time before first fragment-opened
Before sending the first fragment-opened message on the bus, update
the output_fragment_info structure so that the sent message correctly
reports the initial running time.

Fixes #3725

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7361>
2024-08-15 09:14:52 +00:00
Mathieu Duponchelle
bc39c0f54b rtspsrc: expose property for forcing usage of non-compliant URLs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7133>
2024-08-12 20:10:45 +00:00
Jan Schmidt
c1a1584dde splitmuxsrc: Don't create part reader elements initially
Only create the part reader elements internally the first time
the part is activated. Saves some startup time when preloading
a large number of fragments

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
8a1fab9594 splitmuxsrc: Drop lock when unpreparing parts
Parts may emit bus messages that want to take the splitmuxsrc
lock and prevent the downward state change. Avoid a deadlock
after a part sends an error message by taking a ref and
dropping the lock around the unprepare call

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
ec1c6c5b60 splitmuxsrc: Make sure to re-take lock
In the error path when activating a part fails, make
sure to re-take the splitmuxsrc lock before returning
to the caller.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
44005ab9fb splitmuxsink: Fix race in unit tests. Add fragment-id to messages
Publish fragment-id in the messages that splitmuxsink and splitmuxsrc
send, so when they are received out of order (due to async finalization,
for example), they can still be identified / ordered correctly.

Fix a race in the splitmuxsink unit test where messages might be
received out of order

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
356710f6fa splitmuxsrc: Document new properties and signals
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
64fd2b265f splitmuxsrc: Add num-lookahead property
Add a `num-lookahead` property that will 'prepare' a number of
fragments in advance of the playhead if they have been deactivated
or closed by a limited number of `num-open-fragments`. It can help
to avoid any play stalls reading the indexes or headers of the next
file from high-latency media or on resource limited machines.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
93c04e7473 splitmuxsrc: Rename some internal terminology
A part reader can be 'loaded' (prepared, but not currently outputting anything)
or 'playing' (actively being used to output data)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
3121eeeb08 splitmuxsrc: Allow adding fragments during playback
Trigger measurement / inclusion of new fragments into
the playback timeline if they are added after the
element is already running.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:12 +10:00
Jan Schmidt
ed03e8f8ab splitmuxsink: Add fragment offset and duration to message
Publish the playback offset for and duration into the
splitmuxsink-fragment-closed bus message as each fragment
finishes.

These can be passed to splitmuxsrc via the 'add-fragment'
signal to avoid splitmuxsrc measuring all files on startup

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:05 +10:00
Jan Schmidt
b0df6ee408 splitmuxsink: Fix a race in fragment switching with async handling
Only do output/muxer operations at the output side of splitmuxsink
to avoid races if fragments are small, by moving the RUNNING_TIME
qdata setting.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:05 +10:00
Jan Schmidt
eca97e7940 splitmuxsink: Refactor command queue buffer
Make the command struct a bit clearer by giving it an explicit
enum cmd_type instead of just a boolean to differentiate a
finish-fragment command from a release-gop command

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:05 +10:00
Jan Schmidt
bfdaae81f4 splitmuxsrc: Default to only keeping 100 files open
Add a reasonably large default for the number of simulataneous
files to open, that won't affect users that split recordings into
a few large files, but will help prevent fd exhaustion for users
that make recordings with lots of small fragments

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:04 +10:00
Jan Schmidt
1294264ab9 splitmuxsrc: Keep streams aligned during adjustments
When calculating the timestamp offset to apply to
media streams in a fragment, ensure that all fragments
are offset "together" to preserve alignment in cases
where there might gaps in a recording at a fragment boundary.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:04 +10:00
Jan Schmidt
682db96a41 splitmuxsrc: Add add-fragment signal and examples
Add a signal that allows adding fragments with a specific offset
and duration directly to splitmuxsrc's list. By providing the
fragment's offset on the playback timeline and duration directly,
splitmuxsrc doesn't need to measure the fragment making for faster
startup times.

Add a bus message that's published when fragments are measured,
reporting the offset and duration, so they can be cached by an
application and used on future invocations.

Add examples for handling the bus message and using the 'add-fragment'
signal.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:04 +10:00
Jan Schmidt
1821b52dd5 splitmuxsrc: Add num-open-fragments property
Add a property to limit the number of parts splitmux will open
simultaneously. Modify the part handling to support deactivating
and reactivating the demuxing for each part.

The default is '0', to preserve the existing behaviour of opening
all parts at the beginning.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:04 +10:00
Jan Schmidt
eeb5a42b5d splitmuxsrc: Report minimum timestamp for each media stream
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7053>
2024-08-02 15:30:04 +10:00
Sebastian Dröge
a786c85c4f taginject: Modify existing tag events of the selected scope
Not doing so would mean that tags would be overidden by any tag events sent by
upstream. Also only send a tag event directly if upstream never sent one.

By default use GST_TAG_MERGE_REPLACE to override tags that exist in both the
upstream event and this element with the ones from this element, but provide a
new "merge-mode" property to adjust the behaviour.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7145>
2024-07-10 13:00:34 +00:00
Sebastian Dröge
a36b3d9fcd taginject: Add getters for the properties
There's no reason why they should be write-only.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7145>
2024-07-10 13:00:34 +00:00
Sebastian Dröge
2ed84fe298 taginject: Use proper GType macro for the GstTagScope enum
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7145>
2024-07-10 13:00:33 +00:00
Tim-Philipp Müller
8d845d4a02 rtpdtmfsrc: minor logging clean-up
Only serialise event structure for debug logging purposes
if logging is actually enabled.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7060>
2024-06-19 07:32:49 +00:00
Tim-Philipp Müller
62047a9f8d rtpdtmfsrc: fix leak when shutting down mid-event
.. and update rtpdtmfdepay unit test to trigger
the potential leak more reliably (without the fix).

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3633

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7060>
2024-06-19 07:32:49 +00:00
Tim-Philipp Müller
ab61233f30 rtpdtmfdepay: fix caps negotiation with audioconvert
Specify "layout" field in src template to make sure it's
set and gets fixated properly if the downstream element
supports both interleaved and non-interleaved caps.

Fixes

  gst_pad_set_caps: assertion 'caps != NULL && gst_caps_is_fixed (caps)' failed

critical with e.g.

  gst-launch-1.0 rtpdtmfsrc ! rtpdtmfdepay ! audioconvert ! fakesink

Not that the layout really matters in our case since we always
output mono anyway, but non-interleaved requires adding AudioMeta,
so this is the easiest fix.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7036>
2024-06-18 00:11:28 +01:00
Mathieu Duponchelle
a20ef245a0 rtspsrc: fix invalid seqnum assertions
Upon fatal errors the loop function will first post an error message
then push out an EOS event.

An application may react immediately to the error message by setting the
state of the pipeline to NULL, meaning by the time we push out the EOS
event PAUSED_TO_READY may have reset the seek seqnum to -1.

While this is harmless, the assertion when setting an invalid seqnum
isn't tidy, fix this by simply not resetting to INVALID as it serves no
practical purpose and the next READY_TO_PAUSED will select a new seqnum
anyway.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7032>
2024-06-14 11:28:06 +02:00
Sebastian Dröge
441e71d1ff flvmux: Use GDateTime instead of gmtime()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6872>
2024-06-06 08:33:51 +00:00
Sebastian Dröge
9b60b32cf8 rtspsrc: Only update from the Content-Base header in the initial OPTION / DESCRIBE response
Some servers send a new content base in the SETUP response, which is
just the non-aggregate control URL of the individual streams.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3563

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6926>
2024-06-01 11:30:44 +00:00
Sebastian Dröge
e65344afac rtspsrc: Handle the case of * as session-wide control URL from the SDP
Just like the comment above says this is supposed to indicate that the
same URL should be used as for the connection so far. If encountering
this case simply do nothing.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6926>
2024-06-01 11:30:44 +00:00
Sebastian Dröge
e73e34fd6f rtspsrc: Also handle rtsps:// and similar URLs as absolute in other places
Previously a direct comparison with `rtsp://` was performed, which
didn't catch cases like `rtsps://`.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3563

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6926>
2024-06-01 11:30:44 +00:00
Sebastian Dröge
966c39b92e rtspsrc: Don't try the SETUP workaround for broken servers with absolute control URIs
Previously only control URIs that started with "rtsp://" were ignored
but it makes more sense to ignore all absolute URIs.

gst_uri_is_valid() conveniently checks for exactly that.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3563

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6926>
2024-06-01 11:30:43 +00:00
Seungha Yang
fd21d97060 qtdemux: Handle keyunit trick mode in case of push mode too
Skip non-keyframe video frames if trickmode-keyunit flag is set

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5900>
2024-05-31 11:21:55 +00:00
Seungha Yang
05f9eadcaf qtmux: Handle time information value > UINT32_MAX
If any duration in timescale is larger than UINT32_MAX, use version 1
atom, otherwise file header will be constructed with truncated values.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6843>
2024-05-28 16:09:58 +00:00
Sebastian Dröge
9156b373e6 rtpbin: Regularly emit the sync signal
Even if no new synchronization information is available.

This is necessary because the timestamp offset logic in rtpbin depends
on the base RTP time that is determined by the jitterbuffer, but this
changes all the time (especially in mode=slave) and the timestamp
offsets have to be updated accordingly. Doing so is especially important
if they're only determined by the RTP-Info, which never changes from the
very beginning.

The interval can be configured via the new min-sync-interval property.
Synchronization happens at least that often, but at most as often as the
old sync-interval property allows.
Both intervals are now based on the monotonic system clock.

Additionally, clean up synchronization code a bit, only emit either
inband NTP or RTCP SR synchronization at the same time, based on which
one has the more recent time information, and only emit RTP-Info
synchronization if it wasn't provided previously at the same time as the
NTP-based synchronization information.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:31 +00:00
Sebastian Dröge
df8c29e340 rtpjitterbuffer: Set max-rtcp-rtp-sync-time to -1 (disabled)
There is generally no requirement to ignore RTCP SR if the RTP time of
the SR differs a lot from the last received RTP packet. The mapping
between RTP and NTP time stays valid until there was a stream reset, in
which case we wouldn't use that information anyway.

When using rtcp-sync-send-time=false the default of 1s difference can
easily be exceeded, e.g. if encoding of the stream after capture adds
more than 1s of latency.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
95a0649945 rtpbin: Allow synchronizing against RTP-Info without having received any RTCP
Previously the information was provided from rtpjitterbuffer to rtpbin
only once the first RTCP SR was received, which is not necessary at all
as all required information is available from the caps already.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1162

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
8bfba72ea4 rtpbin: Add new never/ntp RTCP sync modes
Never is useful for some RTSP servers that report plain garbage both via
RTCP SR and RTP-Info, for example.

NTP is useful if synchronization should only ever happen based on RTCP
SR or NTP-64 RTP header extension.

Also slightly change the behaviour of always/initial to take RTP-Info
based synchronization into account too. It's supposed to give the same
values as the RTCP SR and is available earlier, so will generally cause
fewer synchronization glitches if it's made use of.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
158f12b5da rtpbin: Handle switches between RTP-Info and NTP-based stream association better
Instead of switching on the very first stream, require that all streams
have switched before switching to the different synchronization
mechanism.

Without this there will be a noticeable gap during the switch. E.g. when
going from RTP-Info to NTP-based association, first the first stream
only would get an offset, then the first two, ... then all of them.
Depending on the order of streams this will cause a lot of changes in
ts-offset during the transition.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
b30671a8ee rtpbin: Pass NPT start from rtpjitterbuffer to rtpbin
And use it to detect synchronization changes (e.g. seeks) more reliably
when doing RTP-Info based synchronization.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
3eb22af88b rtpbin: Clean up stream association state
Use fewer magic numbers and keep track of the different synchronization
mechanisms separately. Also keep track of more state to detect more
situations when resynchronization should happen.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
d8dabf142f rtpbin: Constify function parameters and use correct types
Previously these parameters were randomly changed in the body of the
function to avoid having to declare a new variable, which made the code
very hard to follow. By marking them as const this won't be possible
anymore in the future.

Also the RTP clock-base (RTP time from RTSP RTP-Info) is an unsigned
64 bit integer as it's an extended RTP timestamp.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
155c3fb3b2 rtpbin: Untangle NTP-based and RTP-Info based stream association
Both were entangled previously and very hard to follow what happens
under which conditions. Now as a very first step the code decides which
of the two cases it is going to apply, and then proceeds accordingly.
This also avoids calculating completely invalid values along the way and
even printing them int the debug output.

Also improve debug output in various places.

This shouldn't cause any behaviour changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
7d0c7144ba rtpbin: Remove unused variable / function parameter
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
4421c3de75 rtpbin: Handle ntp-sync=true before everything else
This simplifies the code as it's a much simpler case than the normal
inter-stream synchronization, and interleaving it with that only
reduces readability of the code.

Also improve some debug output in this code path.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
4b0e75a094 rtpbin: Add some documentation to gst_rtp_bin_associate()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sebastian Dröge
70a435c0c4 rtpbin: Don't do any timestamp offsetting in rfc7273-sync=true mode
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1160

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6543>
2024-05-28 11:52:30 +00:00
Sergey Krivohatskiy
1c5e1798b6 flacparse: fix buffer overflow in gst_flac_parse_frame_is_valid
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6835>
2024-05-27 23:31:44 +00:00
Tim-Philipp Müller
8bd1a3213e level: fix old "message" property doc chunk
In the online documentation the new post-messages
property would show up as deprecated refering to
itself.

Fixes #3561

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6911>
2024-05-23 21:36:37 +00:00
Jan Schmidt
64133b40a7 rtpmp4gdepay: Set duration on outgoing buffers
If we have constant duration buffers, set the duration on
outgoing buffers, like rtpmp4adepay does. This fixes
problems with (for example) muxers like mp4mux not writing
the duration of the final sample into the index.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6878>
2024-05-20 15:24:32 +00:00
Guillaume Desmottes
210487b50a wavparse: reset when receiving STREAM_START
We need to reset the internal state to be able to parse a new stream.
When doing so keep seek event and do not destroy the adapter.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6840>
2024-05-16 11:35:02 +00:00
Sebastian Dröge
a4514c5458 level: Don't post a message on EOS without a valid audio info
If EOS is received before caps, e.g. because of an error, then rate and
number of channels would be 0 and some divisions by zero would happen.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6819>
2024-05-12 07:06:32 +00:00