basecamerasrc: Add mode property

Move mode property from v4l2camerasrc to basecamerasrc, as all
camera sources should handle it.
This commit is contained in:
Thiago Santos 2010-12-04 10:15:34 -03:00
parent b11342d325
commit 87eddd54d5
4 changed files with 29 additions and 23 deletions

View file

@ -125,7 +125,11 @@ gst_base_camera_src_set_mode (GstBaseCameraSrc * self, GstCameraBinMode mode)
g_return_val_if_fail (bclass->set_mode, FALSE);
return bclass->set_mode (self, mode);
if (bclass->set_mode (self, mode)) {
self->mode = mode;
return TRUE;
}
return FALSE;
}
/**
@ -274,6 +278,10 @@ gst_base_camera_src_set_property (GObject * object,
GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (object);
switch (prop_id) {
case ARG_MODE:
gst_base_camera_src_set_mode (GST_BASE_CAMERA_SRC (self),
g_value_get_enum (value));
break;
case ARG_ZOOM:{
g_atomic_int_set (&self->zoom, g_value_get_int (value));
/* does not set it if in NULL, the src is not created yet */
@ -294,6 +302,9 @@ gst_base_camera_src_get_property (GObject * object,
GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (object);
switch (prop_id) {
case ARG_MODE:
g_value_set_enum (value, self->mode);
break;
case ARG_ZOOM:
g_value_set_int (value, g_atomic_int_get (&self->zoom));
break;
@ -414,6 +425,11 @@ gst_base_camera_src_class_init (GstBaseCameraSrcClass * klass)
gobject_class->get_property = gst_base_camera_src_get_property;
// g_object_class_install_property ....
g_object_class_install_property (gobject_class, ARG_MODE,
g_param_spec_enum ("mode", "Mode",
"The capture mode (still image capture or video recording)",
GST_TYPE_CAMERABIN_MODE, MODE_IMAGE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gstelement_class->change_state = gst_base_camera_src_change_state;
@ -437,6 +453,7 @@ gst_base_camera_src_init (GstBaseCameraSrc * self,
self->zoom = DEFAULT_ZOOM;
self->image_capture_width = 0;
self->image_capture_height = 0;
self->mode = MODE_IMAGE;
self->night_mode = FALSE;

View file

@ -41,7 +41,9 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_CAMERA_SRC))
#define GST_IS_BASE_CAMERA_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_CAMERA_SRC))
GType gst_base_camera_src_get_type (void);
#define GST_BASE_CAMERA_SRC_CAST(obj) \
((GstBaseCameraSrc *) (obj))
GType gst_base_camera_src_get_type (void);
typedef struct _GstBaseCameraSrc GstBaseCameraSrc;
typedef struct _GstBaseCameraSrcClass GstBaseCameraSrcClass;
@ -58,6 +60,8 @@ struct _GstBaseCameraSrc
GstPad *imgsrc;
GstPad *vidsrc;
gint mode;
/* XXX preview pads? */
/* Resolution of the buffers configured to camerabin */

View file

@ -83,10 +83,6 @@ gst_v4l2_camera_src_set_property (GObject * object,
GstV4l2CameraSrc *self = GST_V4L2_CAMERA_SRC (object);
switch (prop_id) {
case ARG_MODE:
gst_base_camera_src_set_mode (GST_BASE_CAMERA_SRC (self),
g_value_get_enum (value));
break;
case ARG_FILTER_CAPS:
GST_OBJECT_LOCK (self);
gst_caps_replace (&self->view_finder_caps,
@ -130,9 +126,6 @@ gst_v4l2_camera_src_get_property (GObject * object,
GstV4l2CameraSrc *self = GST_V4L2_CAMERA_SRC (object);
switch (prop_id) {
case ARG_MODE:
g_value_set_enum (value, self->mode);
break;
case ARG_READY_FOR_CAPTURE:
g_value_set_boolean (value, !self->capturing);
break;
@ -724,7 +717,6 @@ start_image_capture (GstV4l2CameraSrc * self)
static gboolean
gst_v4l2_camera_src_set_mode (GstBaseCameraSrc * bcamsrc, GstCameraBinMode mode)
{
GstV4l2CameraSrc *self = GST_V4L2_CAMERA_SRC (bcamsrc);
GstPhotography *photography = gst_base_camera_src_get_photography (bcamsrc);
if (photography) {
@ -733,8 +725,6 @@ gst_v4l2_camera_src_set_mode (GstBaseCameraSrc * bcamsrc, GstCameraBinMode mode)
g_object_set (G_OBJECT (photography), "capture-mode", mode, NULL);
}
}
self->mode = mode;
return TRUE;
}
@ -1047,6 +1037,7 @@ gst_v4l2_camera_src_finish_image_capture (GstBaseCameraSrc * bcamsrc)
static void
gst_v4l2_camera_src_start_capture (GstV4l2CameraSrc * src)
{
GstBaseCameraSrc *camerasrc = GST_BASE_CAMERA_SRC_CAST (src);
g_mutex_lock (src->capturing_mutex);
if (src->capturing) {
GST_WARNING_OBJECT (src, "Capturing already ongoing");
@ -1055,10 +1046,11 @@ gst_v4l2_camera_src_start_capture (GstV4l2CameraSrc * src)
}
src->capturing = TRUE;
if (src->mode == MODE_IMAGE) {
/* TODO should we use a macro? */
if (camerasrc->mode == MODE_IMAGE) {
src->image_capture_count = 1;
start_image_capture (src);
} else if (src->mode == MODE_VIDEO) {
} else if (camerasrc->mode == MODE_VIDEO) {
if (src->video_rec_status == GST_VIDEO_RECORDING_STATUS_DONE) {
src->video_rec_status = GST_VIDEO_RECORDING_STATUS_STARTING;
}
@ -1074,13 +1066,14 @@ gst_v4l2_camera_src_start_capture (GstV4l2CameraSrc * src)
static void
gst_v4l2_camera_src_stop_capture (GstV4l2CameraSrc * src)
{
GstBaseCameraSrc *camerasrc = GST_BASE_CAMERA_SRC_CAST (src);
g_mutex_lock (src->capturing_mutex);
if (!src->capturing) {
GST_DEBUG_OBJECT (src, "No ongoing capture");
g_mutex_unlock (src->capturing_mutex);
return;
}
if (src->mode == MODE_VIDEO) {
if (camerasrc->mode == MODE_VIDEO) {
if (src->video_rec_status == GST_VIDEO_RECORDING_STATUS_STARTING) {
GST_DEBUG_OBJECT (src, "Aborting, had not started recording");
src->video_rec_status = GST_VIDEO_RECORDING_STATUS_DONE;
@ -1125,11 +1118,6 @@ gst_v4l2_camera_src_class_init (GstV4l2CameraSrcClass * klass)
gobject_class->get_property = gst_v4l2_camera_src_get_property;
/* g_object_class_install_property .... */
g_object_class_install_property (gobject_class, ARG_MODE,
g_param_spec_enum ("mode", "Mode",
"The capture mode (still image capture or video recording)",
GST_TYPE_CAMERABIN_MODE, MODE_IMAGE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstV4l2CameraSrc:ready-for-capture:
@ -1181,7 +1169,6 @@ gst_v4l2_camera_src_init (GstV4l2CameraSrc * self,
GstV4l2CameraSrcClass * klass)
{
/* TODO where are variables reset? */
self->mode = MODE_IMAGE;
self->image_capture_count = 0;
self->video_rec_status = GST_VIDEO_RECORDING_STATUS_DONE;
self->capturing_mutex = g_mutex_new ();

View file

@ -57,8 +57,6 @@ struct _GstV4l2CameraSrc
{
GstBaseCameraSrc parent;
GstCameraBinMode mode;
gboolean capturing;
GMutex *capturing_mutex;