summaryrefslogtreecommitdiffstats
path: root/gst/camerabin
diff options
context:
space:
mode:
authorDave Robillard <dave@drobilla.net>2009-08-09 00:14:42 -0400
committerDave Robillard <dave@drobilla.net>2009-08-09 00:14:42 -0400
commitaf3f7e7f20eaf961f4384940ec6ad987bb0afbb6 (patch)
treec42a7ad4f2dea47dd645a729a6ee0399bd80cfb1 /gst/camerabin
parentadadf06b0a9e26005ba9363aa0049dc0b740c94d (diff)
parentdd5afbf0c6557ad89994cbfd91e4117e8503b81a (diff)
downloadgst-plugins-bad-af3f7e7f20eaf961f4384940ec6ad987bb0afbb6.tar.gz
gst-plugins-bad-af3f7e7f20eaf961f4384940ec6ad987bb0afbb6.tar.bz2
gst-plugins-bad-af3f7e7f20eaf961f4384940ec6ad987bb0afbb6.zip
Merge branch 'fdo' into lv2
Diffstat (limited to 'gst/camerabin')
-rw-r--r--gst/camerabin/camerabinvideo.c48
-rw-r--r--gst/camerabin/camerabinvideo.h6
-rw-r--r--gst/camerabin/gstcamerabin.c19
-rw-r--r--gst/camerabin/gstcamerabinphotography.c14
4 files changed, 64 insertions, 23 deletions
diff --git a/gst/camerabin/camerabinvideo.c b/gst/camerabin/camerabinvideo.c
index bc915243..f9c9d875 100644
--- a/gst/camerabin/camerabinvideo.c
+++ b/gst/camerabin/camerabinvideo.c
@@ -186,6 +186,11 @@ gst_camerabin_video_init (GstCameraBinVideo * vid,
vid->mute = ARG_DEFAULT_MUTE;
+ vid->aud_src_probe_id = 0;
+ vid->vid_src_probe_id = 0;
+ vid->vid_tee_probe_id = 0;
+ vid->vid_sink_probe_id = 0;
+
/* Create src and sink ghost pads */
vid->sinkpad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (vid), vid->sinkpad);
@@ -194,7 +199,7 @@ gst_camerabin_video_init (GstCameraBinVideo * vid,
gst_element_add_pad (GST_ELEMENT (vid), vid->srcpad);
/* Add probe for handling eos when stopping recording */
- gst_pad_add_event_probe (vid->sinkpad,
+ vid->vid_sink_probe_id = gst_pad_add_event_probe (vid->sinkpad,
G_CALLBACK (camerabin_video_sink_have_event), vid);
}
@@ -206,6 +211,11 @@ gst_camerabin_video_dispose (GstCameraBinVideo * vid)
g_string_free (vid->filename, TRUE);
vid->filename = NULL;
+ if (vid->vid_sink_probe_id) {
+ gst_pad_remove_event_probe (vid->sinkpad, vid->vid_sink_probe_id);
+ vid->vid_sink_probe_id = 0;
+ }
+
if (vid->user_post) {
gst_object_unref (vid->user_post);
vid->user_post = NULL;
@@ -439,6 +449,10 @@ camerabin_video_pad_aud_src_have_buffer (GstPad * pad, GstBuffer * buffer,
{
GstCameraBinVideo *vid = (GstCameraBinVideo *) u_data;
+ GST_LOG ("buffer in with size %d duration %" G_GINT64_FORMAT " ts %"
+ GST_TIME_FORMAT, GST_BUFFER_SIZE (buffer), GST_BUFFER_DURATION (buffer),
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+
if (vid->calculate_adjust_ts_aud) {
GstEvent *event;
GstPad *peerpad = NULL;
@@ -561,7 +575,7 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
}
/* Add probe for rewriting video timestamps */
- gst_pad_add_buffer_probe (vid->tee_video_srcpad,
+ vid->vid_tee_probe_id = gst_pad_add_buffer_probe (vid->tee_video_srcpad,
G_CALLBACK (camerabin_video_pad_tee_src0_have_buffer), vid);
#ifdef USE_TIMEOVERLAY
@@ -666,12 +680,12 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
vid_srcpad = gst_element_get_static_pad (queue, "src");
gst_ghost_pad_set_target (GST_GHOST_PAD (vid->srcpad), vid_srcpad);
/* Never let video bin eos events reach view finder */
- gst_pad_add_event_probe (vid_srcpad,
+ vid->vid_src_probe_id = 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,
+ vid->aud_src_probe_id = gst_pad_add_buffer_probe (pad,
G_CALLBACK (camerabin_video_pad_aud_src_have_buffer), vid);
gst_object_unref (pad);
@@ -700,6 +714,32 @@ gst_camerabin_video_destroy_elements (GstCameraBinVideo * vid)
{
GST_DEBUG ("destroying video elements");
+ /* Remove buffer probe from audio src pad */
+ if (vid->aud_src_probe_id) {
+ GstPad *pad = gst_element_get_static_pad (vid->aud_src, "src");
+ if (pad) {
+ gst_pad_remove_buffer_probe (pad, vid->aud_src_probe_id);
+ gst_object_unref (pad);
+ }
+ vid->aud_src_probe_id = 0;
+ }
+
+ /* Remove EOS event probe from videobin srcpad (queue's srcpad) */
+ if (vid->vid_src_probe_id) {
+ GstPad *pad = gst_ghost_pad_get_target (GST_GHOST_PAD (vid->srcpad));
+ if (pad) {
+ gst_pad_remove_event_probe (pad, vid->vid_src_probe_id);
+ gst_object_unref (pad);
+ }
+ vid->vid_src_probe_id = 0;
+ }
+
+ /* Remove buffer probe from video tee srcpad */
+ if (vid->vid_tee_probe_id) {
+ gst_pad_remove_buffer_probe (vid->tee_video_srcpad, vid->vid_tee_probe_id);
+ vid->vid_tee_probe_id = 0;
+ }
+
/* Release tee request pads */
if (vid->tee_video_srcpad) {
gst_element_release_request_pad (vid->tee, vid->tee_video_srcpad);
diff --git a/gst/camerabin/camerabinvideo.h b/gst/camerabin/camerabinvideo.h
index dd094d52..c318e9c3 100644
--- a/gst/camerabin/camerabinvideo.h
+++ b/gst/camerabin/camerabinvideo.h
@@ -82,6 +82,12 @@ struct _GstCameraBinVideo
GstEvent *pending_eos;
+ /* Probe IDs */
+ gulong aud_src_probe_id;
+ gulong vid_src_probe_id;
+ gulong vid_tee_probe_id;
+ gulong vid_sink_probe_id;
+
gboolean mute;
};
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
index 22a33477..c3010ab8 100644
--- a/gst/camerabin/gstcamerabin.c
+++ b/gst/camerabin/gstcamerabin.c
@@ -1095,7 +1095,6 @@ gst_camerabin_get_allowed_input_caps (GstCameraBin * camera)
GstCaps *caps = NULL;
GstPad *pad = NULL, *peer_pad = NULL;
GstState state;
- gboolean temp_videosrc_pause = FALSE;
GstElement *videosrc;
g_return_val_if_fail (camera != NULL, NULL);
@@ -1121,27 +1120,25 @@ gst_camerabin_get_allowed_input_caps (GstCameraBin * camera)
state = GST_STATE (videosrc);
- /* Make this function work also in READY and NULL state */
- if (state == GST_STATE_READY || state == GST_STATE_NULL) {
- GST_DEBUG_OBJECT (camera, "setting videosrc to paused temporarily");
- temp_videosrc_pause = TRUE;
+ /* Make this function work also in NULL state */
+ if (state == GST_STATE_NULL) {
+ GST_DEBUG_OBJECT (camera, "setting videosrc to ready temporarily");
peer_pad = gst_pad_get_peer (pad);
if (peer_pad) {
gst_pad_unlink (pad, peer_pad);
}
- /* Set videosrc to PAUSED to open video device */
+ /* Set videosrc to READY to open video device */
gst_element_set_locked_state (videosrc, TRUE);
- gst_element_set_state (videosrc, GST_STATE_PAUSED);
+ gst_element_set_state (videosrc, GST_STATE_READY);
}
camera->allowed_caps = gst_pad_get_caps (pad);
/* Restore state and re-link if necessary */
- if (temp_videosrc_pause) {
+ if (state == GST_STATE_NULL) {
GST_DEBUG_OBJECT (camera, "restoring videosrc state %d", state);
/* Reset videosrc to NULL state, some drivers seem to need this */
gst_element_set_state (videosrc, GST_STATE_NULL);
- gst_element_set_state (videosrc, state);
if (peer_pad) {
gst_pad_link (pad, peer_pad);
gst_object_unref (peer_pad);
@@ -1597,13 +1594,11 @@ gst_camerabin_start_video_recording (GstCameraBin * camera)
gst_camerabin_rewrite_tags (camera);
/* Pause the pipeline in order to distribute new clock in paused_to_playing */
- /* audio src timestamps will be 0 without state change to READY. ??? */
- gst_element_set_state (GST_ELEMENT (camera), GST_STATE_READY);
- gst_element_set_locked_state (camera->vidbin, FALSE);
state_ret = gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PAUSED);
if (state_ret != GST_STATE_CHANGE_FAILURE) {
g_mutex_lock (camera->capture_mutex);
+ gst_element_set_locked_state (camera->vidbin, FALSE);
g_object_set (G_OBJECT (camera->src_out_sel), "resend-latest", FALSE,
"active-pad", camera->pad_src_vid, NULL);
diff --git a/gst/camerabin/gstcamerabinphotography.c b/gst/camerabin/gstcamerabinphotography.c
index cb17abca..c5689149 100644
--- a/gst/camerabin/gstcamerabinphotography.c
+++ b/gst/camerabin/gstcamerabinphotography.c
@@ -42,7 +42,7 @@ gst_camerabin_set_ev_compensation (GstPhotography * photo,
gfloat ev_compensation)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
@@ -82,7 +82,7 @@ static gboolean
gst_camerabin_set_iso_speed (GstPhotography * photo, guint iso_speed)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
@@ -120,7 +120,7 @@ gst_camerabin_set_white_balance_mode (GstPhotography * photo,
GstWhiteBalanceMode white_balance_mode)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
@@ -161,7 +161,7 @@ gst_camerabin_set_colour_tone_mode (GstPhotography * photo,
GstColourToneMode colour_tone_mode)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
@@ -201,7 +201,7 @@ static gboolean
gst_camerabin_set_flash_mode (GstPhotography * photo, GstFlashMode flash_mode)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
@@ -269,7 +269,7 @@ static gboolean
gst_camerabin_set_scene_mode (GstPhotography * photo, GstSceneMode scene_mode)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
@@ -345,7 +345,7 @@ static gboolean
gst_camerabin_set_config (GstPhotography * photo, GstPhotoSettings * config)
{
GstCameraBin *camera;
- gboolean ret = FALSE;
+ gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
camera = GST_CAMERABIN (photo);