From 2676b79eb67fd733bd5f7d8bb6a66a62ce69c7f6 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 9 Nov 2003 20:54:24 +0000 Subject: [PATCH] Fix device probing from multiple childs. It's done once in the parent class only now, but the childs do get the corre... Original commit message from CVS: Fix device probing from multiple childs. It's done once in the parent class only now, but the childs do get the correct values. Also fixes an incorrect succesful state change if we opened a v4l device that doesn't have the capabilities that are needed by the plugin. --- sys/v4l/gstv4lelement.c | 11 +++++++---- sys/v4l/v4l_calls.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/sys/v4l/gstv4lelement.c b/sys/v4l/gstv4lelement.c index 5a2308e..4287bfb 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 42bfdb3..515299b 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); -- 2.7.4