diff options
author | Dave Robillard <dave@drobilla.net> | 2009-07-03 20:01:30 -0400 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-07-03 20:01:30 -0400 |
commit | caba48f261421d397900471b19350da2e5a4a4e5 (patch) | |
tree | ace87e1bd5c819454aefaa722203c30ed83f4ec1 /gst/camerabin/gstcamerabin.c | |
parent | 699e4f4d044d8111053b631baba4b324a60b1274 (diff) | |
parent | 6a763f6a471e9fbbd86358b0175498a6af78666e (diff) | |
download | gst-plugins-bad-caba48f261421d397900471b19350da2e5a4a4e5.tar.gz gst-plugins-bad-caba48f261421d397900471b19350da2e5a4a4e5.tar.bz2 gst-plugins-bad-caba48f261421d397900471b19350da2e5a4a4e5.zip |
Merge branch 'master' of git://anongit.freedesktop.org/gstreamer/gst-plugins-bad into fdo
Diffstat (limited to 'gst/camerabin/gstcamerabin.c')
-rw-r--r-- | gst/camerabin/gstcamerabin.c | 87 |
1 files changed, 48 insertions, 39 deletions
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 0a110f50..9d8a14cc 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -500,8 +500,7 @@ camerabin_setup_src_elements (GstCameraBin * camera) if (camera->fps_n > 0 && camera->fps_d > 0) { if (camera->night_mode) { - GST_WARNING_OBJECT (camera, - "night mode, lowest allowed fps will be forced"); + GST_INFO_OBJECT (camera, "night mode, lowest allowed fps will be forced"); camera->pre_night_fps_n = camera->fps_n; camera->pre_night_fps_d = camera->fps_d; detect_framerate = TRUE; @@ -531,7 +530,9 @@ camerabin_setup_src_elements (GstCameraBin * camera) g_object_set (camera->src_zoom_scale, "method", CAMERABIN_DEFAULT_ZOOM_METHOD, NULL); + /* we create new caps in any way and they take ownership of the structure st */ gst_caps_replace (&camera->view_finder_caps, new_caps); + gst_caps_unref (new_caps); /* Set caps for view finder mode */ gst_camerabin_set_capsfilter_caps (camera, camera->view_finder_caps); @@ -805,22 +806,27 @@ camerabin_destroy_elements (GstCameraBin * camera) /* Release request pads */ if (camera->pad_view_vid) { gst_element_release_request_pad (camera->view_in_sel, camera->pad_view_vid); + gst_object_unref (camera->pad_view_vid); camera->pad_view_vid = NULL; } if (camera->pad_src_vid) { gst_element_release_request_pad (camera->src_out_sel, camera->pad_src_vid); + gst_object_unref (camera->pad_src_vid); camera->pad_src_vid = NULL; } if (camera->pad_src_img) { gst_element_release_request_pad (camera->src_out_sel, camera->pad_src_img); + gst_object_unref (camera->pad_src_img); camera->pad_src_img = NULL; } if (camera->pad_view_src) { gst_element_release_request_pad (camera->view_in_sel, camera->pad_view_src); + /* don't unref, we have not requested it */ camera->pad_view_src = NULL; } if (camera->pad_src_view) { gst_element_release_request_pad (camera->src_out_sel, camera->pad_src_view); + gst_object_unref (camera->pad_src_view); camera->pad_src_view = NULL; } @@ -856,6 +862,8 @@ camerabin_destroy_elements (GstCameraBin * camera) static void camerabin_dispose_elements (GstCameraBin * camera) { + GST_INFO ("cleaning"); + if (camera->capture_mutex) { g_mutex_free (camera->capture_mutex); camera->capture_mutex = NULL; @@ -878,24 +886,18 @@ camerabin_dispose_elements (GstCameraBin * camera) camera->user_vid_src = NULL; } + /* Free caps */ if (camera->image_capture_caps) { - gst_caps_unref (camera->image_capture_caps); - camera->image_capture_caps = NULL; + gst_caps_replace (&camera->image_capture_caps, NULL); } - if (camera->view_finder_caps) { - gst_caps_unref (camera->view_finder_caps); - camera->view_finder_caps = NULL; + gst_caps_replace (&camera->view_finder_caps, NULL); } - if (camera->allowed_caps) { - gst_caps_unref (camera->allowed_caps); - camera->allowed_caps = NULL; + gst_caps_replace (&camera->allowed_caps, NULL); } - if (camera->preview_caps) { - gst_caps_unref (camera->preview_caps); - camera->preview_caps = NULL; + gst_caps_replace (&camera->preview_caps, NULL); } if (camera->event_tags) { @@ -1685,6 +1687,7 @@ gst_camerabin_send_preview (GstCameraBin * camera, GstBuffer * buffer) if (prev) { s = gst_structure_new (PREVIEW_MESSAGE_NAME, "buffer", GST_TYPE_BUFFER, prev, NULL); + gst_buffer_unref (prev); msg = gst_message_new_element (GST_OBJECT (camera), s); @@ -2202,30 +2205,32 @@ gst_camerabin_update_aspect_filter (GstCameraBin * camera, GstCaps * new_caps) if (sink_pad) { sink_caps = gst_pad_get_caps (sink_pad); gst_object_unref (sink_pad); - if (sink_caps && !gst_caps_is_any (sink_caps)) { - GST_DEBUG_OBJECT (camera, "sink element caps %" GST_PTR_FORMAT, - sink_caps); - /* Get maximum resolution that view finder sink accepts */ - st = gst_caps_get_structure (sink_caps, 0); - if (gst_structure_has_field_typed (st, "width", GST_TYPE_INT_RANGE)) { - range = gst_structure_get_value (st, "width"); - sink_w = gst_value_get_int_range_max (range); - } - if (gst_structure_has_field_typed (st, "height", GST_TYPE_INT_RANGE)) { - range = gst_structure_get_value (st, "height"); - sink_h = gst_value_get_int_range_max (range); + if (sink_caps) { + if (!gst_caps_is_any (sink_caps)) { + GST_DEBUG_OBJECT (camera, "sink element caps %" GST_PTR_FORMAT, + sink_caps); + /* Get maximum resolution that view finder sink accepts */ + st = gst_caps_get_structure (sink_caps, 0); + if (gst_structure_has_field_typed (st, "width", GST_TYPE_INT_RANGE)) { + range = gst_structure_get_value (st, "width"); + sink_w = gst_value_get_int_range_max (range); + } + if (gst_structure_has_field_typed (st, "height", GST_TYPE_INT_RANGE)) { + range = gst_structure_get_value (st, "height"); + sink_h = gst_value_get_int_range_max (range); + } + GST_DEBUG_OBJECT (camera, "sink element accepts max %dx%d", sink_w, + sink_h); + + /* Get incoming frames' resolution */ + if (sink_h && sink_w) { + st = gst_caps_get_structure (new_caps, 0); + gst_structure_get_int (st, "width", &in_w); + gst_structure_get_int (st, "height", &in_h); + GST_DEBUG_OBJECT (camera, "new caps with %dx%d", in_w, in_h); + } } gst_caps_unref (sink_caps); - GST_DEBUG_OBJECT (camera, "sink element accepts max %dx%d", sink_w, - sink_h); - - /* Get incoming frames' resolution */ - if (sink_h && sink_w) { - st = gst_caps_get_structure (new_caps, 0); - gst_structure_get_int (st, "width", &in_w); - gst_structure_get_int (st, "height", &in_h); - GST_DEBUG_OBJECT (camera, "new caps with %dx%d", in_w, in_h); - } } } @@ -2251,13 +2256,14 @@ gst_camerabin_update_aspect_filter (GstCameraBin * camera, GstCaps * new_caps) G_TYPE_INT, target_h, NULL); } else { GST_DEBUG_OBJECT (camera, "no scaling"); - ar_caps = gst_caps_ref (new_caps); + ar_caps = new_caps; } GST_DEBUG_OBJECT (camera, "aspect ratio filter caps %" GST_PTR_FORMAT, ar_caps); g_object_set (G_OBJECT (camera->aspect_filter), "caps", ar_caps, NULL); - gst_caps_unref (ar_caps); + if (ar_caps != new_caps) + gst_caps_unref (ar_caps); #endif } @@ -2742,7 +2748,6 @@ gst_camerabin_dispose (GObject * object) gst_camerabin_preview_destroy_pipeline (camera); camerabin_destroy_elements (camera); - camerabin_dispose_elements (camera); G_OBJECT_CLASS (parent_class)->dispose (object); @@ -2860,7 +2865,9 @@ gst_camerabin_set_property (GObject * object, guint prop_id, if (camera->view_finder_caps) { gst_caps_unref (camera->view_finder_caps); } - camera->view_finder_caps = gst_caps_copy (gst_value_get_caps (value)); + /* just ref, we don't modify it inplace */ + camera->view_finder_caps = + gst_caps_ref ((GstCaps *) gst_value_get_caps (value)); GST_OBJECT_UNLOCK (camera); if (GST_STATE (camera) != GST_STATE_NULL) { gst_camerabin_set_capsfilter_caps (camera, camera->view_finder_caps); @@ -3139,6 +3146,8 @@ gst_camerabin_user_start (GstCameraBin * camera) if (camera->capturing) { GST_WARNING_OBJECT (camera, "capturing \"%s\" ongoing, set new filename", camera->filename->str); + /* FIXME: we need to send something more to the app, so that it does not for + * for img-done */ g_mutex_unlock (camera->capture_mutex); return; } |