Commit graph

969 commits

Author SHA1 Message Date
Tim-Philipp Müller
f5310ce346 tests: qtdemux: fix typo in caps field
timesacle -> timescale

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/815>
2020-11-12 23:40:13 +00:00
Tim-Philipp Müller
2ce5909f3a tests: qtdemux: fix crash on 32-bit architectures
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/803

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/815>
2020-11-12 23:40:13 +00:00
Jan Schmidt
81ecf076e8 splitmuxsrc: Fix comment in a test
Fix a comment in the splitmuxsrc robust muxing test so it
describes the test properly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/798>
2020-10-31 02:50:51 +00:00
Stian Selnes
95579a00c0 rtpvp9depay: Improve SVC parsing, aggregate all layers
- Fix start and end of picture to support multiple layers. Start of
  picture is the first packet of the base layer, while end of picture
  is when the marker bit is set (last packet of the enhancement
  layers).
- All "layers" (aka "frames") of a picture are pushed downstream in a
  single buffer when picture is complete.
- Forgive SID=0 for enhancement layers (invalid, but Chrome and
  Firefox sends it)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/773>
2020-10-30 17:46:30 +01:00
Stian Selnes
d77fcf251b rtpvp8depay: Send lost events when marker bit is missing
This means the previous frame was incomplete.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/796>
2020-10-30 03:43:19 +01:00
Mikhail Fludkov
346b077ae0 rtpvp*depay: possibly forward might-have-been-fec PacketLost events
This is ad adaptation of a Pexip patch for dealing with spurious
GstRTPPacketLost events caused by lost ulpfec packets: as FEC packets
under that scheme are spliced in the same sequence domain as the media
packets, it is not generally possible to determine whether a lost packet
was a FEC packet or a media packet.

When upstreaming pexip's ulpfec patches, we decided to drop all lost
events at the base depayloader level, and where the original patch
from pexip was making use of picture ids and marker bits to determine
whether a packet should be forwarded, this patch makes use of those
to determine whether they should be dropped instead (by removing their
might-have-been-fec field).

Spurious lost events coming out of the depayloader can cause the
decoder to stop decoding until the next keyframe and / or request a new
keyframe, and while this is not desirable it makes sense to forward
that information when we have other means to determine whether a lost
packet was indeed a FEC packet, as is the case with VP8 / VP9 payloads
when they carry a picture id.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/769>
2020-10-29 19:56:07 +01:00
Havard Graff
63c7a9ae43 rtpjitterbuffer: don't send multiple instant RTX for the same packet
Due to us not properly acknowleding the time when the last RTX was sent
when scheduling a new one, it can easily happen that due to the packet
you are requesting have a PTS that is slightly old (but not too old when
adding the latency of the jitterbuffer), both its calculated second and
third (etc.) timeout could already have passed. This would lead to a burst
of RTX requests, which acts completely against its purpose, potentially
spending a lot more bandwidth than needed.

This has been properly reproduced in the test:
test_rtx_not_bursting_requests

The good news is that slightly re-thinking the logic concerning
re-requesting RTX, made it a lot simpler to understand, and allows us
to remove two members of the RtpTimer which no longer serves any purpose
due to the refactoring. If desirable the whole "delay" concept can actually
be removed completely from the timers, and simply just added to the timeout
by the caller of the API. But that can be a change for a another time.

The only external change (other than the improved behavior around bursting
RTX) is that the "delay" field now stricly represents the delay between
the PTS of the RTX-requested packet and the time it is requested on,
whereas before this calculation was more about the theoretical calculated
delay. This is visible in three other RTX-tests where the delay had
to be adjusted slightly. I am confident however that this change is
correct.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/789>
2020-10-28 01:22:24 +01:00
John-Mark Bell
3348c5ceae rtpvp8pay: payload temporally scaled bitstreams.
Co-Authored-By: Vincent Sanders <vince@pexip.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/728>
2020-10-16 09:25:10 +00:00
John-Mark Bell
d9cedee042 vp8enc: finish support for temporally scaled encoding
- introduce two new properties:

    * temporal-scalability-layer-flags:

      Provide fine-grained control of layer encoding to the
      outside world. The flags sequence should be a multiple of
      the periodicity and is indexed by a running count of encoded
      frames modulo the sequence length.

    * temporal-scalability-layer-sync-flags:

      Specify the pattern of inter-layer synchronisation (i.e.
      which of the frames generated by the layer encoding
      specification represent an inter-layer synchronisation).
      There must be one entry per entry in
      temporal-scalability-layer-flags.

  - apply temporal scalability settings and expose as buffer
    metadata.

    This allows the codec to allocate a given frame to the correct
    internal bitrate allocator. Additionally, all the
    non-bitstream metadata needed to payload a temporally scaled
    stream is now attached to each output buffer as a
    GstVideoVP8Meta.

  - add unit test for temporally scaled encoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/728>
2020-10-16 09:25:10 +00:00
Mathieu Duponchelle
591af0f38a rtpmanager: implement SMPTE 2022-1 FEC encoder
+ improve integration of FEC encoders in rtpbin

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/753>
2020-10-08 22:22:18 +00:00
Mathieu Duponchelle
cff42d4c26 rtpmanager: implement SMPTE 2022-1 FEC decoder
+ improve integration of FEC decoders in rtpbin

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/753>
2020-10-08 22:22:18 +00:00
Olivier Crête
7c9a5e86fe rtpfunnel: Also forward custom sticky event
This is useful to track metadata about each group of packets

Also include a unit test

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/666>
2020-10-06 20:57:49 +00:00
Matthew Waters
e81ce6f2d7 qtmux: properly support initial caps nego failure
Scenario:
- gap event causes h264parse to push made up caps that may fail checks
  inside qtmux (e.g missing codec_data).
- the caps event has already been marked as received and is sticky on
  the sink pad
- gst_qt_mux_pad_can_renegotiate() will retrieve the failed caps event
  using gst_pad_get_current_caps() and reject the correct updated caps
  with codec_data.
- Failure!

Keep track of the configured caps ourselves instead of relying on the
sticky event on the pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/732>
2020-09-28 15:37:12 +10:00
Matthew Waters
ea61714c70 rtph26*depay: drop FU's without a corresponding start bit
If we have not received a FU with a start bit set, any subsequent FU
data is not useful at all and would result in an invalid stream.

This case is constructed from multiple requirements in
RFC 3984 Section 5.8 and RFC 7798 Section 4.4.3.  Following are excerpts
from RFC 3984 but RFC 7798 contains similar language.

The FU in a single FU case is forbidden:

   A fragmented NAL unit MUST NOT be transmitted in one FU; i.e., the
   Start bit and End bit MUST NOT both be set to one in the same FU
   header.

and dropping is possible:

   If a fragmentation unit is lost, the receiver SHOULD discard all
   following fragmentation units in transmission order corresponding to
   the same fragmented NAL unit.

The jump in seqnum case is supported by this from the specification
instead of implementing the forbidden_zero_bit mangling:

   If a fragmentation unit is lost, the receiver SHOULD discard all
   following fragmentation units in transmission order corresponding to
   the same fragmented NAL unit.

   A receiver in an endpoint or in a MANE MAY aggregate the first n-1
   fragments of a NAL unit to an (incomplete) NAL unit, even if fragment
   n of that NAL unit is not received.  In this case, the
   forbidden_zero_bit of the NAL unit MUST be set to one to indicate a
   syntax violation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/730>
2020-09-21 08:08:38 +00:00
Matthew Waters
52b63de19a isomp4/mux: add a fragment mode for initial moov with data
Used by some proprietary software for their fragmented files.

Adds some support for multi-stream fragmented files

Flow is as follows.
1. The first 'fragment' is written as a self-contained fragmented
   mdat+moov complete with an edit list and durations, tags, etc.
2. Subsequent fragments are written with a mdat+moof and each stream is
   interleaved as data arrives (currently ignoring the interleave-*
   properties).  data-offsets in both the traf and the trun ensure
   data is read from the correct place on demuxing.  Data/chunk offsets
   are also kept for writing out the final moov.
3. On finalisation, the initial moov is invalidated to a hoov and the
   size of the first mdat is extended to cover the entire file contents.
   Then a moov is written as regularly would in moov-at-end mode (the
   default).

This results in a file that is playable throughout while leaving a
finalised file on completion for players that do not understand
fragmented mp4.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/643>
2020-09-21 12:08:14 +10:00
John-Mark Bell
8f684913cf vp8enc: improve unit tests
- make test_encode_simple cope with libvpx built with
    CONFIG_REALTIME_ONLY. Sadly, there's no way to detect this at
    runtime beyond trying to set lag-in-frames to >0, pushing a
    buffer and catching the GST_FLOW_NOT_NEGOTIATED return.

  - fix bitrot in test_encode_simple_when_bitrate_set_to_zero.

  - port test_encode_simple to GstHarness and introduce a separate
    test for the lag-in-frames property.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/708>
2020-09-08 22:59:29 +00:00
Sebastian Dröge
e9a0307b94 rtph26[45]pay: Change default aggregate-mode to "none" for backwards compatibility
We didn't aggregate at all in previous versions and there are apparently
various RTP implementations that don't handle aggregation well at all.

As part of this also document that for RTSP it is recommended to keep it
set to "none" while for WebRTC it should be set to "zero-latency".

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/692>
2020-08-08 10:08:31 +03:00
Hosang Lee
d6f6e8410e tests: qtdemux: test correct pad names are created
Test correct pad names are created in accordance to their media type
in mss mode.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/628>
2020-07-28 11:41:51 +00:00
Justin Chadwell
738f32d5d0 qtdemux: fix allocation explosion with stsd entries
Previously, the user input for stsd entries is trusted completely, and
so a maliciously crafted file could choose the length of the stsd
entries arbitrarily and cause qtdemux to try to allocate up to 2GB of
memory (half of a 32 bit max int).

This patch fixes this by sanity checking the stsd input against the
size of the entire stsd atom.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/670>
2020-07-15 12:10:45 +00:00
Justin Chadwell
e6f66f4681 qtdemux: fix crashes when input stream contained no stsd entries
During trak parsing, we need to check for the existence of stsd_entries,
otherwise, we end up with a NULL pointer to them. It is entirely
possible for the stsd to exist, but for it to have no entries, which the
previous checks did not take into account.

This patch adds a simply check to ensure that all files that do not
contain a stsd entry are deemed corrupt, and adds a test case to prevent
a regression.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/670>
2020-07-15 12:10:45 +00:00
Sebastian Dröge
3ad86bdf30 imagefreeze: Add test for new live mode
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/653>
2020-06-29 12:07:14 +03:00
Havard Graff
cdba5952ed rtpsession: make tests more stable
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/410>
2020-06-20 19:45:33 +00:00
Guillaume Desmottes
0594d2f981 tests: vp9enc: enforce I420 format
Test was not enforcing a video format on videotestsrc. I420 was picked
as it was the first format in GST_VIDEO_FORMATS_ALL which will no longer
be true (gst-plugins-base!689).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/615>
2020-06-08 17:58:29 +02:00
Mikhail Fludkov
7b390a8bbd vpxenc: Add new bit-per-pixel property to select a better "default" bitrate
As part of this also change the default bitrate value to 0. The default
value was 256000 previously. In reality, if the property was not set the
bitrate value would be scaled according to the resolution which is not
very intuitive behavior. It is better to use 0 for this purpose. Now
together with newly introduced property "bits-per-pixel" 0 means to
assign the bitrate according to resolution/framerate.

The default bitrates are now
 - 1.2Mbps for VP8 720p@30fps
 - 0.8Mbps for VP9 720p@30fps
and scaled accordingly for different resolutions/framerates.

Previously the default bitrate was also not scaled according to the
framerate but only took the resolution into account.

This also fixes the side effect of setting bitrate to 0. Previously
encoder would not produce any data at all.

Addition from Sebastian Dröge <sebastian@centricular.com> to assume
30fps if no framerate is given in the caps instead of not calculating
any bitrate at all.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/611>
2020-06-04 20:14:03 +00:00
Stian Selnes
44e4de43da vpxdec: Check that output width and height != 0
For VP8 it's possible to signal width or height to be 0, but it does
not make sense to do so. For VP9 it's impossible. Hence, we most
likely have a corrupt stream. Trying to negotiate caps downstream with
either width or height as 0 will fail with something like

gst_video_decoder_negotiate_default: assertion 'GST_VIDEO_INFO_WIDTH (&state->info) != 0' failed

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/610>
2020-06-02 23:59:20 +03:00
Seungha Yang
ea1797ccb5 tests: splitmuxsink: Add more timecode based split test
... and split test cases to run tests in parallel
2020-04-20 21:39:54 +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
Kristofer Björkström
586fc57e55 rtpjpeg: Use gst_memory_map() instead of gst_buffer_map()
gst_buffer_map () results in memcopying when a GstBuffer contains
more than one GstMemory.
This has quite an impact on performance on systems with limited amount
of resources. With this patch the whole GstBuffer will not be mapped at
once, instead each individual GstMemory will be iterated and mapped
separately.
2020-04-03 17:01:24 +02:00
Havard Graff
d9aaa15a30 rtpopuspay: make depay ! pay work
There is a use-case for a server to re-payload opus going through it.

Problem was that the payloader requires channels in the caps, but
this is not something the depayloader can parse out of the stream, meaning
caps-negotiation would fail.

Removing the requirement of channels in the template-caps fixes this.
2020-04-03 09:04:32 +00:00
Seungha Yang
018218dd73 tests: Split splitmux test case
Since we are adding more and more tests into splitmux,
we need to split it to avoid CI timeout.
2020-04-03 17:08:51 +09:00
Seungha Yang
599066726f splitmuxsink: Don't send too many force key unit event
splitmuxsink should requst keyframe depending on configured
threshold and previously requested time in order to avoid too many
keyframe request.
2020-04-03 15:00:37 +09:00
Havard Graff
9f1062dc05 rtpjitterbuffer: various test-improvements
Mainly generalize all the latest tests that have found various stalls
in the jitterbuffer, so that they only consist of a series of packets
with various seqnum/rtptime/rtx combinations, arriving at a specific time.

This means future tests can be more easily written to prove certain
behavior does not cause stalls.

Also fix the warning on windows:
warning C4244: 'initializing': conversion from 'double' to 'gint', possible loss of data
2020-03-31 04:01:38 +02:00
Jan Schmidt
8ef172d8b4 splitmux: Make the unit test faster
The playback test is considerably faster if it runs with the
appsink set to sync=false
2020-03-26 11:23:24 +00:00
Seungha Yang
d06970c561 tests: splitmux: Add test for timecode based split 2020-03-25 13:22:31 +00:00
Xavier Claessens
6e1758d509 Fix usage of C99
It's 2020, way too early for that, let's stick to C89 for now.
2020-03-23 21:32:04 -04:00
Havard Graff
a710bda1ab rtptimerqueue: remove ->num from the timer
This concept was only used by the "multi"-lost timer, and since that
one is not around any longer, the "num" concept is superfluous.
2020-03-20 13:17:20 +00:00
Havard Graff
f1ff80ced0 rtpjitterbuffer: remove the concept of "already-lost"
This is a concept that only applies when a buffer arrives in the chain
function, and it has already been scheduled as part of a "multi"-lost
timer.

However, "multi"-lost timers are now a thing of the past, making this
whole concept superflous, and this buffer is now simply counted as "late",
having already been pushed out (albeit as a lost-event).
2020-03-20 13:17:20 +00:00
Havard Graff
5dacf366c0 rtpjitterbuffer: immediately insert a lost-event on multiple lost packets
There is a problem with the code today, where a single timer will
be scheduled for a series of lost packets, and then if the first packet
in that series arrives, it will cause a rescheduling of that timer, going
from a "multi"-timer to a single-timer, causing a lot of the packets
in that timer to be unaccounted for, and creating a situation in where
the jitterbuffer will never again push out another packet.

This patch solves the problem by instead of scheduling those lost packets
as another timer, it instead asks to have that lost-event pushed straight
out.

This very much goes with the intent of the code here: These packets are
so desperately late that no cure exists, and we might as well get the
lost-event out of the way and get on with it.

This change has some interesting knock-on effect being presented in
later commits. It completely removes the concept of "already-lost", so
that is why that test has been disabled in this commit, to be
removed later.
2020-03-20 13:17:20 +00:00
Havard Graff
d045b40db9 rtpjitterbuffer: rework large-gap tests
Make sure to set the time the buffer is supposed to arrive at, so
as not to trigger an artificial situation.
2020-03-20 13:17:20 +00:00
Havard Graff
9eaf084d7a test/check: split out rtptimerqueue-tests in a separate file 2020-03-20 13:17:20 +00:00
Seungha Yang
18e09de0a2 splitmuxsink: Decouple keyframe request and the decision for fragmentation
Split the decision for keyframe request and fragmentation in order to
ensure periodic keyframe request.
2020-03-19 10:17:21 +00:00
Tim-Philipp Müller
66296fcae3 tests: rtp-payloading: add minimal vp8/vp9 rtp payloading/depayloading test 2020-03-12 16:55:44 +00:00
Ognyan Tonchev
a78a74bff0 rtph26x: Use gst_memory_map() instead of gst_buffer_map() in avc mode
gst_buffer_map () results in memcopying when a GstBuffer contains
more than one GstMemory and when AVC (length-prefixed) alignment is used.
This has quite an impact on performance on systems with limited amount of
resources. With this patch the whole GstBuffer will not be mapped at once,
instead each individual GstMemory will be iterated and mapped separately.
2020-03-06 10:44:16 +00:00
Havard Graff
026223cde2 rtpjitterbuffer: fix stalling when resetting timers
When calling gst_rtp_jitter_buffer_reset you pass in a seqnum.

This is considered the starting-point for a new stream.

However, the old behavior would unref this buffer, basically lying to
the thread that is pushing out buffers saying that it can expect
this buffer, when it would never arrive. The resulting effect being no
more buffer pushed out of the jitterbuffer, and it would buffer
incoming data indefinitely.

By instead inserting the buffer in the gap_packets queue, the _reset()
function will take responsibility for using that as the first buffer
of the new stream.

Fixes #703
2020-03-04 12:55:52 +01:00
Jan Schmidt
f490c38416 splitmux: Avoid negative DTS
In order to concatenate fragments, splitmuxsrc offsets
the start of each fragment PTS to 0 to align it with the
previous file. This means that DTS can go negative for
the first fragment, with really bad results.

Add a fixed offset to outgoing timestamp ranges to
avoid that.
2020-03-04 05:42:21 +00:00
Yeongjin Jeong
830db205f6 tests: flvmux: Instead of using the testclock, just send eos event for drain
When using the testclock for determining clock in test, it is sometimes observed
that the clock entry is not registered in time by the aggregator. So deadlock occurs
between the aggregator and the test thread.
2020-03-02 01:37:27 +09:00
Håvard Graff
fdf002d069 rtpsession: fix crash when no extension-header present for twcc 2020-02-24 13:06:27 +00:00
Yeongjin Jeong
9feb35638a tests: flvmux: Add test for rollover timestamp
The timestamps that exceed uint32 maximum value should be handled to rollover.
2020-02-18 18:39:34 +09:00
Havard Graff
1df706448c rtpmanager: Google Transport-Wide Congestion Control RTP Extension
Generating and parsing the RTCP-messages described in:
https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01
2020-02-14 10:09:02 +00:00
Håvard Graff
9ba9837058 rtpfunnel: various cleanups
* Organize GstRtpFunnelPad and GstRtpFunnel separately
* Use G_GNUC_UNUSED instead of (void) casts
* Don't call an event "caps"
* Use semicolons after GST_END_TEST (helps gst-indent)
2020-02-14 10:08:05 +00:00