platform/upstream/gstreamer.git
4 years agoh265parse: Fix offset by one error in pic timing SEI
Dylan Yip [Fri, 7 Feb 2020 08:13:49 +0000 (00:13 -0800)]
h265parse: Fix offset by one error in pic timing SEI

Offset by one error causes a free/malloc error when parsing pic timing
SEI messages.

4 years agod3d11decoder: Ensure the written bitstream buffer size is 128 bytes aligned
Seungha Yang [Fri, 21 Feb 2020 12:02:47 +0000 (21:02 +0900)]
d3d11decoder: Ensure the written bitstream buffer size is 128 bytes aligned

DXVA spec is saying that the size of bitstream buffer provided by hardware decoder
should be 128 bytes aligned. And also the host software decoder should
align the size of written buffer to 128 bytes. That means if the slice
(or frame in case of VP9) size is not aligned with 128 bytes,
the rest of non 128 bytes aligned memory should be zero-padded.

In addition to aligning implementation, some variables are renamed
to be more intuitive by this commit.

4 years agomsdk: libva: Don't set the hint if MFX_VERSION is lower than 1025
Haihao Xiang [Wed, 12 Feb 2020 02:24:55 +0000 (10:24 +0800)]
msdk: libva: Don't set the hint if MFX_VERSION is lower than 1025

MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET is defined since MFX_VERSION
1025.

4 years agortmp2: Expose connection stats as property
Jan Alexander Steffens (heftig) [Mon, 27 Jan 2020 14:13:58 +0000 (15:13 +0100)]
rtmp2: Expose connection stats as property

Save the stats before we destroy the connection, so we can still
retrieve them afterwards.

4 years agortmp2: Add gst_rtmp_connection_get_stats and _get_null_stats
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 13:53:46 +0000 (14:53 +0100)]
rtmp2: Add gst_rtmp_connection_get_stats and _get_null_stats

The former uses a thread-safe way of getting statistics from the
connection without having to protect the fields with a lock.

The latter produces a zeroed statistics structure for use when no
connection exists.

4 years agortmp2: Count outgoing bytes and acked bytes
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 11:34:44 +0000 (12:34 +0100)]
rtmp2: Count outgoing bytes and acked bytes

For statistics.

4 years agortmp2sink: Add a property for the outgoing chunk size
Jan Alexander Steffens (heftig) [Mon, 27 Jan 2020 15:30:20 +0000 (16:30 +0100)]
rtmp2sink: Add a property for the outgoing chunk size

4 years agortmp2: Add gst_rtmp_connection_set_chunk_size
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 11:34:19 +0000 (12:34 +0100)]
rtmp2: Add gst_rtmp_connection_set_chunk_size

4 years agortmp2: Handle outgoing set chunk/window size properly
Jan Alexander Steffens (heftig) [Mon, 27 Jan 2020 15:22:20 +0000 (16:22 +0100)]
rtmp2: Handle outgoing set chunk/window size properly

Apply outgoing sizes only after writing the chunk to the peer. This is
important particularly for the set chunk size and allows exposing it
without threading issues.

4 years agortmp2: Chunk messages as buffers in loop thread
Jan Alexander Steffens (heftig) [Mon, 27 Jan 2020 13:05:31 +0000 (14:05 +0100)]
rtmp2: Chunk messages as buffers in loop thread

Move output chunking from gst_rtmp_connection_queue_message into
gst_rtmp_connection_start_write, which effectively moves it from the
streaming thread into the loop thread.

This allows us to handle the outgoing chunk-size message (which is
generated by changing the future chunk-size property) properly, which
could come from any other thread.

4 years agortmp2: Consistently use GstBuffer for RTMP chunks
Jan Alexander Steffens (heftig) [Wed, 12 Feb 2020 15:55:15 +0000 (16:55 +0100)]
rtmp2: Consistently use GstBuffer for RTMP chunks

4 years agortmp2: Add gst_rtmp_chunk_stream_serialize_all
Jan Alexander Steffens (heftig) [Wed, 12 Feb 2020 15:47:30 +0000 (16:47 +0100)]
rtmp2: Add gst_rtmp_chunk_stream_serialize_all

Serializes an RTMP message into a series of chunks, all in one buffer.

Similar to what gst_rtmp_connection_queue_message does to serialize
into a GByteArray.

4 years agortmp2: Add gst_rtmp_output_stream_write_all_buffer_async
Jan Alexander Steffens (heftig) [Wed, 12 Feb 2020 15:43:30 +0000 (16:43 +0100)]
rtmp2: Add gst_rtmp_output_stream_write_all_buffer_async

Similar to gst_rtmp_output_stream_write_all_bytes_async, but takes a
GstBuffer instead of a GBytes. It can also return the number of bytes
written, which might be lower in case of an error.

4 years agortmp2: Improve handling incoming set chunk/window size
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 11:28:43 +0000 (12:28 +0100)]
rtmp2: Improve handling incoming set chunk/window size

Reject out-of-spec sizes and warn about suspiciously small sizes.

4 years agortmp2: Lock self->lock before OBJECT_LOCK
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 13:26:27 +0000 (14:26 +0100)]
rtmp2: Lock self->lock before OBJECT_LOCK

OBJECT_LOCK is used to protect property access only. self->lock is
used to access the RtmpConnection, mostly between the streaming thread
and the loop thread.

To avoid deadlocks involving these two locks, we obey a lock order:
If both self->lock and OBJECT_LOCK are needed, self->lock must be locked
first. Clarify this.

4 years agortmp2: Reject oversized messages
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 11:20:32 +0000 (12:20 +0100)]
rtmp2: Reject oversized messages

We only have 24 bits for the size, so reject anything larger.

4 years agortmp2: Count in_bytes_acked instead of in_bytes_unacked
Jan Alexander Steffens (heftig) [Fri, 14 Feb 2020 10:49:23 +0000 (11:49 +0100)]
rtmp2: Count in_bytes_acked instead of in_bytes_unacked

This is nicer for statistics.

4 years agortmp2: rtmpconnection: Use more appropriate size types
Jan Alexander Steffens (heftig) [Wed, 12 Feb 2020 17:27:56 +0000 (18:27 +0100)]
rtmp2: rtmpconnection: Use more appropriate size types

- guint32 for chunk size and window size
- guint64 for running counters

4 years agortmp2: Add a g_return_val_if_fail
Jan Alexander Steffens (heftig) [Wed, 12 Feb 2020 15:55:45 +0000 (16:55 +0100)]
rtmp2: Add a g_return_val_if_fail

4 years agortmp2: Replace explicit unref with g_main_context_invoke_full
Jan Alexander Steffens (heftig) [Wed, 12 Feb 2020 15:49:45 +0000 (16:49 +0100)]
rtmp2: Replace explicit unref with g_main_context_invoke_full

4 years agortmp2: rtmpconnection: Use GST_*_OBJECT logging
Jan Alexander Steffens (heftig) [Mon, 27 Jan 2020 14:27:28 +0000 (15:27 +0100)]
rtmp2: rtmpconnection: Use GST_*_OBJECT logging

GstRtmpConnection isn't a GstObject with a name or path, but we still
get the GObject's type and address.

4 years agorist: fix two minor memory leaks
Marc Leeman [Fri, 21 Feb 2020 10:33:35 +0000 (11:33 +0100)]
rist: fix two minor memory leaks

4 years agortpmanagerbad: fix two minor memory leaks
Marc Leeman [Wed, 19 Feb 2020 16:07:35 +0000 (17:07 +0100)]
rtpmanagerbad: fix two minor memory leaks

4 years agortpmanagerbad: reduce lock in rtpsink
Marc Leeman [Wed, 19 Feb 2020 16:07:23 +0000 (17:07 +0100)]
rtpmanagerbad: reduce lock in rtpsink

4 years agortpmanagerbad: documentation comment fix
Marc Leeman [Wed, 19 Feb 2020 16:06:18 +0000 (17:06 +0100)]
rtpmanagerbad: documentation comment fix

4 years agowebrtc: Configure transportsendbin latency internally
Jan Schmidt [Thu, 20 Feb 2020 16:39:14 +0000 (03:39 +1100)]
webrtc: Configure transportsendbin latency internally

Add latency configuration logic to transportsendbin to
isolate it from the overall pipeline latency. That means that
it configures minimum latency internally based on the
latency query, and sends a latency event upstream that
matches.

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

4 years agod3d11decoder: Add padding space on decoder output view when it's not aligned
Seungha Yang [Thu, 20 Feb 2020 07:19:09 +0000 (16:19 +0900)]
d3d11decoder: Add padding space on decoder output view when it's not aligned

Most H/W decoders have required alignment and dxva is also the case.

4 years agod3d11decoder: Register elements per GPU device with capability check
Seungha Yang [Fri, 14 Feb 2020 16:23:32 +0000 (01:23 +0900)]
d3d11decoder: Register elements per GPU device with capability check

This implementation is similar to what we've done for nvcodec plugin.
Since supported resolution, profiles, and formats are device dependent ones,
single template caps cannot represent them, so this modification
will help autoplugging and fallback.

Note that the legacy gpu list and list of resolution to query were
taken from chromium's code.

4 years agod3d11device: Fix typo
Seungha Yang [Mon, 17 Feb 2020 06:04:28 +0000 (15:04 +0900)]
d3d11device: Fix typo

s/vender/vendor

4 years agod3d11device: Adjust debug level for when _new() fails
Seungha Yang [Fri, 14 Feb 2020 11:27:28 +0000 (20:27 +0900)]
d3d11device: Adjust debug level for when _new() fails

gst_d3d11_device_new might be used to enumerate device.

4 years agovkswapper: keep a reference on the input buffer until present is finished
Matthew Waters [Thu, 6 Feb 2020 05:39:06 +0000 (16:39 +1100)]
vkswapper: keep a reference on the input buffer until present is finished

Otherwise, there may be a very small period of time where the buffer can
be freed while being presented.

4 years agowebrtc: Merge ICE candidates to local descriptions
Jan Schmidt [Fri, 14 Feb 2020 01:52:30 +0000 (12:52 +1100)]
webrtc: Merge ICE candidates to local descriptions

When emitting ICE candidates, also merge them to the local and
pending description so they show up in the SDP if those are
retrieved from the current-local-description and
pending-local-description properties.

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

4 years agod3d11videosink: Ensure upload staging texture to fallback render texture
Seungha Yang [Sun, 16 Feb 2020 08:11:29 +0000 (17:11 +0900)]
d3d11videosink: Ensure upload staging texture to fallback render texture

gst_video_frame_copy will copy input frame to stating texture
of fallback frame. Then, we need to map fallback texture with GST_MAP_D3D11
flag to upload the staging texture to render texture. Otherwise
the render texture wouldn't be updated.

4 years agod3d11decoder: Fix copying decoder view to staging
Seungha Yang [Thu, 13 Feb 2020 12:19:37 +0000 (21:19 +0900)]
d3d11decoder: Fix copying decoder view to staging

Source texture (decoder view) might be larger than destination (staging) texture.
In that case, D3D11_BOX structure should be passed to CopySubresourceRegion method
in order to specify the exact target area.

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.