rpicamsrc: hook up to build
authorTim-Philipp Müller <tim@centricular.com>
Thu, 9 Jul 2020 16:07:30 +0000 (16:07 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 10 Jul 2020 16:37:28 +0000 (17:37 +0100)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/667>

meson_options.txt
sys/meson.build
sys/rpicamsrc/gstrpicamsrc.c
sys/rpicamsrc/gstrpicamsrcdeviceprovider.c
sys/rpicamsrc/gstrpicamsrcdeviceprovider.h
sys/rpicamsrc/meson.build

index dc704b2..5c96f65 100644 (file)
@@ -74,6 +74,11 @@ option('vpx', type : 'feature', value : 'auto', description : 'VP8 and VP9 video
 option('waveform', type : 'feature', value : 'auto', description : 'Windows waveform audio sink plugin')
 option('wavpack', type : 'feature', value : 'auto', description : 'Wavpack audio codec plugin')
 
+# rpicamsrc plugin options
+option('rpicamsrc', type : 'feature', value : 'auto', description : 'Raspberry Pi camera module plugin')
+option('rpi-header-dir', type : 'string', value : '/opt/vc/include', description : 'Directory where VideoCore/MMAL headers and bcm_host.h can be found')
+option('rpi-lib-dir', type : 'string', value : '/opt/vc/lib', description : 'Directory where VideoCore/MMAL libraries can be found')
+
 # ximagesrc plugin options
 option('ximagesrc', type : 'feature', value : 'auto', description : 'X11 ximagesrc plugin')
 option('ximagesrc-xshm', type : 'feature', value : 'auto', description : 'X11 ximagesrc plugin (XSHM support)')
index c5c8d64..d337015 100644 (file)
@@ -3,6 +3,7 @@ subdir('oss')
 subdir('oss4')
 subdir('osxaudio')
 subdir('osxvideo')
+subdir('rpicamsrc')
 subdir('v4l2')
 subdir('waveform')
 subdir('ximage')
index 544efe3..eb57f25 100644 (file)
@@ -1455,23 +1455,21 @@ static gboolean
 plugin_init (GstPlugin * plugin)
 {
   gboolean ret;
+
   GST_DEBUG_CATEGORY_INIT (gst_rpi_cam_src_debug, "rpicamsrc",
       0, "rpicamsrc debug");
+
   ret = gst_element_register (plugin, "rpicamsrc", GST_RANK_NONE,
       GST_TYPE_RPICAMSRC);
-#if GST_CHECK_VERSION (1,4,0)
+
   ret &= gst_device_provider_register (plugin, "rpicamsrcdeviceprovider",
       GST_RANK_PRIMARY, GST_TYPE_RPICAMSRC_DEVICE_PROVIDER);
-#endif
+
   return ret;
 }
 
-#ifndef PACKAGE
-#define PACKAGE "gstrpicamsrc"
-#endif
-
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     GST_VERSION_MINOR,
     rpicamsrc,
     "Raspberry Pi Camera Source",
-    plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
+    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
index ff80832..1d2077a 100644 (file)
@@ -25,8 +25,6 @@
 
 #include <string.h>
 
-#if GST_CHECK_VERSION (1,4,0)
-
 #include "RaspiCapture.h"
 
 /* FIXME: translations */
@@ -145,5 +143,3 @@ gst_rpi_cam_src_device_new (void)
 
   return device;
 }
-
-#endif /* GST_CHECK_VERSION (1,4,0) */
index cd5e9aa..d4ed19c 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <gst/gst.h>
 
-#if GST_CHECK_VERSION (1,4,0)
-
 G_BEGIN_DECLS
 
 typedef struct _GstRpiCamSrcDeviceProvider GstRpiCamSrcDeviceProvider;
@@ -74,6 +72,4 @@ GType  gst_rpi_cam_src_device_get_type (void);
 
 G_END_DECLS
 
-#endif /* GST_CHECK_VERSION (1,4,0) */
-
 #endif /* __GST_RPICAMSRC_DEVICE_PROVIDER_H__ */
index c3a1651..a71be6f 100644 (file)
@@ -7,7 +7,48 @@ rpicamsrc_sources = [
   'RaspiCLI.c',
 ]
 
-# glib-mkenums
+if host_system != 'linux' or (host_cpu != 'arm' and host_cpu != 'aarch64')
+  assert(not get_option('rpicamsrc').enabled())
+  subdir_done()
+endif
+
+if get_option('rpicamsrc').disabled()
+  subdir_done()
+endif
+
+rpi_inc_path = get_option('rpi-header-dir')
+rpi_lib_path = get_option('rpi-lib-dir')
+
+rpi_inc_args = [
+  '-I' + rpi_inc_path,
+  '-I' + join_paths(rpi_inc_path, 'interface', 'vcos', 'pthreads'),
+  '-I' + join_paths(rpi_inc_path, 'interface', 'vmcs_host', 'linux'),
+]
+
+if not cc.has_header('bcm_host.h', args: rpi_inc_args)
+  if get_option('rpicamsrc').enabled()
+    error('Could not find bcm_host.h. Please pass the location of this header via -Drpi-header-dir=/path')
+  else
+    subdir_done()
+  endif
+endif
+
+mmal_deps = []
+foreach rpi_lib : ['mmal_core', 'mmal_util', 'mmal_vc_client', 'vcos', 'bcm_host']
+  l = cc.find_library(rpi_lib, dirs: rpi_lib_path, required: false)
+  if not l.found()
+    if get_option('rpicamsrc').enabled()
+      error('''
+            Could not find lib@0@ in standard library paths and @1@.
+           Please pass the location of these libs via -Dwith-rpi-lib-dir=/path.
+           '''.format(rpi_lib, rpi_lib_path))
+    else
+      subdir_done()
+    endif
+  endif
+  mmal_deps += [l]
+endforeach
+
 gnome = import('gnome')
 
 enums = gnome.mkenums_simple('gstrpicam-enum-types',
@@ -15,10 +56,14 @@ enums = gnome.mkenums_simple('gstrpicam-enum-types',
   identifier_prefix: 'GstRpiCamSrc',
   symbol_prefix: 'gst_rpi_cam_src')
 
-library('gstrpicamsrc',
+# we might need '-Wl,--no-as-needed' or b_asneeded=false on ubuntu, tbd
+gstrpicamsrc = library('gstrpicamsrc',
   rpicamsrc_sources, enums,
-  c_args : gst_rpicamsrc_args,
-  include_directories : config_inc,
-  dependencies : [gst_dep, gstbase_dep, gstvideo_dep] + mmal_deps,
-  install : true,
-  install_dir : plugins_install_dir)
+  c_args: [gst_plugins_good_args, rpi_inc_args],
+  include_directories: [configinc, libsinc],
+  dependencies: [gst_dep, gstbase_dep, gstvideo_dep] + mmal_deps,
+  install_dir: plugins_install_dir,
+  install: true)
+
+pkgconfig.generate(gstrpicamsrc, install_dir: plugins_pkgconfig_install_dir)
+plugins += [gstrpicamsrc]