Commit graph

10123 commits

Author SHA1 Message Date
Jan Schmidt
0ddfc5020f qtdemux: Move some tree parsing files out to a separate file.
Reduce a tiny bit of the bulk of qtdemux.c by moving some
agnostic helper functions out.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/634>
2020-06-18 14:41:27 +00:00
Jan Schmidt
e2d75939bb qtdemux: Factor out svmi parsing. Fix bounds checking.
Move the SVMI stereoscopic atom parsing out to a helper
function to shrink qtdemux_parse_trak a bit.

Add a bounds check that the received atom is large enough
before parsing it.

Add a note to the atom parser that svmi comes from the
MPEG-A spec 23000-11.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/634>
2020-06-18 14:41:27 +00:00
Seungha Yang
8b4f18d53b rtspsrc: Don't return TRUE for unhandled query
Expected return value for unhandled query is FALSE

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/629>
2020-06-16 19:35:30 +09:00
Vivia Nikolaidou
536ff4776f deinterlace: Add yadif ASM optimisations
Measured to be about 3.4x faster than C

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/621>
2020-06-16 12:53:25 +03:00
Vivia Nikolaidou
ef78014d15 deinterlace: Fix invalid read in yadif
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/621>
2020-06-12 13:21:02 +03:00
Sebastian Dröge
556e7ab210 flvdemux: Change a GST_ERROR_OBJECT() back to GST_DEBUG_OBJECT()
It was accidentally changed in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/436

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/624>
2020-06-12 09:52:56 +03:00
Jordan Petridis
3e2420361a Use gst_element_class_set_metadata when passing dynamic strings
gst_element_class_set_metadata is meant to only be used with
static or inlined strings, which isn't the case for the 2 elements
here resulting in use-after-free later on.

https://gstreamer.freedesktop.org/documentation/gstreamer/gstelement.html?gi-language=c#gst_element_class_set_static_metadata

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/622>
2020-06-11 20:39:33 +03:00
Sebastian Dröge
f8196e06d5 Revert "rtpjitterbuffer: Avoid deadlock on flush"
This reverts commit 54810bf44f

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/620>
2020-06-10 16:31:06 +00:00
U. Artie Eoff
bf0842aa0c rtpjitterbuffer: g_queue_clear_full introduced in glib 2.60
Define g_queue_clear_full if glib < 2.60.

Fixes #747

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/619>
2020-06-09 13:09:20 -07:00
Thibault Saunier
29a661d4a4 rtpsession: Make internal-ssrc as show default for doc 2020-06-09 11:45:13 -04:00
Nicolas Dufresne
5b2ad31583 rtptimerqueue: Fix leak on timer collision
While the caller should make sure this does not happen, make sure timer
collision are not silently ignored and leaked.

Fixes #726

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/616>
2020-06-08 17:54:53 -04:00
Nicolas Dufresne
b4f421e9aa rtpjitterbuffer: Keep JBUF lock while processing timers
Until now, do_expected_timeout() was shortly dropping the JBUF_LOCK in order
to push RTX event event without causing deadlock. As a side effect, some
CPU hung would happen as the timerqueue would get filled while looping over
the due timers. To mitigate this, we were processing the lost timer first and
placing into a queue the remainign to be processed later.

In the gap caused by an unlock, we could endup receiving one of the seqnum
present in the pending timers. In that case, the timer would not be found and
a new one was created. When we then update the expected timer, the seqnum
would already exist and the updated timer would be lost.

In this patch we remove the unlock from do_expected_timeout() and place all
pending RTX event into a queue (instead of pending timer). Then, as soon as
we have selected a timer to wait (or if there is no timer to wait for) we send
all the upstream RTX events. As we no longer unlock, we no longer need to pop
more then one timer from the queue, and we do so with the lock held, which
blocks any new colliding timers from being created.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/616>
2020-06-08 17:54:53 -04:00
Edward Hervey
54810bf44f rtpjitterbuffer: Avoid deadlock on flush
When a GST_EVENT_FLUSH_START reaches the jitterbuffer, there is a chance that
our task is currently blocking waiting for a timer.

There was two problems:
* That wait wasn't checking for flushing situations
* The flushing handling wasn't waking up that conditional (to check whether it
should abort)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/608>
2020-06-08 13:34:26 +02:00
Mathieu Duponchelle
f63299ff2f plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:42:25 +02:00
Sebastian Dröge
e527eb3e4c rtpbin: Initialize uninitialized variable correctly
`last_out` would be used uninitialized if the element has no `set-active`
signal. Initialize it to -1 as that's what the "default" value is
further below.

CID 1455443

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/727

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/613>
2020-06-05 11:49:17 +03:00
Thibault Saunier
6f0f41fef0 doc: Fix wrong link to GString in rtpjitterbuffer 2020-06-03 22:44:09 -04:00
Mathieu Duponchelle
37c619f995 plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-06-03 22:44:09 -04:00
Sebastian Dröge
b94b9988fa rtspsrc: Use the correct type for storing the max-rtcp-rtp-time-diff property
It's an integer property and rtpbin also expects an integer. Passing it
as a GstClockTime (guint64) to g_object_set() will cause problems, and
on big endian MIPS apparently causes crashes.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/737

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/605>
2020-05-27 22:33:31 +03:00
Thibault Saunier
3fdae346ca rtspsrc: Error out when failling to receive message response
And let it rety twice.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/717

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/601>
2020-05-25 20:13:06 -04:00
Sebastian Dröge
2c278bb2ab flvdemux: Send gap events if one of the streams falls behind the other by more than 3s
Same mechanism and threshold as in other demuxers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/597>
2020-05-20 18:46:41 +00:00
Sebastian Dröge
0bb9880b36 flvdemux: Remove unused audio_linked/video_linked booleans
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/597>
2020-05-20 18:46:41 +00:00
Edward Hervey
5dd3643d94 flvdemux: Answer bitrate queries from upstream
If upstream (such as queue2 in urisourcebin) asks for our bitrate, check if we
have stored audio/video bitrates, and use them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/596>
2020-05-20 16:51:47 +03:00
Edward Hervey
e8282661b6 flvdemux: Handle empty metadata strings
g_utf8_validate() errors out on empty string. But empty strings are valid,
so only check if they're not

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/596>
2020-05-20 10:48:06 +02:00
Edward Hervey
9f5f906515 flvdemux: Set ACCEPT_TEMPLATE flag on sinkpad
A demuxer can accept any caps matching its sinkpad template caps

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/596>
2020-05-20 10:48:06 +02:00
Jan Schmidt
d8f0deadc3 deinterlace: Split out NULL checks in yadif
Separate out explicit NULL checks for fields we depend on so
that coverity can hopefully verify dependencies better.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/585>
2020-05-09 03:09:03 +10:00
Jan Schmidt
1106eb16b6 deinterlace: Handle NV12/NV21 for the greedyl mode.
Don't fall back on the default interpolate_scanline function, which
blindly tries to copy from the next field, which can be NULL in
mixed progressive/interlaced streams

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/585>
2020-05-09 03:07:33 +10:00
Vivia Nikolaidou
82dc670f1f deinterlace: Support packed formats for YADIF
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/444>
2020-05-06 17:08:06 +00:00
Vivia Nikolaidou
5fce46f5ef deinterlace: Call the planar functions for the Y plane of nv12/nv21
In some algorithms (like yadif), the Y plane has to be handled different
than the UV plane. Therefore, the planar_y functions are now called for
the Y plane, and the nv12/nv21 functions are handling only the UV/VU
planes respectively.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/444>
2020-05-06 17:08:06 +00:00
Jan Schmidt
e9ee7ab0af deinterlace: Add C implementation of YADIF
Import the YADIF deinterlacer from ffmpeg and modify
it to match the simple deinterlace scanlines structure.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/444>
2020-05-06 17:08:06 +00:00
Jan Schmidt
1c1bc56a3b deinterlace: Allow for 5 fields for interpolation
Add an extra field to the simple deinterlace implementation,
so that methods can potentially use 5 fields - the current
field, and 2 before and 2 after.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/444>
2020-05-06 17:08:06 +00:00
Jan Schmidt
5468988223 deinterlace: Force renegotiation when changing mode
Switching the deinterlacing mode on-the-fly from disabled to
auto used to work, but was broken by commit #1f21747c some
years ago.

Force re-negotiation with downstream when the mode or
fields properties are changed, otherwise deinterlace
never switches out of the passthrough mode.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/584>
2020-05-07 01:31:59 +10:00
Sebastian Dröge
e5feaa76ed imagefreeze: Handle flushing correctly
First of all get rid of the atomic seeking boolean, which was only ever
set and never read. Replace it with a flushing boolean that is used in
the loop function to distinguish no buffer because of flushing and no
buffer because of an error as otherwise we could end up in a
GST_FLOW_ERROR case during flushing.

Also only reset the state of imagefreeze in flush-stop when all
processing is stopped instead of doing it as part of flush-start.

And last, get a reference to the imagefreeze buffer in the loop function
in the very beginning and work from that as otherwise it could in theory
be replaced or set to NULL in the meantime as we release and re-take the
mutex a couple of times during the loop function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/580>
2020-05-06 08:06:33 +00:00
Edward Hervey
756f390f56 videbox: Use MIN instead of CLAMP for uint
an unsigned int is always positive.

CID #206207
CID #206208
CID #206209
CID #206210
CID #206211

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/583>
2020-05-06 06:49:09 +00:00
Edward Hervey
619457ae26 avidemux: Avoid potential double-free
stream->name was being freed (without being NULL-ed) before we were certain it
would be set again.

CID #1456071

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/582>
2020-05-06 04:36:46 +00:00
Edward Hervey
518d192dc5 deinterlace: Don't leak frame in error case
CID #1455494

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/581>
2020-05-05 17:30:48 +02:00
Edward Hervey
cfb9a5d53a slitmuxsrc: Properly stop the loop if not part reader is present
Previously this would end up in a refcounting loop of hell.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/578>
2020-05-05 15:32:58 +02:00
Vivia Nikolaidou
6a38961561 flvmux: Add skip-backwards-streams property
Backwards timestamps confuse librtmp, even if they're only backwards
relative to the other stream. If the timestamp of a stream is going
backwards related to the other stream, this property allows the muxer to
skip a few buffers until it reaches the timestamp of the other stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/572>
2020-04-27 16:18:34 +03:00
Vivia Nikolaidou
b0855113c6 flvmux: Allow requesting streamable pads after header is written
Allows us to request pads after writing header for streamable flv's.

For non-streamable it doesn't make sense to request a new pad after
writing the header, because the headers have been written already and we
can't add the new stream. But for streamable, any clients that connect
after the new pad has been added will be able to see both streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/572>
2020-04-27 14:11:10 +03:00
Olivier Crête
3ae1bae2a3 qtdemux: Add 'mp3 ' fourcc that VLC seems to produce now
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/574>
2020-04-22 15:32:31 -04:00
Sebastian Dröge
7b22397cf5 rtpjitterbuffer: Properly free internal packets queue in finalize()
As we override the GLib item with our own structure, we cannot use any
function from GList or GQueue that would try to free the RTPJitterBufferItem.
In this patch, we move away from g_queue_new() which forces using
g_queue_free(). This this function could use g_slice_free() if there is any items
left in the queue. Passing the wrong size to GSLice may cause data corruption
and crash.

A better approach would be to use a proper intrusive linked list
implementation but that's left as an exercise for the next person
running into crashes caused by this.

Be ware that this regression was introduced 6 years ago in the following
commit [0], the call to flush() looked useless, as there was a g_queue_free()
afterward.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

[0] 479c7642fd

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/573>
2020-04-22 10:28:30 -04:00
Seungha Yang
ca48f5265e splitmuxsink: Enhancement for timecode based split
The calculated threshold for timecode might be varying depending on
"max-size-timecode" and framerate.
For instance, with framerate 29.97 (30000/1001) and
"max-size-timecode=00:02:00;02", every fragment will have identical
number of frames 3598. However, when "max-size-timecode=00:02:00;00",
calculated next keyframe via gst_video_time_code_add_interval()
can be different per fragment, but this is the nature of timecode.
To compensate such timecode drift, we should keep track of expected
timecode of next fragment based on observed timecode.
2020-04-20 21:39:49 +09:00
Seungha Yang
fe73c3b0f3 splitmuxsink: Post error when requested timecode interval is invalid
In case we cannot rely on max-size-timecode for split decision,
post error instead of crashing
2020-04-19 20:23:32 +09:00
Havard Graff
981d0c02de rtpjitterbuffer: don't use RTX packets in rate-calc and reset-logic
The problem was this:

Due to the highly irregular arrival of RTX-packet the max-misorder variable
could be pushed very low. (-10).

If you then at some point get a big in the sequence-numbers (62 in the
test) you end up sending RTX-requests for some of those packets, and then
if the sender answers those requests, you are going to get a bunch of
RTX-packets arriving. (-13 and then 5 more packets in the test)

Now, if max-misorder is pushed very low at this point, these RTX-packets
will trigger the handle_big_gap_buffer() logic, and because they arriving
so neatly in order, (as they would, since they have been requested like
that), the gst_rtp_jitter_buffer_reset() will be called, and two things
will happen:
1. priv->next_seqnum will be set to the first RTX packet
2. the 5 RTX-packet will be pushed into the chain() function

However, at this point, these RTX-packets are no longer valid, the
jitterbuffer has already pushed lost-events for these, so they will now
be dropped on the floor, and never make it to the waiting loop-function.

And, since we now have a priv->next_seqnum that will never arrive
in the loop-function, the jitterbuffer is now stalled forever, and will
not push out another buffer.

The proposed fixes:
1. Don't use RTX in calculation of the packet-rate.
2. Don't use RTX in large-gap logic, as they are likely to be dropped.
2020-04-16 17:06:31 +02:00
Sebastian Dröge
d75ea5b340 splitmuxsink: Do split-at-running-time splitting based on the time of the start of the GOP
If the start of the GOP is >= the requested running time, put it into a
new fragment. That is, split-at-running-time would always ensure that a
split happens as early as possible after the given running time.

Previously it was comparing against the current incoming timestamp,
which does not tell us what we actually want to know as it has no direct
relation to the GOP start/end.
2020-04-15 17:52:41 +03:00
Sebastian Dröge
0ab0f92cac splitmuxsink: Fix off-by-one in running time comparison for split-at-running-time
If we get a keyframe exactly at the requested running time we would only
split on the next keyframe afterwards due to wrong usage of > vs. >=.
2020-04-15 13:33:17 +03:00
Thibault Saunier
fd7ecac793 rtspsrc: Properly set segments seqnums after seeks 2020-04-09 14:03:04 -04:00
Vivia Nikolaidou
9189cdcb1d flvdemux: Don't write an empty string as a tag
To stop warnings like:

GStreamer-WARNING **: 19:47:48.186: Trying to set empty string on
taglist field 'encoder'. Please file a bug.
2020-04-08 20:22:51 +03:00
Thibault Saunier
00539e1277 rtspsrc: Avoid stack overflow recursing waiting for response
Instead of recursing, simply implement a loop with gotos, the same
way it was done before 8121752887

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/710
2020-04-08 09:49:49 -04:00
Sebastian Dröge
cf3fbf57bf qtmux: Add property for enforcing the creation of chunks in single-stream files
This is disabled by default as it unnecessarily creates bigger headers
but it is something that is required by some applications and most
notably the Apple ProRes spec.
2020-04-06 16:25:59 +03:00
Jan Schmidt
a3933ea53d flvmux: Fix invalid padlist accesses.
Request pads can released at any time, so make sure to hold
the object lock when iterating the element sinkpads list where
that's safe, or to use other safe pad iteration patterns in
other places.

When choosing a best pad, return a reference to the pad to make sure it
stays alive for output in the aggregator srcpad task.

Should fix a spurious valgrind error in the CI flvmux tests and some
other potential problems if the request sink pads are released while
the element is running..

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/714
2020-04-05 11:50:43 +00:00