X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=sys%2Fv4l2%2Fgstv4l2object.h;h=c12ff099c31452df9c0a532805777b636bb9cff0;hb=99f8db82856180acc427259c612aba30f91438c2;hp=c13cd645680c5e176e36de9d8dc07d1cc2f3e8be;hpb=e2fd7e274eb5bdb3fa03c4e8254086f42cf80b0c;p=platform%2Fupstream%2Fgst-plugins-good.git diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index c13cd64..c12ff09 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -1,7 +1,7 @@ /* GStreamer * * Copyright (C) 2001-2002 Ronald Bultje - * 2006 Edgard Lima + * 2006 Edgard Lima * * gstv4l2object.h: base class for V4L2 elements * @@ -25,15 +25,20 @@ #define __GST_V4L2_OBJECT_H__ #include "ext/videodev2.h" +#ifdef HAVE_LIBV4L2 +# include +#endif + +#include "v4l2-utils.h" #include #include #include +#include typedef struct _GstV4l2Object GstV4l2Object; typedef struct _GstV4l2ObjectClassHelper GstV4l2ObjectClassHelper; -typedef struct _GstV4l2Xv GstV4l2Xv; #include @@ -63,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) @@ -77,14 +90,48 @@ typedef gboolean (*GstV4l2UpdateFpsFunction) (GstV4l2Object * v4l2object); #define GST_V4L2_SET_ACTIVE(o) ((o)->active = TRUE) #define GST_V4L2_SET_INACTIVE(o) ((o)->active = FALSE) +/* checks whether the current v4lv4l2object has already been open()'ed or not */ +#define GST_V4L2_CHECK_OPEN(v4l2object) \ + if (!GST_V4L2_IS_OPEN(v4l2object)) \ + { \ + GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \ + (_("Device is not open.")), (NULL)); \ + return FALSE; \ + } + +/* checks whether the current v4lv4l2object is close()'ed or whether it is still open */ +#define GST_V4L2_CHECK_NOT_OPEN(v4l2object) \ + if (GST_V4L2_IS_OPEN(v4l2object)) \ + { \ + GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \ + (_("Device is open.")), (NULL)); \ + return FALSE; \ + } + +/* checks whether we're out of capture mode or not */ +#define GST_V4L2_CHECK_NOT_ACTIVE(v4l2object) \ + if (GST_V4L2_IS_ACTIVE(v4l2object)) \ + { \ + GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \ + (NULL), ("Device is in streaming mode")); \ + return FALSE; \ + } + + 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; @@ -118,8 +165,8 @@ struct _GstV4l2Object { gboolean prefered_non_contiguous; /* This will be set if supported in decide_allocation. It can be used to - * calculate the minimum latency of a m2m decoder. */ - guint32 min_buffers_for_capture; + * calculate the minimum latency. */ + guint32 min_buffers; /* wanted mode */ GstV4l2IOMode req_mode; @@ -129,12 +176,8 @@ struct _GstV4l2Object { /* the video device's capabilities */ struct v4l2_capability vcap; - - /* the video device's window properties */ - struct v4l2_window vwin; - - /* some more info about the current input's capabilities */ - struct v4l2_input vinput; + /* opened device specific capabilities */ + guint32 device_caps; /* lists... */ GSList *formats; /* list of available capture formats */ @@ -153,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 { @@ -196,13 +249,14 @@ 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, GstV4l2SetInOutFunction set_in_out_func, GstV4l2UpdateFpsFunction update_fps_func); -void gst_v4l2_object_destroy (GstV4l2Object * v4l2object); +void gst_v4l2_object_destroy (GstV4l2Object * v4l2object); /* properties */ @@ -219,97 +273,70 @@ gboolean gst_v4l2_object_get_property_helper (GstV4l2Object *v4l2objec guint prop_id, GValue * value, GParamSpec * pspec); /* open/close */ -gboolean gst_v4l2_object_open (GstV4l2Object *v4l2object); -gboolean gst_v4l2_object_open_shared (GstV4l2Object *v4l2object, GstV4l2Object *other); -gboolean gst_v4l2_object_close (GstV4l2Object *v4l2object); +gboolean gst_v4l2_object_open (GstV4l2Object * v4l2object); +gboolean gst_v4l2_object_open_shared (GstV4l2Object * v4l2object, GstV4l2Object * other); +gboolean gst_v4l2_object_close (GstV4l2Object * v4l2object); /* probing */ -#if 0 -const GList* gst_v4l2_probe_get_properties (GstPropertyProbe * probe); - -void gst_v4l2_probe_probe_property (GstPropertyProbe * probe, guint prop_id, - const GParamSpec * pspec, - GList ** klass_devices); -gboolean gst_v4l2_probe_needs_probe (GstPropertyProbe * probe, guint prop_id, - const GParamSpec * pspec, - GList ** klass_devices); -GValueArray* gst_v4l2_probe_get_values (GstPropertyProbe * probe, guint prop_id, - const GParamSpec * pspec, - GList ** klass_devices); -#endif -GstCaps* gst_v4l2_object_get_all_caps (void); +GstCaps* gst_v4l2_object_get_all_caps (void); -GstCaps* gst_v4l2_object_get_raw_caps (void); +GstCaps* gst_v4l2_object_get_raw_caps (void); -GstCaps* gst_v4l2_object_get_codec_caps (void); +GstCaps* gst_v4l2_object_get_codec_caps (void); -gboolean gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps); +gint gst_v4l2_object_extrapolate_stride (const GstVideoFormatInfo * finfo, + gint plane, gint stride); -gboolean gst_v4l2_object_caps_equal (GstV4l2Object * v4l2object, GstCaps * caps); +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_unlock (GstV4l2Object * v4l2object); -gboolean gst_v4l2_object_unlock_stop (GstV4l2Object * v4l2object); +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_stop (GstV4l2Object * v4l2object); +gboolean gst_v4l2_object_unlock (GstV4l2Object * v4l2object); +gboolean gst_v4l2_object_unlock_stop (GstV4l2Object * v4l2object); -GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object, - GstCaps * filter); +gboolean gst_v4l2_object_stop (GstV4l2Object * v4l2object); -gboolean gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object, - GstVideoInfo * info); +GstCaps * gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object, GstCaps * filter); +GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object, GstCaps * filter); -gboolean gst_v4l2_object_set_crop (GstV4l2Object * obj); +gboolean gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object, GstVideoInfo * info); -gboolean gst_v4l2_object_decide_allocation (GstV4l2Object * v4l2object, - GstQuery * query); +gboolean gst_v4l2_object_set_crop (GstV4l2Object * obj); -gboolean gst_v4l2_object_propose_allocation (GstV4l2Object * obj, - GstQuery * query); +gboolean gst_v4l2_object_decide_allocation (GstV4l2Object * v4l2object, GstQuery * query); -GstStructure * gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc); +gboolean gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query); +GstStructure * gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc); -#define GST_IMPLEMENT_V4L2_PROBE_METHODS(Type_Class, interface_as_function) \ - \ -static void \ -interface_as_function ## _probe_probe_property (GstPropertyProbe * probe, \ - guint prop_id, \ - const GParamSpec * pspec) \ -{ \ - Type_Class *this_class = (Type_Class*) G_OBJECT_GET_CLASS (probe); \ - gst_v4l2_probe_probe_property (probe, prop_id, pspec, \ - &this_class->v4l2_class_devices); \ -} \ - \ -static gboolean \ -interface_as_function ## _probe_needs_probe (GstPropertyProbe * probe, \ - guint prop_id, \ - const GParamSpec * pspec) \ -{ \ - Type_Class *this_class = (Type_Class*) G_OBJECT_GET_CLASS (probe); \ - return gst_v4l2_probe_needs_probe (probe, prop_id, pspec, \ - &this_class->v4l2_class_devices); \ -} \ - \ -static GValueArray * \ -interface_as_function ## _probe_get_values (GstPropertyProbe * probe, \ - guint prop_id, \ - const GParamSpec * pspec) \ -{ \ - Type_Class *this_class = (Type_Class*) G_OBJECT_GET_CLASS (probe); \ - return gst_v4l2_probe_get_values (probe, prop_id, pspec, \ - &this_class->v4l2_class_devices); \ -} \ - \ -static void \ -interface_as_function ## _property_probe_interface_init (GstPropertyProbeInterface * iface) \ -{ \ - iface->get_properties = gst_v4l2_probe_get_properties; \ - iface->probe_property = interface_as_function ## _probe_probe_property; \ - iface->needs_probe = interface_as_function ## _probe_needs_probe; \ - iface->get_values = interface_as_function ## _probe_get_values; \ -} +/* TODO Move to proper namespace */ +/* open/close the device */ +gboolean gst_v4l2_open (GstV4l2Object * v4l2object); +gboolean gst_v4l2_dup (GstV4l2Object * v4l2object, GstV4l2Object * other); +gboolean gst_v4l2_close (GstV4l2Object * v4l2object); + +/* norm/input/output */ +gboolean gst_v4l2_get_norm (GstV4l2Object * v4l2object, v4l2_std_id * norm); +gboolean gst_v4l2_set_norm (GstV4l2Object * v4l2object, v4l2_std_id norm); +gboolean gst_v4l2_get_input (GstV4l2Object * v4l2object, gint * input); +gboolean gst_v4l2_set_input (GstV4l2Object * v4l2object, gint input); +gboolean gst_v4l2_get_output (GstV4l2Object * v4l2object, gint * output); +gboolean gst_v4l2_set_output (GstV4l2Object * v4l2object, gint output); + +/* frequency control */ +gboolean gst_v4l2_get_frequency (GstV4l2Object * v4l2object, gint tunernum, gulong * frequency); +gboolean gst_v4l2_set_frequency (GstV4l2Object * v4l2object, gint tunernum, gulong frequency); +gboolean gst_v4l2_signal_strength (GstV4l2Object * v4l2object, gint tunernum, gulong * signal); + +/* attribute control */ +gboolean gst_v4l2_get_attribute (GstV4l2Object * v4l2object, int attribute, int * value); +gboolean gst_v4l2_set_attribute (GstV4l2Object * v4l2object, int attribute, const int value); +gboolean gst_v4l2_set_controls (GstV4l2Object * v4l2object, GstStructure * controls); G_END_DECLS