diff --git a/sys/v4l/gstv4lelement.c b/sys/v4l/gstv4lelement.c index 5a2308ef41..4287bfbf51 100644 --- a/sys/v4l/gstv4lelement.c +++ b/sys/v4l/gstv4lelement.c @@ -122,16 +122,17 @@ gst_v4l_class_probe_devices (GstV4lElementClass *klass, gboolean check) { static gboolean init = FALSE; + static GList *devices = NULL; if (!init && !check) { gchar *dev_base[] = { "/dev/video", "/dev/v4l/video", NULL }; gint base, n, fd; - while (klass->devices) { - GList *item = klass->devices; + while (devices) { + GList *item = devices; gchar *device = item->data; - klass->devices = g_list_remove (klass->devices, item); + devices = g_list_remove (devices, item); g_free (device); } @@ -148,7 +149,7 @@ gst_v4l_class_probe_devices (GstV4lElementClass *klass, if (fd > 0) close (fd); - klass->devices = g_list_append (klass->devices, device); + devices = g_list_append (devices, device); break; } } @@ -159,6 +160,8 @@ gst_v4l_class_probe_devices (GstV4lElementClass *klass, init = TRUE; } + klass->devices = devices; + return init; } diff --git a/sys/v4l/v4l_calls.c b/sys/v4l/v4l_calls.c index 42bfdb3760..515299b98f 100644 --- a/sys/v4l/v4l_calls.c +++ b/sys/v4l/v4l_calls.c @@ -38,6 +38,10 @@ #include "gstv4ltuner.h" #include "gstv4lcolorbalance.h" +#include "gstv4lsrc.h" +#include "gstv4lmjpegsrc.h" +#include "gstv4lmjpegsink.h" + #define DEBUG(format, args...) \ GST_DEBUG_OBJECT (\ GST_ELEMENT(v4lelement), \ @@ -130,6 +134,21 @@ gst_v4l_open (GstV4lElement *v4lelement) return FALSE; } + /* device type check */ + if ((GST_IS_V4LSRC(v4lelement) && + !(v4lelement->vcap.type & VID_TYPE_CAPTURE)) || + (GST_IS_V4LMJPEGSRC(v4lelement) && + !(v4lelement->vcap.type & VID_TYPE_MJPEG_ENCODER)) || + (GST_IS_V4LMJPEGSINK(v4lelement) && + !(v4lelement->vcap.type & VID_TYPE_MJPEG_DECODER))) { + gst_element_error(GST_ELEMENT(v4lelement), + "Device opened, but wrong type (0x%x)", + v4lelement->vcap.type); + close(v4lelement->video_fd); + v4lelement->video_fd = -1; + return FALSE; + } + gst_info("Opened device \'%s\' (\'%s\') successfully\n", v4lelement->vcap.name, v4lelement->videodev);