From: Teemu Katajisto Date: Tue, 31 Aug 2010 21:06:15 +0000 (-0300) Subject: camerabin: remove photography interface implementation from camerabin X-Git-Tag: 1.19.3~507^2~16475 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3582a4a595b0c51f98ebd9c04206afba8dfbacec;p=platform%2Fupstream%2Fgstreamer.git camerabin: remove photography interface implementation from camerabin Remove notify signal proxy for video-source. Application can use video-source directly from now on to get notified of property changes. Add monitoring scene-mode property change to select lowest possible framerate for video capture when night mode is selected. Fixes #616923 --- diff --git a/gst/camerabin/Makefile.am b/gst/camerabin/Makefile.am index 2316b84..d77dae4 100644 --- a/gst/camerabin/Makefile.am +++ b/gst/camerabin/Makefile.am @@ -20,7 +20,6 @@ libgstcamerabin_la_SOURCES = gstcamerabin.c \ camerabinvideo.c \ camerabingeneral.c \ camerabinpreview.c \ - gstcamerabinphotography.c \ gstcamerabin-enum.c nodist_libgstcamerabin_la_SOURCES = $(built_sources) @@ -43,5 +42,4 @@ noinst_HEADERS = gstcamerabin.h \ camerabindebug.h \ camerabingeneral.h \ camerabinpreview.h \ - gstcamerabinphotography.h \ gstcamerabin-enum.h diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 0e420ba..ff725bb 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -69,18 +69,6 @@ * * * - * Photography interface - * - * GstCameraBin implements #GstPhotography interface, which can be used to set - * and get different settings related to digital imaging. Since currently many - * of these settings require low-level support the photography interface support - * is dependent on video src element. In practice photography interface settings - * cannot be used successfully until in PAUSED state when the video src has - * opened the video device. However it is possible to configure photography - * settings in NULL state and camerabin will try applying them later. - * - * - * * States * * Elements within GstCameraBin are created and destroyed when switching @@ -162,7 +150,6 @@ #include "gstcamerabin.h" #include "gstcamerabincolorbalance.h" -#include "gstcamerabinphotography.h" #include "camerabindebug.h" #include "camerabingeneral.h" @@ -305,7 +292,7 @@ gst_camerabin_update_aspect_filter (GstCameraBin * camera, GstCaps * new_caps); static void gst_camerabin_finish_image_capture (GstCameraBin * camera); static void gst_camerabin_adapt_image_capture (GstCameraBin * camera, GstCaps * new_caps); -static void gst_camerabin_proxy_notify_cb (GObject * video_source, +static void gst_camerabin_scene_mode_notify_cb (GObject * video_source, GParamSpec * pspec, gpointer user_data); static void gst_camerabin_monitor_video_source_properties (GstCameraBin * camera); @@ -328,9 +315,6 @@ 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 */ @@ -411,11 +395,7 @@ gst_camerabin_iface_supported (GstImplementsInterface * iface, GType iface_type) } else { return FALSE; } - } else if (iface_type == GST_TYPE_PHOTOGRAPHY) { - /* Always support photography interface */ - return TRUE; } - return FALSE; } @@ -449,11 +429,6 @@ camerabin_init_interfaces (GType type) NULL, NULL, }; - static const GInterfaceInfo camerabin_photography_info = { - (GInterfaceInitFunc) gst_camerabin_photography_init, - NULL, - NULL, - }; g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, &camerabin_info); @@ -463,9 +438,6 @@ camerabin_init_interfaces (GType type) g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &camerabin_tagsetter_info); - - g_type_add_interface_static (type, GST_TYPE_PHOTOGRAPHY, - &camerabin_photography_info); } GST_BOILERPLATE_FULL (GstCameraBin, gst_camerabin, GstPipeline, @@ -2427,17 +2399,60 @@ gst_camerabin_adapt_image_capture (GstCameraBin * camera, GstCaps * in_caps) } } +/* + * gst_camerabin_handle_scene_mode: + * @camera: camerabin object + * scene_mode: scene mode + * + * Handle scene mode if night mode was selected/deselected in video-source + * + */ +static void +gst_camerabin_handle_scene_mode (GstCameraBin * camera, GstSceneMode scene_mode) +{ + if (scene_mode == GST_PHOTOGRAPHY_SCENE_MODE_NIGHT) { + if (!camera->night_mode) { + GST_DEBUG ("enabling night mode, lowering fps"); + /* Make camerabin select the lowest allowed frame rate */ + camera->night_mode = TRUE; + /* Remember frame rate before setting night mode */ + camera->pre_night_fps_n = camera->fps_n; + camera->pre_night_fps_d = camera->fps_d; + g_signal_emit_by_name (camera, "set-video-resolution-fps", camera->width, + camera->height, 0, 1, NULL); + } else { + GST_DEBUG ("night mode already enabled"); + } + } else { + if (camera->night_mode) { + GST_DEBUG ("disabling night mode, restoring fps to %d/%d", + camera->pre_night_fps_n, camera->pre_night_fps_d); + camera->night_mode = FALSE; + g_signal_emit_by_name (camera, "set-video-resolution-fps", camera->width, + camera->height, camera->pre_night_fps_n, camera->pre_night_fps_d, 0); + } + } +} + +/* + * gst_camerabin_scene_mode_notify_cb: + * @video_source: videosrc object + * @pspec: GParamSpec for property + * @user_data: camerabin object + * + * Update framerate if scene mode was updated in video-source + * + */ static void -gst_camerabin_proxy_notify_cb (GObject * video_source, GParamSpec * pspec, +gst_camerabin_scene_mode_notify_cb (GObject * video_source, GParamSpec * pspec, gpointer user_data) { + GstSceneMode scene_mode; const gchar *name = g_param_spec_get_name (pspec); - GstElement *camerabin = GST_ELEMENT (user_data); - - GST_DEBUG_OBJECT (camerabin, "proxying %s notify from %" GST_PTR_FORMAT, name, - GST_ELEMENT (video_source)); - g_object_notify (G_OBJECT (camerabin), name); + GstCameraBin *camera = GST_CAMERABIN (user_data); + g_object_get (video_source, name, &scene_mode, NULL); + gst_camerabin_handle_scene_mode (camera, scene_mode); } /* @@ -2445,40 +2460,21 @@ gst_camerabin_proxy_notify_cb (GObject * video_source, GParamSpec * pspec, * @camera: camerabin object * * Monitor notify signals from video source photography interface - * properties, and proxy the notifications to application. + * property scene mode. * */ static void gst_camerabin_monitor_video_source_properties (GstCameraBin * camera) { - GParamSpec **properties; - gchar *notify_string; - gpointer photo_iface; - guint i, n_properties = 0; - GST_DEBUG_OBJECT (camera, "checking for photography interface support"); if (GST_IS_ELEMENT (camera->src_vid_src) && gst_element_implements_interface (camera->src_vid_src, GST_TYPE_PHOTOGRAPHY)) { GST_DEBUG_OBJECT (camera, - "start monitoring property changes in %" GST_PTR_FORMAT, + "connecting to %" GST_PTR_FORMAT " - notify::scene-mode", camera->src_vid_src); - photo_iface = g_type_default_interface_ref (GST_TYPE_PHOTOGRAPHY); - properties = - g_object_interface_list_properties (photo_iface, &n_properties); - if (properties) { - for (i = 0; i < n_properties; i++) { - notify_string = - g_strconcat ("notify::", g_param_spec_get_name (properties[i]), - NULL); - GST_DEBUG_OBJECT (camera, "connecting to %" GST_PTR_FORMAT " - %s", - camera->src_vid_src, notify_string); - g_signal_connect (G_OBJECT (camera->src_vid_src), notify_string, - (GCallback) gst_camerabin_proxy_notify_cb, camera); - g_free (notify_string); - } - } - g_type_default_interface_unref (photo_iface); + g_signal_connect (G_OBJECT (camera->src_vid_src), "notify::scene-mode", + (GCallback) gst_camerabin_scene_mode_notify_cb, camera); } } @@ -3034,8 +3030,6 @@ 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->capture_start = gst_camerabin_capture_start; klass->capture_stop = gst_camerabin_capture_stop; klass->capture_pause = gst_camerabin_capture_pause; @@ -3177,55 +3171,11 @@ 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); - - g_object_class_override_property (gobject_class, - ARG_IMAGE_CAPTURE_SUPPORTED_CAPS, - GST_PHOTOGRAPHY_PROP_IMAGE_CAPTURE_SUPPORTED_CAPS); - - g_object_class_override_property (gobject_class, ARG_FLICKER_MODE, - GST_PHOTOGRAPHY_PROP_FLICKER_MODE); - - g_object_class_override_property (gobject_class, ARG_FOCUS_MODE, - GST_PHOTOGRAPHY_PROP_FOCUS_MODE); -} - -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), @@ -3464,9 +3414,6 @@ 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); @@ -3632,7 +3579,7 @@ gst_camerabin_change_state (GstElement * element, GstStateChange transition) } g_mutex_unlock (camera->capture_mutex); g_signal_handlers_disconnect_by_func (camera->src_vid_src, - gst_camerabin_proxy_notify_cb, camera); + gst_camerabin_scene_mode_notify_cb, camera); break; case GST_STATE_CHANGE_READY_TO_NULL: camerabin_destroy_elements (camera); diff --git a/gst/camerabin/gstcamerabinphotography.c b/gst/camerabin/gstcamerabinphotography.c deleted file mode 100644 index 4780909..0000000 --- a/gst/camerabin/gstcamerabinphotography.c +++ /dev/null @@ -1,777 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008 Nokia Corporation - * - * Photography interface implementation for camerabin. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "gstcamerabinphotography.h" -#include "gstcamerabin.h" -#include "gstcamerabin-enum.h" - -GST_DEBUG_CATEGORY_STATIC (camerabinphoto_debug); -#define GST_CAT_DEFAULT camerabinphoto_debug - -#define PHOTOGRAPHY_IS_OK(photo_elem) (GST_IS_ELEMENT (photo_elem) && \ - gst_element_implements_interface (photo_elem, GST_TYPE_PHOTOGRAPHY)) -static void -gst_camerabin_handle_scene_mode (GstCameraBin * camera, - GstSceneMode scene_mode); - -static gboolean -gst_camerabin_set_ev_compensation (GstPhotography * photo, - gfloat ev_compensation) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.ev_compensation = ev_compensation; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = - gst_photography_set_ev_compensation (GST_PHOTOGRAPHY - (camera->src_vid_src), ev_compensation); - } - return ret; -} - -static gboolean -gst_camerabin_get_ev_compensation (GstPhotography * photo, - gfloat * ev_compensation) -{ - 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_ev_compensation (GST_PHOTOGRAPHY - (camera->src_vid_src), ev_compensation); - } - return ret; -} - -static gboolean -gst_camerabin_set_iso_speed (GstPhotography * photo, guint iso_speed) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.iso_speed = iso_speed; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = gst_photography_set_iso_speed (GST_PHOTOGRAPHY (camera->src_vid_src), - iso_speed); - } - return ret; -} - -static gboolean -gst_camerabin_get_iso_speed (GstPhotography * photo, guint * iso_speed) -{ - 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_iso_speed (GST_PHOTOGRAPHY (camera->src_vid_src), - iso_speed); - } - return ret; -} - -static gboolean -gst_camerabin_set_white_balance_mode (GstPhotography * photo, - GstWhiteBalanceMode white_balance_mode) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.wb_mode = white_balance_mode; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = - gst_photography_set_white_balance_mode (GST_PHOTOGRAPHY - (camera->src_vid_src), white_balance_mode); - } - return ret; -} - -static gboolean -gst_camerabin_get_white_balance_mode (GstPhotography * photo, - GstWhiteBalanceMode * white_balance_mode) -{ - 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_white_balance_mode (GST_PHOTOGRAPHY - (camera->src_vid_src), white_balance_mode); - } - return ret; -} - -static gboolean -gst_camerabin_set_colour_tone_mode (GstPhotography * photo, - GstColourToneMode colour_tone_mode) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.tone_mode = colour_tone_mode; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = - gst_photography_set_colour_tone_mode (GST_PHOTOGRAPHY - (camera->src_vid_src), colour_tone_mode); - } - return ret; -} - -static gboolean -gst_camerabin_get_colour_tone_mode (GstPhotography * photo, - GstColourToneMode * colour_tone_mode) -{ - 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_colour_tone_mode (GST_PHOTOGRAPHY - (camera->src_vid_src), colour_tone_mode); - } - return ret; -} - -static gboolean -gst_camerabin_set_flash_mode (GstPhotography * photo, GstFlashMode flash_mode) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.flash_mode = flash_mode; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = gst_photography_set_flash_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - flash_mode); - } - return ret; -} - -static gboolean -gst_camerabin_get_flash_mode (GstPhotography * photo, GstFlashMode * flash_mode) -{ - 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_flash_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - flash_mode); - } - return ret; -} - -static gboolean -gst_camerabin_set_scene_mode (GstPhotography * photo, GstSceneMode scene_mode) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.scene_mode = scene_mode; - - gst_camerabin_handle_scene_mode (camera, scene_mode); - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = gst_photography_set_scene_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - scene_mode); - if (ret) { - gst_photography_get_config (GST_PHOTOGRAPHY (camera->src_vid_src), - &camera->photo_settings); - } - } - return ret; -} - -static gboolean -gst_camerabin_get_scene_mode (GstPhotography * photo, GstSceneMode * scene_mode) -{ - 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_scene_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - scene_mode); - } - return ret; -} - -static GstPhotoCaps -gst_camerabin_get_capabilities (GstPhotography * photo) -{ - GstCameraBin *camera; - /* camerabin can zoom by itself */ - GstPhotoCaps pcaps = GST_PHOTOGRAPHY_CAPS_ZOOM; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - if (GST_IS_ELEMENT (camera->src_vid_src) && - gst_element_implements_interface (camera->src_vid_src, - GST_TYPE_PHOTOGRAPHY)) { - GstPhotography *p2 = GST_PHOTOGRAPHY (camera->src_vid_src); - pcaps |= gst_photography_get_capabilities (p2); - } - - return pcaps; -} - -static void -gst_camerabin_set_autofocus (GstPhotography * photo, gboolean on) -{ - GstCameraBin *camera; - - g_return_if_fail (photo != NULL); - - camera = GST_CAMERABIN (photo); - - GST_DEBUG_OBJECT (camera, "setting autofocus %s", on ? "ON" : "OFF"); - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - gst_photography_set_autofocus (GST_PHOTOGRAPHY (camera->src_vid_src), 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; - gboolean ret = TRUE; - g_return_val_if_fail (photo != NULL, FALSE); - camera = GST_CAMERABIN (photo); - - /* Cache the settings */ - memcpy (&camera->photo_settings, config, sizeof (GstPhotoSettings)); - - /* Handle night mode */ - gst_camerabin_handle_scene_mode (camera, config->scene_mode); - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = - gst_photography_set_config (GST_PHOTOGRAPHY (camera->src_vid_src), - config); - } - return ret; -} - -static gboolean -gst_camerabin_get_config (GstPhotography * photo, GstPhotoSettings * config) -{ - 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_config (GST_PHOTOGRAPHY (camera->src_vid_src), - config); - } - return ret; -} - -static void -gst_camerabin_handle_scene_mode (GstCameraBin * camera, GstSceneMode scene_mode) -{ - if (scene_mode == GST_PHOTOGRAPHY_SCENE_MODE_NIGHT) { - if (!camera->night_mode) { - GST_DEBUG ("enabling night mode, lowering fps"); - /* Make camerabin select the lowest allowed frame rate */ - camera->night_mode = TRUE; - /* Remember frame rate before setting night mode */ - camera->pre_night_fps_n = camera->fps_n; - camera->pre_night_fps_d = camera->fps_d; - g_signal_emit_by_name (camera, "set-video-resolution-fps", camera->width, - camera->height, 0, 1, NULL); - } else { - GST_DEBUG ("night mode already enabled"); - } - } else { - if (camera->night_mode) { - GST_DEBUG ("disabling night mode, restoring fps to %d/%d", - camera->pre_night_fps_n, camera->pre_night_fps_d); - camera->night_mode = FALSE; - g_signal_emit_by_name (camera, "set-video-resolution-fps", camera->width, - camera->height, camera->pre_night_fps_n, camera->pre_night_fps_d, 0); - } - } -} - -static gboolean -gst_camerabin_set_flicker_mode (GstPhotography * photo, - GstFlickerReductionMode flicker_mode) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.flicker_mode = flicker_mode; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = - gst_photography_set_flicker_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - flicker_mode); - } - return ret; -} - -static gboolean -gst_camerabin_get_flicker_mode (GstPhotography * photo, - GstFlickerReductionMode * flicker_mode) -{ - 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_flicker_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - flicker_mode); - } - return ret; -} - -static gboolean -gst_camerabin_set_focus_mode (GstPhotography * photo, GstFocusMode focus_mode) -{ - GstCameraBin *camera; - gboolean ret = TRUE; - - g_return_val_if_fail (photo != NULL, FALSE); - - camera = GST_CAMERABIN (photo); - - /* Cache the setting */ - camera->photo_settings.focus_mode = focus_mode; - - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - ret = - gst_photography_set_focus_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - focus_mode); - } - return ret; -} - -static gboolean -gst_camerabin_get_focus_mode (GstPhotography * photo, GstFocusMode * focus_mode) -{ - 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_focus_mode (GST_PHOTOGRAPHY (camera->src_vid_src), - focus_mode); - } - return ret; -} - -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; - } - case ARG_IMAGE_CAPTURE_SUPPORTED_CAPS: - { - GST_DEBUG_OBJECT (camera, "==== GETTING PROP_IMAGE_CAPTURE_CAPS ===="); - if (PHOTOGRAPHY_IS_OK (camera->src_vid_src)) { - g_object_get_property (G_OBJECT (camera->src_vid_src), - "image-capture-supported-caps", value); - } else { - g_object_get_property (G_OBJECT (camera), "video-source-caps", value); - } - ret = TRUE; - break; - } - case ARG_FLICKER_MODE: - { - GstFlickerReductionMode mode; - GST_DEBUG_OBJECT (camera, "==== GETTING PROP_FLICKER_MODE ===="); - if (gst_camerabin_get_flicker_mode ((GstPhotography *) camera, &mode)) { - g_value_set_enum (value, mode); - } - ret = TRUE; - break; - } - case ARG_FOCUS_MODE: - { - GstFocusMode mode; - GST_DEBUG_OBJECT (camera, "==== GETTING PROP_FOCUS_MODE ===="); - if (gst_camerabin_get_focus_mode ((GstPhotography *) camera, &mode)) { - g_value_set_enum (value, mode); - } - 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; - case ARG_FLICKER_MODE: - GST_DEBUG_OBJECT (camera, "==== SETTING PROP_FLICKER_MODE ===="); - gst_camerabin_set_flicker_mode ((GstPhotography *) camera, - g_value_get_enum (value)); - ret = TRUE; - break; - case ARG_FOCUS_MODE: - GST_DEBUG_OBJECT (camera, "==== SETTING PROP_FOCUS_MODE ===="); - gst_camerabin_set_focus_mode ((GstPhotography *) camera, - g_value_get_enum (value)); - ret = TRUE; - break; - default: - break; - } - - return ret; -} - - -void -gst_camerabin_photography_init (GstPhotographyInterface * iface) -{ - GST_DEBUG_CATEGORY_INIT (camerabinphoto_debug, "camerabinphoto", 0, - "Camerabin photography interface debugging"); - - GST_INFO ("initing"); - - iface->set_ev_compensation = gst_camerabin_set_ev_compensation; - iface->get_ev_compensation = gst_camerabin_get_ev_compensation; - - iface->set_iso_speed = gst_camerabin_set_iso_speed; - iface->get_iso_speed = gst_camerabin_get_iso_speed; - - iface->set_white_balance_mode = gst_camerabin_set_white_balance_mode; - iface->get_white_balance_mode = gst_camerabin_get_white_balance_mode; - - iface->set_colour_tone_mode = gst_camerabin_set_colour_tone_mode; - iface->get_colour_tone_mode = gst_camerabin_get_colour_tone_mode; - - iface->set_scene_mode = gst_camerabin_set_scene_mode; - iface->get_scene_mode = gst_camerabin_get_scene_mode; - - iface->set_flash_mode = gst_camerabin_set_flash_mode; - iface->get_flash_mode = gst_camerabin_get_flash_mode; - - iface->get_capabilities = gst_camerabin_get_capabilities; - - iface->set_autofocus = gst_camerabin_set_autofocus; - - iface->set_config = gst_camerabin_set_config; - iface->get_config = gst_camerabin_get_config; -} diff --git a/gst/camerabin/gstcamerabinphotography.h b/gst/camerabin/gstcamerabinphotography.h deleted file mode 100644 index 94083b1..0000000 --- a/gst/camerabin/gstcamerabinphotography.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * GStreamer - * Copyright (C) 2008 Nokia Corporation - * - * Photography interface implementation for camerabin - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GST_CAMERABIN_PHOTOGRAPHY_H__ -#define __GST_CAMERABIN_PHOTOGRAPHY_H__ - -#include - -#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__ */