diff --git a/autogen.sh b/autogen.sh index d89003b..9647c50 100755 --- a/autogen.sh +++ b/autogen.sh @@ -50,8 +50,7 @@ autoreconf --verbose --force --install --make || { exit 1; } -args="--prefix=/usr \ ---libdir=/usr/lib" +args="--prefix=/usr" ./configure $args || { echo 'configure failed'; diff --git a/configure.ac b/configure.ac index b3314d3..071b604 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,12 @@ AC_ARG_WITH([androidstubs], AC_ARG_WITH([haladaptor], AC_HELP_STRING([--with-haladaptor], [Link hal adaptor library [default=no]])) +AC_ARG_ENABLE([gstdrmformat], + AC_HELP_STRING([--enable-gstdrmformat], [Enable DRM format [default=no]])) + +AC_ARG_ENABLE([internalbuild], + AC_HELP_STRING([--enable-internalbuild], [Internal build [default=no]])) + AC_ARG_VAR([DEFAULT_CAMERA], [the default camera ID]) @@ -169,23 +175,12 @@ PKG_CHECK_MODULES(GST, [ ]) ]) -if test "x$with_haladaptor" == "xyes"; then - echo Building with hal_adaptor - PKG_CHECK_MODULES(CAMHAL, [hal_adaptor], [ - AC_SUBST(CAMHAL_CFLAGS) - AC_SUBST(CAMHAL_LIBS) - ], [ - AC_MSG_ERROR([Cannot find hal_adaptor pkgconfig]) - ]) -else - echo Building with libcamhal - PKG_CHECK_MODULES(CAMHAL, [libcamhal], [ - AC_SUBST(CAMHAL_CFLAGS) - AC_SUBST(CAMHAL_LIBS) - ], [ - AC_MSG_ERROR([Cannot find libcamhal pkgconfig]) - ]) -fi +PKG_CHECK_MODULES(CAMHAL, [libcamhal], [ + AC_SUBST(CAMHAL_CFLAGS) + AC_SUBST(CAMHAL_LIBS) +], [ + AC_MSG_ERROR([Cannot find libcamhal pkgconfig]) +]) PKG_CHECK_MODULES(LIBDRM, [libdrm libdrm_intel], [ AC_SUBST(LIBDRM_CFLAGS) @@ -194,26 +189,28 @@ PKG_CHECK_MODULES(LIBDRM, [libdrm libdrm_intel], [ AC_MSG_ERROR([Cannot find libdrm pkgconfig]) ]) -PKG_CHECK_MODULES(LIBGSTREAMERVA, [gstreamer-va-1.0], [ - AC_SUBST(LIBGSTREAMERVA_CFLAGS) - AC_SUBST(LIBGSTREAMERVA_LIBS) -], [ - AC_MSG_WARN([Cannot find gstreamer-va-1.0 pkgconfig]) -]) +AS_IF([test "x$enable_gstdrmformat" = "xyes"], [ + PKG_CHECK_MODULES(GST_1_23, [gstreamer-1.0 >= 1.23], [ have_gstdrmformat=yes ], [ + PKG_CHECK_MODULES(GST_1_22_6, [gstreamer-1.0 = 1.22.6], [ have_gstdrmformat=yes ], [ have_gstdrmformat=no ]) + ]) -PKG_CHECK_MODULES(LIBVA, [libva], [ - AC_SUBST(LIBVA_CFLAGS) - AC_SUBST(LIBVA_LIBS) -], [ - AC_MSG_WARN([Cannot find libva pkgconfig]) -]) + AS_IF([test "x$have_gstdrmformat" = "xyes"], [ + PKG_CHECK_MODULES(DEP_GSTDRMFORMAT, [gstreamer-va-1.0 libva libva-drm], [ + AC_SUBST(DEP_GSTDRMFORMAT_CFLAGS) + AC_SUBST(DEP_GSTDRMFORMAT_LIBS) + ], [ + have_gstdrmformat=no + AC_MSG_ERROR([Need gstreamer-va-1.0 libva libva-drm to enable GstVaDisplay]) + ]) + ], [ + AC_MSG_ERROR([Need GStreamer >= 1.23 or == 1.22.6, and gstreamer-va-1.0 libva libva-drm to enable GstVaDisplay]) + ]) -PKG_CHECK_MODULES(LIBVA_DRM, [libva-drm], [ - AC_SUBST(LIBVA_DRM_CFLAGS) - AC_SUBST(LIBVA_DRM_LIBS) -], [ - AC_MSG_WARN([Cannot find libva-drm pkgconfig]) -]) + AS_IF([test "x$have_gstdrmformat" = "xyes"], [ + AC_DEFINE([GST_DRM_FORMAT], [1], [GStreamer at least 1.23 or exactly 1.22.6 supports DRM format]) + AC_MSG_NOTICE(Define GST_DRM_FORMAT) + ]) +], []) dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS) AC_MSG_CHECKING([to see if compiler understands -Wall]) diff --git a/src/Makefile.am b/src/Makefile.am index 8dfd846..8e9ae08 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -73,9 +73,7 @@ libgsticamerasrc_la_CPPFLAGS = \ $(GST_CFLAGS) \ $(CAMHAL_CFLAGS) \ $(LIBDRM_CFLAGS) \ - $(LIBVA_CFLAGS) \ - $(LIBVA_DRM_CFLAGS) \ - $(LIBGSTREAMERVA_CFLAGS) \ + $(DEP_GSTDRMFORMAT_CFLAGS) \ -std=c++11 \ -Werror \ $(LIBUTILS_CFLAGS) \ @@ -94,9 +92,7 @@ libgsticamerasrc_la_LIBADD = $(GST_LIBS) \ -lgstvideo-$(GST_API_VERSION) \ interfaces/libgsticamerainterface-$(GST_API_VERSION).la \ $(LIBDRM_LIBS) \ - $(LIBVA_LIBS) \ - $(LIBVA_DRM_LIBS) \ - $(LIBGSTREAMERVA_LIBS) \ + $(DEP_GSTDRMFORMAT_LIBS) \ $(CAMHAL_LIBS) libgsticamerasrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/src/gstcambasesrc.cpp b/src/gstcambasesrc.cpp index 6f616a9..8646c7f 100644 --- a/src/gstcambasesrc.cpp +++ b/src/gstcambasesrc.cpp @@ -42,7 +42,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include "gstcambasesrc.h" @@ -447,7 +447,7 @@ gst_cam_base_src_init(GstCamBaseSrc *basesrc, GstCamBaseSrcClass *klass) gst_video_info_init(&basesrc->srcpad_info); basesrc->is_info_change = FALSE; #endif -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT basesrc->is_dma_drm_caps = FALSE; #endif @@ -3738,13 +3738,13 @@ gst_cam_base_src_negotiate (GstCamBaseSrc * basesrc, GstPad *pad) caps = gst_pad_get_current_caps (pad); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT basesrc->is_dma_drm_caps = gst_video_is_dma_drm_caps(caps); #endif #if GST_VERSION_MINOR >= 18 if (basesrc->is_info_change) { -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (!CameraSrcUtils::gst_video_info_from_dma_drm_caps(&vinfo, caps)) #else if (!gst_video_info_from_caps(&vinfo, caps)) diff --git a/src/gstcambasesrc.h b/src/gstcambasesrc.h index f02b07c..3eac0bb 100644 --- a/src/gstcambasesrc.h +++ b/src/gstcambasesrc.h @@ -135,7 +135,7 @@ struct _GstCamBaseSrc { GstVideoInfo srcpad_info; gboolean is_info_change; #endif -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT /* indicate current caps is dma_drm type for io_mode=dma_mode. */ bool is_dma_drm_caps; #endif diff --git a/src/gstcameradeinterlace.cpp b/src/gstcameradeinterlace.cpp index 2c7a0ea..cffb420 100644 --- a/src/gstcameradeinterlace.cpp +++ b/src/gstcameradeinterlace.cpp @@ -44,7 +44,7 @@ #define LOG_TAG "GstCameraDeinterlace" #ifdef HAVE_CONFIG_H -# include +#include #endif #include diff --git a/src/gstcameraformat.cpp b/src/gstcameraformat.cpp index e5bf25d..bba2548 100644 --- a/src/gstcameraformat.cpp +++ b/src/gstcameraformat.cpp @@ -44,7 +44,7 @@ #define LOG_TAG "GstCameraFormat" #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -93,7 +93,7 @@ static void update_main_resolution(int format, cameraSrc_Res_Range res_range, vector &main_res_range); static GstStructure *create_structure (guint32 fourcc); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT static void set_structure_to_caps(vector main_res_range, GstCaps **caps, GstVaDisplay *display_drm); @@ -179,7 +179,7 @@ create_structure (guint32 fourcc) * Merge all structures into caps */ #define GST_CAPS_FEATURE_MEMORY_DMABUF "memory:DMABuf" -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT static void set_structure_to_caps(vector main_res_range, GstCaps **caps, GstVaDisplay *display_drm) @@ -190,7 +190,7 @@ set_structure_to_caps(vector main_res_range, GstCaps { GstStructure *structure = NULL; int feature_index = 0; -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (display_drm) { /* Set caps with dmabuffer */ for (auto &res_range : main_res_range) { @@ -390,7 +390,7 @@ GstCaps *gst_camerasrc_get_all_caps () if (caps != NULL && GST_IS_CAPS(caps)) { return caps; } -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT GstVaDisplay *display_drm = NULL; display_drm = gst_va_display_drm_new_from_path("/dev/dri/renderD128"); if (NULL == display_drm) { @@ -407,7 +407,7 @@ GstCaps *gst_camerasrc_get_all_caps () int ret = get_camera_info(i, info); if (ret != 0) { g_printerr("failed to get camera info from libcamhal"); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (display_drm) { gst_object_unref(display_drm); display_drm = NULL; @@ -420,7 +420,7 @@ GstCaps *gst_camerasrc_get_all_caps () ret = register_format_and_resolution(configs, fmt_res, main_res_range); if (ret != 0) { g_printerr("failed to get format info from libcamhal"); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (display_drm) { gst_object_unref(display_drm); display_drm = NULL; @@ -431,14 +431,14 @@ GstCaps *gst_camerasrc_get_all_caps () } caps = gst_caps_new_empty(); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT set_structure_to_caps(main_res_range, &caps, display_drm); #else set_structure_to_caps(main_res_range, &caps); #endif caps = gst_caps_simplify(caps); main_res_range.clear(); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (display_drm) { gst_object_unref(display_drm); display_drm = NULL; diff --git a/src/gstcamerasrc.cpp b/src/gstcamerasrc.cpp index e46379b..88c4530 100644 --- a/src/gstcamerasrc.cpp +++ b/src/gstcamerasrc.cpp @@ -46,7 +46,7 @@ #define LOG_TAG "GstCameraSrc" #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -1296,7 +1296,7 @@ gst_camerasrc_init (Gstcamerasrc * camerasrc) camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].stream_config_done = FALSE; camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].activated = TRUE; camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].stream_usage = DEFAULT_PROP_SRC_STREAM_USAGE; -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT camerasrc->streams[GST_CAMERASRC_MAIN_STREAM_ID].drm_modifier = DRM_FORMAT_MOD_LINEAR; #endif @@ -2494,7 +2494,7 @@ gst_camerasrc_get_caps_info (Gstcamerasrc* camerasrc, GstCaps * caps, int stream GstStructure *structure = gst_caps_get_structure (caps, 0); const gchar *mimetype = gst_structure_get_name (structure); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (!gst_video_is_dma_drm_caps(caps)) { #endif /* raw caps, parse into video info */ @@ -2503,7 +2503,7 @@ gst_camerasrc_get_caps_info (Gstcamerasrc* camerasrc, GstCaps * caps, int stream camerasrc->device_id, stream_id); return FALSE; } -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT } else { GstVideoInfoDmaDrm drm_info; if (!gst_video_info_dma_drm_from_caps(&drm_info, caps)) { @@ -2697,7 +2697,7 @@ gst_camerasrc_set_caps(GstCamBaseSrc *src, GstPad *pad, GstCaps *caps) #if GST_VERSION_MINOR >= 18 if (camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_MODE) { -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (CameraSrcUtils::gst_video_info_from_dma_drm_caps(&vinfo, caps)) { #else if (gst_video_info_from_caps(&vinfo, caps)) { diff --git a/src/gstcamerasrc.h b/src/gstcamerasrc.h index 91ad707..508a405 100644 --- a/src/gstcamerasrc.h +++ b/src/gstcamerasrc.h @@ -463,7 +463,7 @@ struct _GstStreamInfo /* Buffer config */ guint bpl; GstVideoInfo info; -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT /* drm modifier used currently after negotiated. */ guint64 drm_modifier; #endif diff --git a/src/gstcamerasrcbufferpool.cpp b/src/gstcamerasrcbufferpool.cpp index 2d253c9..12228c9 100644 --- a/src/gstcamerasrcbufferpool.cpp +++ b/src/gstcamerasrcbufferpool.cpp @@ -44,7 +44,7 @@ #define LOG_TAG "GstCameraSrcBufferPool" #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -141,7 +141,7 @@ gst_camerasrc_buffer_pool_finalize (GObject * object) PERF_CAMERA_ATRACE(); GstCamerasrcBufferPool *pool = GST_CAMERASRC_BUFFER_POOL (object); GST_INFO("CameraId=%d, StreamId=%d.", pool->src->device_id, pool->stream_id); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (pool->display_drm) { gst_object_unref(pool->display_drm); pool->display_drm = NULL; @@ -178,7 +178,7 @@ gst_camerasrc_buffer_pool_init (GstCamerasrcBufferPool * pool) pool->need_alignment = FALSE; #endif -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT pool->display_drm = NULL; #endif } @@ -199,7 +199,7 @@ gst_camerasrc_buffer_pool_new (Gstcamerasrc *camerasrc, if (camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_MODE) { #if GST_VERSION_MINOR >= 18 -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (!CameraSrcUtils::gst_video_info_from_dma_drm_caps(&info, caps)) { #else if (!gst_video_info_from_caps(&info, caps)) { @@ -291,7 +291,7 @@ gst_camerasrc_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * conf } #if GST_VERSION_MINOR >= 18 -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (!CameraSrcUtils::gst_video_info_from_dma_drm_caps(&video_info, caps)) { #else if (!gst_video_info_from_caps (&video_info, caps)) { @@ -313,7 +313,7 @@ gst_camerasrc_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * conf pool->allocator = NULL; if (camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_EXPORT || camerasrc->io_mode == GST_CAMERASRC_IO_MODE_DMA_MODE) { -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (NULL == pool->display_drm) { pool->display_drm = gst_va_display_drm_new_from_path("/dev/dri/renderD128"); @@ -693,7 +693,7 @@ gst_camerasrc_alloc_dma_mode(GstCamerasrcBufferPool *pool, if ((*meta)->buffer == NULL) return GST_FLOW_ERROR; -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT if (!GST_CAM_BASE_SRC(src)->is_dma_drm_caps) { #endif @@ -747,7 +747,7 @@ gst_camerasrc_alloc_dma_mode(GstCamerasrcBufferPool *pool, close(intel_fd); drm_intel_bufmgr_destroy(bufmgr); drm_intel_bo_unreference(drm_bo); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT } else { if (NULL == pool->display_drm) { GST_ERROR("Couldn't create a VA DRM display"); diff --git a/src/gstcamerasrcbufferpool.h b/src/gstcamerasrcbufferpool.h index e011970..981fecd 100644 --- a/src/gstcamerasrcbufferpool.h +++ b/src/gstcamerasrcbufferpool.h @@ -90,7 +90,7 @@ struct _GstCamerasrcBufferPool GstVideoAlignment alignment; #endif -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT /* operate on /dev/dri/renderD128 */ GstVaDisplay *display_drm; #endif diff --git a/src/utils.cpp b/src/utils.cpp index 70bac7e..8996619 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -43,6 +43,9 @@ #define LOG_TAG "GstCameraUtils" +#ifdef HAVE_CONFIG_H +#include +#endif #include "utils.h" struct FormatCvt { @@ -165,7 +168,7 @@ int CameraSrcUtils::get_stream_id_by_pad(map &streamMap, GstPad *pa return stream_id; } -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT #define VA_NSB_FIRST 0 /* No Significant Bit */ diff --git a/src/utils.h b/src/utils.h index cf66e95..2a938dd 100644 --- a/src/utils.h +++ b/src/utils.h @@ -55,11 +55,12 @@ #include #include -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT #include #include #define GST_USE_UNSTABLE_API #include +#undef GST_USE_UNSTABLE_API #include #endif @@ -114,7 +115,7 @@ namespace CameraSrcUtils { int get_stream_id_by_pad(map &streamMap, GstPad *pad); -#if GST_VERSION_MINOR == 22 && GST_VERSION_MICRO == 6 || GST_VERSION_MINOR >= 23 +#ifdef GST_DRM_FORMAT gboolean gst_video_info_from_dma_drm_caps(GstVideoInfo *info, const GstCaps *caps);