camerabin: fix setting filter-caps property in NULL state

Split _set_capsfilter_caps() into two parts so that we can call one part
regardless of the element state.
This commit is contained in:
Lasse Laukkanen 2009-11-04 13:24:13 +02:00 committed by Stefan Kost
parent 1b10553f90
commit c6f6f1b595

View file

@ -298,6 +298,8 @@ gst_camerabin_update_aspect_filter (GstCameraBin * camera, GstCaps * new_caps);
static void gst_camerabin_finish_image_capture (GstCameraBin * camera); static void gst_camerabin_finish_image_capture (GstCameraBin * camera);
static void gst_camerabin_adapt_image_capture (GstCameraBin * camera, static void gst_camerabin_adapt_image_capture (GstCameraBin * camera,
GstCaps * new_caps); GstCaps * new_caps);
static void gst_camerabin_configure_format (GstCameraBin * camera,
GstCaps * caps);
/* /*
* GObject callback functions declaration * GObject callback functions declaration
@ -1392,19 +1394,9 @@ gst_camerabin_rewrite_tags (GstCameraBin * camera)
static void static void
gst_camerabin_set_capsfilter_caps (GstCameraBin * camera, GstCaps * new_caps) gst_camerabin_set_capsfilter_caps (GstCameraBin * camera, GstCaps * new_caps)
{ {
GstStructure *st;
GST_INFO_OBJECT (camera, "new_caps:%" GST_PTR_FORMAT, new_caps); GST_INFO_OBJECT (camera, "new_caps:%" GST_PTR_FORMAT, new_caps);
st = gst_caps_get_structure (new_caps, 0); gst_camerabin_configure_format (camera, new_caps);
gst_structure_get_int (st, "width", &camera->width);
gst_structure_get_int (st, "height", &camera->height);
if (gst_structure_has_field (st, "framerate")) {
gst_structure_get_fraction (st, "framerate", &camera->fps_n,
&camera->fps_d);
}
/* Update zoom */ /* Update zoom */
gst_camerabin_setup_zoom (camera); gst_camerabin_setup_zoom (camera);
@ -2331,6 +2323,30 @@ gst_camerabin_adapt_image_capture (GstCameraBin * camera, GstCaps * in_caps)
} }
} }
/*
* gst_camerabin_configure_format:
* @camera: camerabin object
* @caps: caps describing new format
*
* Configure internal video format for camerabin.
*
*/
static void
gst_camerabin_configure_format (GstCameraBin * camera, GstCaps * caps)
{
GstStructure *st;
st = gst_caps_get_structure (caps, 0);
gst_structure_get_int (st, "width", &camera->width);
gst_structure_get_int (st, "height", &camera->height);
if (gst_structure_has_field_typed (st, "framerate", GST_TYPE_FRACTION)) {
gst_structure_get_fraction (st, "framerate", &camera->fps_n,
&camera->fps_d);
}
}
/* /*
* GObject callback functions implementation * GObject callback functions implementation
*/ */
@ -2976,9 +2992,7 @@ gst_camerabin_set_property (GObject * object, guint prop_id,
gst_caps_replace (&camera->view_finder_caps, gst_caps_replace (&camera->view_finder_caps,
(GstCaps *) gst_value_get_caps (value)); (GstCaps *) gst_value_get_caps (value));
GST_OBJECT_UNLOCK (camera); GST_OBJECT_UNLOCK (camera);
if (GST_STATE (camera) != GST_STATE_NULL) { gst_camerabin_configure_format (camera, camera->view_finder_caps);
gst_camerabin_set_capsfilter_caps (camera, camera->view_finder_caps);
}
break; break;
case ARG_PREVIEW_CAPS: case ARG_PREVIEW_CAPS:
{ {