diff options
-rw-r--r-- | src/gstreamer/gstlibcamera-utils.cpp | 30 | ||||
-rw-r--r-- | src/gstreamer/gstlibcamerasrc.cpp | 2 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 36b9564c..16aac441 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -20,6 +20,12 @@ static struct { /* Compressed */ { GST_VIDEO_FORMAT_ENCODED, formats::MJPEG }, + /* Bayer formats, gstreamer only supports 8-bit */ + { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR8 }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG8 }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 }, + { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB8 }, + /* RGB16 */ { GST_VIDEO_FORMAT_RGB16, formats::RGB565 }, @@ -228,6 +234,22 @@ gst_format_to_pixel_format(GstVideoFormat gst_format) return PixelFormat{}; } +static const gchar * +bayer_format_to_string(int format) +{ + switch (format) { + case formats::SBGGR8: + return "bggr"; + case formats::SGBRG8: + return "gbrg"; + case formats::SGRBG8: + return "grbg"; + case formats::SRGGB8: + return "rggb"; + } + return NULL; +} + static GstStructure * bare_structure_from_format(const PixelFormat &format) { @@ -243,6 +265,14 @@ bare_structure_from_format(const PixelFormat &format) switch (format) { case formats::MJPEG: return gst_structure_new_empty("image/jpeg"); + + case formats::SBGGR8: + case formats::SGBRG8: + case formats::SGRBG8: + case formats::SRGGB8: + return gst_structure_new("video/x-bayer", "format", G_TYPE_STRING, + bayer_format_to_string(format), nullptr); + default: return nullptr; } diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp index 8d97d7c2..a10cbd4f 100644 --- a/src/gstreamer/gstlibcamerasrc.cpp +++ b/src/gstreamer/gstlibcamerasrc.cpp @@ -161,7 +161,7 @@ G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT, GST_DEBUG_CATEGORY_INIT(source_debug, "libcamerasrc", 0, "libcamera Source")) -#define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; image/jpeg") +#define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; image/jpeg; video/x-bayer") /* For the simple case, we have a src pad that is always present. */ GstStaticPadTemplate src_template = { |