Age | Commit message (Collapse) | Author |
|
With this patch, the element is now able to push buffers to the next
element in the graph. The buffers are currently missing any metadata
like timestamp, sequence number. This will be added in the next commit.
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>
|
|
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>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
This adds getters on pad/pool/allocator so that we can retrieve the
Stream or FrameBuffer.
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>
|
|
Setup the allocation and the release of buffers in the
element. We have one pooling GstAllocator that wraps the
FrameBufferAllocator and tracks the lifetime of FrameBuffer
objects. Then, for each pad we have a GstBufferPool object
which is only used to avoid re-allocating the GstBuffer
structure every time we push a buffer.
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>
|
|
This adds get/set helper to store a pool on the pad.
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>
|
|
This is needed to track the lifetime of the FrameBufferAllocator in relation to
the GstBuffer/GstMemory objects travelling inside GStreamer.
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>
|
|
Now that we have stream-start and caps, we can now push a segment event to
announce what time will our buffer correlate to. For live sources this is just
an open segment in time format.
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>
|
|
This is not expected to work in every possible cases, but should be sufficient as
an initial implementation. What it does is that it turns the StreamFormats into
caps and queries downstream caps with that as a filter.
The result is the subset of caps that can be used. We then keep the first
structure in that result and fixate using the default values found in
StreamConfiguration as a default in case a range is available.
We then validate this configuration and turn the potentially modified
configuration into caps that we push downstream. Note that we trust the order
in StreamFormats as being sorted best first, but this is not currently in
libcamera. A todo has been added in the head of this file as a reminder to fix
that in the core.
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>
|
|
This adds helpers to deal with the conversion from StreamConfiguration
to caps and vice-versa. This is needed to implement caps negotiation.
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>
|
|
Prior to sending caps, we need to send a stream-start event. This requires
generating a stream and a group id. The stream id is random for live sources and
the group id is shared across all pads.
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>
|
|
This will allow implementing generic algorithm even if we cannot
request pads 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>
|
|
Each pad can have a different roles. Users will have to request and configure
their pads role before moving to a higher state.
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>
|
|
Use a GstTask as our internal streaming thread. Unlike GstBaseSrc, we
will be running a streaming thread at the element level rather than
per pad. This is needed to combine buffer request for multiple pads.
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>
|
|
This adds code to select and acquire a camera. With this, it is now
possible to run a pipeline like:
gst-launch-1.0 libcamerasrc ! fakesink
Though no buffer will be streamed yet. In this function, we implement the
change_state() virtual method to trigger actions on specific state transitions.
Note that we also return GST_STATE_CHANGE_NO_PREROLL in
GST_STATE_CHANGE_READY_TO_PAUSED and GST_STATE_CHANGE_PLAYING_TO_PAUSED
transitions as this is required for all live sources.
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>
|
|
This will allow selecting libcamerasrc traces with the following
environment:
GST_DEBUG=libcamerasrc:7
Or all libcamera GStreamer element traces using
GST_DEBUG="libcamera*:7"
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>
|
|
This property will be used to select by name the camera to use.
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>
|
|
This pad will always be present and will allow simple pipeline to be used to
stream from the camera.
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>
|
|
This simply adds the boiler plate for pads on the source element. The
design is that we have one pad, called "src", that will always be
present, and then more pads can be requested prior in READY 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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
The std::atomic_uint64_t specialization was missing from C++14, and only
added to C++17 (see LWG 2441). It was treated as a Defect Report and
backported to earlier C++ standards by gcc and clang, but is missing
from libstdc++ shipped with gcc 5 and gcc 6. Fix the compilation error
by using std::atomic<uint64_t> instead.
Fixes: 4e0d1eca10b7 ("libcamera: V4L2BufferCache: Improve cache eviction strategy")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
|
The strategy used to find a free cache entry in the first implementation
was not the smartest, it picked the first free entry. This lead to
unwanted performance issues as the cache was not used as good as it
could for imported buffers.
Improve this by adding a last usage sequence number to the cache entries
and change the eviction strategy to use the oldest free entry instead of
the first one it finds.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Check for a hot cache hit before updating which buffer is best to evict
in case no hot hit is found. This doesn't change the behaviour, but
follows a more logical flow.
Suggested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Instead of looking up the index in the storage vector use the reference
to it created at the beginning of the loop.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
The comparison operator does not change any state, mark it as const.
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
Add the '-p'|'--list-properties' option to the cam application to list
the properties of a camera.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add support for serializing and deserializing control values that store
arrays of values. The serialized format is extended to explicitly handle
arrays.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Use the zero-copy variant of ByteStreamBuffer::read() to read packet
headers and control entries. This enhances the performance of
ControlList and ControlInfoMap deserialization.
Deserialization of the actual ControlValue is untouched for now and will
be optimized later.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.binghm@ideasonboard.com>
|
|
Use the ControlValue::data() function to access raw data stored in the
control value and simplify serialization.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.binghm@ideasonboard.com>
|
|
Replace the default case with an explicit ControlTypeNone case in
ControlSerializer::load() to catch omissions when adding new control
types.
A return statement needs to be added to the end of the function to avoid
gcc incorrectly reporting that some exit paths don't contain a return
statement. The compiler will still warn that not all cases are handled
when adding a new control type.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add a read() function to ByteStreamBuffer that returns a pointer to the
data instead of copying it. Overflow check is still handled by the
class, but the caller must check the returned pointer explicitly.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add support to write and read a Span<> to and from the ByteStreamBuffer
class.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The documentation of the read() and write() functions refer to non
existent 'size' and 'data' parameters in their brief. Fix them.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Report in a new field of the ipa_control_value_entry structure if the
value contains an array. Reorganize the other fields of the structure to
avoid increasing its size.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The C++ boolean types are lower case, and std::ostream::operator<<(bool)
produces a lowercase string (when std::boolalpha is in effect, otherwise
it produces 0 or 1). Switch ControlValue::toString() to produce
lowercase "true" and "false" strings too for consistency.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add support for byte values to the control framework and to the control
serializer.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add support for float values in Control<> and ControlValue classes.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add a 'size' property to the control yaml description, to convey the
size constraints of array controls. The semantics of the property
contents is currently unspecified, but its presence triggers the
generation of an array control (Control<Span<const T>>).
Example:
- BayerGains:
type: float
description: Gains to apply to the four Bayer colour components for white balance
size: [4]
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
For array controls, the ControlList::set() function takes a value as a
type convertible to Span<T>. This allows passing an std::array or an
std::vector in addition to an explicit Span, but doesn't accept an
std::initializer list as Span has no constructor that takes an
initializer list. Callers are thus forced to create temporary objects
explicitly, which isn't nice.
Fix the issue by providing a ControlList::set() function that takes an
std::initializer_list, and convert it to a Span internally.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add array controls support to the ControlValue class. The polymorphic
class can now store more than a single element and supports access and
creation through the use of Span<>.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Add a data() function to the ControlValue class to expose the raw data
stored by the class as a Span<const uint8_t>. This will be useful to
simplify the serialization of ControlValue instances.
The size computation for the raw data is moved from the
ControlSerializer, which is updated accordingly to use the data()
function in order to access the size. Simplification of the
ControlSerializer will happen in a subsequent change.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
To avoid defining all specializations of the Control constructor
manually, move the definition of those functions to controls.h and turn
them into a single template function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
To avoid defining all specializations of the ControlValue constructor
manually, move the definition of those functions to controls.h and turn
them into a single template function. The default constructor is still
kept in controls.cpp.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
To avoid defining all specializations of ControlValue::get() and
ControlValue::set() manually, move the definition of those functions to
controls.h and turn them into single template functions.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The ControlList::get() and ControlValue::get() methods return the
control value by reference. This requires the ControlValue class to
store the control value in the same form as the one returned by those
functions. For the array controls that are soon to be added, the
ControlValue class would need to store a span<> instance in addition to
the control value itself, which would increase the required storage
space.
Prepare for support of array controls by returning from get() by value.
As all control values are 8 bytes at most, this doesn't affect
efficiency negatively.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The ControlList::set() method takes a reference to a Control<T>, and
requires the value to be a reference to T. This prevents the set()
method from being used with value types that are convertible to T, and
in particular with std::array or std::vector value types when the
Control type is a Span<> to support array controls.
Fix this by decoupling the control type and value type in the template
parameters. The compiler will still catch invalid conversions, including
cases where the constructor of type T from the value type is explicit.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
The ControlValue::get<T>() method verifies that the T type corresponds
to the ControlValue type. It however accepts int32_t as a return type
for 64-bit integer controls, and int64_t as a return type for 32-bit
integer controls. There's no reason to do so anymore, make the type
check stricter.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
|
Reorder functions in ControlValue class to group const methods together.
Cosmetic change only.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
|