summaryrefslogtreecommitdiffstats
path: root/gst/camerabin
diff options
context:
space:
mode:
Diffstat (limited to 'gst/camerabin')
-rw-r--r--gst/camerabin/camerabinpreview.c15
-rw-r--r--gst/camerabin/camerabinvideo.c8
-rw-r--r--gst/camerabin/gstcamerabin.c87
3 files changed, 69 insertions, 41 deletions
diff --git a/gst/camerabin/camerabinpreview.c b/gst/camerabin/camerabinpreview.c
index b64b2143..9b12bbac 100644
--- a/gst/camerabin/camerabinpreview.c
+++ b/gst/camerabin/camerabinpreview.c
@@ -183,7 +183,7 @@ gst_camerabin_preview_convert (GstCameraBin * camera, GstBuffer * buf)
if (!src || !sink) {
GST_WARNING ("pipeline doesn't have src / sink elements");
- goto no_pipeline;
+ goto missing_elements;
}
g_object_set (src, "size", (gint64) GST_BUFFER_SIZE (buf),
@@ -234,6 +234,7 @@ gst_camerabin_preview_convert (GstCameraBin * camera, GstBuffer * buf)
g_return_val_if_reached (NULL);
}
}
+ gst_message_unref (msg);
} else {
g_warning ("Could not make preview image: %s", "timeout during conversion");
result = NULL;
@@ -245,9 +246,21 @@ gst_camerabin_preview_convert (GstCameraBin * camera, GstBuffer * buf)
GST_BUFFER_FLAGS (buf) = bflags;
+done:
+ if (src)
+ gst_object_unref (src);
+ if (sink)
+ gst_object_unref (sink);
+
return result;
/* ERRORS */
+missing_elements:
+ {
+ g_warning ("Could not make preview image: %s",
+ "missing elements in pipeline (unknown error)");
+ goto done;
+ }
no_pipeline:
{
g_warning ("Could not make preview image: %s",
diff --git a/gst/camerabin/camerabinvideo.c b/gst/camerabin/camerabinvideo.c
index 2569772a..4bbc5057 100644
--- a/gst/camerabin/camerabinvideo.c
+++ b/gst/camerabin/camerabinvideo.c
@@ -398,6 +398,7 @@ camerabin_video_pad_tee_src0_have_buffer (GstPad * pad, GstBuffer * buffer,
GstEvent *event;
GstObject *tee;
GstPad *sinkpad;
+
vid->adjust_ts_video = GST_BUFFER_TIMESTAMP (buffer) - vid->last_ts_video;
vid->calculate_adjust_ts_video = FALSE;
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
@@ -417,7 +418,6 @@ camerabin_video_pad_tee_src0_have_buffer (GstPad * pad, GstBuffer * buffer,
if (GST_BUFFER_DURATION_IS_VALID (buffer))
vid->last_ts_video += GST_BUFFER_DURATION (buffer);
-
GST_LOG ("buffer out with size %d ts %" GST_TIME_FORMAT,
GST_BUFFER_SIZE (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
return TRUE;
@@ -442,6 +442,7 @@ camerabin_video_pad_aud_src_have_buffer (GstPad * pad, GstBuffer * buffer,
if (vid->calculate_adjust_ts_aud) {
GstEvent *event;
GstPad *peerpad = NULL;
+
vid->adjust_ts_aud = GST_BUFFER_TIMESTAMP (buffer) - vid->last_ts_aud;
vid->calculate_adjust_ts_aud = FALSE;
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
@@ -459,6 +460,7 @@ camerabin_video_pad_aud_src_have_buffer (GstPad * pad, GstBuffer * buffer,
vid->last_ts_aud = GST_BUFFER_TIMESTAMP (buffer);
if (GST_BUFFER_DURATION_IS_VALID (buffer))
vid->last_ts_aud += GST_BUFFER_DURATION (buffer);
+
GST_LOG ("buffer out with size %d ts %" GST_TIME_FORMAT,
GST_BUFFER_SIZE (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
return TRUE;
@@ -549,6 +551,7 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
vid_sinkpad = gst_element_get_static_pad (vid->tee, "sink");
}
gst_ghost_pad_set_target (GST_GHOST_PAD (vid->sinkpad), vid_sinkpad);
+ gst_object_unref (vid_sinkpad);
/* Add queue element for video */
@@ -668,6 +671,7 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
/* Never let video bin eos events reach view finder */
gst_pad_add_event_probe (vid_srcpad,
G_CALLBACK (gst_camerabin_drop_eos_probe), vid);
+ gst_object_unref (vid_srcpad);
pad = gst_element_get_static_pad (vid->aud_src, "src");
gst_pad_add_buffer_probe (pad,
@@ -702,10 +706,12 @@ gst_camerabin_video_destroy_elements (GstCameraBinVideo * vid)
/* Release tee request pads */
if (vid->tee_video_srcpad) {
gst_element_release_request_pad (vid->tee, vid->tee_video_srcpad);
+ gst_object_unref (vid->tee_video_srcpad);
vid->tee_video_srcpad = NULL;
}
if (vid->tee_vf_srcpad) {
gst_element_release_request_pad (vid->tee, vid->tee_vf_srcpad);
+ gst_object_unref (vid->tee_vf_srcpad);
vid->tee_vf_srcpad = NULL;
}
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;
}