summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorTeemu Katajisto <ext-teemu.katajisto@nokia.com>2009-11-27 14:38:04 +0200
committerStefan Kost <ensonic@users.sf.net>2009-11-27 15:10:57 +0200
commit62ddc736235e063b4c675231dc16376a2e5c70c1 (patch)
treed04682871fb6d8e8e891e2a7db522d8b7926d756 /gst
parent2c158ffad98e958104062cc9926bb4f949aee0e5 (diff)
camerabin: photography interface properties. Fixes #573370 (partially)
Added GObject properties to photography interface and implemented them in camerabin. Changed zooming to check if video-source has zoom property.
Diffstat (limited to 'gst')
-rw-r--r--gst/camerabin/gstcamerabin-enum.h34
-rw-r--r--gst/camerabin/gstcamerabin.c91
-rw-r--r--gst/camerabin/gstcamerabinphotography.c274
-rw-r--r--gst/camerabin/gstcamerabinphotography.h12
4 files changed, 337 insertions, 74 deletions
diff --git a/gst/camerabin/gstcamerabin-enum.h b/gst/camerabin/gstcamerabin-enum.h
index 8bbd2645f..379420162 100644
--- a/gst/camerabin/gstcamerabin-enum.h
+++ b/gst/camerabin/gstcamerabin-enum.h
@@ -24,6 +24,40 @@
#include <gst/gst.h>
G_BEGIN_DECLS
+
+enum
+{
+ ARG_0,
+ ARG_FILENAME,
+ ARG_MODE,
+ ARG_FLAGS,
+ ARG_MUTE,
+ ARG_ZOOM,
+ ARG_IMAGE_POST,
+ ARG_IMAGE_ENC,
+ ARG_VIDEO_POST,
+ ARG_VIDEO_ENC,
+ ARG_AUDIO_ENC,
+ ARG_VIDEO_MUX,
+ ARG_VF_SINK,
+ ARG_VIDEO_SRC,
+ ARG_AUDIO_SRC,
+ ARG_INPUT_CAPS,
+ ARG_FILTER_CAPS,
+ ARG_PREVIEW_CAPS,
+ ARG_WB_MODE,
+ ARG_COLOUR_TONE,
+ ARG_SCENE_MODE,
+ ARG_FLASH_MODE,
+ ARG_FOCUS_STATUS,
+ ARG_CAPABILITIES,
+ ARG_SHAKE_RISK,
+ ARG_EV_COMP,
+ ARG_ISO_SPEED,
+ ARG_APERTURE,
+ ARG_EXPOSURE
+};
+
/**
* GstCameraBinFlags:
* @GST_CAMERABIN_FLAG_SOURCE_RESIZE: enable video crop and scale
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
index 4982b06b2..31bba3db6 100644
--- a/gst/camerabin/gstcamerabin.c
+++ b/gst/camerabin/gstcamerabin.c
@@ -185,27 +185,6 @@ enum
LAST_SIGNAL
};
-enum
-{
- ARG_0,
- ARG_FILENAME,
- ARG_MODE,
- ARG_FLAGS,
- ARG_MUTE,
- ARG_ZOOM,
- ARG_IMAGE_POST,
- ARG_IMAGE_ENC,
- ARG_VIDEO_POST,
- ARG_VIDEO_ENC,
- ARG_AUDIO_ENC,
- ARG_VIDEO_MUX,
- ARG_VF_SINK,
- ARG_VIDEO_SRC,
- ARG_AUDIO_SRC,
- ARG_INPUT_CAPS,
- ARG_FILTER_CAPS,
- ARG_PREVIEW_CAPS
-};
/*
* defines and static global vars
@@ -339,6 +318,9 @@ static void gst_camerabin_set_property (GObject * object, guint prop_id,
static void gst_camerabin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+static void gst_camerabin_override_photo_properties (GObjectClass *
+ gobject_class);
+
/*
* GstElement function declarations
*/
@@ -1030,29 +1012,19 @@ gst_camerabin_change_filename (GstCameraBin * camera, const gchar * name)
}
static gboolean
-gst_camerabin_set_photo_iface_zoom (GstCameraBin * camera, gint zoom)
+gst_camerabin_set_videosrc_zoom (GstCameraBin * camera, gint zoom)
{
- GstPhotography *photo = NULL;
- GstPhotoCaps pcaps = GST_PHOTOGRAPHY_CAPS_NONE;
gboolean ret = FALSE;
-
- if (GST_IS_ELEMENT (camera->src_vid_src) &&
- gst_element_implements_interface (camera->src_vid_src,
- GST_TYPE_PHOTOGRAPHY)) {
- /* Try setting zoom using photography interface */
- photo = GST_PHOTOGRAPHY (camera->src_vid_src);
- if (photo) {
- pcaps = gst_photography_get_capabilities (photo);
- }
- if (pcaps & GST_PHOTOGRAPHY_CAPS_ZOOM) {
- GST_DEBUG_OBJECT (camera, "setting zoom %d using photography interface",
- zoom);
- ret = gst_photography_set_zoom (photo, (gfloat) zoom / 100.0);
- }
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (camera->src_vid_src),
+ "zoom")) {
+ g_object_set (G_OBJECT (camera->src_vid_src), "zoom",
+ (gfloat) zoom / 100, NULL);
+ ret = TRUE;
}
return ret;
}
+
static gboolean
gst_camerabin_set_element_zoom (GstCameraBin * camera, gint zoom)
{
@@ -1110,8 +1082,8 @@ gst_camerabin_setup_zoom (GstCameraBin * camera)
GST_INFO_OBJECT (camera, "setting zoom %d", zoom);
- if (gst_camerabin_set_photo_iface_zoom (camera, zoom)) {
- GST_INFO_OBJECT (camera, "zoom set using photography interface");
+ if (gst_camerabin_set_videosrc_zoom (camera, zoom)) {
+ GST_INFO_OBJECT (camera, "zoom set using videosrc");
} else if (gst_camerabin_set_element_zoom (camera, zoom)) {
GST_INFO_OBJECT (camera, "zoom set using gst elements");
} else {
@@ -2721,6 +2693,8 @@ gst_camerabin_class_init (GstCameraBinClass * klass)
__gst_camerabin_marshal_BOOLEAN__STRING, G_TYPE_BOOLEAN, 1,
G_TYPE_STRING);
+ gst_camerabin_override_photo_properties (gobject_class);
+
klass->user_start = gst_camerabin_user_start;
klass->user_stop = gst_camerabin_user_stop;
klass->user_pause = gst_camerabin_user_pause;
@@ -2857,11 +2831,45 @@ gst_camerabin_finalize (GObject * object)
}
static void
+gst_camerabin_override_photo_properties (GObjectClass * gobject_class)
+{
+ g_object_class_override_property (gobject_class, ARG_WB_MODE,
+ GST_PHOTOGRAPHY_PROP_WB_MODE);
+
+ g_object_class_override_property (gobject_class, ARG_COLOUR_TONE,
+ GST_PHOTOGRAPHY_PROP_COLOUR_TONE);
+
+ g_object_class_override_property (gobject_class, ARG_SCENE_MODE,
+ GST_PHOTOGRAPHY_PROP_SCENE_MODE);
+
+ g_object_class_override_property (gobject_class, ARG_FLASH_MODE,
+ GST_PHOTOGRAPHY_PROP_FLASH_MODE);
+
+ g_object_class_override_property (gobject_class, ARG_CAPABILITIES,
+ GST_PHOTOGRAPHY_PROP_CAPABILITIES);
+
+ g_object_class_override_property (gobject_class, ARG_EV_COMP,
+ GST_PHOTOGRAPHY_PROP_EV_COMP);
+
+ g_object_class_override_property (gobject_class, ARG_ISO_SPEED,
+ GST_PHOTOGRAPHY_PROP_ISO_SPEED);
+
+ g_object_class_override_property (gobject_class, ARG_APERTURE,
+ GST_PHOTOGRAPHY_PROP_APERTURE);
+
+ g_object_class_override_property (gobject_class, ARG_EXPOSURE,
+ GST_PHOTOGRAPHY_PROP_EXPOSURE);
+}
+
+static void
gst_camerabin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstCameraBin *camera = GST_CAMERABIN (object);
+ if (gst_camerabin_photography_set_property (camera, prop_id, value))
+ return;
+
switch (prop_id) {
case ARG_MUTE:
gst_camerabin_video_set_mute (GST_CAMERABIN_VIDEO (camera->vidbin),
@@ -3015,6 +3023,9 @@ gst_camerabin_get_property (GObject * object, guint prop_id,
{
GstCameraBin *camera = GST_CAMERABIN (object);
+ if (gst_camerabin_photography_get_property (camera, prop_id, value))
+ return;
+
switch (prop_id) {
case ARG_FILENAME:
g_value_set_string (value, camera->filename->str);
diff --git a/gst/camerabin/gstcamerabinphotography.c b/gst/camerabin/gstcamerabinphotography.c
index 9dcf628f5..a5940f483 100644
--- a/gst/camerabin/gstcamerabinphotography.c
+++ b/gst/camerabin/gstcamerabinphotography.c
@@ -27,6 +27,7 @@
#include <string.h>
#include "gstcamerabinphotography.h"
#include "gstcamerabin.h"
+#include "gstcamerabin-enum.h"
GST_DEBUG_CATEGORY_STATIC (camerabinphoto_debug);
#define GST_CAT_DEFAULT camerabinphoto_debug
@@ -235,37 +236,6 @@ gst_camerabin_get_flash_mode (GstPhotography * photo, GstFlashMode * flash_mode)
}
static gboolean
-gst_camerabin_set_zoom (GstPhotography * photo, gfloat zoom)
-{
- GstCameraBin *camera;
-
- g_return_val_if_fail (photo != NULL, FALSE);
-
- camera = GST_CAMERABIN (photo);
-
- /* camerabin can zoom by itself */
- g_object_set (camera, "zoom", (gint) (CLAMP (zoom, 1.0, 10.0) * 100), NULL);
-
- return TRUE;
-}
-
-static gboolean
-gst_camerabin_get_zoom (GstPhotography * photo, gfloat * zoom)
-{
- GstCameraBin *camera;
- gint cb_zoom = 0;
-
- g_return_val_if_fail (photo != NULL, FALSE);
-
- camera = GST_CAMERABIN (photo);
-
- g_object_get (camera, "zoom", &cb_zoom, NULL);
- *zoom = (gfloat) (cb_zoom / 100.0);
-
- return TRUE;
-}
-
-static gboolean
gst_camerabin_set_scene_mode (GstPhotography * photo, GstSceneMode scene_mode)
{
GstCameraBin *camera;
@@ -346,6 +316,70 @@ gst_camerabin_set_autofocus (GstPhotography * photo, gboolean on)
}
static gboolean
+gst_camerabin_get_aperture (GstPhotography * photo, guint * aperture)
+{
+ GstCameraBin *camera;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (photo != NULL, FALSE);
+
+ camera = GST_CAMERABIN (photo);
+
+ if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) {
+ ret = gst_photography_get_aperture (GST_PHOTOGRAPHY (camera->src_vid_src),
+ aperture);
+ }
+ return ret;
+}
+
+static void
+gst_camerabin_set_aperture (GstPhotography * photo, guint aperture)
+{
+ GstCameraBin *camera;
+
+ g_return_if_fail (photo != NULL);
+
+ camera = GST_CAMERABIN (photo);
+
+ if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) {
+ gst_photography_set_aperture (GST_PHOTOGRAPHY (camera->src_vid_src),
+ aperture);
+ }
+}
+
+static gboolean
+gst_camerabin_get_exposure (GstPhotography * photo, guint32 * exposure)
+{
+ GstCameraBin *camera;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (photo != NULL, FALSE);
+
+ camera = GST_CAMERABIN (photo);
+
+ if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) {
+ ret = gst_photography_get_exposure (GST_PHOTOGRAPHY (camera->src_vid_src),
+ exposure);
+ }
+ return ret;
+}
+
+static void
+gst_camerabin_set_exposure (GstPhotography * photo, guint32 exposure)
+{
+ GstCameraBin *camera;
+
+ g_return_if_fail (photo != NULL);
+
+ camera = GST_CAMERABIN (photo);
+
+ if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) {
+ gst_photography_set_exposure (GST_PHOTOGRAPHY (camera->src_vid_src),
+ exposure);
+ }
+}
+
+static gboolean
gst_camerabin_set_config (GstPhotography * photo, GstPhotoSettings * config)
{
GstCameraBin *camera;
@@ -409,6 +443,181 @@ gst_camerabin_handle_scene_mode (GstCameraBin * camera, GstSceneMode scene_mode)
}
}
+gboolean
+gst_camerabin_photography_get_property (GstCameraBin * camera, guint prop_id,
+ GValue * value)
+{
+ gboolean ret = FALSE;
+
+ GST_DEBUG_OBJECT (camera, "Photointerface property: %d", prop_id);
+
+ switch (prop_id) {
+ case ARG_WB_MODE:
+ {
+ GstWhiteBalanceMode wb_mode;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_WB_MODE ====");
+ if (gst_camerabin_get_white_balance_mode ((GstPhotography *) camera,
+ &wb_mode)) {
+ g_value_set_enum (value, wb_mode);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_COLOUR_TONE:
+ {
+ GstColourToneMode tone;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_COLOUR_TONE ====");
+ if (gst_camerabin_get_colour_tone_mode ((GstPhotography *) camera, &tone)) {
+ g_value_set_enum (value, tone);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_SCENE_MODE:
+ {
+ GstSceneMode scene;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_SCENE_MODE ====");
+ if (gst_camerabin_get_scene_mode ((GstPhotography *) camera, &scene)) {
+ g_value_set_enum (value, scene);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_FLASH_MODE:
+ {
+ GstFlashMode flash;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_FLASH_MODE ====");
+ if (gst_camerabin_get_flash_mode ((GstPhotography *) camera, &flash)) {
+ g_value_set_enum (value, flash);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_CAPABILITIES:
+ {
+ gulong capabilities;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_CAPABILITIES ====");
+ capabilities =
+ (gulong) gst_camerabin_get_capabilities ((GstPhotography *) camera);
+ g_value_set_ulong (value, capabilities);
+ ret = TRUE;
+ break;
+ }
+ case ARG_EV_COMP:
+ {
+ gfloat ev_comp;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_EV_COMP ====");
+ if (gst_camerabin_get_ev_compensation ((GstPhotography *) camera,
+ &ev_comp)) {
+ g_value_set_float (value, ev_comp);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_ISO_SPEED:
+ {
+ guint iso_speed;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_ISO_SPEED ====");
+ if (gst_camerabin_get_iso_speed ((GstPhotography *) camera, &iso_speed)) {
+ g_value_set_uint (value, iso_speed);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_APERTURE:
+ {
+ guint aperture;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_APERTURE ====");
+ if (gst_camerabin_get_aperture ((GstPhotography *) camera, &aperture)) {
+ g_value_set_uint (value, aperture);
+ }
+ ret = TRUE;
+ break;
+ }
+ case ARG_EXPOSURE:
+ {
+ guint32 exposure;
+ GST_DEBUG_OBJECT (camera, "==== GETTING PROP_EXPOSURE ====");
+ if (gst_camerabin_get_exposure ((GstPhotography *) camera, &exposure)) {
+ g_value_set_uint (value, exposure);
+ }
+ ret = TRUE;
+ break;
+ }
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+
+/*
+ *
+ */
+gboolean
+gst_camerabin_photography_set_property (GstCameraBin * camera, guint prop_id,
+ const GValue * value)
+{
+ gboolean ret = FALSE;
+
+ switch (prop_id) {
+ case ARG_WB_MODE:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_WB_MODE ====");
+ gst_camerabin_set_white_balance_mode ((GstPhotography *) camera,
+ g_value_get_enum (value));
+ ret = TRUE;
+ break;
+ case ARG_COLOUR_TONE:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_COLOUR_TONE ====");
+ gst_camerabin_set_colour_tone_mode ((GstPhotography *) camera,
+ g_value_get_enum (value));
+ ret = TRUE;
+ break;
+ case ARG_SCENE_MODE:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_SCENE_MODE ====");
+ gst_camerabin_set_scene_mode ((GstPhotography *) camera,
+ g_value_get_enum (value));
+ ret = TRUE;
+ break;
+ case ARG_FLASH_MODE:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_FLASH_MODE ====");
+ gst_camerabin_set_flash_mode ((GstPhotography *) camera,
+ g_value_get_enum (value));
+ ret = TRUE;
+ break;
+ case ARG_EV_COMP:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_EV_COMP ====");
+ gst_camerabin_set_ev_compensation ((GstPhotography *) camera,
+ g_value_get_float (value));
+ ret = TRUE;
+ break;
+ case ARG_ISO_SPEED:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_ISO_SPEED ====");
+ gst_camerabin_set_iso_speed ((GstPhotography *) camera,
+ g_value_get_uint (value));
+ ret = TRUE;
+ break;
+ case ARG_APERTURE:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_APERTURE ====");
+ gst_camerabin_set_aperture ((GstPhotography *) camera,
+ g_value_get_uint (value));
+ ret = TRUE;
+ break;
+ case ARG_EXPOSURE:
+ GST_DEBUG_OBJECT (camera, "==== SETTING PROP_EXPOSURE ====");
+ gst_camerabin_set_exposure ((GstPhotography *) camera,
+ g_value_get_uint (value));
+ ret = TRUE;
+ break;
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+
void
gst_camerabin_photography_init (GstPhotographyInterface * iface)
{
@@ -435,9 +644,6 @@ gst_camerabin_photography_init (GstPhotographyInterface * iface)
iface->set_flash_mode = gst_camerabin_set_flash_mode;
iface->get_flash_mode = gst_camerabin_get_flash_mode;
- iface->set_zoom = gst_camerabin_set_zoom;
- iface->get_zoom = gst_camerabin_get_zoom;
-
iface->get_capabilities = gst_camerabin_get_capabilities;
iface->set_autofocus = gst_camerabin_set_autofocus;
diff --git a/gst/camerabin/gstcamerabinphotography.h b/gst/camerabin/gstcamerabinphotography.h
index 721efabf4..94083b1fc 100644
--- a/gst/camerabin/gstcamerabinphotography.h
+++ b/gst/camerabin/gstcamerabinphotography.h
@@ -25,6 +25,18 @@
#include <gst/interfaces/photography.h>
+#include "gstcamerabin.h"
+
+gboolean
+gst_camerabin_photography_set_property (GstCameraBin * camerabin,
+ guint prop_id,
+ const GValue * value);
+
+gboolean
+gst_camerabin_photography_get_property (GstCameraBin * camerabin,
+ guint prop_id,
+ GValue * value);
+
void gst_camerabin_photography_init (GstPhotographyInterface * iface);
#endif /* #ifndef __GST_CAMERABIN_PHOTOGRAPHY_H__ */