GST_INFO ("done");
}
-static void
-test_photography_settings (GstElement * cam)
-{
- GTypeClass *tclass;
- gfloat ev_comp, orig_ev_comp;
- guint iso_speed = 100, orig_iso_speed;
- GstFlashMode flash, orig_flash;
- GstWhiteBalanceMode wb, orig_wb;
- GstColourToneMode ct, orig_ct;
- GstSceneMode sm, orig_sm;
- GstFlickerReductionMode flm, orig_flm;
- GstFocusMode fm, orig_fm;
- gfloat zoom, orig_zoom;
-
- if (!GST_IS_PHOTOGRAPHY (cam)) {
- GST_WARNING
- ("omitting photography settings test, "
- "photography interface not implemented");
- return;
- }
-
- for (ev_comp = -3.0; ev_comp <= 3.0; ev_comp += 0.5) {
- orig_ev_comp = ev_comp;
- gst_photography_set_ev_compensation (GST_PHOTOGRAPHY (cam), ev_comp);
- gst_photography_get_ev_compensation (GST_PHOTOGRAPHY (cam), &ev_comp);
- fail_if (orig_ev_comp != ev_comp,
- "setting photography ev compensation failed");
- ev_comp = orig_ev_comp;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
-
- /* FIXME: what are the actual iso values? */
- for (iso_speed = 100; iso_speed <= 800; iso_speed *= 2) {
- orig_iso_speed = iso_speed;
- gst_photography_set_iso_speed (GST_PHOTOGRAPHY (cam), iso_speed);
- gst_photography_get_iso_speed (GST_PHOTOGRAPHY (cam), &iso_speed);
- fail_if (orig_iso_speed != iso_speed,
- "setting photography iso speed failed");
- iso_speed = orig_iso_speed;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
-
- tclass = g_type_class_ref (GST_TYPE_FLASH_MODE);
- for (flash = 0; flash < G_ENUM_CLASS (tclass)->n_values; flash++) {
- orig_flash = flash;
- gst_photography_set_flash_mode (GST_PHOTOGRAPHY (cam), flash);
- gst_photography_get_flash_mode (GST_PHOTOGRAPHY (cam), &flash);
- fail_if (orig_flash != flash, "setting photography flash failed");
- flash = orig_flash;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_WHITE_BALANCE_MODE);
- for (wb = 0; wb < G_ENUM_CLASS (tclass)->n_values; wb++) {
- orig_wb = wb;
- gst_photography_set_white_balance_mode (GST_PHOTOGRAPHY (cam), wb);
- gst_photography_get_white_balance_mode (GST_PHOTOGRAPHY (cam), &wb);
- fail_if (orig_wb != wb, "setting photography white balance mode failed");
- wb = orig_wb;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_COLOUR_TONE_MODE);
- for (ct = 0; ct < G_ENUM_CLASS (tclass)->n_values; ct++) {
- orig_ct = ct;
- gst_photography_set_colour_tone_mode (GST_PHOTOGRAPHY (cam), ct);
- gst_photography_get_colour_tone_mode (GST_PHOTOGRAPHY (cam), &ct);
- fail_if (orig_ct != ct, "setting photography colour tone mode failed");
- ct = orig_ct;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_SCENE_MODE);
- for (sm = 0; sm < G_ENUM_CLASS (tclass)->n_values; sm++) {
- orig_sm = sm;
- gst_photography_set_scene_mode (GST_PHOTOGRAPHY (cam), sm);
- gst_photography_get_scene_mode (GST_PHOTOGRAPHY (cam), &sm);
- fail_if (orig_sm != sm, "setting photography scene mode failed");
- sm = orig_sm;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_FOCUS_MODE);
- for (fm = 0; fm < G_ENUM_CLASS (tclass)->n_values; fm++) {
- orig_fm = fm;
- gst_photography_set_focus_mode (GST_PHOTOGRAPHY (cam), fm);
- gst_photography_get_focus_mode (GST_PHOTOGRAPHY (cam), &fm);
- fail_if (orig_fm != fm, "setting photography focus mode failed");
- fm = orig_fm;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_FLICKER_REDUCTION_MODE);
- for (flm = 0; flm < G_ENUM_CLASS (tclass)->n_values; flm++) {
- orig_flm = flm;
- gst_photography_set_flicker_mode (GST_PHOTOGRAPHY (cam), flm);
- gst_photography_get_flicker_mode (GST_PHOTOGRAPHY (cam), &flm);
- fail_if (orig_flm != flm, "setting photography flicker mode failed");
- flm = orig_flm;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- for (zoom = 1.0; zoom <= 10.0; zoom += 1.0) {
- orig_zoom = zoom;
- gst_photography_set_zoom (GST_PHOTOGRAPHY (cam), zoom);
- gst_photography_get_zoom (GST_PHOTOGRAPHY (cam), &zoom);
- fail_if (orig_zoom != zoom, "setting photography zoom failed");
- zoom = orig_zoom;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
-}
-
-static void
-test_photography_properties (GstElement * cam)
-{
- GTypeClass *tclass;
- gulong capabilities;
- guint aperture;
- guint32 exposure;
- gfloat ev_comp, orig_ev_comp;
- guint iso_speed = 100, orig_iso_speed;
- GstFlashMode flash, orig_flash;
- GstWhiteBalanceMode wb, orig_wb;
- GstColourToneMode ct, orig_ct;
- GstSceneMode sm, orig_sm;
- GstFocusMode fm, orig_fm;
- GstFlickerReductionMode flm, orig_flm;
- GstCaps *caps = NULL;
-
- if (!GST_IS_PHOTOGRAPHY (cam)) {
- GST_WARNING
- ("omitting photography properties test, not photography interface");
- return;
- }
-
- /* NOTE: unit testing uses videotestsrc element which is doesn't implement
- photography interface so we just check that values returned
- are sane */
-
- /* read only flags */
- g_object_get (GST_PHOTOGRAPHY (cam), "capabilities", &capabilities, NULL);
- fail_if (capabilities < 0, "getting photography capabilities failed");
-
- /* for image-capture-supported-caps we should get something always */
- g_object_get (GST_PHOTOGRAPHY (cam), "image-capture-supported-caps", &caps,
- NULL);
- fail_if (caps == NULL, "getting photography capabilities failed");
- if (caps)
- gst_caps_unref (caps);
-
- exposure = 0; /* auto */
- g_object_set (GST_PHOTOGRAPHY (cam), "exposure", exposure, NULL);
- g_object_get (GST_PHOTOGRAPHY (cam), "exposure", &exposure, NULL);
- fail_if (exposure < 0, "setting photography exposure failed");
-
- aperture = 0; /* auto */
- g_object_set (GST_PHOTOGRAPHY (cam), "aperture", aperture, NULL);
- g_object_get (GST_PHOTOGRAPHY (cam), "aperture", &aperture, NULL);
- fail_if (aperture < 0 || aperture > 255,
- "setting photography aperture failed");
-
- for (ev_comp = -2.5; ev_comp <= 2.5; ev_comp += 0.5) {
- orig_ev_comp = ev_comp;
- g_object_set (GST_PHOTOGRAPHY (cam), "ev-compensation", ev_comp, NULL);
- g_object_get (GST_PHOTOGRAPHY (cam), "ev-compensation", &ev_comp, NULL);
- fail_if (ev_comp < -2.5 || ev_comp > 2.5,
- "setting photography ev compensation failed");
- ev_comp = orig_ev_comp;
- }
-
- /* FIXME: what are the actual iso values? */
- for (iso_speed = 100; iso_speed <= 800; iso_speed *= 2) {
- orig_iso_speed = iso_speed;
- g_object_set (GST_PHOTOGRAPHY (cam), "iso-speed", iso_speed, NULL);
- g_object_get (GST_PHOTOGRAPHY (cam), "iso-speed", &iso_speed, NULL);
- fail_if (iso_speed < 0 || iso_speed > 800,
- "setting photography iso speed failed");
- iso_speed = orig_iso_speed;
- }
-
- tclass = g_type_class_ref (GST_TYPE_FLASH_MODE);
- for (flash = 0; flash < G_ENUM_CLASS (tclass)->n_values; flash++) {
- orig_flash = flash;
- g_object_set (GST_PHOTOGRAPHY (cam), "flash-mode", flash, NULL);
- g_object_get (GST_PHOTOGRAPHY (cam), "flash-mode", &flash, NULL);
- fail_if (flash < 0 || flash >= G_ENUM_CLASS (tclass)->n_values,
- "setting photography flash failed");
- flash = orig_flash;
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_WHITE_BALANCE_MODE);
- for (wb = 0; wb < G_ENUM_CLASS (tclass)->n_values; wb++) {
- orig_wb = wb;
- g_object_set (G_OBJECT (cam), "white-balance-mode", wb, NULL);
- g_object_get (G_OBJECT (cam), "white-balance-mode", &wb, NULL);
- fail_if (wb < 0 || wb >= G_ENUM_CLASS (tclass)->n_values,
- "setting photography white balance mode failed");
- wb = orig_wb;
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_COLOUR_TONE_MODE);
- for (ct = 0; ct < G_ENUM_CLASS (tclass)->n_values; ct++) {
- orig_ct = ct;
- g_object_set (G_OBJECT (cam), "colour-tone-mode", ct, NULL);
- g_object_get (G_OBJECT (cam), "colour-tone-mode", &ct, NULL);
- fail_if (ct < 0 || ct >= G_ENUM_CLASS (tclass)->n_values,
- "setting photography colour tone mode failed");
- ct = orig_ct;
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_SCENE_MODE);
- for (sm = 0; sm < G_ENUM_CLASS (tclass)->n_values; sm++) {
- orig_sm = sm;
- g_object_set (G_OBJECT (cam), "scene-mode", sm, NULL);
- g_object_get (G_OBJECT (cam), "scene-mode", &sm, NULL);
- fail_if (sm < 0 || sm > G_ENUM_CLASS (tclass)->n_values,
- "setting photography scene mode failed");
- sm = orig_sm;
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_FOCUS_MODE);
- for (fm = 0; fm < G_ENUM_CLASS (tclass)->n_values; fm++) {
- orig_fm = fm;
- g_object_set (G_OBJECT (cam), "focus-mode", fm, NULL);
- g_object_get (G_OBJECT (cam), "focus-mode", &fm, NULL);
- fail_if (fm < 0 || fm > G_ENUM_CLASS (tclass)->n_values,
- "setting photography focus mode failed");
- fm = orig_fm;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-
- tclass = g_type_class_ref (GST_TYPE_FLICKER_REDUCTION_MODE);
- for (flm = 0; flm < G_ENUM_CLASS (tclass)->n_values; flm++) {
- orig_flm = flm;
- g_object_set (G_OBJECT (cam), "flicker-mode", flm, NULL);
- g_object_get (G_OBJECT (cam), "flicker-mode", &flm, NULL);
- fail_if (flm < 0 || flm > G_ENUM_CLASS (tclass)->n_values,
- "setting photography flicker reduction mode failed");
- flm = orig_flm;
- g_usleep (PHOTO_SETTING_DELAY_US);
- }
- g_type_class_unref (tclass);
-}
-
static void
test_camerabin_properties (GstElement * cam)
{
/* Test photography iface settings */
gst_element_get_state (GST_ELEMENT (camera), NULL, NULL, (2 * GST_SECOND));
- test_photography_settings (camera);
- test_photography_properties (camera);
test_camerabin_properties (camera);
/* set flags to disable additional elements */