static void gst_v4l2src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+/* get_frame io methods */
+static GstFlowReturn
+gst_v4l2src_get_read (GstV4l2Src * v4l2src, GstBuffer ** buf);
+static GstFlowReturn
+gst_v4l2src_get_mmap (GstV4l2Src * v4l2src, GstBuffer ** buf);
+
static void
gst_v4l2src_base_init (gpointer g_class)
{
if (!gst_v4l2src_capture_init (v4l2src, caps))
return FALSE;
+ if (v4l2src->use_mmap) {
+ v4l2src->get_frame = gst_v4l2src_get_mmap;
+ } else {
+ v4l2src->get_frame = gst_v4l2src_get_read;
+ }
+
if (!gst_v4l2src_capture_start (v4l2src))
return FALSE;
again:
ret = gst_v4l2src_grab_frame (v4l2src, &temp);
- if (ret != GST_FLOW_OK)
+ if (G_UNLIKELY (ret != GST_FLOW_OK))
goto done;
if (v4l2src->frame_byte_size > 0) {
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
GstFlowReturn ret;
- if (v4l2src->use_mmap) {
- ret = gst_v4l2src_get_mmap (v4l2src, buf);
- } else {
- ret = gst_v4l2src_get_read (v4l2src, buf);
- }
+ ret = v4l2src->get_frame (v4l2src, buf);
/* set buffer metadata */
- if (ret == GST_FLOW_OK && *buf) {
+ if (G_LIKELY (ret == GST_FLOW_OK && *buf)) {
GstClock *clock;
GstClockTime timestamp;
typedef struct _GstV4l2Src GstV4l2Src;
typedef struct _GstV4l2SrcClass GstV4l2SrcClass;
-
+typedef GstFlowReturn (*GstV4l2SrcGetFunc)(GstV4l2Src * v4l2src, GstBuffer ** buf);
/**
* GstV4l2Src:
guint64 offset;
gint fps_d, fps_n; /* framerate if device is open */
+
+ GstV4l2SrcGetFunc get_frame;
};
struct _GstV4l2SrcClass