Commit graph

2846 commits

Author SHA1 Message Date
Sebastian Dröge
b691700f5e directsoundsrc: Don't dynamically load one DirectSound symbol at runtime
Just link statically to it, like for all other DirectSound symbols.
2018-01-22 15:24:56 +02:00
Nirbheek Chauhan
1450851095 wasapi: Rewrite most of the code to make it work
Both the source and the sink elements were broken in a number of ways:

* prepare() was assuming that the format was always S16LE 2ch 44.1KHz.
  We now probe the preferred format with GetMixFormat().
* Device initialization was done with the wrong buffer size
  (buffer_time is in microseconds, not nanoseconds).
* sink_write() and src_read() were just plain wrong and would never
  write or read anything useful.
* Some functions in prepare() were always returning FALSE which meant
  trying to use the elements would *always* fail.
* get_caps() and delay() were not implemented at all.

TODO: support for >2 channels
TODO: pro-audio low-latency
TODO: SPDIF and other encoded passthroughs

Three new properties are now implemented: role, mute, and device.

* 'role' designates the stream role of the initialized device, see:
   https://msdn.microsoft.com/en-us/library/windows/desktop/dd370842(v=vs.85).aspx
* 'device' is a system-wide GUIDesque string for a specific device.
* 'mute' is a sink property and simply mutes it.

On my Windows 8.1 system, the lowest latency that works is:

  wasapisrc buffer-time=20000
  wasapisink buffer-time=10000

aka, 20ms and 10ms respectively. These values are close to the lowest
possible with the IAudioClient interface. Further improvements require
porting to IAudioClient2 or IAudioClient3.

https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/low-latency-audio
2018-01-22 14:18:53 +05:30
Víctor Manuel Jáquez Leal
568c552ac0 msdk: change plugin's description
There are not only encoders nowadays, there are decoders too and a
postprocessor in the future.
2018-01-11 11:29:38 +01:00
Sreerenj Balachandran
b6c26919df msdk: init the debug category for mpeg2dec
https://bugzilla.gnome.org/show_bug.cgi?id=792260
2018-01-10 18:24:07 -09:00
Sreerenj Balachandran
7536d12095 msdk: Add mpeg2 decoder
https://bugzilla.gnome.org/show_bug.cgi?id=792260
2018-01-10 10:40:24 -09:00
Vivia Nikolaidou
b5ff71fc3c decklinkaudiosrc: Extrapolate stream/hw reference timestamps when video frame is missing
Sometimes we might get an audio packet without a corresponding video
frame. In these cases, the stream and hardware reference timestamps
would be missing, because they're called on the video frame. Instead of
potentially breaking stuff downstream that might depend on these, we now
extrapolate them.

https://bugzilla.gnome.org/show_bug.cgi?id=792042
2018-01-04 15:51:16 +02:00
Vivia Nikolaidou
a3a7d2e0ff decklink: Detect gaps on incoming stream times, issue warnings
When we receive a video or audio buffer, we calculate the next stream
time based on the current stream time + buffer duration. If the next
buffer's stream time is after that, we issue a warning.

This happens because the stream time incoming from Decklink should be
really constant and without gaps. If there is a gap, it means that
something went wrong, e.g. the internal buffer pool is empty (too many
buffers queued up downstream).

https://bugzilla.gnome.org/show_bug.cgi?id=781776
2018-01-04 15:43:17 +02:00
Vivia Nikolaidou
42a03a8124 Revert "WIP: Revert "Revert "decklink: Detect gaps on incoming stream times, issue warnings"""
This reverts commit 8dceeb5ccd.
2018-01-04 15:41:51 +02:00
Vivia Nikolaidou
8ee1534b80 Revert "decklinkaudiosrc: Extrapolate stream/hw reference timestamps when video frame is missing"
This reverts commit 6af863916a.
2018-01-04 15:41:44 +02:00
Vivia Nikolaidou
6af863916a decklinkaudiosrc: Extrapolate stream/hw reference timestamps when video frame is missing
Sometimes we might get an audio packet without a corresponding video
frame. In these cases, the stream and hardware reference timestamps
would be missing, because they're called on the video frame. Instead of
potentially breaking stuff downstream that might depend on these, we now
extrapolate them.

https://bugzilla.gnome.org/show_bug.cgi?id=792042
2018-01-04 13:54:37 +02:00
Vivia Nikolaidou
8dceeb5ccd WIP: Revert "Revert "decklink: Detect gaps on incoming stream times, issue warnings""
This reverts commit 07819afda4.
2018-01-04 13:54:37 +02:00
Olivier Crête
e19e02db93 shmsink: Block in preroll_wait on unlock
The correct behaviour of anything stuck in the ->render() function
between ->unlock() and ->unlock_stop() is to call
gst_base_sink_wait_preroll() and only return an error if this returns an
error, otherwise, it must continue where it left off!

https://bugzilla.gnome.org/show_bug.cgi?id=774950
2017-12-19 17:41:43 -05:00
Marcin Lewandowski
9a128603c9 smhsink: Check return values of functions working on memory
https://bugzilla.gnome.org/show_bug.cgi?id=768530
2017-12-19 17:32:19 -05:00
Tim-Philipp Müller
f4b9d8c299 applemedia: don't include private cocoa gl header 2017-12-19 21:35:31 +00:00
Tim-Philipp Müller
3010afa976 applemedia: fix build after gl move to -base 2017-12-19 17:57:22 +00:00
Tim-Philipp Müller
06e4403fdb gl: update plugins to use GstGL from -base 2017-12-19 12:02:31 +00:00
Sebastian Dröge
2b8f82f929 decklinkaudiosink: Start audio pre-rolling if the output is not started yet in render()
This seems to allow to schedule audio samples correctly at their right
times already.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
011649790d decklinkvideosink: Only start if both sinks are set to PLAYING already
Not only if the video sink is set to PLAYING so far. Also give more
useful debug output about why we don't start, and don't start if already
started.

Also refactor the function to early-return instead of having a huge
if-else block over the whole function.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
a38cf7d8a9 decklinkaudiosink: Include final flow return in debug output
https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
3e70f00209 decklinkaudiosink: Check also against the clock if we run ahead of the clock too much
The buffer level as reported by the Decklink driver is completely
unreliable, and we could otherwise easily run ahead >1s if we're
unlucky.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
118b2967e7 decklinkaudiosink: Implement resampling/buffer reversing for trick-modes
https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Sebastian Dröge
86888d9918 decklinkaudiosink: Re-implement around GstBaseSink instead of GstAudioBaseSink
The Decklink and GstAudioBaseSink APIs don't fit very well together,
which causes various problems due to inaccuracies in the clock
calculations and the actual ringbuffer and GStreamer's copy getting of
sync.

Problems are audio drop-outs and A/V sync getting wrong after
pausing/seeking.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-14 10:37:20 +02:00
Josep Torra
5676005235 vtenc: fix a warning when building in MacOS 10.12
vtenc.c:564:20: error: incompatible pointer types passing 'GstVTEnc *' (aka 'struct _GstVTEnc *')
to parameter of type 'GstVideoEncoder *' (aka 'struct _GstVideoEncoder *')
2017-12-12 08:40:33 +01:00
Nicolas Dufresne
44dabe21d9 kmssink: Fix CropMeta support
We copy the meta's from the original buffer to the wrapper or copied
buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=790473
2017-12-06 13:34:19 -05:00
Nicolas Dufresne
d33aff0fa0 kmssink: Enforce pixel aspect ratio when we cannot scale
When we cannot scale, we need to enforce the pixel aspect ratio.
This was partly implemented in the previous patch. Doing this
simplify some of the code.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-06 13:34:19 -05:00
Sebastian Dröge
02e4d92cbf decklinkvideosink: Wait until scheduled playback is actually stopped before continuing
Otherwise we might "start" again, just to get finally stopped and then
getting errors all over the place.

https://bugzilla.gnome.org/show_bug.cgi?id=790114
2017-12-06 19:38:55 +02:00
Ursula Maplehurst
236398ee3f androidmedia: when flushing, better handle IllegalStateException received from getOutputBuffer
1. Similar to 880f3d8, don't consider not getting an output buffer as
   an error during flushing. I've seen the following sometimes when
   encoding:

   W GStreamer+amcvideoenc: java.lang.IllegalStateException
   W GStreamer+amcvideoenc:         at android.media.MediaCodec.getBuffer(Native Method)
   W GStreamer+amcvideoenc:         at android.media.MediaCodec.getOutputBuffer(MediaCodec.java:2886)

2. For amcvideodec/enc, call _find_nearest_frame (which grabs a fresh
   reference on a GstVideoCodecFrame) after we have an output buffer,
   so as to not leak the reference, in case getting an output buffer
   fails.

   Otherwise, if we get an error grabbing the output buffer, we leak
   the reference to the frame. This can cause issues with a
   v4l2bufferpool feeding the encoder not being able to clean itself
   up properly due to buffers still being marked as in-use.

https://bugzilla.gnome.org/show_bug.cgi?id=791258
2017-12-06 10:32:02 +02:00
Nicolas Dufresne
737067e793 kmssink: Add display-width/height properties
This is to be used with gst_video_overlay_set_render_rectangle()
so the application can calculate a rectangle that fits inside
the display. The property changes are notify in a way that you
can watch either notify::display-width or notify::display-height
and both will be up-to-data when this is called back. Before the
element is started, the size will be 0x0.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-01 12:01:59 -05:00
Haihua Hu
b24bb73101 kmssink: support videooverlay interface
Implement videooverlay interface in kmssink, divided into two cases:
when driver supports scale, then we do refresh in show_frame(); if
not, send a reconfigure event to upstream and re-negotiate, using the
new size.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-01 09:44:47 -05:00
Haihua Hu
ff9a4390cb kmssink: add can-scale property
https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-12-01 09:44:47 -05:00
Edward Hervey
c9acaae376 uvch264src: Check return values of all xu_query calls
And use warnings/returns like for other calls

CID #1373414
CID #1373417
2017-11-24 08:06:52 +01:00
Hyunjun Ko
3301dd34b5 msdkdec: keep draining even if a finish_task fails
Should continue draining so that it could try to
discard the rest of pending frames even if a finish_task fails.

https://bugzilla.gnome.org/show_bug.cgi?id=790312
2017-11-23 10:08:13 +02:00
Edward Hervey
6c2b9a4fae dvb: Fix previous commit
strlen on strings (and not sizeof) *sigh*
2017-11-23 08:14:06 +01:00
Edward Hervey
e12a86995e dvb: Fix sock_addr usage (for real)
It was great checking that the string was not too big ... but
it's better if we actually copy the proper amount of bytes :)

CID #206004
2017-11-23 08:12:03 +01:00
Edward Hervey
5706178d54 ipcpipeline: Don't leak structure
CID #1416131
2017-11-23 08:09:36 +01:00
Edward Hervey
39cd2bf8fe ipcpipeline: Simplify usage of g_cond_wait_until()
It will return FALSE if a timeout happened. So don't check if we
timed out afterwards, just use the return value.

CID #1416347
2017-11-23 08:05:48 +01:00
Edward Hervey
00cfa72085 ipcpipeline: Check the proper value
The code is meant to check the *peer* state change return value
(and not the sink's one).

CID #1416128
2017-11-23 08:02:58 +01:00
Hyunjun Ko
0933b8b45a msdkdec: fix buffer leaks during drain and a leak of videobufferpool
https://bugzilla.gnome.org/show_bug.cgi?id=790312
2017-11-22 17:30:07 +02:00
Hyunjun Ko
ddd9355767 msdkenc: handle the MORE_DATA case
If the driver requires more data, just unref the frame at the moment
then retreive/finish the frame after encoding is finished.

This also fixes a memory leak.

https://bugzilla.gnome.org/show_bug.cgi?id=790312
2017-11-22 17:30:07 +02:00
Sebastian Dröge
e2c8afa261 decklinkvideosink: Print "Starting" instead of "Stopping" when starting 2017-11-22 17:22:03 +02:00
Matthew Waters
4e422bec4f nvdec: implement flush/drain
Fixes outputted frame sequence when performing a seek

i.e. when seeking backwards, the first frame after the seek was a frame
from the future.  This would result in GstVideoDecoder essentially
marking all the timestamps as essentially bogus and the base class would
attempt to compensate.  A visible indication of this was 'decreasing timestamp'
warning after a seek.

https://bugzilla.gnome.org/show_bug.cgi?id=790478
2017-11-22 14:34:33 +11:00
Nicolas Dufresne
72eebe7f53 kmssink: Add Raspberry Pi (vc4) support 2017-11-21 12:04:58 -05:00
Sebastian Dröge
538aae2404 msdkh264enc: Implement frame-packing SEI insertion for side-by-side and top-bottom
Ideally this would be supported directly in the Intel MediaSDK but
that's not the case nowadays.

https://bugzilla.gnome.org/show_bug.cgi?id=774920
2017-11-20 14:39:03 +02:00
Hyunjun Ko
3c611da315 msdkenc: Fix handling of YUY2, UYVY, BGRA surfaces
https://bugzilla.gnome.org/show_bug.cgi?id=789847
2017-11-20 14:38:34 +02:00
Sebastian Dröge
d3eeb98f0c msdkenc: Add support for YV12, YUY2, UYVY and BGRA
By doing conversion with VPP to NV12 before the actual encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=789847
2017-11-20 14:38:25 +02:00
Vivia Nikolaidou
71bfbce84d decklink: Remove unused "bflags" variable
We are ignoring all its flags anyway, so let's remove it altogether.
2017-11-09 12:08:35 +02:00
Vivia Nikolaidou
5ab660c4e2 decklink: Ignore some driver-set timecode flags
The "fields" flag is ignored because currently GStreamer doesn't support
having only top or only bottom fields inside a frame. The "drop frame"
flag is ignored because some occurrences have been spotted where it
wasn't set while it should have been. In practice, when we have 29.97 or
59.94 FPS, it's always drop-frame.

https://bugzilla.gnome.org/show_bug.cgi?id=790112
2017-11-09 11:55:13 +02:00
Vivia Nikolaidou
bae9427dc1 decklink: Don't crash when getting hw serial number doesn't return OK
If the return value isn't OK, it means we might be getting data that
points to an invalid memory address. That shouldn't make us crash.
2017-11-09 00:19:42 +02:00
Vivia Nikolaidou
07819afda4 Revert "decklink: Detect gaps on incoming stream times, issue warnings"
This reverts commit c1294e10f9.

Was not ready to be pushed yet.
2017-11-07 21:12:42 +02:00
Vivia Nikolaidou
c1294e10f9 decklink: Detect gaps on incoming stream times, issue warnings
When we receive a video or audio buffer, we calculate the next stream
time based on the current stream time + buffer duration. If the next
buffer's stream time is after that, we issue a warning.

This happens because the stream time incoming from Decklink should be
really constant and without gaps. If there is a gap, it means that
something went wrong, e.g. the internal buffer pool is empty (too many
buffers queued up downstream).

https://bugzilla.gnome.org/show_bug.cgi?id=781776
2017-11-07 16:45:52 +02:00