mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
v4l: open/close device in ready.
Simillar change like in v4l2src. This allows probing feature in paused, where streaming is noit yet started.
This commit is contained in:
parent
61441ff183
commit
b64be90326
2 changed files with 34 additions and 34 deletions
|
@ -54,15 +54,15 @@ static void gst_v4lelement_init_interfaces (GType type);
|
||||||
GST_BOILERPLATE_FULL (GstV4lElement, gst_v4lelement, GstPushSrc,
|
GST_BOILERPLATE_FULL (GstV4lElement, gst_v4lelement, GstPushSrc,
|
||||||
GST_TYPE_PUSH_SRC, gst_v4lelement_init_interfaces);
|
GST_TYPE_PUSH_SRC, gst_v4lelement_init_interfaces);
|
||||||
|
|
||||||
|
|
||||||
static void gst_v4lelement_dispose (GObject * object);
|
static void gst_v4lelement_dispose (GObject * object);
|
||||||
static void gst_v4lelement_set_property (GObject * object,
|
static void gst_v4lelement_set_property (GObject * object,
|
||||||
guint prop_id, const GValue * value, GParamSpec * pspec);
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
||||||
static void gst_v4lelement_get_property (GObject * object,
|
static void gst_v4lelement_get_property (GObject * object,
|
||||||
guint prop_id, GValue * value, GParamSpec * pspec);
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
||||||
static gboolean gst_v4lelement_start (GstBaseSrc * src);
|
|
||||||
static gboolean gst_v4lelement_stop (GstBaseSrc * src);
|
|
||||||
|
|
||||||
|
/* element methods */
|
||||||
|
static GstStateChangeReturn gst_v4lelement_change_state (GstElement * element,
|
||||||
|
GstStateChange transition);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_v4l_iface_supported (GstImplementsInterface * iface, GType iface_type)
|
gst_v4l_iface_supported (GstImplementsInterface * iface, GType iface_type)
|
||||||
|
@ -325,13 +325,16 @@ static void
|
||||||
gst_v4lelement_class_init (GstV4lElementClass * klass)
|
gst_v4lelement_class_init (GstV4lElementClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstBaseSrcClass *basesrc_class;
|
GstElementClass *element_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
basesrc_class = (GstBaseSrcClass *) klass;
|
element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->set_property = gst_v4lelement_set_property;
|
gobject_class->set_property = gst_v4lelement_set_property;
|
||||||
gobject_class->get_property = gst_v4lelement_get_property;
|
gobject_class->get_property = gst_v4lelement_get_property;
|
||||||
|
gobject_class->dispose = gst_v4lelement_dispose;
|
||||||
|
|
||||||
|
element_class->change_state = gst_v4lelement_change_state;
|
||||||
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEVICE,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEVICE,
|
||||||
g_param_spec_string ("device", "Device", "Device location",
|
g_param_spec_string ("device", "Device", "Device location",
|
||||||
|
@ -344,10 +347,6 @@ gst_v4lelement_class_init (GstV4lElementClass * klass)
|
||||||
GST_TYPE_V4L_DEVICE_FLAGS, 0,
|
GST_TYPE_V4L_DEVICE_FLAGS, 0,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
basesrc_class->start = gst_v4lelement_start;
|
|
||||||
basesrc_class->stop = gst_v4lelement_stop;
|
|
||||||
|
|
||||||
gobject_class->dispose = gst_v4lelement_dispose;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,32 +439,39 @@ gst_v4lelement_get_property (GObject * object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static GstStateChangeReturn
|
||||||
gst_v4lelement_start (GstBaseSrc * src)
|
gst_v4lelement_change_state (GstElement * element, GstStateChange transition)
|
||||||
{
|
{
|
||||||
GstV4lElement *v4lelement = GST_V4LELEMENT (src);
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
||||||
|
GstV4lElement *v4lelement = GST_V4LELEMENT (element);
|
||||||
if (!gst_v4l_open (v4lelement))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
|
/* open the device */
|
||||||
|
if (!gst_v4l_open (v4lelement))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
#ifdef HAVE_XVIDEO
|
#ifdef HAVE_XVIDEO
|
||||||
gst_v4l_xoverlay_start (v4lelement);
|
gst_v4l_xoverlay_start (v4lelement);
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_v4lelement_stop (GstBaseSrc * src)
|
|
||||||
{
|
|
||||||
GstV4lElement *v4lelement = GST_V4LELEMENT (src);
|
|
||||||
|
|
||||||
|
switch (transition) {
|
||||||
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
|
/* close the device */
|
||||||
#ifdef HAVE_XVIDEO
|
#ifdef HAVE_XVIDEO
|
||||||
gst_v4l_xoverlay_stop (v4lelement);
|
gst_v4l_xoverlay_stop (v4lelement);
|
||||||
#endif
|
#endif
|
||||||
|
if (!gst_v4l_close (v4lelement))
|
||||||
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!gst_v4l_close (v4lelement))
|
return ret;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -676,9 +676,6 @@ gst_v4lsrc_start (GstBaseSrc * src)
|
||||||
{
|
{
|
||||||
GstV4lSrc *v4lsrc = GST_V4LSRC (src);
|
GstV4lSrc *v4lsrc = GST_V4LSRC (src);
|
||||||
|
|
||||||
if (!GST_BASE_SRC_CLASS (parent_class)->start (src))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
v4lsrc->offset = 0;
|
v4lsrc->offset = 0;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -697,9 +694,6 @@ gst_v4lsrc_stop (GstBaseSrc * src)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GST_BASE_SRC_CLASS (parent_class)->stop (src))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
g_list_free (v4lsrc->colorspaces);
|
g_list_free (v4lsrc->colorspaces);
|
||||||
v4lsrc->colorspaces = NULL;
|
v4lsrc->colorspaces = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue