platform/upstream/gstreamer.git
4 years agowebrtcbin: Block the source pads before dtlssrtpdec inside transportreceivebin
Sebastian Dröge [Wed, 12 Feb 2020 15:50:53 +0000 (17:50 +0200)]
webrtcbin: Block the source pads before dtlssrtpdec inside transportreceivebin

Otherwise dropped sticky events are not actually re-sent on the next
opportunity and we can end up with data-flow before stream-start/segment
events.

4 years agosctp: Take some socket configurations from Firefox's datachannel code
Sebastian Dröge [Thu, 6 Feb 2020 17:40:20 +0000 (19:40 +0200)]
sctp: Take some socket configurations from Firefox's datachannel code

- Do not send ABORTs for unexpected packets are as response to INIT
- Enable interleaving of messages of different streams
- Configure 1MB send and receive buffer for the socket
- Enable SCTP_SEND_FAILED_EVENT and SCTP_PARTIAL_DELIVERY_EVENT events
- Set SCTP_REUSE_PORT configuration
- Set SCTP_EXPLICIT_EOR and the corresponding send flag. We probably
  want to split packets to a maximum size later and only set the flag
  on the last packet. Firefox uses 0x4000 as maximum size here.
- Enable SCTP_ENABLE_CHANGE_ASSOC_REQ
- Disable PMTUD and set an maximum initial MTU of 1200

4 years agosctp: Start connection synchronously when starting the association
Sebastian Dröge [Thu, 6 Feb 2020 16:43:35 +0000 (18:43 +0200)]
sctp: Start connection synchronously when starting the association

Calling bind() only sets up some data structures and calling connect()
only produces one packet before it returns. That packet is stored in a
queue that is asynchronously forwarded by the encoder's source pad loop,
so not much is happening there either. Especially no waiting is
happening here and no forwarding of data to other elements.

This fixes a race condition during connection setup: the connection
would immediately fail if we pass a packet from the peer to the socket
before bind() and connect() have returned.

This can't happen anymore as bind() and connect() have returned already
before both elements reach the PAUSED state, and in webrtcbin there is
an additional blocking pad probe before the decoder that does not let
any data pass through before that anyway.

4 years agosctp: Switch back to a non-recursive mutex and don't hold it while calling any usrsct...
Sebastian Dröge [Thu, 6 Feb 2020 14:42:01 +0000 (16:42 +0200)]
sctp: Switch back to a non-recursive mutex and don't hold it while calling any usrsctp functions

The library is thread-safe by itself and potentially calls back into our
code, not only from the same thread but also from other threads. This
can easily lead to deadlocks if we try to hold our mutex on both sides.

4 years agod3d11window: Fix for broken dirty rect drawing on Windows 7
Seungha Yang [Wed, 12 Feb 2020 13:29:31 +0000 (22:29 +0900)]
d3d11window: Fix for broken dirty rect drawing on Windows 7

DXGI_SWAP_EFFECT_DISCARD cannot be used with dirty rect drawing feature
of IDXGISwapChain1::Present().
Note that IDXGISwapChain1 interface is available on Platform Update for Windows 7
and DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL is also the case.

4 years agod3d11window: Fix for dxva decoder output view rendering
Seungha Yang [Tue, 11 Feb 2020 04:12:33 +0000 (13:12 +0900)]
d3d11window: Fix for dxva decoder output view rendering

Use resolution specified in caps for input_rect instead of
passed width and height value. The width and height might be modified
ones by d3d11videosink, then frame resolution might be different.

4 years agod3d11decoder: Refactor decoding process
Seungha Yang [Wed, 5 Feb 2020 12:27:23 +0000 (21:27 +0900)]
d3d11decoder: Refactor decoding process

* Move decoding process to handle_frame
* Remove GstVideoDecoder::parse implementation
* Clarify flush/drain/finish usage

In forward playback case, have_frame() call will be followed by
handle_frame() but reverse playback is not the case.
To ensure GstVideoCodecFrame, the decoding process should be placed inside
of handle_frame(), instead of parse().

Since we don't support alignment=nal, the parse() implementation is not worth.
In order to fix broken reverse playback, let's remove the parse()
implementation and revisit it when adding alignment=nal support.

4 years agod3d11decoder: Move handle_frame implementation to baseclass
Seungha Yang [Thu, 30 Jan 2020 11:04:58 +0000 (20:04 +0900)]
d3d11decoder: Move handle_frame implementation to baseclass

... and remove unused start, stop method from subclass.

Current implementation does not require subclass specific behavior
for the handle_frame() method.

4 years agod3d11videosink: Remove max size condition from pool
Seungha Yang [Wed, 5 Feb 2020 09:20:57 +0000 (18:20 +0900)]
d3d11videosink: Remove max size condition from pool

Actually our buffer pool size and the number of backbuffer are
independent. In case of reverse playback, upstream might request
a lot of buffers (up to GOP size).

4 years agonvcodec: Mark class data as may-be-leaked to quiet the leaks tracer
Nirbheek Chauhan [Tue, 11 Feb 2020 18:30:51 +0000 (00:00 +0530)]
nvcodec: Mark class data as may-be-leaked to quiet the leaks tracer

The class data with the caps in it will be leaked if the element is
registered but never instantiated. There is no way around this. Mark
the caps as such so that the leaks tracer does not warn about it.

This is the same as pad template caps getting leaked, which are also
marked as may-be-leaked. These objects are initialized exactly once,
and are 'global' data.

4 years agowpe: Add software rendering support support
Philippe Normand [Sat, 8 Feb 2020 12:05:03 +0000 (12:05 +0000)]
wpe: Add software rendering support support

Starting from WPEBackend-FDO 1.6.x, software rendering support is available.
This features allows wpesrc to be used on machines without GPU, and/or for
testing purpose. To enable it, set the `LIBGL_ALWAYS_SOFTWARE=true` environment
variable and make sure `video/x-raw, format=BGRA` caps are negotiated by the
wpesrc element.

4 years agofluiddec: Move logging init into plugin_init
Jan Alexander Steffens (heftig) [Tue, 11 Feb 2020 11:15:09 +0000 (12:15 +0100)]
fluiddec: Move logging init into plugin_init

This is a nicer place to keep it. We also initialize it before touching
the drivers.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026

4 years agofluiddec: Keep fluidsynth from probing audio drivers
Jan Alexander Steffens (heftig) [Wed, 5 Feb 2020 10:17:33 +0000 (11:17 +0100)]
fluiddec: Keep fluidsynth from probing audio drivers

It might cause problems and we don't need the drivers anyway. This also
avoids a bunch of stderr spam from the drivers.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026

4 years agofluiddec: Avoid deprecated fluid_synth_set_sample_rate
Jan Alexander Steffens (heftig) [Wed, 5 Feb 2020 10:17:32 +0000 (11:17 +0100)]
fluiddec: Avoid deprecated fluid_synth_set_sample_rate

This function is used to change the rate at runtime, which has issues:
https://github.com/FluidSynth/fluidsynth/issues/585

Use the settings key instead (which already defaults to 44100, but I did
test other rates).

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/1026

4 years agotsparse: Add split-on-rai property
Vivia Nikolaidou [Wed, 22 Jan 2020 14:20:28 +0000 (16:20 +0200)]
tsparse: Add split-on-rai property

If set, buffers sized smaller than the alignment will be sent so that
RAI packets are at the start of a new buffer.

Fixes: #1190

4 years agowebrtc: In all blocking pad probes except for sink pads also handle serialized events
Sebastian Dröge [Thu, 6 Feb 2020 12:29:13 +0000 (14:29 +0200)]
webrtc: In all blocking pad probes except for sink pads also handle serialized events

Otherwise it can happen that e.g. the stream-start event is tried to be
sent as part of pushing the first buffer. Downstream might not be in
PAUSED/PLAYING yet, so the event is rejected with GST_FLOW_FLUSHING and
because it's an event would not cause the blocking pad probe to trigger
first. This would then return GST_FLOW_FLUSHING for the buffer and shut
down all of upstream.

To solve this we return GST_PAD_PROBE_DROP for all events. In case of
sticky events they would be resent again later once we unblocked after
blocking on the buffer and everything works fine.

Don't handle events specifically in sink pad blocking pad probes as here
downstream is not linked yet and we are actually waiting for the
following CAPS event before unblocking can happen.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1172

4 years agowebrtcbin: Add a blocking pad probe for the receivebin -> sctpdec connection
Sebastian Dröge [Thu, 6 Feb 2020 12:27:42 +0000 (14:27 +0200)]
webrtcbin: Add a blocking pad probe for the receivebin -> sctpdec connection

Without this it might happen that received data from the DTLS transport
is already passed to sctpdec before its state was set to PLAYING. This
would cause the data to be dropped, GST_FLOW_FLUSHING to be returned and
the whole DTLS transport to shut down.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1172
among other things.

4 years agowebrtcbin/transportreceivebin: Use actual pad blocks instead of an additional GCond...
Sebastian Dröge [Thu, 6 Feb 2020 12:24:41 +0000 (14:24 +0200)]
webrtcbin/transportreceivebin: Use actual pad blocks instead of an additional GCond for blocking pads

Using a GCond can easily lead to deadlocks and only duplicates the
waiting code from gstpad.c in the best case.

In this case it actually could lead to a deadlock if both RTP and RTCP
were waiting. Only one of them would be woken up because g_cond_signal()
was used instead of g_cond_broadcast().

4 years agowebrtc/transportsendbin: Clean up pad probe removal
Sebastian Dröge [Thu, 6 Feb 2020 12:22:17 +0000 (14:22 +0200)]
webrtc/transportsendbin: Clean up pad probe removal

We already have a helper function for this so just use it instead of
duplicating it.

4 years agomsdkvp9enc: output raw vp9 stream instead of IVF stream
Haihao Xiang [Wed, 15 Jan 2020 08:02:11 +0000 (16:02 +0800)]
msdkvp9enc: output raw vp9 stream instead of IVF stream

video/x-vp9 is required in the src pad, however the output includes a
IVF header, which makes the pipeline below doesn't work

  gst-launch-1.0 videotestsrc ! msdkvp9enc ! msdkvp9dec ! fakesink

Since mfx 1.26, the VP9 encoder supports bitstream without IVF header,
so in this patch, the mfx version is checked and msdkvp9enc is enabled
only if mfx 1.26+ is available

4 years agoandroidmedia: Support float i-frame-interval
Jan Schmidt [Thu, 30 Jan 2020 15:01:12 +0000 (02:01 +1100)]
androidmedia: Support float i-frame-interval

Android 25 added support for i-frame-interval to be a floating
point value. Store the property as a float and use the newer
version when it's available.

4 years agoandroidmedia: Allow dynamic bitrate changes on Android >= 19
Jan Schmidt [Thu, 30 Jan 2020 14:33:51 +0000 (01:33 +1100)]
androidmedia: Allow dynamic bitrate changes on Android >= 19

Android 19 added an API for dynamically changing the bitrate in a running
codec.

Also make it so that even when not update-able at runtime, parameters will at least
be stored so that they take effect the next the codec is restarted.

4 years agoandroidmedia: Handle force-keyunit requests
Jan Schmidt [Thu, 30 Jan 2020 14:21:34 +0000 (01:21 +1100)]
androidmedia: Handle force-keyunit requests

Use API from Android 19 to request a keyframe from the MediaCodec
when indicated by the base class.

4 years agoandroidmedia: Permit Codec surface to be NULL
Jan Schmidt [Wed, 5 Feb 2020 10:13:49 +0000 (21:13 +1100)]
androidmedia: Permit Codec surface to be NULL

The AMC encoder wrapper doesn't support input surfaces yet,
and passes NULL when configuring the underlying codec.

This was broken in commit 7fcf3e
Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1102

4 years agoavtp: Build with clang
Ederson de Souza [Fri, 24 Jan 2020 18:58:32 +0000 (10:58 -0800)]
avtp: Build with clang

Minor non-conformity on AVTP code made it not compile with clang.

4 years agoavtp: Plug several leaks
Ederson de Souza [Fri, 24 Jan 2020 23:47:56 +0000 (15:47 -0800)]
avtp: Plug several leaks

After finally running tests with valgrind enabled, some leaks were found
- both on code and on tests themselves. This patch plugs them all!

4 years agogstcurlhttpsink: Update HTTP header for curl 7.66
Ludvig Rappe [Fri, 7 Feb 2020 13:24:53 +0000 (13:24 +0000)]
gstcurlhttpsink: Update HTTP header for curl 7.66

Change how content-length is set for HTTP POST headers, letting curl set
the header (given the content-length) instead of manually writing it.
This enables curl to know the content-length of the data.
In curl 7.66, if curl does not know the content-length (e.g. when
manually writing the header) curl will use Transfer-Encoding: chunked,
which might not be desired.

4 years agonvcodec: Fix crash in decoder on 32-bit Windows
Nirbheek Chauhan [Mon, 20 Jan 2020 09:52:26 +0000 (15:22 +0530)]
nvcodec: Fix crash in decoder on 32-bit Windows

Same fix as 1a7ea45ffde40a4bea63562a2cc9892396d9f7eb, but I didn't
test the decoder so I missed that the function pointers here weren't
using the correct calling convention too.

4 years agoladspa: only multiply bounded rate properties by sample rate
Tim-Philipp Müller [Wed, 5 Feb 2020 16:12:28 +0000 (16:12 +0000)]
ladspa: only multiply bounded rate properties by sample rate

We don't want to accidentally multiply G_MAXFLOAT or -GMAXFLOAT
with the sample rate.

4 years agoladspa: fix unbounded integer properties
Tim-Philipp Müller [Wed, 5 Feb 2020 16:03:06 +0000 (16:03 +0000)]
ladspa: fix unbounded integer properties

Use a double instead of a plain float for intermediary
property values, so we have enough bits to store INT_MAX
and it doesn't get rounded and wrapped to -1 when cast
back to a 32-bit integer.

Fixes criticals like

  g_param_spec_int: assertion 'default_value >= minimum && default_value <= maximum' failed

when loading LADSPA plugins from the Linux Studio Plugins
Project (http://lsp-plug.in) in GStreamer.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1194

4 years agoavtpsink: Implement synchronization mechanism
Andre Guedes [Fri, 4 Oct 2019 18:39:10 +0000 (11:39 -0700)]
avtpsink: Implement synchronization mechanism

The avtpsink element is expected to transmit AVTPDUs at specific times,
according to GstBuffer timestamps. Currently, the transmission time is
controlled in software via the rendering synchronization mechanism
provided by GstBaseSink class. However, that mechanism may not cope with
some AVB use-cases such as Class A streams, where AVTPDUs are expected
to be transmitted at every 125 us. Thus, this patch introduces avtpsink
own mechanism which leverages the socket transmission scheduling
infrastructure introduced in Linux kernel 4.19.  When supported by the
NIC, the transmission scheduling is offloaded to the hardware, improving
transmission time accuracy considerably.

To illustrate that, a before-after experiment was carried out. The
experimental setup consisted in 2 PCs with Intel i210 card connected
back-to-back running an up-to-date Archlinux with kernel 5.3.1. In one
host gst-launch-1.0 was used to generate a 2-minute Class A stream while
the other host captured the packets. The metric under evaluation is the
transmission interval and it is measured by checking the 'time_delta'
information from ethernet frames captured at the receiving side.

The table below shows the outcome for a 48 kHz, 16-bit sample, stereo
audio stream. The unit is nanoseconds.

       |   Mean |   Stdev |     Min |     Max |   Range |
-------+--------+---------+---------+---------+---------+
Before | 125000 │    2401 │  110056 │  288432 │  178376 |
After  | 125000 │      18 │  124943 │  125055 │     112 |

Before this patch, the transmission interval mean is equal to the
optimal value (Class A stream -> 125 us interval), and it is kept the
same after the patch.  The dispersion measurements, however, had
improved considerably, meaning the system is now consistently
transmitting AVTPDUs at the correct time.

Finally, the socket transmission scheduling infrastructure requires the
system clock to be synchronized with PTP clock so this patches modifies
the AVTP plugin documentation to cover how to achieve that.

4 years agoavtpsink: Prepare code to new synchronization mechanism
Andre Guedes [Fri, 4 Oct 2019 18:17:22 +0000 (11:17 -0700)]
avtpsink: Prepare code to new synchronization mechanism

This patch refactors gst_avtp_sink_start() by moving all socket
initialization code to its own function. This change prepares the code
to the next patch which will introduce avtpsink's own rendering
synchronization mechanism.

4 years agoavtpsink: Remove SOCK_NONBLOCK from avtpsink
Andre Guedes [Fri, 4 Oct 2019 18:11:23 +0000 (11:11 -0700)]
avtpsink: Remove SOCK_NONBLOCK from avtpsink

Current avtpsink code opens the AF_PACKET socket with SOCK_NONBLOCK
option. However, we actually want sendto() to block in case there isn't
available space in socket buffer.

4 years agoavtp: Refactor if_index code
Andre Guedes [Fri, 4 Oct 2019 17:56:30 +0000 (10:56 -0700)]
avtp: Refactor if_index code

This patch refactors both avtpsink and avtpsrc code so we use the
if_nametoindex() helper instead of building a request and issuing an
ioctl to get the if_index.

4 years agod3d11window: Clear cached buffer per new caps
Seungha Yang [Wed, 5 Feb 2020 13:12:15 +0000 (22:12 +0900)]
d3d11window: Clear cached buffer per new caps

d3d11window holds one buffer to redraw client area per resize event.

When the input format is being changed, this buffer should be cleared
to avoid mismatch beween newly configured shader/videoprocessor and
the format of previously cached buffer.

4 years agonvdec: Don't leak template caps when registering elements with old NVIDIA driver
Sebastian Dröge [Tue, 4 Feb 2020 09:31:43 +0000 (11:31 +0200)]
nvdec: Don't leak template caps when registering elements with old NVIDIA driver

4 years agod3d11decoder: Use consistent resolution between output caps and video meta
Seungha Yang [Mon, 3 Feb 2020 13:23:21 +0000 (22:23 +0900)]
d3d11decoder: Use consistent resolution between output caps and video meta

h264/h265 decoded buffer might have crop area then we need to
adjust video meta based on the padding space

4 years agod3d11memory: Add a method to specify padding space
Seungha Yang [Mon, 3 Feb 2020 12:55:55 +0000 (21:55 +0900)]
d3d11memory: Add a method to specify padding space

4 years agod3d11decoder: Add support for zero-copy playback
Seungha Yang [Sat, 1 Feb 2020 08:38:29 +0000 (17:38 +0900)]
d3d11decoder: Add support for zero-copy playback

When downstream support d3d11 memory with forward playback case,
expose decoder output view memory objects without copying.

4 years agod3d11decoder: Create decoder output view whenever it's required
Seungha Yang [Mon, 3 Feb 2020 16:00:00 +0000 (01:00 +0900)]
d3d11decoder: Create decoder output view whenever it's required

Whatever the reason, buffer in pool might be freed then we need to
configure decoder output views again.

4 years agod3d11decoder: Need to zero initilized for g_once
Seungha Yang [Mon, 3 Feb 2020 15:55:24 +0000 (00:55 +0900)]
d3d11decoder: Need to zero initilized for g_once

A vairable to be used for g_once, it should be zero initialized

4 years agod3d11allocator: Work as if buffer pool when running on texture array mode
Seungha Yang [Thu, 30 Jan 2020 09:11:52 +0000 (18:11 +0900)]
d3d11allocator: Work as if buffer pool when running on texture array mode

Because the size of texture array cannot be updated dynamically,
allocator should block the allocation request. This cannot be
done at buffer pool side if this d3d11 memory is shared among
multiple buffer objects. Note that setting NO_SHARE flag to
d3d11 memory is very inefficient. It would cause most likey
copy of the d3d11 texture.

4 years agod3d11videosink: Fix fallback buffer copy
Seungha Yang [Thu, 30 Jan 2020 15:17:13 +0000 (00:17 +0900)]
d3d11videosink: Fix fallback buffer copy

Since we don't use dynamic texture now, cpu access to the fallback
texture should not happen.

4 years agod3d11window: Don't create swapchain again per caps change
Seungha Yang [Thu, 30 Jan 2020 12:12:31 +0000 (21:12 +0900)]
d3d11window: Don't create swapchain again per caps change

Creating swapchain is relatively heavy operation. If output dxgi format
is not being chagned, we don't need to destroy and create swachain again.

4 years agod3d11window: Invoke initial resize method from baseclass
Seungha Yang [Fri, 10 Jan 2020 12:45:43 +0000 (21:45 +0900)]
d3d11window: Invoke initial resize method from baseclass

... instead of calling from subclass in order for baseclass to handle
more things between swapchain creation and resource creation.

4 years agod3d11videosink: Use ID3D11VideoProcessor interface
Seungha Yang [Wed, 29 Jan 2020 12:10:00 +0000 (21:10 +0900)]
d3d11videosink: Use ID3D11VideoProcessor interface

...for color space conversion if available

ID3D11VideoProcessor is equivalent to DXVA-HD video processor
which might use specialized blocks for video processing
instead of general GPU resource. In addition to that feature,
we need to use this API for color space conversion of DXVA2 decoder
output memory, because any d3d11 texture arrays that were
created with D3D11_BIND_DECODER cannot be used for shader resource.

This is prework for d3d11decoder zero-copy rendering and also
for conditional HDR tone-map support.
Note that some Intel platform is known to support tone-mapping
at the driver level using this API on Windows 10.

4 years agod3d11: Add video processor object
Seungha Yang [Fri, 10 Jan 2020 14:54:43 +0000 (23:54 +0900)]
d3d11: Add video processor object

ID3D11VideoProcessor interface provides various image conversion
methods. Note that it's analogous to VAAPI VPP.

4 years agod3d11format: Add util methods for mapping DXGI color space with ours
Seungha Yang [Wed, 29 Jan 2020 08:29:04 +0000 (17:29 +0900)]
d3d11format: Add util methods for mapping DXGI color space with ours

Move color space mapping and hdr10 metadata conversion methods to
d3d11format in order to reuse the code.

4 years agofdkaacdec: add support for mpegversion=2
Stéphane Cerveau [Sat, 1 Feb 2020 18:18:44 +0000 (19:18 +0100)]
fdkaacdec: add support for mpegversion=2

Fix for #1199

4 years agonvenc: Query maximum supported API version
Seungha Yang [Wed, 29 Jan 2020 09:55:55 +0000 (18:55 +0900)]
nvenc: Query maximum supported API version

We've been using NvEncodeAPICreateInstance method to find the supported API
version, but that seems to be insufficient since there is a case
where plugin failed in opening encoding session even if NvEncodeAPICreateInstance
succeeded. Asking driver about the version would be the most certain way.

4 years agosdpdemux: check if connections are available on media entry before get
Thiago Santos [Sat, 1 Feb 2020 01:25:08 +0000 (17:25 -0800)]
sdpdemux: check if connections are available on media entry before get

Otherwise we trigger an assert.

4 years agowebrtcbin: fix blocking of receive bin
Mathieu Duponchelle [Sat, 1 Feb 2020 00:37:08 +0000 (01:37 +0100)]
webrtcbin: fix blocking of receive bin

The receive bin should block buffers from reaching dtlsdec before
the dtls connection has started.

While there was code to block its sinkpads until receive_state
was different from BLOCK, nothing was ever setting it to BLOCK
in the first place. This commit corrects this by setting the
initial state to BLOCK, directly in the constructor.

In addition, now that blocking is effective, we want to only
block buffers and buffer lists, as that's what might trigger
errors, we want to still let events and queries go through,
not doing so causes immediate deadlocks when linking the
bin.

4 years agokmssink: Fix crash with force-modesetting=1
Nicolas Dufresne [Fri, 31 Jan 2020 14:47:59 +0000 (09:47 -0500)]
kmssink: Fix crash with force-modesetting=1

This is a master regression, we would allocate a bo without having
created the allocator yet. As of now, we lazily create the allocator.

4 years agosctpassociation: Add missing return to prevent double unlock
Sebastian Dröge [Fri, 31 Jan 2020 06:33:38 +0000 (08:33 +0200)]
sctpassociation: Add missing return to prevent double unlock

4 years agosctpenc: Report errors when sending out data and the association is in error or disco...
Sebastian Dröge [Thu, 30 Jan 2020 15:29:40 +0000 (17:29 +0200)]
sctpenc: Report errors when sending out data and the association is in error or disconnected state

4 years agosctp: Clean up association state handling and go into error/disconnected state in...
Sebastian Dröge [Thu, 30 Jan 2020 15:21:49 +0000 (17:21 +0200)]
sctp: Clean up association state handling and go into error/disconnected state in more circumstances

4 years agosctpassociation: Use GStreamer logging system instead of g_warning() and g_log()
Sebastian Dröge [Thu, 30 Jan 2020 14:28:25 +0000 (16:28 +0200)]
sctpassociation: Use GStreamer logging system instead of g_warning() and g_log()

4 years agosctp: Add more logging to the encoder/decoder elements on data processing
Sebastian Dröge [Thu, 30 Jan 2020 14:13:19 +0000 (16:13 +0200)]
sctp: Add more logging to the encoder/decoder elements on data processing

And convert g_warning()s into normal log output instead.

4 years agosctpenc: Correctly log/handle errors and handle short writes
Sebastian Dröge [Thu, 30 Jan 2020 14:11:57 +0000 (16:11 +0200)]
sctpenc: Correctly log/handle errors and handle short writes

4 years agosctp: Constify buffers in callbacks and functions
Sebastian Dröge [Thu, 30 Jan 2020 14:09:40 +0000 (16:09 +0200)]
sctp: Constify buffers in callbacks and functions

And free data with the correct free() function in the receive callback
by passing it to gst_buffer_new_wrapped_full() instead of
gst_buffer_new_wrapped().

4 years agosctp: Make receive/packetout callbacks thread-safe
Sebastian Dröge [Thu, 30 Jan 2020 14:06:09 +0000 (16:06 +0200)]
sctp: Make receive/packetout callbacks thread-safe

4 years agosctp: Add logging and missing cleanup on errors when creating pads
Sebastian Dröge [Thu, 30 Jan 2020 14:00:33 +0000 (16:00 +0200)]
sctp: Add logging and missing cleanup on errors when creating pads

4 years agosctpenc: Use g_signal_emit() instead of g_signal_emit_by_name()
Sebastian Dröge [Thu, 30 Jan 2020 13:59:12 +0000 (15:59 +0200)]
sctpenc: Use g_signal_emit() instead of g_signal_emit_by_name()

We have all the required information around so make use of it.

4 years agosctpenc: Propagate downstream flow errors upstream
Sebastian Dröge [Thu, 30 Jan 2020 13:58:30 +0000 (15:58 +0200)]
sctpenc: Propagate downstream flow errors upstream

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1180

4 years agosctpdec: Use a flow combiner for the source pad flow returns and propagate errors...
Sebastian Dröge [Thu, 30 Jan 2020 13:56:36 +0000 (15:56 +0200)]
sctpdec: Use a flow combiner for the source pad flow returns and propagate errors upstream

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1180

4 years agompegtsparse: Moved dispose function into finalize
Vivia Nikolaidou [Fri, 17 Jan 2020 15:44:34 +0000 (17:44 +0200)]
mpegtsparse: Moved dispose function into finalize

dispose can be called several times and would double-free the flow
combiner in that case.

4 years agompegtsparse: Added alignment property
Vivia Nikolaidou [Wed, 22 Jan 2020 11:55:58 +0000 (13:55 +0200)]
mpegtsparse: Added alignment property

alignment works like in mpegtsmux, joining several MpegTS packets into
one buffer. Default value of 0 joins as many as possible for each
incoming buffer, to optimise CPU usage.

4 years agompegtsparse: Set delta unit flag on non-random-access buffers
Vivia Nikolaidou [Fri, 10 Jan 2020 16:00:07 +0000 (18:00 +0200)]
mpegtsparse: Set delta unit flag on non-random-access buffers

If they don't have the random access flag set, they cannot be decoded
independently.

4 years agompegtsparse: Packetize output on default srcpad
Vivia Nikolaidou [Fri, 10 Jan 2020 15:58:34 +0000 (17:58 +0200)]
mpegtsparse: Packetize output on default srcpad

Align buffer boundaries with mpeg-ts packets, instead of keeping
whatever packetization we have from the source (network, file reading).

4 years agompegtsparse: Factor common code into mpegts_packet_to_buffer
Vivia Nikolaidou [Fri, 10 Jan 2020 15:54:54 +0000 (17:54 +0200)]
mpegtsparse: Factor common code into mpegts_packet_to_buffer

The same code was used twice for turning an MpegTSPacketizerPacket into
a GstBuffer.

4 years agompegtspacketizer: Fix typo in flag name
Vivia Nikolaidou [Fri, 10 Jan 2020 15:52:58 +0000 (17:52 +0200)]
mpegtspacketizer: Fix typo in flag name

4 years agomsdkdec: Fix GstMsdkContext leak
Seungha Yang [Wed, 29 Jan 2020 05:10:06 +0000 (14:10 +0900)]
msdkdec: Fix GstMsdkContext leak

4 years agomsdk: Clear reference counted object in dispose() method
Seungha Yang [Wed, 29 Jan 2020 05:02:09 +0000 (14:02 +0900)]
msdk: Clear reference counted object in dispose() method

Follow GObject's memory management model

4 years agowaylandsink: Clear window when pipeline is stopped
Guillermo Rodríguez [Tue, 28 Jan 2020 12:06:59 +0000 (13:06 +0100)]
waylandsink: Clear window when pipeline is stopped

When a pipeline is stopped (actually when the waylandsink element
state changes from PAUSED to READY) the video surface is cleared, but
the opaque black surface behind is not. Fix this by actually clearing
both surfaces.

4 years agomsdk: use cached response for DMABuf when the frame size is same
Haihao Xiang [Thu, 9 Jan 2020 14:23:17 +0000 (22:23 +0800)]
msdk: use cached response for DMABuf when the frame size is same

User is seeing corrupted display when running `videotestsrc !
video/x-raw,format=NV12,width=xxx,height=xxx ! msdkh265enc ! msdkh265dec
! glimagesink` with changed frame size, e.g. from 1920x1080 to 1920x240

The root cause is a same dmabuf fd is used for frames with
different size, which causes some unexpected result. This patch requires
cached response is used for frames with same size only for DMABuf, so a
dmabuf fd can't be used for frames with different size any more.

4 years agod3d11window_win32: Let DXGI choose client area
Seungha Yang [Sat, 25 Jan 2020 09:39:52 +0000 (18:39 +0900)]
d3d11window_win32: Let DXGI choose client area

Don't specify the resolution of backbuffer. Then dxgi will let us know the
actual client area. When upstream resolution is chagned, updating the size
of backbuffer without the consideration for client size would cause mismatch
between them.

4 years agonvdec: Do not map GStreamer discont to CUVid discont
Nicolas Dufresne [Thu, 23 Jan 2020 16:01:33 +0000 (11:01 -0500)]
nvdec: Do not map GStreamer discont to CUVid discont

Setting the CUVID_PKT_DISCONTINUITY implies clearing any past information
about the stream in the decoder. The GStreamer discont flag is used for
discontinuity caused by a seek, for first buffer and if a buffer was
dropped. In the first two cases, the parsers and demuxers should ensure we
start from a synchronization point, so it's unlikely that delta will be
matched against the wrong state.

For packet lost, the discontinuity flag will prevent the decoder from doing
any concealment, with a result that ca be much worst visually, or freeze the
playback until an IDR is met. It's better to let the decoder handle that for
us.

Removing this flag, also workaround a but in NVidia parser that makes it
ignore our ENDOFFRAME flag and increase the latency by one frame.

4 years agonvdec: Tell the parser we have complete pictures
Nicolas Dufresne [Wed, 22 Jan 2020 15:26:02 +0000 (10:26 -0500)]
nvdec: Tell the parser we have complete pictures

This sets the CUVID_PKT_ENDOFPICTURE flag in order to inform the decoder that
we have a complete picture. This should remove one frame latency otherwise
introduce by NVidia parser.

4 years agoccconverter: Fill remainder of the cc_data in CDP packets with empty packets
Sebastian Dröge [Thu, 23 Jan 2020 16:08:53 +0000 (18:08 +0200)]
ccconverter: Fill remainder of the cc_data in CDP packets with empty packets

Instead of filling it completely with zeroes. Filling with zeroes is
considered invalid by various CC implementations.

4 years agod3d11window_corewindow: Always call methods of CoreWindow interface from UI thread
Seungha Yang [Tue, 21 Jan 2020 12:25:28 +0000 (21:25 +0900)]
d3d11window_corewindow: Always call methods of CoreWindow interface from UI thread

Like swapchain panel implementation, most methods of CoreWindow
should be called from UI thread.

4 years agompegdemux: Update the last_ts correctly if we have no DTS
Sebastian Dröge [Tue, 21 Jan 2020 14:50:22 +0000 (16:50 +0200)]
mpegdemux: Update the last_ts correctly if we have no DTS

If we have no DTS but a PTS then this means both are the same, and we
should update the last_ts with the PTS. Only if both are unknown then we
don't know the current position and should not update it at all.

Previously we would always update the last_ts to GST_CLOCK_TIME_NONE if
the DTS is unknown, which caused the position to jump around and to
cause spurious gap events to be sent.

4 years agomsdk: Fix compiler warning
Haihao Xiang [Tue, 21 Jan 2020 07:14:08 +0000 (15:14 +0800)]
msdk: Fix compiler warning

This patch fixed compiler warning below:

[1/4] Compiling C object 'sys/msdk/dc44ea0@@gstmsdk@sha/gstmsdkvpp.c.o'.
../../gst-plugins-bad/sys/msdk/gstmsdkvpp.c: In function
‘gst_msdkvpp_context_prepare’:
../../gst-plugins-bad/sys/msdk/gstmsdkvpp.c:214:7: warning: suggest
parentheses around operand of ‘!’ or change ‘&’ to ‘&&’ or ‘!’ to ‘~’
[-Wparentheses]

4 years agowebrtcbin: connect rtp funnel after updating ptmaps
Mathieu Duponchelle [Tue, 21 Jan 2020 11:14:49 +0000 (12:14 +0100)]
webrtcbin: connect rtp funnel after updating ptmaps

We need the streams' pt maps updated before requesting pads
on rtpbin, because this is what will trigger the requesting
of FEC encoders, and our handler for this request looks for
the payload types in the relevant stream's pt map.

Fixes #1187

4 years agompegpsdemux: Send gap events for late streams whenever updating the SCR
Sebastian Dröge [Mon, 20 Jan 2020 14:35:50 +0000 (16:35 +0200)]
mpegpsdemux: Send gap events for late streams whenever updating the SCR

Instead of doing it on each packet and doing it based on the distance to
the previous SCR instead of based on the DTS.

Previously we would send gap events for audio all the time if the SCR
distance was 400ms because the threshold for audio is 300ms and by only
ever updating the position when the SCR updates we would always be 100ms
above the threshold and send needless gap events.

This fixes audio glitches on various files caused by gap events.

4 years agonvenc: Do not access to broken encode session
Seungha Yang [Thu, 16 Jan 2020 04:00:33 +0000 (13:00 +0900)]
nvenc: Do not access to broken encode session

If an encode session failed in initializing, the encode
session would be broken and the next nvenc API will cause crash.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1179

4 years agomsdk: Fix increasing memory usage in dynamic pipelines
Nirbheek Chauhan [Fri, 17 Jan 2020 05:37:47 +0000 (11:07 +0530)]
msdk: Fix increasing memory usage in dynamic pipelines

Our context is non-persistent, and we propagate it throughout the
pipeline. This means that if we try to reuse any gstmsdk element by
removing it from the pipeline and then re-adding it, we'll clone the
mfxSession and create a new gstmsdk context as a child of the old one
inside `gst_msdk_context_new_with_parent()`.

Normally this only allocates a few KB inside the driver, but on
Windows it seems to allocate tens of MBs which leads to linearly
increasing memory usage for each PLAYING->NULL->PLAYING state cycle
for the process. The contexts will only be freed when the pipeline
itself goes to `NULL`, which would defeat the purpose of dynamic
pipelines.

Essentially, we need to optimize the case in which the element is
removed from the pipeline and re-added and the same context is re-set
on it. To detect that case, we set the context on `old_context`, and
compare it to the new one when preparing the context. If they're the
same, we don't need to do anything.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/946

4 years agomsdk: Reorganize context preparation code
Nirbheek Chauhan [Fri, 17 Jan 2020 05:13:11 +0000 (10:43 +0530)]
msdk: Reorganize context preparation code

Split it out into a separate function with early exits to make the
flow clearer, and document what the function is doing clearly.
No functional changes.

4 years agomsdk: Fix warning about unused variable on Windows
Nirbheek Chauhan [Fri, 17 Jan 2020 04:43:49 +0000 (10:13 +0530)]
msdk: Fix warning about unused variable on Windows

4 years agomsdk: Use gst_clear_object()
Nirbheek Chauhan [Fri, 17 Jan 2020 08:15:35 +0000 (13:45 +0530)]
msdk: Use gst_clear_object()

`gst_object_replace()` is not supposed to be used for unreffing and
NULLing objects.

4 years agonvcodec: Print debug info when initializing nvenc
Nirbheek Chauhan [Mon, 20 Jan 2020 10:57:30 +0000 (16:27 +0530)]
nvcodec: Print debug info when initializing nvenc

We weren't printing the return value.

4 years agonvcodec: Fix crash on 32-bit Windows
Nirbheek Chauhan [Mon, 20 Jan 2020 09:52:26 +0000 (15:22 +0530)]
nvcodec: Fix crash on 32-bit Windows

We weren't using the correct calling convention when calling CUDA and
CUVID APIs. `CUDAAPI` is `__stdcall` on Windows. This was working fine
on x64 because `__stdcall` is ignored and there's no special calling
convention. However, on x86, we need to use `__stdcall`.

4 years agonvcodec: cuda.h only needs glib.h, not gst.h
Nirbheek Chauhan [Mon, 20 Jan 2020 09:40:51 +0000 (15:10 +0530)]
nvcodec: cuda.h only needs glib.h, not gst.h

Just a nitpick. Also, force the compiler to use our stub header
instead of searching for it in the include paths.

4 years agowebrtcbin: Start datachannel SCTP elements only after the DTLS connection is established
Sebastian Dröge [Fri, 17 Jan 2020 09:19:53 +0000 (11:19 +0200)]
webrtcbin: Start datachannel SCTP elements only after the DTLS connection is established

Otherwise we would start sending data to the DTLS connection before, and
the DTLS elements consider this an error.

Also RFC 8261 mentions:
  o A DTLS connection MUST be established before an SCTP association can
    be set up.

4 years agowebrtcbin: Add handling of unspecified peer-connection-state situation
Sebastian Dröge [Sun, 12 Jan 2020 15:04:22 +0000 (17:04 +0200)]
webrtcbin: Add handling of unspecified peer-connection-state situation

For us it can happen that the DTLS transports are still in the process
of connecting while the ICE transport is already completed. This
situation is not specified in the spec but conceptually that means it is
still in the process of connecting.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758

4 years agowebrtcbin: Return the old state if we ended up being in an unspecified situation
Sebastian Dröge [Sun, 12 Jan 2020 14:32:20 +0000 (16:32 +0200)]
webrtcbin: Return the old state if we ended up being in an unspecified situation

Previously we would've returned NEW, which is usually more wrong.

4 years agowebrtcbin: Fix transitions for the peer connection state
Sebastian Dröge [Thu, 9 Jan 2020 17:21:08 +0000 (19:21 +0200)]
webrtcbin: Fix transitions for the peer connection state

They're now mapping exactly to what
  https://www.w3.org/TR/webrtc/#rtcpeerconnectionstate-enum
actually specifies.

Related to https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758

4 years agowebrtcbin: Fix transitions for the connection state
Sebastian Dröge [Thu, 9 Jan 2020 16:55:56 +0000 (18:55 +0200)]
webrtcbin: Fix transitions for the connection state

They're now mapping exactly to what
  https://www.w3.org/TR/webrtc/#dom-rtciceconnectionstate
actually specifies.

Related to https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758

4 years agowebrtc/dtlstransport: Proxy DTLS connection state from the DTLS elements to the transport
Sebastian Dröge [Sun, 12 Jan 2020 14:25:01 +0000 (16:25 +0200)]
webrtc/dtlstransport: Proxy DTLS connection state from the DTLS elements to the transport

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/758

4 years agodtls: Keep track of the connection state and signal it through all the layers
Sebastian Dröge [Sun, 12 Jan 2020 14:18:09 +0000 (16:18 +0200)]
dtls: Keep track of the connection state and signal it through all the layers

This allows the application to keep track of the underlying DTLS
connection state and act accordingly.

4 years agodtls: Handle errors/close_notify at all steps and propagate through the layers properly
Sebastian Dröge [Sun, 12 Jan 2020 11:56:00 +0000 (13:56 +0200)]
dtls: Handle errors/close_notify at all steps and propagate through the layers properly

Previously we simply logged errors but never reported them to elements
or even to the user. Fatal errors are now properly reported.

Additionally proper connection closing is implemented based on EOS:
- dtlsenc: EOS will cause close_notify to be sent to the peer and only
           if the peer also sent back close_notify we will forward the
           EOS event.
- dtlsdec: EOS will be forwarded normally, this only means that the
           unterlying transport was closed. On receiving a DTLS packet
           containing close_notify, return EOS and send EOS downstream.