static void gst_v4l2src_dispose (GObject * object);
static void gst_v4l2src_finalize (GstV4l2Src * v4l2src);
+/* element methods */
+static GstStateChangeReturn gst_v4l2src_change_state (GstElement * element,
+ GstStateChange transition);
+
/* basesrc methods */
static gboolean gst_v4l2src_start (GstBaseSrc * src);
static gboolean gst_v4l2src_unlock (GstBaseSrc * src);
gst_v4l2src_class_init (GstV4l2SrcClass * klass)
{
GObjectClass *gobject_class;
+ GstElementClass *element_class;
GstBaseSrcClass *basesrc_class;
GstPushSrcClass *pushsrc_class;
gobject_class = G_OBJECT_CLASS (klass);
+ element_class = GST_ELEMENT_CLASS (klass);
basesrc_class = GST_BASE_SRC_CLASS (klass);
pushsrc_class = GST_PUSH_SRC_CLASS (klass);
gobject_class->set_property = gst_v4l2src_set_property;
gobject_class->get_property = gst_v4l2src_get_property;
+ element_class->change_state = gst_v4l2src_change_state;
+
gst_v4l2_object_install_properties_helper (gobject_class);
g_object_class_install_property (gobject_class, PROP_QUEUE_SIZE,
g_param_spec_uint ("queue-size", "Queue size",
{
GstV4l2Src *v4l2src = GST_V4L2SRC (src);
- /* open the device */
- if (!gst_v4l2_object_start (v4l2src->v4l2object))
- return FALSE;
-
v4l2src->offset = 0;
return TRUE;
return TRUE;
}
-
static gboolean
gst_v4l2src_stop (GstBaseSrc * src)
{
return FALSE;
}
- /* close the device */
- if (!gst_v4l2_object_stop (v4l2src->v4l2object))
- return FALSE;
-
v4l2src->fps_d = 0;
v4l2src->fps_n = 0;
return TRUE;
}
+static GstStateChangeReturn
+gst_v4l2src_change_state (GstElement * element, GstStateChange transition)
+{
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstV4l2Src *v4l2src = GST_V4L2SRC (element);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ /* open the device */
+ if (!gst_v4l2_object_start (v4l2src->v4l2object))
+ return GST_STATE_CHANGE_FAILURE;
+ break;
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ /* close the device */
+ if (!gst_v4l2_object_stop (v4l2src->v4l2object))
+ return GST_STATE_CHANGE_FAILURE;
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
static GstFlowReturn
gst_v4l2src_get_read (GstV4l2Src * v4l2src, GstBuffer ** buf)
{