examples: camerabin: Don't set default values for GstPhotography interface settings

Don't set any default values for source element GstPhotography interface
settings, source elements should have sane defaults themselves.
Also, setting scene-mode is tricky as it is a superset of other GstPhotography
settings. This might cause problem with defaults e.g. setting scene-mode to
'night' may configure flash-mode as 'on' by definition, and after that
we don't want to override this flash-mode setting with gst-camerabin-test default
value. Moreover, user needs have an option to set scene mode first and then force
some individual setting to a different value from the scene-mode definition.

https://bugzilla.gnome.org/show_bug.cgi?id=639841
This commit is contained in:
Lasse Laukkanen 2011-01-12 16:26:19 +02:00 committed by Thiago Santos
parent a791f5070c
commit 10830c9544

View file

@ -136,15 +136,6 @@ static gint view_framerate_num = 2825;
static gint view_framerate_den = 100;
static gboolean no_xwindow = FALSE;
/* photography interface command line options */
static gfloat ev_compensation = 0.0;
static gint aperture = 0;
static gint flash_mode = 0;
static gint scene_mode = 6;
static gint64 exposure = 0;
static gint iso_speed = 0;
static gint wb_mode = 0;
static gint color_mode = 0;
static gint mode = 1;
static gint flags = 0x4f;
static gboolean mute = FALSE;
@ -154,6 +145,24 @@ static gint capture_time = 10;
static gint capture_count = 0;
static gint capture_total = 1;
/* photography interface command line options */
#define EV_COMPENSATION_NONE -G_MAXFLOAT
#define APERTURE_NONE -G_MAXINT
#define FLASH_MODE_NONE -G_MAXINT
#define SCENE_MODE_NONE -G_MAXINT
#define EXPOSURE_NONE -G_MAXINT64
#define ISO_SPEED_NONE -G_MAXINT
#define WHITE_BALANCE_MODE_NONE -G_MAXINT
#define COLOR_TONE_MODE_NONE -G_MAXINT
static gfloat ev_compensation = EV_COMPENSATION_NONE;
static gint aperture = APERTURE_NONE;
static gint flash_mode = FLASH_MODE_NONE;
static gint scene_mode = SCENE_MODE_NONE;
static gint64 exposure = EXPOSURE_NONE;
static gint iso_speed = ISO_SPEED_NONE;
static gint wb_mode = WHITE_BALANCE_MODE_NONE;
static gint color_mode = COLOR_TONE_MODE_NONE;
/* audio capsfilter options */
static gint audio_bitrate = 128000;
static gint audio_samplerate = 48000;
@ -634,14 +643,24 @@ run_pipeline (gpointer user_data)
if (video_source) {
if (GST_IS_ELEMENT (video_source) &&
gst_element_implements_interface (video_source, GST_TYPE_PHOTOGRAPHY)) {
g_object_set (video_source, "ev-compensation", ev_compensation, NULL);
g_object_set (video_source, "aperture", aperture, NULL);
g_object_set (video_source, "flash-mode", flash_mode, NULL);
g_object_set (video_source, "scene-mode", scene_mode, NULL);
g_object_set (video_source, "exposure", exposure, NULL);
g_object_set (video_source, "iso-speed", iso_speed, NULL);
g_object_set (video_source, "white-balance-mode", wb_mode, NULL);
g_object_set (video_source, "colour-tone-mode", color_mode, NULL);
/* Set GstPhotography interface options. If option not given as
command-line parameter use default of the source element. */
if (scene_mode != SCENE_MODE_NONE)
g_object_set (video_source, "scene-mode", scene_mode, NULL);
if (ev_compensation != EV_COMPENSATION_NONE)
g_object_set (video_source, "ev-compensation", ev_compensation, NULL);
if (aperture != APERTURE_NONE)
g_object_set (video_source, "aperture", aperture, NULL);
if (flash_mode != FLASH_MODE_NONE)
g_object_set (video_source, "flash-mode", flash_mode, NULL);
if (exposure != EXPOSURE_NONE)
g_object_set (video_source, "exposure", exposure, NULL);
if (iso_speed != ISO_SPEED_NONE)
g_object_set (video_source, "iso-speed", iso_speed, NULL);
if (wb_mode != WHITE_BALANCE_MODE_NONE)
g_object_set (video_source, "white-balance-mode", wb_mode, NULL);
if (color_mode != COLOR_TONE_MODE_NONE)
g_object_set (video_source, "colour-tone-mode", color_mode, NULL);
}
g_object_unref (video_source);
}
@ -669,27 +688,29 @@ main (int argc, char *argv[])
GOptionEntry options[] = {
{"ev-compensation", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_STRING,
&ev_option,
"EV compensation (-2.5..2.5, default = 0)", NULL},
"EV compensation for source element GstPhotography interface", NULL},
{"aperture", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT, &aperture,
"Aperture (size of lens opening, default = 0 (auto))", NULL},
"Aperture (size of lens opening) for source element GstPhotography interface",
NULL},
{"flash-mode", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT,
&flash_mode,
"Flash mode (default = 0 (auto))", NULL},
"Flash mode for source element GstPhotography interface", NULL},
{"scene-mode", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT,
&scene_mode,
"Scene mode (default = 6 (auto))", NULL},
"Scene mode for source element GstPhotography interface", NULL},
{"exposure", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT64,
&exposure,
"Exposure (default = 0 (auto))", NULL},
"Exposure time (in ms) for source element GstPhotography interface",
NULL},
{"iso-speed", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT,
&iso_speed,
"ISO speed (default = 0 (auto))", NULL},
"ISO speed for source element GstPhotography interface", NULL},
{"white-balance-mode", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT,
&wb_mode,
"White balance mode (default = 0 (auto))", NULL},
"White balance mode for source element GstPhotography interface", NULL},
{"colour-tone-mode", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT,
&color_mode,
"Colour tone mode (default = 0 (auto))", NULL},
"Colour tone mode for source element GstPhotography interface", NULL},
{"directory", '\0', 0, G_OPTION_ARG_STRING, &fn_option,
"Directory for capture file(s) (default is current directory)", NULL},
{"mode", '\0', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_INT, &mode,