v4l2src: Add new property for auto scan device feature
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2object.h
index 54fb1be..c12ff09 100644 (file)
 #ifndef __GST_V4L2_OBJECT_H__
 #define __GST_V4L2_OBJECT_H__
 
+#include "ext/videodev2.h"
 #ifdef HAVE_LIBV4L2
 #  include <libv4l2.h>
-#else
-#  include "ext/videodev2.h"
-#  include <sys/ioctl.h>
-#  include <sys/mman.h>
-#  include <unistd.h>
-#  define v4l2_fd_open(fd, flags) (fd)
-#  define v4l2_close    close
-#  define v4l2_dup      dup
-#  define v4l2_ioctl    ioctl
-#  define v4l2_read     read
-#  define v4l2_mmap     mmap
-#  define v4l2_munmap   munmap
 #endif
 
-#include "ext/videodev2.h"
 #include "v4l2-utils.h"
 
 #include <gst/gst.h>
 #include <gst/base/gstpushsrc.h>
 
 #include <gst/video/video.h>
+#include <unistd.h>
 
 typedef struct _GstV4l2Object GstV4l2Object;
 typedef struct _GstV4l2ObjectClassHelper GstV4l2ObjectClassHelper;
-typedef struct _GstV4l2Xv GstV4l2Xv;
 
 #include <gstv4l2bufferpool.h>
 
@@ -80,6 +68,14 @@ typedef gboolean  (*GstV4l2GetInOutFunction)  (GstV4l2Object * v4l2object, gint
 typedef gboolean  (*GstV4l2SetInOutFunction)  (GstV4l2Object * v4l2object, gint input);
 typedef gboolean  (*GstV4l2UpdateFpsFunction) (GstV4l2Object * v4l2object);
 
+/* On Android NDK r18b the ioctl() signature uses 'unsigned' instead of
+ * 'unsigned long' for the 2nd parameter */
+#ifdef __ANDROID__
+typedef unsigned ioctl_req_t;
+#else
+typedef gulong ioctl_req_t;
+#endif
+
 #define GST_V4L2_WIDTH(o)        (GST_VIDEO_INFO_WIDTH (&(o)->info))
 #define GST_V4L2_HEIGHT(o)       (GST_VIDEO_INFO_HEIGHT (&(o)->info))
 #define GST_V4L2_PIXELFORMAT(o)  ((o)->fmtdesc->pixelformat)
@@ -124,12 +120,18 @@ typedef gboolean  (*GstV4l2UpdateFpsFunction) (GstV4l2Object * v4l2object);
 
 struct _GstV4l2Object {
   GstElement * element;
+  GstObject * dbg_obj;
 
   enum v4l2_buf_type type;   /* V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_BUF_TYPE_VIDEO_OUTPUT */
 
   /* the video device */
   char *videodev;
 
+#ifdef TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE
+  /* auto scan device */
+  gboolean auto_scan_device;
+#endif /* TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE */
+
   /* the video-device's file descriptor */
   gint video_fd;
   GstV4l2IOMode mode;
@@ -166,9 +168,6 @@ struct _GstV4l2Object {
    * calculate the minimum latency. */
   guint32 min_buffers;
 
-  /* This will be set if supported in propose allocation. */
-  guint32 min_buffers_for_output;
-
   /* wanted mode */
   GstV4l2IOMode req_mode;
 
@@ -180,12 +179,6 @@ struct _GstV4l2Object {
   /* opened device specific capabilities */
   guint32 device_caps;
 
-  /* the video device's window properties */
-  struct v4l2_window vwin;
-
-  /* some more info about the current input's capabilities */
-  struct v4l2_input vinput;
-
   /* lists... */
   GSList *formats;              /* list of available capture formats */
   GstCaps *probed_caps;
@@ -203,21 +196,31 @@ struct _GstV4l2Object {
   gboolean keep_aspect;
   GValue *par;
 
-  /* X-overlay */
-  GstV4l2Xv *xv;
-  gulong xwindow_id;
-
   /* funcs */
   GstV4l2GetInOutFunction  get_in_out_func;
   GstV4l2SetInOutFunction  set_in_out_func;
   GstV4l2UpdateFpsFunction update_fps_func;
 
+  /* syscalls */
+  gint (*fd_open) (gint fd, gint v4l2_flags);
+  gint (*close) (gint fd);
+  gint (*dup) (gint fd);
+  gint (*ioctl) (gint fd, ioctl_req_t request, ...);
+  gssize (*read) (gint fd, gpointer buffer, gsize n);
+  gpointer (*mmap) (gpointer start, gsize length, gint prot, gint flags,
+      gint fd,  off_t offset);
+  gint (*munmap) (gpointer _start, gsize length);
+
   /* Quirks */
   /* Skips interlacing probes */
   gboolean never_interlaced;
   /* Allow to skip reading initial format through G_FMT. Some devices
    * just fails if you don't call S_FMT first. (ex: M2M decoders) */
   gboolean no_initial_format;
+  /* Avoid any try_fmt probe. This is used by v4l2src to speedup start up time
+   * on slow USB firmwares. When this is set, gst_v4l2_set_format() will modify
+   * the caps to reflect what was negotiated during fixation */
+  gboolean skip_try_fmt_probes;
 };
 
 struct _GstV4l2ObjectClassHelper {
@@ -246,6 +249,7 @@ GType gst_v4l2_object_get_type (void);
 
 /* create/destroy */
 GstV4l2Object*  gst_v4l2_object_new       (GstElement * element,
+                                           GstObject * dbg_obj,
                                            enum v4l2_buf_type  type,
                                            const char * default_device,
                                            GstV4l2GetInOutFunction get_in_out_func,
@@ -286,8 +290,11 @@ gint         gst_v4l2_object_extrapolate_stride (const GstVideoFormatInfo * finf
 
 gboolean     gst_v4l2_object_set_format  (GstV4l2Object * v4l2object, GstCaps * caps, GstV4l2Error * error);
 gboolean     gst_v4l2_object_try_format  (GstV4l2Object * v4l2object, GstCaps * caps, GstV4l2Error * error);
+gboolean     gst_v4l2_object_try_import  (GstV4l2Object * v4l2object, GstBuffer * buffer);
 
-gboolean     gst_v4l2_object_caps_equal  (GstV4l2Object * v4l2object, GstCaps * caps);
+gboolean     gst_v4l2_object_caps_equal       (GstV4l2Object * v4l2object, GstCaps * caps);
+gboolean     gst_v4l2_object_caps_is_subset   (GstV4l2Object * v4l2object, GstCaps * caps);
+GstCaps *    gst_v4l2_object_get_current_caps (GstV4l2Object * v4l2object);
 
 gboolean     gst_v4l2_object_unlock      (GstV4l2Object * v4l2object);
 gboolean     gst_v4l2_object_unlock_stop (GstV4l2Object * v4l2object);
@@ -331,8 +338,6 @@ gboolean     gst_v4l2_get_attribute   (GstV4l2Object * v4l2object, int attribute
 gboolean     gst_v4l2_set_attribute   (GstV4l2Object * v4l2object, int attribute, const int value);
 gboolean     gst_v4l2_set_controls    (GstV4l2Object * v4l2object, GstStructure * controls);
 
-gboolean     gst_v4l2_get_capabilities (GstV4l2Object * v4l2object);
-
 G_END_DECLS
 
 #endif /* __GST_V4L2_OBJECT_H__ */