Commit graph

1637 commits

Author SHA1 Message Date
William Manley
56b1d088a9 v4l2: Warn, don't assert if v4l gives us a buffer with a too large size
I've seen problems where the `bytesused` field of `v4l2_buffer` would be
a silly number causing the later call to:

    gst_memory_resize (group->mem[i], 0, group->planes[i].bytesused);

to result in this error to be printed:

    (pulsevideo:11): GStreamer-CRITICAL **: gst_memory_resize: assertion 'size + mem->offset + offset <= mem->maxsize' failed

besides causing who-knows what other problems.

We make the assumption that this buffer has still been dequeued correctly
so just clamp to a valid size so downstream elements won't end up in
undefined behaviour.

The invalid `v4l2_buffer` I saw from my capture device was:

    buffer = {
      index = 0,
      type = 1,
      bytesused = 534748928, // <- Invalid
      flags = 8260, // V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC | V4L2_BUF_FLAG_ERROR | V4L2_BUF_FLAG_DONE
      field = 01330, // <- Invalid
      timestamp = {
        tv_sec = 0,
        tv_usec = 0
      },
      timecode = {
        type = 0,
        flags = 0,
        frames = 0 '\000',
        seconds = 0 '\000',
        minutes = 0 '\000',
        hours = 0 '\000',
        userbits = "\000\000\000"
      },
      sequence = 0,
      memory = 2,
      m = {
        offset = 3537219584,
        userptr = 140706665836544, // Could be nonsense, not sure
        planes = 0x7ff8d2d5b000,
        fd = -757747712
      },
      length = 2764800,
      reserved2 = 0,
      reserved = 0
    }

This is from gdb with my own annotations added.

This was with gst-plugins-good 1.8.1, a Magewell XI100DUSB-HDMI video
capture device and kernel 3.13 using a dodgy HDMI cable which is great at
breaking HDMI capture devices.  I'm using io-mode=userptr and have built
gst-plugins-good without libv4l.

https://bugzilla.gnome.org/show_bug.cgi?id=769765
2016-11-01 20:12:56 +02:00
Tobias Schneider
932adb1968 v4l2object: fix extra-controls leak
Gst struct v4l2object->extra_controls is created if user sets appropriate
option but it is not freed on destruction of v4l2object.

https://bugzilla.gnome.org/show_bug.cgi?id=773580
2016-10-31 12:06:27 -04:00
Scott D Phillips
91e9a94492 meson: directsound: Add ole32 library dependency
https://bugzilla.gnome.org/show_bug.cgi?id=773114
2016-10-21 06:01:16 -03:00
Gaurav Gupta
1950b72e2b waveformsink: Fix Memory leak using GST_PTR_FORMAT
https://bugzilla.gnome.org/show_bug.cgi?id=772497
2016-10-20 13:14:10 +03:00
Nicolas Dufresne
8cec944149 osxaudio: Distribute device provider files
Those where missing the the dev release tarballs for 1.9.2 which
prevented building from tarball on OSX platform
2016-09-07 15:35:06 -04:00
Jan Schmidt
9cc497e5c3 osxvideo: Remove QuickTime references.
QuickTime.h is no longer available on OS X 10.12 (Sierra),
and both the header and the framework seem unnecessary
for compilation - at least as of 10.11 (El Capitan).

https://bugzilla.gnome.org/show_bug.cgi?id=770526
2016-08-31 05:52:37 +10:00
Nirbheek Chauhan
b09f478e80 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-20 11:21:12 +01:00
Nirbheek Chauhan
4048a4e137 v4l2: consistently check #ifdef HAVE_GUDEV instead of #if
Both work with autotools but they definitely don't mean the same thing, cause
problems with other build systems, and are bad form. Existence should always be
checked with #ifdef or #if defined.
2016-08-18 20:20:20 +01:00
Nirbheek Chauhan
af1d49d039 directsound: port away from old DirectX API
D3DX has been deprecated for the last 4 years and latest versions of
Windows no longer ship headers for it. This is fine as long as you're
building with Cerbero's Wine-based DirectX headers, but sucks if you
want to build against the actual Windows SDK.

We were just using it to get error strings anyway, so just use the
generic error string API.
2016-08-18 20:20:15 +01:00
Nicolas Dufresne
ab075b2013 v4l2provider: Fix device type detection
The type detection would lead to assertion as it would try
to create a device without having found any type for it. It
also didn't detect MPLANE devices properly.
2016-07-11 19:17:49 -04:00
Nicolas Dufresne
f0678d73b1 v4l2object: Don't assert when used by the monitor
The monitor sets the object->element object as a GstObject. This
works for debug traces, but will assert for ELEMENT_ERROR. This
was the only case where that could happen. Add a check for that.
2016-07-11 19:17:49 -04:00
Nicolas Dufresne
e62bd2f7d8 v4l2object: Indent very long line 2016-07-11 19:17:49 -04:00
Nicolas Dufresne
5a9c0aa9f5 v4l2: Also copy device_caps in gst_v4l2_dup
This fixes regression where M2M error out saying they have no output
format (the V4L2 CAPTURE side).

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-10 21:37:24 -04:00
Luis de Bethencourt
eaa01071e0 v4l2: fix multiplanar capture
After switching to using V4L2_CAP_DEVICE_CAPS we lost support for
multiplanar device types. After some research, it looks like
vcap.capabilities treated the multiplanar flag of output and capture
devices equally, but not the new device_caps.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-08 19:03:51 +01:00
Luis de Bethencourt
67c2b93106 v4l2: fix v4l2 probe build error
A typo in gst_v4l2_probe_and_register() caused a build error when building
with --enable-v4l2-probe. Fixing it.

gstv4l2.c: In function 'gst_v4l2_probe_and_register':
gstv4l2.c:150:25: error: 'struct v4l2_capability' has no member named 'capabilitites'
       device_caps = vcap.capabilitites;
2016-07-07 23:55:33 +01:00
Reynaldo H. Verdejo Pinochet
dfdc15c548 v4l2src: use gst_caps_intersect_full in negotiate()
Instead of reimplementing the GST_CAPS_INTERSECT_FIRST
interection mode.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-07 17:46:06 -04:00
Reynaldo H. Verdejo Pinochet
4b16b16aaf v4l2: use opened device caps instead of physical device ones
The same physical device can export multiple devices. In
this case, the capabilities field now contains a union of
all caps available from all exported V4L2 devices alongside
a V4L2_CAP_DEVICE_CAPS flag that should be used to decide
what capabilities to consider. In our case, we need the
ones from the exported device we are using.

https://bugzilla.gnome.org/show_bug.cgi?id=768195
2016-07-07 17:46:06 -04:00
Tim-Philipp Müller
2d6c93efe5 v4l2: fix potential double-free of error debug string
gst_v4l2_clear_error() doesn't work like g_clear_error(), it
doesn't NULLify the pointer, so set freed debug string to NULL
so it doesn't get freed again if gst_v4l2_clear_error() is
called twice on the error.

CID 1362901
2016-07-01 11:54:57 +01:00
Nicolas Dufresne
462800e9c6 v4l2videodec: Keep part of the input buffer
Instead of completely getting rid of the input buffer, copy
the metadata, the flags and the timestamp into an empty buffer.
This way the decoder base class can copy that information again
to the output buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=758424
2016-06-07 17:03:40 -04:00
Nicolas Dufresne
a0a590369a v4l2videodec: Coding style fixes 2016-06-07 17:02:47 -04:00
Nicolas Dufresne
e31c6aa427 v4l2object: Coding style fixes 2016-06-07 17:02:47 -04:00
Nicolas Dufresne
3b5cac3659 v4l2: Add an error return to _try/_set_format
This way one can easily ignore errors. Previously, error were always
posted ont he bus.

https://bugzilla.gnome.org/show_bug.cgi?id=766172
2016-06-07 17:02:43 -04:00
Nicolas Dufresne
e228430788 v4l2-util: Introduce GstV4l2Error
This is to allow returning an error that can easily be sent as
message to the application if the element needs it. Using this
also allow ignoring errors.

https://bugzilla.gnome.org/show_bug.cgi?id=766172
2016-06-07 17:02:34 -04:00
Nicolas Dufresne
ec169a1517 v4l2src: Avoid decide allocation on active pool
v4l2src will renegotiate only if the format have changed. As of now,
it's not possible to change the allocationw without resetting the
camera. To avoid unwanted side effect, simply keep the old allocation
if no renegotiation is taking place. This fixes assertion and possible
failures in USERPTR or DMABUF import mode (when using downstream pools).

https://bugzilla.gnome.org/show_bug.cgi?id=754042
2016-06-07 12:46:53 -04:00
Philipp Zabel
96d82357f2 v4l2videodec: use decoder stop command instead of queueing empty buffers
Only if the decoder stop command fails, keep queueing empty buffers to
signal end of stream as before.

https://bugzilla.gnome.org/show_bug.cgi?id=733864
2016-06-07 10:49:43 -04:00
Peter Seiderer
ddf7d9d6de v4l2videodec: add gst_v4l2_decoder_cmd helper
https://bugzilla.gnome.org/show_bug.cgi?id=733864
2016-06-07 10:49:43 -04:00
Nicolas Dufresne
f9e01a53d8 v4l2transform: Use looser caps for upstream
When we fixate for upstream, try to not introduce new fields when not
needed. This was imported from videoconvert element.
2016-06-06 17:54:10 -04:00
Enrico Jorns
5829f326b0 gstv4l2transform: format fixation for preferring passthrough
* If outgoing format is unfixated, try to set it to input format.

* Call gst_caps_fixate () at end of fixation routine

https://bugzilla.gnome.org/show_bug.cgi?id=766719
2016-06-06 17:53:02 -04:00
Philipp Zabel
3eeef5fa09 v4l2transform: allow to change pixel aspect ratio
Scalers may change width and height independently,
allow to change pixel aspect ratio.

https://bugzilla.gnome.org/show_bug.cgi?id=766712
2016-06-06 17:50:41 -04:00
Philipp Zabel
89a2f0a647 v4l2transform: fix scaling in case of fixed pixel aspect ratio
To change pixel aspect ratio from DAR to PAR, the necessary scaling factor
is DAR/PAR, not DAR*PAR.
For good measure, add debug output similar to the fixed-width and
fixed-height cases.

https://bugzilla.gnome.org/show_bug.cgi?id=766711
2016-06-06 17:45:38 -04:00
Philipp Zabel
616ccbb0db v4l2object: fill colorimetry in gst_v4l2_object_acquire_format
Instead of relying on the default colorimetry chosen by
gst_video_info_set_format(), set info.colorimetry from the
values returned by G_FMT. This allows decoders to propagate
their input colorimetry downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=766383
2016-06-06 17:39:26 -04:00
Philipp Zabel
b5530a19a7 v4l2object: refactor gst_v4l2_object_get_colorspace to take a v4l2_format parameter
Move the extraction of colorimetry parameters from struct v4l2_format and the
setting of the identity matrix for RGB formats into the function to avoid code
duplication.

https://bugzilla.gnome.org/show_bug.cgi?id=766383
2016-06-06 17:39:26 -04:00
Philipp Zabel
1f31715c98 v4l2videodec: use visible size, not coded size, for downstream negotiation filter
gst_v4l2_probe_caps() returns the coded size, not the visible size. Subtract
the known padding from probed caps with the coded size before using them as
filter for caps negotiation with downstream elements.

https://bugzilla.gnome.org/show_bug.cgi?id=766382
2016-06-06 17:35:47 -04:00
Philipp Zabel
74f020fd2f v4l2object: use G_SELECTION instead of G_CROP in gst_v4l2_object_acquire_format
The gst_v4l2_object_acquire_format() function is used by v4l2videodec to obtain
the currently set capture format. Since G_FMT returns the coded size, the
visible size needs to be obtained from the compose rectangle in order to
negotiate it with downstream elements. The G_CROP call hasn't worked on mem2mem
capture queues for a long time. Instead use the G_SELECTION call to obtain the
compose rectangle and only fall back to G_CROP for ancient kernels.

https://bugzilla.gnome.org/show_bug.cgi?id=766381
2016-06-06 17:33:27 -04:00
Andreas Naumann
b18031cf4b v4l2sink: Use V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY if driver advertises it.
On modern kernels, the G/S_FMT ioctls will always fail using
V4L2_BUF_TYPE_VIDEO_OVERLAY with VFL_DIR_TX (e.g. real overlay out drivers)
since this is not the intented use (rather rx, according to v4l2 API doc).
Probably this is why the Video Output Overlay interface was created, so if
the driver advertises it we might as well use.
For old kernels (pre 2012) the old way might still work so keeping this for
compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=761165
2016-06-06 17:26:13 -04:00
Kieran Bingham
b4e6a71566 v4l2object: Use non-deprecated V4L2 type for RGB15
Support for the updated V4L2_PIX_FMT_XRGB555 was added in commit
2538fee2fd however, when setting the format
for use in v4l2 ioctls, the old deprecated format is still used. Convert
this to the new accepted format type, as the preferred format.

https://bugzilla.gnome.org/show_bug.cgi?id=767300
2016-06-06 17:19:41 -04:00
Josep Torra
b7866315a6 v4l2src: check for valid size on raw video buffers
Discard buffers that doesn't contain enough data when dealing
with raw video inputs.

https://bugzilla.gnome.org/show_bug.cgi?id=767086
2016-06-01 17:35:12 +02:00
Guillaume Desmottes
1840fa9363 v4l2object: fix caps leak
gst_v4l2_object_probe_caps() was taking an extra ref on the returned
caps for no reason.

https://bugzilla.gnome.org/show_bug.cgi?id=766610
2016-05-25 13:40:54 -04:00
Hyunjun Ko
1face2a662 osxaudio: Support audio device provider on osx
https://bugzilla.gnome.org/show_bug.cgi?id=753265
2016-05-02 09:58:49 +03:00
Song Bing
11899106d0 ximageutil: shouldn't implement transform if don't support it
shouldn't implement transform if don't support it. Or gst_buffer_copy_into()
will print ERROR log.

https://bugzilla.gnome.org/show_bug.cgi?id=765583
2016-04-29 10:08:45 +03:00
Dimitrios Katsaros
df9eed0ab5 v4l2: Change warning handling to break infinite message loop
v4l2src can cause an "infinite message loop" when a base control exposed as a
property is not provided by the device. In these cases, if in the warning message
handling for the bus, the GST_DEBUG_BIN_TO_DOT_FILE* category of functions are used,
the src lookup causes a new warning to be posted on the bus, causing a loop.

This patch changes the warning for these controls so they are not posted on the bus.

https://bugzilla.gnome.org/show_bug.cgi?id=758703
2016-04-16 16:36:25 -04:00
Sebastian Dröge
4103f3d7f3 ximage: Initialize all fields in the meta explicitly
The meta is not allocated with all fields initialized to zeroes.

https://bugzilla.gnome.org/show_bug.cgi?id=764902
2016-04-13 09:57:16 +03:00
Wim Taymans
c9c051d53d v4l2: avoid leaking GValues
unset the GValue if we don't use it any more to avoid leaks.
2016-04-12 11:56:08 +02:00
Nirbheek Chauhan
a5369c6be3 v4l2: Don't leak v4l2 objects and props on probe errors 2016-04-04 20:31:43 +01:00
Aurélien Zanelli
c163250f0d v4l2object: probe all colorspace supported by device
A device can support more than one colorspace for a given image
dimension and pixel format. So we have to probe all the supported
colorspace and not only rely on the default one. Otherwise we could end
up with negotiation failure if the caps colorimetry field don't match
the v4l2 device default one even if the v4l2 could support such
colorimetry.

This patch enable probing if colorspace for both capture and output
device. It really makes sense for output device since the colorspace
shall be set by the application and a little less for capture device
which, at the moment, shall provide the colorspace; ie: the v4l2
specification seems to not take into account the fact that a capture
device could do colorspace conversion.

As a side effet, probing takes some times and so sligthly delay v4l2
initialization. Note that this patch only probe colorspace and not all
colorspace, matrix, transfer and range combination to avoid taking too
much time, especially with low-speed devices as full probing do 1782
ioctl.

https://bugzilla.gnome.org/show_bug.cgi?id=755937
2016-03-24 14:05:45 -04:00
Vineeth TM
1071309870 good: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763076
2016-03-24 14:32:20 +02:00
Thomas Roos
93d09f0474 dirctsoundsink: Setting volume should not unmute
https://bugzilla.gnome.org/show_bug.cgi?id=755106
2016-03-08 20:42:09 +02:00
Thomas Roos
e345a7fee9 dirctsoundsink: Fix volume reset on unmute
https://bugzilla.gnome.org/show_bug.cgi?id=755106
2016-03-08 20:42:06 +02:00
Alban Bedel
d746e1ef51 v4l2object: fix capture with bayer formats other than bggr
gst_v4l2_object_get_caps_info() always return V4L2_PIX_FMT_SBGGR8
for all bayer formats. This is obviously broken if the device use
another ordering. Fix this by properly reading the format parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=763318
2016-03-08 11:15:08 -05:00
Josep Torra
c65b66432e v4l2: fix colorimetry for NV12
Replicate V4L2_MAP_QUANTIZATION_DEFAULT macro behavior.
At #v4l it was described that documentation might be wrong and that
we should trust this macro instead.

https://bugzilla.gnome.org/show_bug.cgi?id=762529
2016-03-07 11:36:59 -05:00