summaryrefslogtreecommitdiff
path: root/src/gstreamer
AgeCommit message (Collapse)Author
2020-03-18libcamera: framebuffer_allocator: Lift camera restrictions on allocatorLaurent Pinchart
The Camera class currently requires the allocator to have no allocated buffer before the camera is reconfigured, and the allocator to be destroyed before the camera is released. There's no basis for these restrictions anymore, remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-18libcamera: PixelFormat: Make constructor explicitLaurent Pinchart
To achieve the goal of preventing unwanted conversion between a DRM and a V4L2 FourCC, make the PixelFormat constructor that takes an integer value explicit. All users of pixel formats flagged by the compiler are fixed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-18libcamera: Use PixelFormat instead of unsigned int where appropriateNiklas Söderlund
Use the PixelFormat instead of unsigned int where a pixel format is to be used. PixelFormat is defined as an unsigned int but is about to be turned into a class to add functionality. There is no functional change in this patch. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-07gst: Fix GLib detectionLaurent Pinchart
Commit 17cccc68a88f ("Add GStreamer plugin and element skeleton") has gained a last minute fix for a clang compilation error with GLib prior to v2.63.0. The fix wasn't properly tested, and failed to check the GLib dependency correctly. This resulted in compilation of the GStreamer element to always be disabled. Fix this by changing the GLib package name from 'glib' to 'glib-2.0'. Fixes: 17cccc68a88f ("Add GStreamer plugin and element skeleton") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
2020-03-07gst: Turn the top-level plugin file gstlibcamera.c into a C++ fileLaurent Pinchart
The top-level plugin file gstlibcamera.c is the only C source file in the whole libcamera GStreamer element. To avoid specifying both C and C++ compiler arguments in the future, turn it into a C++ file. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
2020-03-07gst: libcamerasrc: Prevent src task deadlock on exhausted buffer poolJakub Adam
Allow GstLibcameraPool to notify the source when a new buffer has become available in a previously exhausted buffer pool. This can be used to resume a src task that got paused because it couldn't acquire a buffer. Without this change the src task will never resume from pause once the pool gets exhausted. To trigger the deadlock (it doesn't happen every time), run: gst-launch-1.0 libcamerasrc ! queue ! glimagesink Signed-off-by: Jakub Adam <jakub.adam@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-07gst: utils: Factor-out the task resume helperJakub Adam
Task resume will be added in the core GStreamer API in the future and we will need to call this in another location in the following patches. Signed-off-by: Jakub Adam <jakub.adam@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-07/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2020, Google Inc. * * flags.cpp - Flags tests */ #include <iostream> #include <libcamera/base/flags.h> #include "test.h" using namespace libcamera; using namespace std; class FlagsTest : public Test { protected: enum class Option { First = (1 << 0), Second = (1 << 1), Third = (1 << 2), }; using Options = Flags<Option>; enum class Mode { Alpha = (1 << 0), Beta = (1 << 1), laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-07gst: pad: Add method to store retrieve pending buffersNicolas Dufresne
These will be useful for streaming. The requestComplete callback will store the buffers on each pads so that the _run() can pick them up and push them through the pads from a streaming thread. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signe int FlagsTest::run() { /* Commented-out constructs are expected not to compile. */ /* Flags<int> f; */ /* * Unary operators with enum argument. */ Options options; if (options) { cerr << "Default-constructed Flags<> is not zero" << endl; return TestFail; } options |= Option::First; if (!options || options != Option::First) { cerr << "Unary bitwise OR with enum failed" << endl; return TestFail; } /* options &= Mode::Alpha; */ /* options |= Mode::Beta; */ /* options ^= Mode::Gamma; */ options &= ~Option::First; if (options) { cerr << "Unary bitwise AND with enum failed" << endl; return TestFail; } options ^= Option::Second; if (options != Option::Second) { cerr << "Unary bitwise XOR with enum failed" << endl; return TestFail; } options = Options(); /* * Unary operators with Flags argument. */ options |= Options(Option::First); if (options != Option::First) { cerr << "Unary bitwise OR with Flags<> failed" << endl; return TestFail; } /* options &= Options(Mode::Alpha); */ /* options |= Options(Mode::Beta); */ /* options ^= Options(Mode::Gamma); */ options &= ~Options(Option::First); if (options) { cerr << "Unary bitwise AND with Flags<> failed" << endl; return TestFail; } options ^= Options(Option::Second); if (options != Option::Second) { cerr << "Unary bitwise XOR with Flags<> failed" << endl; return TestFail; } options = Options(); /* * Binary operators with enum argument. */ options = options | Option::First; if (!(options & Option::First)) { cerr << "Binary bitwise OR with enum failed" << endl; return TestFail; } /* options = options & Mode::Alpha; */ /* options = options | Mode::Beta; */ /* options = options ^ Mode::Gamma; */ options = options & ~Option::First; if (options != (Option::First & Option::Second)) { cerr << "Binary bitwise AND with enum failed" << endl; return TestFail; } options = options ^ (Option::First ^ Option::Second); if (options != (Option::First | Option::Second)) { cerr << "Binary bitwise XOR with enum failed" << endl; return TestFail; } options = Options(); /* * Binary operators with Flags argument. */ options |= Options(Option::First); if (!(options & Option::First)) { cerr << "Binary bitwise OR with Flags<> failed" << endl; return TestFail; } /* options = options & Options(Mode::Alpha); */ /* options = options | Options(Mode::Beta); */ /* options = options ^ Options(Mode::Gamma); */ options = options & ~Options(Option::First); if (options) { cerr << "Binary bitwise AND with Flags<> failed" << endl; return TestFail; } options = options ^ Options(Option::Second); if (options != Option::Second) { cerr << "Binary bitwise XOR with Flags<> failed" << endl; return TestFail; } options = Options(); /* * Conversion operators. */ options |= Option::First | Option::Second | Option::Third; if (static_cast<Options::Type>(options) != 7) { cerr << "Cast to underlying type failed" << endl; return TestFail; } /* * Conversion of the result of ninary operators on the underlying enum. */ /* unsigned int val1 = Option::First; */ /* unsigned int val2 = ~Option::First; */ /* unsigned int val3 = Option::First | Option::Second; */ /* Option val4 = ~Option::First; */ /* Option val5 = Option::First | Option::Second; */ return TestPass; } TEST_REGISTER(FlagsTest)
Y or less state. Initially pads have one property "stream-role" that let you decide which role this pad will have. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 2020-03-07gst: utils: Add simple scoped lockers for GMutex and GRectMutexNicolas Dufresne While GLib has locker implementation already using g_autoptr(), recursive mutex locker was only introduced in recent GLib. Implement a simple locker for GMutex and GRectMutex in order to allow making locking simpler and safer. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 2020-03-07gst: Add initial device providerNicolas Dufresne This feature is used with GstDeviceMonitor in order to enumerate and monitor devices to be used with the source element. The resulting GstDevice implementation is also used by application to abstract the configuration of the source element. Implementation notes: - libcamera does not support polling yet - The device ID isn't unique in libcamera yet - The "name" property does not yet exist in libcamerasrc yet Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 2020-03-07gst: Add utility to convert StreamFormats to GstCapsNicolas Dufresne This transforms the basic information found in StreamFormats to GstCaps. This can be handy to reply to early caps query or inside a device provider. Note that we ignored generated range as they are harmful to caps negotiation. We also don't simplify the caps for readability reasons, so some of the discrete value may be included in a range. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 2020-03-07Add GStreamer plugin and element skeletonNicolas Dufresne This implements the GStreamer plugin interface and adds libcamerasrc element feature to it. This is just enough to allow plugin introspection. gst-inspect-1.0 build/src/gstreamer/libgstlibcamera.so Plugin Details: Name libcamera Description libcamera capture plugin Filename build/src/gstreamer/libgstlibcamera.so Version 0.0.0+1042-6c9f16d3-dirty License LGPL Source module libcamera Binary package libcamera Origin URL https://libcamera.org libcamerasrc: libcamera Source 1 features: GST_PLUGIN_PATH=$(pwd)/build/src/gstreamer gst-inspect-1.0 libcamerasrc Factory Details: Rank primary (256) Long-name libcamera Source Klass Source/Video Description Linux Camera source using libcamera Author Nicolas Dufresne <nicolas.dufresne@collabora.com Plugin Details: Name libcamera Description libcamera capture plugin Filename /home/nicolas/Sources/libcamera/build/src/gstreamer/libgstlibcamera.so Version 0.0.0+1042-6c9f16d3-dirty License LGPL Source module libcamera Binary package libcamera Origin URL https://libcamera.org GObject +----GInitiallyUnowned +----GstObject +----GstElement +----GstLibcameraSrc Pad Templates: none Element has no clocking capabilities. Element has no URI handling capabilities. Pads: none Element Properties: name : The name of the object flags: accès en lecture, accès en écriture, 0x2000 String. Default: "libcamerasrc0" parent : The parent of the object flags: accès en lecture, accès en écriture, 0x2000 Object of type "GstObject" Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Silence -Wunused-function warning for older GLib versions] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>