platform/upstream/gstreamer.git
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.

4 years agodtls: Propagate write errors backwards through dtlsenc/dtlsconnection
Sebastian Dröge [Sun, 12 Jan 2020 10:48:55 +0000 (12:48 +0200)]
dtls: Propagate write errors backwards through dtlsenc/dtlsconnection

4 years agodtls: Use a plain function pointer instead of a GClosure for the send callback
Sebastian Dröge [Sun, 12 Jan 2020 09:24:15 +0000 (11:24 +0200)]
dtls: Use a plain function pointer instead of a GClosure for the send callback

There's not point in using GClosure and going through all the
GValue/libffi infrastructure for each DTLS packet.

4 years agowebrtcbin: Don't consider transceivers without mid as inactive during ICE gathering...
Sebastian Dröge [Thu, 9 Jan 2020 10:32:24 +0000 (12:32 +0200)]
webrtcbin: Don't consider transceivers without mid as inactive during ICE gathering state updates

We don't have any mid before parsing the SDP, which happens after we
handled the SDP answer and that usually happens long after ICE candidate
gathering is finished.

Without this all transceivers are considered inactive and as such ICE
gathering is for active transceiver was considered complete from the
very beginning.

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

4 years agowebrtcbin: Don't consider RTP receivers stopped
Sebastian Dröge [Thu, 9 Jan 2020 10:27:31 +0000 (12:27 +0200)]
webrtcbin: Don't consider RTP receivers stopped

We don't support stopping RTP receivers currently so let's not consider
them all stopped all the time. This fixes some of the ICE/DTLS state
change handling and specifically fixes the ICE gathering state.

Previously the ICE gathering state was immediately going from NEW to
COMPLETE because it considered all transceivers stopped and as such all
activate transceivers were finished gathering ICE candidates.

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

4 years agowebrtcbin: Improve logging related to ICE/DTLS state changes
Sebastian Dröge [Thu, 9 Jan 2020 10:26:41 +0000 (12:26 +0200)]
webrtcbin: Improve logging related to ICE/DTLS state changes

4 years agoyadif: Re-renable MMX asm on x86_64 with meson
Jan Schmidt [Mon, 30 Dec 2019 15:41:40 +0000 (02:41 +1100)]
yadif: Re-renable MMX asm on x86_64 with meson

The meson build doesn't automatically set HAVE_CPU_* defines
like autotools did, so the yadif plugin was being built without
the MMX assembler support

4 years agoyadif: Only build inline Asm with gcc/clang
Jan Schmidt [Sun, 19 Jan 2020 03:50:12 +0000 (14:50 +1100)]
yadif: Only build inline Asm with gcc/clang

4 years agomsdkdec: align frame list using decoded timestamp
Josep Torra [Wed, 6 Nov 2019 12:45:09 +0000 (04:45 -0800)]
msdkdec: align frame list using decoded timestamp

Before this change decoder used the oldest frame in the list to pair it
with the decoded surface. This only works when there's a perfect stream
like HEADERS,SYNCPOINT,DELTA...

When playing RTSP streams we can get imperfect streams like HEADERS,
DELTA,SYNCPOINT,DELTA... In this case decoder drops the frames
between HEADERS and SYNCPOINT which leads into using wrong PTS on
the output frames.

With this change we inject the input PTS into the bitstream and use it
to align the internal frame list with the actually decoded position.

Fixes playback with:
```
gst-launch-1.0 rtspsrc location=... latency=0 drop-on-latency=1 ! ...
```

4 years agonvenc: Query supported minimum resolution
Seungha Yang [Thu, 28 Nov 2019 12:30:18 +0000 (21:30 +0900)]
nvenc: Query supported minimum resolution

Hard-coded 16x16 resolution is likely to differ from the device's support
in most cases. If we can use NV_ENC_CAPS_WIDTH_MIN and NV_ENC_CAPS_HEIGHT_MIN,
update pad template with returned value.

4 years agonvcodec: Bump SDK header to version 9.1
Seungha Yang [Thu, 28 Nov 2019 11:47:34 +0000 (20:47 +0900)]
nvcodec: Bump SDK header to version 9.1

Update header to query minimum resolution of encoder and to control
the number of reference frame if it's supported

4 years agomxfdemux: add support for Apple ProRes
Tim-Philipp Müller [Wed, 18 Dec 2019 18:01:30 +0000 (18:01 +0000)]
mxfdemux: add support for Apple ProRes

4 years agoexamples: add test-roi for gst-msdk
Haihao Xiang [Wed, 27 Nov 2019 04:23:58 +0000 (12:23 +0800)]
examples: add test-roi for gst-msdk

Copied and pasted from gstreamer-vaapi and did a few changes for gst-msdk.

4 years agomsdkdec: support transform_meta virtual method
Haihao Xiang [Wed, 27 Nov 2019 07:16:17 +0000 (15:16 +0800)]
msdkdec: support transform_meta virtual method

Allow the base class to copy GstVideoRegionOfInterestMeta data to the
output buffer when calling gst_video_decoder_finish_frame

4 years agomsdkenc: set ROI region for msdk{h264, h265}enc
Haihao Xiang [Wed, 27 Nov 2019 08:00:59 +0000 (16:00 +0800)]
msdkenc: set ROI region for msdk{h264, h265}enc

A reconfig is needed when ROI is changed, otherwise the ROI parameters won't
take effect

4 years agomsdkenc: add set_extra_params virtual method
Haihao Xiang [Tue, 3 Dec 2019 02:48:21 +0000 (10:48 +0800)]
msdkenc: add set_extra_params virtual method

set_extra_params is added to allow sub class to add extra mfx parameters
for changed input frame or meta data

4 years agomsdkenc: add need_reconfig virtual method
Haihao Xiang [Thu, 28 Nov 2019 06:54:30 +0000 (14:54 +0800)]
msdkenc: add need_reconfig virtual method

need_reconfig is added to allow sub class requires a reconfig when
the input frame or the MetaData (e.g. GstVideoRegionOfInterestMeta)
attached to the input frame is changed.

4 years agod3d11h265dec: Fix wrong NoRaslOutputFlag setting
Seungha Yang [Mon, 13 Jan 2020 08:20:14 +0000 (17:20 +0900)]
d3d11h265dec: Fix wrong NoRaslOutputFlag setting

... and handle EOS and EOB nals.

Only the first CRA picture should be associated with NoRaslOutputFlag
as the comment in code.

4 years agopkgconfig: Remove unused substitution in uninstalled.pc.in
Nirbheek Chauhan [Sun, 12 Jan 2020 02:37:23 +0000 (08:07 +0530)]
pkgconfig: Remove unused substitution in uninstalled.pc.in

`@videolibdir@` isn't used anymore.

4 years agotests: Fix minor bugs in usage of config.h
Nirbheek Chauhan [Sun, 12 Jan 2020 02:19:47 +0000 (07:49 +0530)]
tests: Fix minor bugs in usage of config.h