mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
camerabin2: Cleanup capturing flag
Cleanup capturing flag when the source switches back to the viewfinder mode
This commit is contained in:
parent
9df40915d6
commit
b4d73cb9a8
2 changed files with 27 additions and 4 deletions
|
@ -122,12 +122,12 @@ gst_camera_bin_start_capture (GstCameraBin * camerabin)
|
||||||
static void
|
static void
|
||||||
gst_camera_bin_stop_capture (GstCameraBin * camerabin)
|
gst_camera_bin_stop_capture (GstCameraBin * camerabin)
|
||||||
{
|
{
|
||||||
g_mutex_lock (camerabin->capture_mutex);
|
/* TODO do we need a lock here? it is just an if */
|
||||||
if (camerabin->capturing) {
|
if (camerabin->capturing) {
|
||||||
|
/* Capturing is cleaned on the notify function because it works
|
||||||
|
* both for images and videos */
|
||||||
g_object_set (camerabin->src, "mode", MODE_PREVIEW, NULL);
|
g_object_set (camerabin->src, "mode", MODE_PREVIEW, NULL);
|
||||||
camerabin->capturing = FALSE;
|
|
||||||
}
|
}
|
||||||
g_mutex_unlock (camerabin->capture_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -144,7 +144,10 @@ gst_camera_bin_dispose (GObject * object)
|
||||||
{
|
{
|
||||||
GstCameraBin *camerabin = GST_CAMERA_BIN_CAST (object);
|
GstCameraBin *camerabin = GST_CAMERA_BIN_CAST (object);
|
||||||
|
|
||||||
gst_object_unref (camerabin->src);
|
if (camerabin->src_mode_notify_id)
|
||||||
|
g_signal_handler_disconnect (camerabin->src, camerabin->src_mode_notify_id);
|
||||||
|
if (camerabin->src)
|
||||||
|
gst_object_unref (camerabin->src);
|
||||||
|
|
||||||
g_mutex_free (camerabin->capture_mutex);
|
g_mutex_free (camerabin->capture_mutex);
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
|
@ -230,6 +233,23 @@ gst_camera_bin_init (GstCameraBin * camerabin)
|
||||||
camerabin->mode = MODE_IMAGE;
|
camerabin->mode = MODE_IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_camera_bin_src_notify_mode (GObject * src, GParamSpec * pspec,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GstCameraBin *camera = GST_CAMERA_BIN_CAST (data);
|
||||||
|
gint mode;
|
||||||
|
|
||||||
|
g_object_get (src, "mode", &mode, NULL);
|
||||||
|
|
||||||
|
if (mode == MODE_PREVIEW) {
|
||||||
|
g_mutex_lock (camera->capture_mutex);
|
||||||
|
g_assert (camera->capturing);
|
||||||
|
camera->capturing = FALSE;
|
||||||
|
g_mutex_unlock (camera->capture_mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_camera_bin_create_elements:
|
* gst_camera_bin_create_elements:
|
||||||
* @param camera: the #GstCameraBin
|
* @param camera: the #GstCameraBin
|
||||||
|
@ -265,6 +285,8 @@ gst_camera_bin_create_elements (GstCameraBin * camera)
|
||||||
vf = gst_element_factory_make ("viewfinderbin", "vf-bin");
|
vf = gst_element_factory_make ("viewfinderbin", "vf-bin");
|
||||||
|
|
||||||
camera->src = gst_object_ref (src);
|
camera->src = gst_object_ref (src);
|
||||||
|
camera->src_mode_notify_id = g_signal_connect (src, "notify::mode",
|
||||||
|
(GCallback) gst_camera_bin_src_notify_mode, camera);
|
||||||
|
|
||||||
vid_queue = gst_element_factory_make ("queue", "video-queue");
|
vid_queue = gst_element_factory_make ("queue", "video-queue");
|
||||||
img_queue = gst_element_factory_make ("queue", "image-queue");
|
img_queue = gst_element_factory_make ("queue", "image-queue");
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct _GstCameraBin
|
||||||
GstPipeline pipeline;
|
GstPipeline pipeline;
|
||||||
|
|
||||||
GstElement *src;
|
GstElement *src;
|
||||||
|
gulong src_mode_notify_id;
|
||||||
|
|
||||||
/* concurrency control */
|
/* concurrency control */
|
||||||
GMutex *capture_mutex;
|
GMutex *capture_mutex;
|
||||||
|
|
Loading…
Reference in a new issue