mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
examples: camerabin: use photoiface properties through video-source
Fixes #616923
This commit is contained in:
parent
e0dae09731
commit
9bace27300
3 changed files with 42 additions and 28 deletions
|
@ -36,8 +36,13 @@ if HAVE_X11
|
||||||
GST_CAMERABIN_X11_EXAMPLES = gst-camerabin-test
|
GST_CAMERABIN_X11_EXAMPLES = gst-camerabin-test
|
||||||
|
|
||||||
gst_camerabin_test_SOURCES = gst-camerabin-test.c
|
gst_camerabin_test_SOURCES = gst-camerabin-test.c
|
||||||
gst_camerabin_test_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
|
gst_camerabin_test_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS)
|
||||||
gst_camerabin_test_LDADD = -lgstinterfaces-@GST_MAJORMINOR@ $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) $(X11_LIBS)
|
gst_camerabin_test_LDADD = \
|
||||||
|
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la \
|
||||||
|
-lgstinterfaces-@GST_MAJORMINOR@ \
|
||||||
|
$(GST_LIBS) \
|
||||||
|
$(GST_PLUGINS_BASE_LIBS) \
|
||||||
|
$(X11_LIBS)
|
||||||
|
|
||||||
else
|
else
|
||||||
GST_CAMERABIN_X11_EXAMPLES =
|
GST_CAMERABIN_X11_EXAMPLES =
|
||||||
|
|
|
@ -819,11 +819,11 @@ on_buttonPause_clicked (GtkButton * button, gpointer user_data)
|
||||||
case CAP_STATE_IMAGE:
|
case CAP_STATE_IMAGE:
|
||||||
if (g_str_equal (gtk_button_get_label (ui_bnt_pause), "Focus")) {
|
if (g_str_equal (gtk_button_get_label (ui_bnt_pause), "Focus")) {
|
||||||
/* Start autofocus */
|
/* Start autofocus */
|
||||||
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_camera_bin), TRUE);
|
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_videosrc), TRUE);
|
||||||
gtk_button_set_label (ui_bnt_pause, "Cancel Focus");
|
gtk_button_set_label (ui_bnt_pause, "Cancel Focus");
|
||||||
} else {
|
} else {
|
||||||
/* Cancel autofocus */
|
/* Cancel autofocus */
|
||||||
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_camera_bin), FALSE);
|
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_videosrc), FALSE);
|
||||||
gtk_button_set_label (ui_bnt_pause, "Focus");
|
gtk_button_set_label (ui_bnt_pause, "Focus");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1043,7 +1043,7 @@ on_key_released (GtkWidget * widget, GdkEventKey * event, gpointer user_data)
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
case GDK_F11:
|
case GDK_F11:
|
||||||
#ifdef HAVE_GST_PHOTO_IFACE_H
|
#ifdef HAVE_GST_PHOTO_IFACE_H
|
||||||
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_camera_bin), FALSE);
|
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_videosrc), FALSE);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1061,7 +1061,7 @@ on_key_pressed (GtkWidget * widget, GdkEventKey * event, gpointer user_data)
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
case GDK_F11:
|
case GDK_F11:
|
||||||
#ifdef HAVE_GST_PHOTO_IFACE_H
|
#ifdef HAVE_GST_PHOTO_IFACE_H
|
||||||
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_camera_bin), TRUE);
|
gst_photography_set_autofocus (GST_PHOTOGRAPHY (gst_videosrc), TRUE);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 0x0:
|
case 0x0:
|
||||||
|
@ -1337,31 +1337,31 @@ photo_menuitem_toggled_cb (GtkRadioMenuItem * menuitem, gpointer user_data)
|
||||||
GstWhiteBalanceMode mode;
|
GstWhiteBalanceMode mode;
|
||||||
ret =
|
ret =
|
||||||
gst_photography_set_white_balance_mode (GST_PHOTOGRAPHY
|
gst_photography_set_white_balance_mode (GST_PHOTOGRAPHY
|
||||||
(gst_camera_bin), val->value);
|
(gst_videosrc), val->value);
|
||||||
gst_photography_get_white_balance_mode (GST_PHOTOGRAPHY (gst_camera_bin),
|
gst_photography_get_white_balance_mode (GST_PHOTOGRAPHY (gst_videosrc),
|
||||||
&mode);
|
&mode);
|
||||||
set_value = (gint) mode;
|
set_value = (gint) mode;
|
||||||
} else if (etype == GST_TYPE_SCENE_MODE) {
|
} else if (etype == GST_TYPE_SCENE_MODE) {
|
||||||
GstSceneMode mode;
|
GstSceneMode mode;
|
||||||
ret =
|
ret =
|
||||||
gst_photography_set_scene_mode (GST_PHOTOGRAPHY (gst_camera_bin),
|
gst_photography_set_scene_mode (GST_PHOTOGRAPHY (gst_videosrc),
|
||||||
val->value);
|
val->value);
|
||||||
gst_photography_get_scene_mode (GST_PHOTOGRAPHY (gst_camera_bin), &mode);
|
gst_photography_get_scene_mode (GST_PHOTOGRAPHY (gst_videosrc), &mode);
|
||||||
set_value = (gint) mode;
|
set_value = (gint) mode;
|
||||||
} else if (etype == GST_TYPE_COLOUR_TONE_MODE) {
|
} else if (etype == GST_TYPE_COLOUR_TONE_MODE) {
|
||||||
GstColourToneMode mode;
|
GstColourToneMode mode;
|
||||||
ret =
|
ret =
|
||||||
gst_photography_set_colour_tone_mode (GST_PHOTOGRAPHY
|
gst_photography_set_colour_tone_mode (GST_PHOTOGRAPHY
|
||||||
(gst_camera_bin), val->value);
|
(gst_videosrc), val->value);
|
||||||
gst_photography_get_colour_tone_mode (GST_PHOTOGRAPHY (gst_camera_bin),
|
gst_photography_get_colour_tone_mode (GST_PHOTOGRAPHY (gst_videosrc),
|
||||||
&mode);
|
&mode);
|
||||||
set_value = (gint) mode;
|
set_value = (gint) mode;
|
||||||
} else if (etype == GST_TYPE_FLASH_MODE) {
|
} else if (etype == GST_TYPE_FLASH_MODE) {
|
||||||
GstFlashMode mode;
|
GstFlashMode mode;
|
||||||
ret =
|
ret =
|
||||||
gst_photography_set_flash_mode (GST_PHOTOGRAPHY (gst_camera_bin),
|
gst_photography_set_flash_mode (GST_PHOTOGRAPHY (gst_videosrc),
|
||||||
val->value);
|
val->value);
|
||||||
gst_photography_get_flash_mode (GST_PHOTOGRAPHY (gst_camera_bin), &mode);
|
gst_photography_get_flash_mode (GST_PHOTOGRAPHY (gst_videosrc), &mode);
|
||||||
set_value = (gint) mode;
|
set_value = (gint) mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,11 +1388,10 @@ photo_iso_speed_toggled_cb (GtkRadioMenuItem * menuitem, gpointer user_data)
|
||||||
if (!g_str_equal (name, "auto")) {
|
if (!g_str_equal (name, "auto")) {
|
||||||
sscanf (name, "%d", &val);
|
sscanf (name, "%d", &val);
|
||||||
}
|
}
|
||||||
if (!gst_photography_set_iso_speed (GST_PHOTOGRAPHY (gst_camera_bin), val)) {
|
if (!gst_photography_set_iso_speed (GST_PHOTOGRAPHY (gst_videosrc), val)) {
|
||||||
g_print ("ISO speed (%d) setting failed\n", val);
|
g_print ("ISO speed (%d) setting failed\n", val);
|
||||||
} else {
|
} else {
|
||||||
gst_photography_get_iso_speed (GST_PHOTOGRAPHY (gst_camera_bin),
|
gst_photography_get_iso_speed (GST_PHOTOGRAPHY (gst_videosrc), &set_val);
|
||||||
&set_val);
|
|
||||||
if (val != set_val) {
|
if (val != set_val) {
|
||||||
g_print ("ISO speed (%d) setting failed, got %d\n", val, set_val);
|
g_print ("ISO speed (%d) setting failed, got %d\n", val, set_val);
|
||||||
}
|
}
|
||||||
|
@ -1411,11 +1410,11 @@ photo_ev_comp_toggled_cb (GtkRadioMenuItem * menuitem, gpointer user_data)
|
||||||
if (active) {
|
if (active) {
|
||||||
name = gtk_widget_get_name (GTK_WIDGET (menuitem));
|
name = gtk_widget_get_name (GTK_WIDGET (menuitem));
|
||||||
sscanf (name, "%f", &val);
|
sscanf (name, "%f", &val);
|
||||||
if (!gst_photography_set_ev_compensation (GST_PHOTOGRAPHY (gst_camera_bin),
|
if (!gst_photography_set_ev_compensation (GST_PHOTOGRAPHY (gst_videosrc),
|
||||||
val)) {
|
val)) {
|
||||||
g_print ("EV compensation (%.1f) setting failed\n", val);
|
g_print ("EV compensation (%.1f) setting failed\n", val);
|
||||||
} else {
|
} else {
|
||||||
gst_photography_get_ev_compensation (GST_PHOTOGRAPHY (gst_camera_bin),
|
gst_photography_get_ev_compensation (GST_PHOTOGRAPHY (gst_videosrc),
|
||||||
&set_val);
|
&set_val);
|
||||||
if (val != set_val) {
|
if (val != set_val) {
|
||||||
g_print ("EV compensation (%.1f) setting failed, got %.1f\n", val,
|
g_print ("EV compensation (%.1f) setting failed, got %.1f\n", val,
|
||||||
|
|
|
@ -85,8 +85,11 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GST_USE_UNSTABLE_API 1
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/interfaces/xoverlay.h>
|
#include <gst/interfaces/xoverlay.h>
|
||||||
|
#include <gst/interfaces/photography.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -102,7 +105,6 @@
|
||||||
*/
|
*/
|
||||||
GST_DEBUG_CATEGORY_STATIC (camerabin_test);
|
GST_DEBUG_CATEGORY_STATIC (camerabin_test);
|
||||||
#define GST_CAT_DEFAULT camerabin_test
|
#define GST_CAT_DEFAULT camerabin_test
|
||||||
|
|
||||||
typedef struct _ResultType
|
typedef struct _ResultType
|
||||||
{
|
{
|
||||||
GstClockTime avg;
|
GstClockTime avg;
|
||||||
|
@ -533,6 +535,7 @@ run_pipeline (gpointer user_data)
|
||||||
GstCaps *preview_caps = NULL;
|
GstCaps *preview_caps = NULL;
|
||||||
gchar *filename_str = NULL;
|
gchar *filename_str = NULL;
|
||||||
GString *filename_buffer = NULL;
|
GString *filename_buffer = NULL;
|
||||||
|
GstElement *video_source = NULL;
|
||||||
|
|
||||||
g_object_set (camera_bin, "mode", mode, NULL);
|
g_object_set (camera_bin, "mode", mode, NULL);
|
||||||
|
|
||||||
|
@ -561,14 +564,21 @@ run_pipeline (gpointer user_data)
|
||||||
g_free (filename_str);
|
g_free (filename_str);
|
||||||
|
|
||||||
|
|
||||||
g_object_set (camera_bin, "ev-compensation", ev_compensation, NULL);
|
g_object_get (camera_bin, "video-source", &video_source, NULL);
|
||||||
g_object_set (camera_bin, "aperture", aperture, NULL);
|
if (video_source) {
|
||||||
g_object_set (camera_bin, "flash-mode", flash_mode, NULL);
|
if (GST_IS_ELEMENT (video_source) &&
|
||||||
g_object_set (camera_bin, "scene-mode", scene_mode, NULL);
|
gst_element_implements_interface (video_source, GST_TYPE_PHOTOGRAPHY)) {
|
||||||
g_object_set (camera_bin, "exposure", exposure, NULL);
|
g_object_set (video_source, "ev-compensation", ev_compensation, NULL);
|
||||||
g_object_set (camera_bin, "iso-speed", iso_speed, NULL);
|
g_object_set (video_source, "aperture", aperture, NULL);
|
||||||
g_object_set (camera_bin, "white-balance-mode", wb_mode, NULL);
|
g_object_set (video_source, "flash-mode", flash_mode, NULL);
|
||||||
g_object_set (camera_bin, "colour-tone-mode", color_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);
|
||||||
|
}
|
||||||
|
g_object_unref (video_source);
|
||||||
|
}
|
||||||
g_object_set (camera_bin, "mute", mute, NULL);
|
g_object_set (camera_bin, "mute", mute, NULL);
|
||||||
g_object_set (camera_bin, "zoom", zoom, NULL);
|
g_object_set (camera_bin, "zoom", zoom, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue