This is a copy of the camerabin2, basecamerabin and photography plugins from gst-plugins-bad. They're needed for applications in Ubuntu main, so we move them here.

Forwarded: not-needed

Gbp-Pq: Name import-camerabin
This commit is contained in:
Ubuntu Developers 2015-02-23 18:49:31 -03:00 committed by openKylinBot
parent 55e8a5c7bf
commit d8e08c63b9
42 changed files with 16699 additions and 1 deletions

View File

@ -1,6 +1,7 @@
DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
ALWAYS_SUBDIRS = \
gst-libs \
gst sys ext \
tests \
docs \

View File

@ -295,6 +295,7 @@ AC_SUBST(GSTPB_PREFIX)
dnl GTK is optional and used in examples
HAVE_GTK=no
HAVE_GTK3=no
GTK_REQ=3.0.0
if test "x$BUILD_EXAMPLES" = "xyes"; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQ, HAVE_GTK=yes, HAVE_GTK=no)
@ -304,8 +305,20 @@ if test "x$BUILD_EXAMPLES" = "xyes"; then
AC_SUBST(GTK_CFLAGS)
fi
AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes")
AM_CONDITIONAL(HAVE_GTK3, test "x$HAVE_GTK" = "xyes")
AM_CONDITIONAL(HAVE_GTK_X11, test "x$HAVE_GTK_X11" = "xyes")
dnl x11 is optional for librfb
HAVE_X11=NO
PKG_CHECK_MODULES(X11, x11, HAVE_X11=yes, HAVE_X11=no)
AC_SUBST(X11_LIBS)
AC_SUBST(X11_CFLAGS)
AC_SUBST(HAVE_X11)
AM_CONDITIONAL(HAVE_X11, test "x$HAVE_X11" = "xyes")
if test "x$HAVE_X11" = "xyes"; then
AC_DEFINE(HAVE_X11, 1, [Define if you have X11 library])
fi
dnl Check for -Bsymbolic-functions linker flag used to avoid
dnl intra-library PLT jumps, if available.
AC_ARG_ENABLE(Bsymbolic,
@ -380,6 +393,7 @@ AG_GST_CHECK_PLUGIN(audioparsers)
AG_GST_CHECK_PLUGIN(auparse)
AG_GST_CHECK_PLUGIN(autodetect)
AG_GST_CHECK_PLUGIN(avi)
AG_GST_CHECK_PLUGIN(camerabin2)
AG_GST_CHECK_PLUGIN(cutter)
AG_GST_CHECK_PLUGIN(debugutils)
AG_GST_CHECK_PLUGIN(deinterlace)
@ -1162,7 +1176,13 @@ fi
AC_SUBST(DEPRECATED_CFLAGS)
VISIBILITY_CFLAGS=""
AS_COMPILER_FLAG([-fvisibility=hidden], [VISIBILITY_CFLAGS="-fvisibility=hidden"])
AS_COMPILER_FLAG([-fvisibility=hidden], [
VISIBILITY_CFLAGS="-fvisibility=hidden"
AC_DEFINE(GST_API_EXPORT, [extern __attribute__ ((visibility ("default")))], [public symbol export define])
], [
VISIBILITY_CFLAGS=""
AC_DEFINE(GST_API_EXPORT, [extern], [public symbol export define])
])
AC_SUBST(VISIBILITY_CFLAGS)
VISIBILITY_CXXFLAGS=""
@ -1228,6 +1248,7 @@ gst/audioparsers/Makefile
gst/auparse/Makefile
gst/autodetect/Makefile
gst/avi/Makefile
gst/camerabin2/Makefile
gst/cutter/Makefile
gst/deinterlace/Makefile
gst/dtmf/Makefile
@ -1264,6 +1285,10 @@ gst/wavenc/Makefile
gst/wavparse/Makefile
gst/flx/Makefile
gst/y4m/Makefile
gst-libs/Makefile
gst-libs/gst/Makefile
gst-libs/gst/interfaces/Makefile
gst-libs/gst/basecamerabinsrc/Makefile
ext/Makefile
ext/aalib/Makefile
ext/cairo/Makefile
@ -1301,6 +1326,7 @@ tests/Makefile
tests/check/Makefile
tests/examples/Makefile
tests/examples/audiofx/Makefile
tests/examples/camerabin2/Makefile
tests/examples/cairo/Makefile
tests/examples/equalizer/Makefile
tests/examples/gtk/Makefile

1
gst-libs/Makefile.am Normal file
View File

@ -0,0 +1 @@
SUBDIRS = gst

3
gst-libs/gst/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
SUBDIRS = interfaces basecamerabinsrc
DIST_SUBDIRS = interfaces basecamerabinsrc

View File

@ -0,0 +1,27 @@
lib_LTLIBRARIES = libgstbasecamerabinsrc-@GST_API_VERSION@.la
CLEANFILES = $(BUILT_SOURCES)
libgstbasecamerabinsrc_@GST_API_VERSION@_la_SOURCES = \
gstcamerabin-enum.c \
gstcamerabinpreview.c \
gstbasecamerasrc.c
libgstbasecamerabinsrc_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/basecamerabinsrc
libgstbasecamerabinsrc_@GST_API_VERSION@include_HEADERS = \
basecamerabinsrc-prelude.h \
gstcamerabin-enum.h \
gstcamerabinpreview.h \
gstbasecamerasrc.h
libgstbasecamerabinsrc_@GST_API_VERSION@_la_CFLAGS = \
$(GST_PLUGINS_BAD_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
-DGST_USE_UNSTABLE_API \
-DBUILDING_GST_BASE_CAMERA_BIN_SRC \
$(GST_CFLAGS)
libgstbasecamerabinsrc_@GST_API_VERSION@_la_LIBADD = \
-lgstapp-$(GST_API_VERSION) $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS)
libgstbasecamerabinsrc_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
/* GStreamer BaseCameraBinSrc Library
* Copyright (C) 2018 GStreamer developers
*
* basecamerasrc-prelude.h: prelude include header for gst-basecamerasrc library
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_BASE_CAMERA_BIN_SRC_PRELUDE_H__
#define __GST_BASE_CAMERA_BIN_SRC_PRELUDE_H__
#include <gst/gst.h>
#ifndef GST_BASE_CAMERA_BIN_SRC_API
# ifdef BUILDING_GST_BASE_CAMERA_BIN_SRC
# define GST_BASE_CAMERA_BIN_SRC_API GST_API_EXPORT /* from config.h */
# else
# define GST_BASE_CAMERA_BIN_SRC_API GST_API_IMPORT
# endif
#endif
#endif /* __GST_BASE_CAMERA_BIN_SRC_PRELUDE_H__ */

View File

@ -0,0 +1,584 @@
/*
* GStreamer
* Copyright (C) 2010 Texas Instruments, Inc
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-basecamerasrc
*
* Base class for the camera source bin used by camerabin for capture.
* Sophisticated camera hardware can derive from this baseclass and map the
* features to this interface.
*
* The design mandates that the subclasses implement the following features and
* behaviour:
* <itemizedlist>
* <listitem><para>
* 3 pads: viewfinder, image capture, video capture
* </para></listitem>
* <listitem><para>
* </para></listitem>
* </itemizedlist>
*
* During construct_pipeline() vmethod a subclass can add several elements into
* the bin and expose 3 srcs pads as ghostpads implementing the 3 pad templates.
*
* However the subclass is responsible for adding the pad templates for the
* source pads and they must be named "vidsrc", "imgsrc" and "vfsrc". The pad
* templates should be installed in the subclass' class_init function, like so:
* |[
* static void
* my_element_class_init (GstMyElementClass *klass)
* {
* GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
* // pad templates should be a #GstStaticPadTemplate with direction
* // #GST_PAD_SRC and name "vidsrc", "imgsrc" and "vfsrc"
* gst_element_class_add_static_pad_template (gstelement_class,
* &amp;vidsrc_template);
* gst_element_class_add_static_pad_template (gstelement_class,
* &amp;imgsrc_template);
* gst_element_class_add_static_pad_template (gstelement_class,
* &amp;vfsrc_template);
* // see #GstElementDetails
* gst_element_class_set_details (gstelement_class, &amp;details);
* }
* ]|
*
* It is also possible to add regular pads from the subclass and implement the
* dataflow methods on these pads. This way all functionality can be implemented
* directly in the subclass without extra elements.
*
* The src will receive the capture mode from #GstCameraBin2 on the
* #GstBaseCameraSrc:mode property. Possible capture modes are defined in
* #GstCameraBinMode.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gst/glib-compat-private.h>
#include "gstbasecamerasrc.h"
enum
{
PROP_0,
PROP_MODE,
PROP_ZOOM,
PROP_MAX_ZOOM,
PROP_READY_FOR_CAPTURE,
PROP_POST_PREVIEW,
PROP_PREVIEW_CAPS,
PROP_PREVIEW_FILTER,
PROP_AUTO_START
};
enum
{
/* action signals */
START_CAPTURE_SIGNAL,
STOP_CAPTURE_SIGNAL,
/* emit signals */
LAST_SIGNAL
};
#define DEFAULT_POST_PREVIEW TRUE
#define DEFAULT_AUTO_START FALSE
static guint basecamerasrc_signals[LAST_SIGNAL];
GST_DEBUG_CATEGORY (base_camera_src_debug);
#define GST_CAT_DEFAULT base_camera_src_debug
#define parent_class gst_base_camera_src_parent_class
G_DEFINE_TYPE (GstBaseCameraSrc, gst_base_camera_src, GST_TYPE_BIN);
/* NOTE: we could provide a vmethod for derived class to overload to provide
* it's own implementation of interface.. but in all cases I can think of at
* moment, either the camerasrc itself, or some element within the bin, will
* be implementing the interface..
*/
/**
* gst_base_camera_src_set_mode:
* @self: the camerasrc bin
* @mode: the mode
*
* Set the chosen #GstCameraBinMode capture mode.
*/
gboolean
gst_base_camera_src_set_mode (GstBaseCameraSrc * self, GstCameraBinMode mode)
{
GstBaseCameraSrcClass *bclass = GST_BASE_CAMERA_SRC_GET_CLASS (self);
g_return_val_if_fail (bclass->set_mode, FALSE);
if (bclass->set_mode (self, mode)) {
self->mode = mode;
return TRUE;
}
return FALSE;
}
/**
* gst_base_camera_src_setup_zoom:
* @self: camerasrc object
*
* Apply zoom configured to camerabin to capture.
*/
void
gst_base_camera_src_setup_zoom (GstBaseCameraSrc * self)
{
GstBaseCameraSrcClass *bclass = GST_BASE_CAMERA_SRC_GET_CLASS (self);
g_return_if_fail (self->zoom);
g_return_if_fail (bclass->set_zoom);
bclass->set_zoom (self, self->zoom);
}
/**
* gst_base_camera_src_setup_preview:
* @self: camerasrc bin
* @preview_caps: preview caps to set
*
* Apply preview caps to preview pipeline and to video source.
*/
void
gst_base_camera_src_setup_preview (GstBaseCameraSrc * self,
GstCaps * preview_caps)
{
GstBaseCameraSrcClass *bclass = GST_BASE_CAMERA_SRC_GET_CLASS (self);
if (self->preview_pipeline) {
GST_DEBUG_OBJECT (self,
"Setting preview pipeline caps %" GST_PTR_FORMAT, self->preview_caps);
gst_camerabin_preview_set_caps (self->preview_pipeline, preview_caps);
}
if (bclass->set_preview)
bclass->set_preview (self, preview_caps);
}
static void
gst_base_camera_src_start_capture (GstBaseCameraSrc * src)
{
GstBaseCameraSrcClass *klass = GST_BASE_CAMERA_SRC_GET_CLASS (src);
g_return_if_fail (klass->start_capture != NULL);
GST_DEBUG_OBJECT (src, "Starting capture");
g_mutex_lock (&src->capturing_mutex);
if (src->capturing) {
GST_WARNING_OBJECT (src, "Capturing already ongoing");
g_mutex_unlock (&src->capturing_mutex);
/* post a warning to notify camerabin2 that the capture failed */
GST_ELEMENT_WARNING (src, RESOURCE, BUSY, (NULL), (NULL));
return;
}
src->capturing = TRUE;
g_object_notify (G_OBJECT (src), "ready-for-capture");
if (klass->start_capture (src)) {
GST_DEBUG_OBJECT (src, "Capture started");
} else {
src->capturing = FALSE;
g_object_notify (G_OBJECT (src), "ready-for-capture");
GST_WARNING_OBJECT (src, "Failed to start capture");
}
g_mutex_unlock (&src->capturing_mutex);
}
static void
gst_base_camera_src_stop_capture (GstBaseCameraSrc * src)
{
GstBaseCameraSrcClass *klass = GST_BASE_CAMERA_SRC_GET_CLASS (src);
g_return_if_fail (klass->stop_capture != NULL);
g_mutex_lock (&src->capturing_mutex);
if (!src->capturing) {
GST_DEBUG_OBJECT (src, "No ongoing capture");
g_mutex_unlock (&src->capturing_mutex);
return;
}
klass->stop_capture (src);
g_mutex_unlock (&src->capturing_mutex);
}
void
gst_base_camera_src_finish_capture (GstBaseCameraSrc * self)
{
GST_DEBUG_OBJECT (self, "Finishing capture");
g_return_if_fail (self->capturing);
self->capturing = FALSE;
g_object_notify (G_OBJECT (self), "ready-for-capture");
}
static void
gst_base_camera_src_dispose (GObject * object)
{
GstBaseCameraSrc *src = GST_BASE_CAMERA_SRC_CAST (object);
g_mutex_clear (&src->capturing_mutex);
if (src->preview_pipeline) {
gst_camerabin_destroy_preview_pipeline (src->preview_pipeline);
src->preview_pipeline = NULL;
}
if (src->preview_caps)
gst_caps_replace (&src->preview_caps, NULL);
if (src->preview_filter) {
gst_object_unref (src->preview_filter);
src->preview_filter = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_base_camera_src_finalize (GstBaseCameraSrc * self)
{
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) (self));
}
static void
gst_base_camera_src_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (object);
switch (prop_id) {
case PROP_MODE:
gst_base_camera_src_set_mode (GST_BASE_CAMERA_SRC (self),
g_value_get_enum (value));
break;
case PROP_ZOOM:{
self->zoom = g_value_get_float (value);
/* limit to max-zoom */
if (self->zoom > self->max_zoom) {
GST_DEBUG_OBJECT (self, "Clipping zoom %f to max-zoom %f", self->zoom,
self->max_zoom);
self->zoom = self->max_zoom;
}
/* does not set it if in NULL, the src is not created yet */
if (GST_STATE (self) != GST_STATE_NULL)
gst_base_camera_src_setup_zoom (self);
break;
}
case PROP_POST_PREVIEW:
self->post_preview = g_value_get_boolean (value);
break;
case PROP_PREVIEW_CAPS:{
GstCaps *new_caps;
new_caps = (GstCaps *) gst_value_get_caps (value);
if (new_caps == NULL) {
new_caps = gst_caps_new_any ();
} else {
new_caps = gst_caps_ref (new_caps);
}
if (!gst_caps_is_equal (self->preview_caps, new_caps)) {
gst_caps_replace (&self->preview_caps, new_caps);
gst_base_camera_src_setup_preview (self, new_caps);
} else {
GST_DEBUG_OBJECT (self, "New preview caps equal current preview caps");
}
gst_caps_unref (new_caps);
}
break;
case PROP_PREVIEW_FILTER:
if (self->preview_filter)
gst_object_unref (self->preview_filter);
self->preview_filter = g_value_dup_object (value);
if (!gst_camerabin_preview_set_filter (self->preview_pipeline,
self->preview_filter)) {
GST_WARNING_OBJECT (self,
"Cannot change preview filter, is element in NULL state?");
}
break;
case PROP_AUTO_START:
self->auto_start = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
break;
}
}
static void
gst_base_camera_src_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (object);
switch (prop_id) {
case PROP_MODE:
g_value_set_enum (value, self->mode);
break;
case PROP_READY_FOR_CAPTURE:
g_value_set_boolean (value, !self->capturing);
break;
case PROP_ZOOM:
g_value_set_float (value, self->zoom);
break;
case PROP_MAX_ZOOM:
g_value_set_float (value, self->max_zoom);
break;
case PROP_POST_PREVIEW:
g_value_set_boolean (value, self->post_preview);
break;
case PROP_PREVIEW_CAPS:
if (self->preview_caps)
gst_value_set_caps (value, self->preview_caps);
break;
case PROP_PREVIEW_FILTER:
if (self->preview_filter)
g_value_set_object (value, self->preview_filter);
break;
case PROP_AUTO_START:
g_value_set_boolean (value, self->auto_start);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
break;
}
}
static gboolean
construct_pipeline (GstBaseCameraSrc * self)
{
GstBaseCameraSrcClass *bclass = GST_BASE_CAMERA_SRC_GET_CLASS (self);
if (bclass->construct_pipeline) {
if (!bclass->construct_pipeline (self)) {
GST_ERROR_OBJECT (self, "pipeline construction failed");
return FALSE;
}
}
return TRUE;
}
static gboolean
setup_pipeline (GstBaseCameraSrc * self)
{
GstBaseCameraSrcClass *bclass = GST_BASE_CAMERA_SRC_GET_CLASS (self);
if (bclass->setup_pipeline)
return bclass->setup_pipeline (self);
return TRUE;
}
static GstStateChangeReturn
gst_base_camera_src_change_state (GstElement * element,
GstStateChange transition)
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstBaseCameraSrc *self = GST_BASE_CAMERA_SRC (element);
GST_DEBUG_OBJECT (self, "%d -> %d",
GST_STATE_TRANSITION_CURRENT (transition),
GST_STATE_TRANSITION_NEXT (transition));
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!construct_pipeline (self))
return GST_STATE_CHANGE_FAILURE;
if (self->preview_pipeline == NULL) {
/* failed to create preview pipeline, fail state change */
return GST_STATE_CHANGE_FAILURE;
}
if (self->preview_caps) {
GST_DEBUG_OBJECT (self,
"Setting preview pipeline caps %" GST_PTR_FORMAT,
self->preview_caps);
gst_camerabin_preview_set_caps (self->preview_pipeline,
self->preview_caps);
}
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!setup_pipeline (self))
return GST_STATE_CHANGE_FAILURE;
/* without this the preview pipeline will not post buffer
* messages on the pipeline */
gst_element_set_state (self->preview_pipeline->pipeline,
GST_STATE_PLAYING);
if (self->auto_start)
g_signal_emit_by_name (G_OBJECT (self), "start-capture", NULL);
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_element_set_state (self->preview_pipeline->pipeline, GST_STATE_READY);
if (self->auto_start)
g_signal_emit_by_name (G_OBJECT (self), "stop-capture", NULL);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_element_set_state (self->preview_pipeline->pipeline, GST_STATE_NULL);
break;
default:
break;
}
return ret;
}
static void
gst_base_camera_src_class_init (GstBaseCameraSrcClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GST_DEBUG_CATEGORY_INIT (base_camera_src_debug, "base_camera_src", 0,
"Base camera src");
gobject_class = G_OBJECT_CLASS (klass);
gstelement_class = GST_ELEMENT_CLASS (klass);
gobject_class->dispose = gst_base_camera_src_dispose;
gobject_class->finalize = (GObjectFinalizeFunc) gst_base_camera_src_finalize;
gobject_class->set_property = gst_base_camera_src_set_property;
gobject_class->get_property = gst_base_camera_src_get_property;
g_object_class_install_property (gobject_class, PROP_MODE,
g_param_spec_enum ("mode", "Mode",
"The capture mode (still image capture or video recording)",
GST_TYPE_CAMERABIN_MODE, MODE_IMAGE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ZOOM,
g_param_spec_float ("zoom", "Zoom",
"Digital zoom factor (e.g. 1.5 means 1.5x)", MIN_ZOOM, G_MAXFLOAT,
DEFAULT_ZOOM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MAX_ZOOM,
g_param_spec_float ("max-zoom", "Maximum zoom level (note: may change "
"depending on resolution/implementation)",
"Digital zoom factor (e.g. 1.5 means 1.5x)", MIN_ZOOM, G_MAXFLOAT,
MAX_ZOOM, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstBaseCameraSrc:post-previews:
*
* When %TRUE, preview images should be posted to the bus when
* captures are made
*/
g_object_class_install_property (gobject_class, PROP_POST_PREVIEW,
g_param_spec_boolean ("post-previews", "Post Previews",
"If capture preview images should be posted to the bus",
DEFAULT_POST_PREVIEW, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PREVIEW_CAPS,
g_param_spec_boxed ("preview-caps", "Preview caps",
"The caps of the preview image to be posted (NULL means ANY)",
GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PREVIEW_FILTER,
g_param_spec_object ("preview-filter", "Preview filter",
"A custom preview filter to process preview image data",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_AUTO_START,
g_param_spec_boolean ("auto-start", "Auto start capture",
"Automatically starts capture when going to the PAUSED state",
DEFAULT_AUTO_START, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstBaseCameraSrc:ready-for-capture:
*
* When TRUE new capture can be prepared. If FALSE capturing is ongoing
* and starting a new capture immediately is not possible.
*
* Note that calling start-capture from the notify callback of this property
* will cause a deadlock. If you need to react like this on the notify
* function, please schedule a new thread to do it. If you're using glib's
* mainloop you can use g_idle_add() for example.
*/
g_object_class_install_property (gobject_class, PROP_READY_FOR_CAPTURE,
g_param_spec_boolean ("ready-for-capture", "Ready for capture",
"Informs this element is ready for starting another capture",
TRUE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/* Signals */
basecamerasrc_signals[START_CAPTURE_SIGNAL] =
g_signal_new_class_handler ("start-capture",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (gst_base_camera_src_start_capture),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
basecamerasrc_signals[STOP_CAPTURE_SIGNAL] =
g_signal_new_class_handler ("stop-capture",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_CALLBACK (gst_base_camera_src_stop_capture),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gstelement_class->change_state = gst_base_camera_src_change_state;
gst_element_class_set_static_metadata (gstelement_class,
"Base class for camerabin src bin", "Source/Video",
"Abstracts capture device for camerabin2", "Rob Clark <rob@ti.com>");
}
static void
gst_base_camera_src_init (GstBaseCameraSrc * self)
{
self->width = DEFAULT_WIDTH;
self->height = DEFAULT_HEIGHT;
self->zoom = DEFAULT_ZOOM;
self->max_zoom = MAX_ZOOM;
self->mode = MODE_IMAGE;
self->auto_start = DEFAULT_AUTO_START;
self->capturing = FALSE;
g_mutex_init (&self->capturing_mutex);
self->post_preview = DEFAULT_POST_PREVIEW;
self->preview_caps = gst_caps_new_any ();
self->preview_pipeline =
gst_camerabin_create_preview_pipeline (GST_ELEMENT_CAST (self), NULL);
}
void
gst_base_camera_src_post_preview (GstBaseCameraSrc * self, GstSample * sample)
{
if (self->post_preview) {
gst_camerabin_preview_pipeline_post (self->preview_pipeline, sample);
} else {
GST_DEBUG_OBJECT (self, "Previews not enabled, not posting");
}
}

View File

@ -0,0 +1,156 @@
/*
* GStreamer
* Copyright (C) 2010 Texas Instruments, Inc
* Copyright (C) 2011 Thiago Santos <thiago.sousa.santos@collabora.com>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_BASE_CAMERA_SRC_H__
#define __GST_BASE_CAMERA_SRC_H__
#ifndef GST_USE_UNSTABLE_API
#warning "GstBaseCameraSrc is unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <gst/gst.h>
#include <gst/gstbin.h>
#include "basecamerabinsrc-prelude.h"
#include "gstcamerabin-enum.h"
#include "gstcamerabinpreview.h"
G_BEGIN_DECLS
#define GST_TYPE_BASE_CAMERA_SRC \
(gst_base_camera_src_get_type())
#define GST_BASE_CAMERA_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_CAMERA_SRC,GstBaseCameraSrc))
#define GST_BASE_CAMERA_SRC_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_CAMERA_SRC, GstBaseCameraSrcClass))
#define GST_BASE_CAMERA_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_CAMERA_SRC,GstBaseCameraSrcClass))
#define GST_IS_BASE_CAMERA_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_CAMERA_SRC))
#define GST_IS_BASE_CAMERA_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_CAMERA_SRC))
#define GST_BASE_CAMERA_SRC_CAST(obj) \
((GstBaseCameraSrc *) (obj))
GST_BASE_CAMERA_BIN_SRC_API
GType gst_base_camera_src_get_type (void);
typedef struct _GstBaseCameraSrc GstBaseCameraSrc;
typedef struct _GstBaseCameraSrcClass GstBaseCameraSrcClass;
#define GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME "vfsrc"
#define GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME "imgsrc"
#define GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME "vidsrc"
#define GST_BASE_CAMERA_SRC_PREVIEW_MESSAGE_NAME "preview-image"
/**
* GstBaseCameraSrc:
*/
struct _GstBaseCameraSrc
{
GstBin parent;
GstCameraBinMode mode;
gboolean auto_start;
gboolean capturing;
GMutex capturing_mutex;
/* Preview convert pipeline */
GstCaps *preview_caps;
gboolean post_preview;
GstElement *preview_filter;
GstCameraBinPreviewPipelineData *preview_pipeline;
/* Resolution of the buffers configured to camerabin */
gint width;
gint height;
gfloat zoom;
gfloat max_zoom;
gpointer _gst_reserved[GST_PADDING_LARGE];
};
/**
* GstBaseCameraSrcClass:
* @construct_pipeline: construct pipeline
* @setup_pipeline: configure pipeline for the chosen settings
* @set_zoom: set the zoom
* @set_mode: set the mode
*/
struct _GstBaseCameraSrcClass
{
GstBinClass parent;
/* Construct pipeline. (called in GST_STATE_CHANGE_NULL_TO_READY) Optional. */
gboolean (*construct_pipeline) (GstBaseCameraSrc *self);
/* (called in GST_STATE_CHANGE_READY_TO_PAUSED). Optional. */
gboolean (*setup_pipeline) (GstBaseCameraSrc *self);
/* Set the zoom. If set, called when changing 'zoom' property. Optional. */
void (*set_zoom) (GstBaseCameraSrc *self, gfloat zoom);
/* Set the mode. If set, called when changing 'mode' property. Optional. */
gboolean (*set_mode) (GstBaseCameraSrc *self,
GstCameraBinMode mode);
/* Set preview caps. If set, called called when setting new 'preview-caps'. Optional. */
gboolean (*set_preview) (GstBaseCameraSrc *self,
GstCaps *preview_caps);
/* Called by the handler for 'start-capture'. Mandatory. */
gboolean (*start_capture) (GstBaseCameraSrc * src);
/* Called by the handler for 'stop-capture'. Mandatory. */
void (*stop_capture) (GstBaseCameraSrc * src);
gpointer _gst_reserved[GST_PADDING_LARGE];
};
#define MIN_ZOOM 1.0f
#define MAX_ZOOM 10.0f
#define ZOOM_1X MIN_ZOOM
GST_BASE_CAMERA_BIN_SRC_API
gboolean gst_base_camera_src_set_mode (GstBaseCameraSrc *self, GstCameraBinMode mode);
GST_BASE_CAMERA_BIN_SRC_API
void gst_base_camera_src_setup_zoom (GstBaseCameraSrc * self);
GST_BASE_CAMERA_BIN_SRC_API
void gst_base_camera_src_setup_preview (GstBaseCameraSrc * self, GstCaps * preview_caps);
GST_BASE_CAMERA_BIN_SRC_API
void gst_base_camera_src_finish_capture (GstBaseCameraSrc *self);
GST_BASE_CAMERA_BIN_SRC_API
void gst_base_camera_src_post_preview (GstBaseCameraSrc *self, GstSample * sample);
// XXX add methods to get/set img capture and vid capture caps..
G_END_DECLS
#endif /* __GST_BASE_CAMERA_SRC_H__ */

View File

@ -0,0 +1,42 @@
/*
* GStreamer
* Copyright (C) 2009 Nokia Corporation <multimedia@maemo.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstcamerabin-enum.h"
GType
gst_camerabin_mode_get_type (void)
{
static GType gtype = 0;
if (gtype == 0) {
static const GEnumValue values[] = {
/* {MODE_PREVIEW, "Preview mode (should be default?)", "mode-preview"}, */
{MODE_IMAGE, "Still image capture (default)", "mode-image"},
{MODE_VIDEO, "Video recording", "mode-video"},
{0, NULL, NULL}
};
gtype = g_enum_register_static ("GstCameraBin2Mode", values);
}
return gtype;
}

View File

@ -0,0 +1,64 @@
/*
* GStreamer
* Copyright (C) 2009 Nokia Corporation <multimedia@maemo.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CAMERABIN_ENUM_H__
#define __GST_CAMERABIN_ENUM_H__
#ifndef GST_USE_UNSTABLE_API
#warning "camerabin enums are unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <gst/gst.h>
#include "basecamerabinsrc-prelude.h"
G_BEGIN_DECLS
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define DEFAULT_CAPTURE_WIDTH 800
#define DEFAULT_CAPTURE_HEIGHT 600
#define DEFAULT_FPS_N 0 /* makes it use the default */
#define DEFAULT_FPS_D 1
#define DEFAULT_ZOOM MIN_ZOOM
/**
* GstCameraBinMode:
* @MODE_IMAGE: image capture
* @MODE_VIDEO: video capture
*
* Capture mode to use.
*/
typedef enum
{
/* MODE_PREVIEW = 0, No use for this */
MODE_IMAGE = 1,
MODE_VIDEO = 2,
} GstCameraBinMode;
#define GST_TYPE_CAMERABIN_MODE (gst_camerabin_mode_get_type ())
GST_BASE_CAMERA_BIN_SRC_API
GType gst_camerabin_mode_get_type (void);
G_END_DECLS
#endif /* #ifndef __GST_CAMERABIN_ENUM_H__ */

View File

@ -0,0 +1,412 @@
/*
* GStreamer
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:camerabingeneral
* @short_description: helper functions for #GstCameraBin and it's modules
*
* Common helper functions for #GstCameraBin, #GstCameraBinImage and
* #GstCameraBinVideo.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/app/gstappsrc.h>
#include <gst/app/gstappsink.h>
#include <gst/glib-compat-private.h>
#include "gstcamerabinpreview.h"
#include "gstbasecamerasrc.h"
GST_DEBUG_CATEGORY_EXTERN (base_camera_src_debug);
#define GST_CAT_DEFAULT base_camera_src_debug
static void _gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData *
preview, GstCaps * caps);
static gboolean
bus_callback (GstBus * bus, GstMessage * message, gpointer user_data)
{
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:{
GError *err;
GstCameraBinPreviewPipelineData *data;
data = user_data;
gst_message_parse_error (message, &err, NULL);
GST_WARNING ("Error from preview pipeline: %s", err->message);
g_error_free (err);
/* TODO Not sure if we should post an Error or Warning here */
GST_ELEMENT_ERROR (data, CORE, FAILED,
("fatal error in preview pipeline, disposing the pipeline"), (NULL));
/* Possible error situations:
* 1) cond_wait pending. prevent deadlock by signalling the cond
* 2) preview_pipeline_post called with new buffer to handle. returns
* because data->pipeline is set to null
* 3) new preview caps incoming. returns because data->pipeline is null
*/
if (data->pipeline) {
gst_element_set_state (data->pipeline, GST_STATE_NULL);
gst_object_unref (data->pipeline);
data->pipeline = NULL;
}
g_cond_signal (&data->processing_cond);
break;
}
default:
break;
}
return TRUE;
}
static GstFlowReturn
gst_camerabin_preview_pipeline_new_sample (GstAppSink * appsink,
gpointer user_data)
{
GstSample *sample;
GstStructure *s;
GstMessage *msg;
GstCameraBinPreviewPipelineData *data;
data = user_data;
sample = gst_app_sink_pull_sample (appsink);
s = gst_structure_new (GST_BASE_CAMERA_SRC_PREVIEW_MESSAGE_NAME,
"sample", GST_TYPE_SAMPLE, sample, NULL);
gst_sample_unref (sample);
msg = gst_message_new_element (GST_OBJECT (data->element), s);
GST_DEBUG_OBJECT (data->element, "sending message with preview image");
if (gst_element_post_message (data->element, msg) == FALSE) {
GST_WARNING_OBJECT (data->element,
"This element has no bus, therefore no message sent!");
}
g_mutex_lock (&data->processing_lock);
data->processing--;
if (data->processing == 0)
g_cond_signal (&data->processing_cond);
g_mutex_unlock (&data->processing_lock);
return GST_FLOW_OK;
}
/**
* gst_camerabin_create_preview_pipeline:
* @element: Owner of this pipeline
* @filter: Custom filter to process preview data (an extra ref is taken)
*
* Creates a new previewing pipeline that can receive buffers
* to be posted as camerabin preview messages for @element
*
* Returns: The newly created #GstCameraBinPreviewPipelineData
*/
GstCameraBinPreviewPipelineData *
gst_camerabin_create_preview_pipeline (GstElement * element,
GstElement * filter)
{
GstCameraBinPreviewPipelineData *data;
GstElement *csp;
GstElement *vscale;
gboolean added = FALSE;
gboolean linkfail = FALSE;
GstBus *bus;
GstAppSinkCallbacks callbacks = { 0, };
data = g_new0 (GstCameraBinPreviewPipelineData, 1);
data->pipeline = gst_pipeline_new ("preview-pipeline");
data->appsrc = gst_element_factory_make ("appsrc", "preview-appsrc");
data->appsink = gst_element_factory_make ("appsink", "preview-appsink");
csp = gst_element_factory_make ("videoconvert", "preview-vconv");
vscale = gst_element_factory_make ("videoscale", "preview-vscale");
if (!data->appsrc || !data->appsink || !csp || !vscale) {
goto error;
}
g_object_set (data->appsrc, "emit-signals", FALSE, NULL);
g_object_set (data->appsink, "sync", FALSE, "enable-last-sample",
FALSE, NULL);
gst_bin_add_many (GST_BIN (data->pipeline), data->appsrc,
data->appsink, csp, vscale, NULL);
if (filter)
gst_bin_add (GST_BIN (data->pipeline), gst_object_ref (filter));
added = TRUE;
if (filter) {
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (data->appsrc, "src",
filter, NULL, GST_PAD_LINK_CHECK_NOTHING));
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (filter, NULL,
vscale, "sink", GST_PAD_LINK_CHECK_CAPS));
} else {
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (data->appsrc, "src",
vscale, "sink", GST_PAD_LINK_CHECK_NOTHING));
}
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (vscale, "src", csp,
"sink", GST_PAD_LINK_CHECK_NOTHING));
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (csp, "src",
data->appsink, "sink", GST_PAD_LINK_CHECK_NOTHING));
if (linkfail) {
GST_WARNING ("Failed to link preview pipeline elements");
goto error;
}
callbacks.new_sample = gst_camerabin_preview_pipeline_new_sample;
gst_app_sink_set_callbacks ((GstAppSink *) data->appsink, &callbacks, data,
NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (data->pipeline));
gst_bus_add_watch (bus, bus_callback, data);
gst_object_unref (bus);
g_object_set (data->appsink, "sync", FALSE, NULL);
data->element = element;
data->filter = filter;
data->vscale = vscale;
g_mutex_init (&data->processing_lock);
g_cond_init (&data->processing_cond);
data->pending_preview_caps = NULL;
data->processing = 0;
return data;
error:
GST_WARNING ("Failed to create camerabin's preview pipeline");
if (!added) {
if (csp)
gst_object_unref (csp);
if (vscale)
gst_object_unref (vscale);
if (data->appsrc)
gst_object_unref (data->appsrc);
if (data->appsink)
gst_object_unref (data->appsink);
}
gst_camerabin_destroy_preview_pipeline (data);
return NULL;
}
/**
* gst_camerabin_destroy_preview_pipeline:
* @preview: the #GstCameraBinPreviewPipelineData
*
* Frees a #GstCameraBinPreviewPipelineData
*/
void
gst_camerabin_destroy_preview_pipeline (GstCameraBinPreviewPipelineData *
preview)
{
g_return_if_fail (preview != NULL);
g_mutex_clear (&preview->processing_lock);
g_cond_clear (&preview->processing_cond);
if (preview->pipeline) {
GstBus *bus;
gst_element_set_state (preview->pipeline, GST_STATE_NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (preview->pipeline));
gst_bus_remove_watch (bus);
gst_object_unref (bus);
gst_object_unref (preview->pipeline);
}
g_free (preview);
}
/**
* gst_camerabin_preview_pipeline_post:
* @preview: the #GstCameraBinPreviewPipelineData
* @sample: the sample to be posted as a preview
*
* Converts the @sample to the desired format and posts the preview
* message to the bus.
*
* Returns: %TRUE on success
*/
gboolean
gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview,
GstSample * sample)
{
g_return_val_if_fail (preview != NULL, FALSE);
g_return_val_if_fail (preview->pipeline != NULL, FALSE);
g_return_val_if_fail (sample, FALSE);
g_mutex_lock (&preview->processing_lock);
g_return_val_if_fail (preview->pipeline != NULL, FALSE);
if (preview->pending_preview_caps) {
if (preview->processing > 0) {
g_cond_wait (&preview->processing_cond, &preview->processing_lock);
}
_gst_camerabin_preview_set_caps (preview, preview->pending_preview_caps);
gst_caps_replace (&preview->pending_preview_caps, NULL);
}
preview->processing++;
g_object_set (preview->appsrc, "caps", gst_sample_get_caps (sample), NULL);
gst_app_src_push_buffer ((GstAppSrc *) preview->appsrc,
gst_buffer_ref (gst_sample_get_buffer (sample)));
g_mutex_unlock (&preview->processing_lock);
return TRUE;
}
static void
_gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview,
GstCaps * caps)
{
GstState state, pending;
GstStateChangeReturn ret;
g_return_if_fail (preview != NULL);
g_return_if_fail (preview->pipeline != NULL);
ret = gst_element_get_state (preview->pipeline, &state, &pending, 0);
if (ret == GST_STATE_CHANGE_FAILURE) {
/* make it try again */
state = GST_STATE_PLAYING;
pending = GST_STATE_VOID_PENDING;
}
gst_element_set_state (preview->pipeline, GST_STATE_NULL);
g_object_set (preview->appsink, "caps", caps, NULL);
if (pending != GST_STATE_VOID_PENDING)
state = pending;
gst_element_set_state (preview->pipeline, state);
}
/**
* gst_camerabin_preview_set_caps:
* @preview: the #GstCameraBinPreviewPipelineData
* @caps: the #GstCaps to be set (a new ref will be taken)
*
* The caps that preview buffers should have when posted
* on the bus
*/
void
gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview,
GstCaps * caps)
{
g_return_if_fail (preview != NULL);
g_mutex_lock (&preview->processing_lock);
if (preview->processing == 0) {
_gst_camerabin_preview_set_caps (preview, caps);
} else {
GST_DEBUG ("Preview pipeline busy, storing new caps as pending");
gst_caps_replace (&preview->pending_preview_caps, caps);
}
g_mutex_unlock (&preview->processing_lock);
}
/**
* gst_camerabin_preview_set_filter:
* @preview: the #GstCameraBinPreviewPipelineData
* @filter: Custom filter to process preview data (an extra ref is taken)
*
* Set the filter element into preview pipeline.
*
* Returns: %TRUE on success
*/
gboolean
gst_camerabin_preview_set_filter (GstCameraBinPreviewPipelineData * preview,
GstElement * filter)
{
gboolean ret = TRUE;
GstState current;
g_return_val_if_fail (preview != NULL, FALSE);
GST_DEBUG ("Preview pipeline setting new filter %p", filter);
g_mutex_lock (&preview->processing_lock);
gst_element_get_state (preview->pipeline, &current, NULL, 0);
if (preview->processing == 0 && current == GST_STATE_NULL) {
gboolean linkfail = FALSE;
if (preview->filter) {
/* Unlink and remove old filter */
gst_element_unlink (preview->appsrc, preview->filter);
gst_element_unlink (preview->filter, preview->vscale);
gst_bin_remove (GST_BIN (preview->pipeline), preview->filter);
} else {
/* Make room for filter by breaking the link between appsrc and vcale */
gst_element_unlink (preview->appsrc, preview->vscale);
}
if (filter) {
/* Add and link the new filter between appsrc and vscale */
gst_bin_add (GST_BIN (preview->pipeline), gst_object_ref (filter));
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (preview->appsrc,
"src", filter, NULL, GST_PAD_LINK_CHECK_NOTHING));
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (filter, NULL,
preview->vscale, "sink", GST_PAD_LINK_CHECK_CAPS));
} else {
/* No filter was given. Just link the appsrc to vscale directly */
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (preview->appsrc,
"src", preview->vscale, "sink", GST_PAD_LINK_CHECK_NOTHING));
}
if (linkfail) {
GST_WARNING ("Linking the filter to pipeline failed");
ret = FALSE;
} else {
GST_DEBUG ("Linking the filter to pipeline successful");
preview->filter = filter;
}
} else {
GST_WARNING ("Cannot change filter when pipeline is running");
ret = FALSE;
}
g_mutex_unlock (&preview->processing_lock);
return ret;
}

View File

@ -0,0 +1,66 @@
/*
* GStreamer
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __CAMERABIN_PREVIEW_H_
#define __CAMERABIN_PREVIEW_H_
#ifndef GST_USE_UNSTABLE_API
#warning "camera bin preview is unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <gst/gst.h>
#include "basecamerabinsrc-prelude.h"
typedef struct
{
GstElement *pipeline;
GstElement *appsrc;
GstElement *filter;
GstElement *appsink;
GstElement *vscale;
GstElement *element;
GstCaps *pending_preview_caps;
guint processing;
GMutex processing_lock;
GCond processing_cond;
} GstCameraBinPreviewPipelineData;
GST_BASE_CAMERA_BIN_SRC_API
GstCameraBinPreviewPipelineData *gst_camerabin_create_preview_pipeline (GstElement * element, GstElement * filter);
GST_BASE_CAMERA_BIN_SRC_API
void gst_camerabin_destroy_preview_pipeline (GstCameraBinPreviewPipelineData * preview);
GST_BASE_CAMERA_BIN_SRC_API
gboolean gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview, GstSample * sample);
GST_BASE_CAMERA_BIN_SRC_API
void gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview, GstCaps * caps);
GST_BASE_CAMERA_BIN_SRC_API
gboolean gst_camerabin_preview_set_filter (GstCameraBinPreviewPipelineData * preview, GstElement * filter);
#endif /* #ifndef __CAMERABIN_PREVIEW_H_ */

View File

@ -0,0 +1,27 @@
camerabin_sources = [
'gstcamerabin-enum.c',
'gstcamerabinpreview.c',
'gstbasecamerasrc.c',
]
camerabin_headers = [
'basecamerabinsrc-prelude.h',
'gstcamerabin-enum.h',
'gstcamerabinpreview.h',
'gstbasecamerasrc.h',
]
install_headers(camerabin_headers, subdir : 'gstreamer-1.0/gst/basecamerabinsrc')
gstbasecamerabin = library('gstbasecamerabinsrc-' + api_version,
camerabin_sources,
c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API', '-DBUILDING_GST_BASE_CAMERA_BIN_SRC'],
include_directories : [configinc, libsinc],
version : libversion,
soversion : soversion,
darwin_versions : osxversion,
install : true,
dependencies : [gstapp_dep],
)
gstbasecamerabin_dep = declare_dependency(link_with : gstbasecamerabin,
include_directories : [libsinc],
dependencies : [gstapp_dep])

View File

@ -0,0 +1,49 @@
lib_LTLIBRARIES = libgstphotography-@GST_API_VERSION@.la
libgstphotographyincludedir = \
$(includedir)/gstreamer-@GST_API_VERSION@/gst/interfaces
headers_photography = \
photography.h
# variables used for enum/marshal generation
glib_enum_headers=$(headers_photography)
glib_enum_define=GST_PHOTOGRAPHY
glib_gen_prefix=gst_photography
glib_gen_basename=photography
glib_gen_decl_banner=GST_PHOTOGRAPHY_API
glib_gen_decl_include=\#include <gst/interfaces/photography-prelude.h>
built_sources = \
photography-enumtypes.c
built_headers = \
photography-enumtypes.h
libgstphotographyinclude_HEADERS = \
photography-prelude.h \
$(headers_photography)
nodist_libgstphotographyinclude_HEADERS = \
photography-enumtypes.h
libgstphotography_@GST_API_VERSION@_la_SOURCES = \
photography.c
nodist_libgstphotography_@GST_API_VERSION@_la_SOURCES = \
$(built_sources)
libgstphotography_@GST_API_VERSION@_la_CFLAGS = \
-DGST_USE_UNSTABLE_API \
-DBUILDING_GST_PHOTOGRAPHY \
$(GST_PLUGINS_BAD_CFLAGS) \
$(GST_CFLAGS)
libgstphotography_@GST_API_VERSION@_la_LIBADD = $(GST_LIBS)
libgstphotography_@GST_API_VERSION@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
BUILT_SOURCES = \
$(built_sources) \
$(built_headers)
CLEANFILES = $(BUILT_SOURCES)
include $(top_srcdir)/common/gst-glib-gen.mak

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
photography_sources = ['photography.c']
photo_headers = ['photography.h', 'photography-prelude.h']
install_headers(photo_headers, subdir : 'gstreamer-1.0/gst/interfaces')
photo_enums = gnome.mkenums_simple('photography-enumtypes',
sources : photo_headers,
body_prefix : '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif',
header_prefix : '#include <gst/interfaces/photography-prelude.h>',
decorator: 'GST_PHOTOGRAPHY_API',
install_header: true,
install_dir : join_paths(get_option('includedir'), 'gstreamer-1.0/gst/interfaces'))
photoenum_c = photo_enums[0]
photoenum_h = photo_enums[1]
gstphotography = library('gstphotography-' + api_version,
photography_sources, photoenum_h, photoenum_c,
c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API', '-DBUILDING_GST_PHOTOGRAPHY'],
include_directories : [configinc, libsinc],
version : libversion,
soversion : soversion,
darwin_versions : osxversion,
install : true,
dependencies : [gst_dep],
)
gstphotography_dep = declare_dependency(link_with : gstphotography,
include_directories : [libsinc],
dependencies : [gst_dep],
sources : [photoenum_h])

View File

@ -0,0 +1,35 @@
/* GStreamer Photography Library
* Copyright (C) 2018 GStreamer developers
*
* photography-prelude.h: prelude include header for gst-photography library
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PHOTOGRAPHY_PRELUDE_H__
#define __GST_PHOTOGRAPHY_PRELUDE_H__
#include <gst/gst.h>
#ifndef GST_PHOTOGRAPHY_API
# ifdef BUILDING_GST_PHOTOGRAPHY
# define GST_PHOTOGRAPHY_API GST_API_EXPORT /* from config.h */
# else
# define GST_PHOTOGRAPHY_API GST_API_IMPORT
# endif
#endif
#endif /* __GST_PHOTOGRAPHY_PRELUDE_H__ */

View File

@ -0,0 +1,714 @@
/* GStreamer
*
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
*
* photography.c: photography interface for digital imaging
*
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "photography.h"
/**
* SECTION:gstphotography
* @short_description: Interface for digital image capture elements
* @stability: Unstable
*
* The interface allows access to some common digital image capture parameters.
*
* <note>
* The GstPhotography interface is unstable API and may change in future.
* One can define GST_USE_UNSTABLE_API to acknowledge and avoid this warning.
* </note>
*/
static void gst_photography_iface_base_init (GstPhotographyInterface * iface);
static void gst_photography_iface_class_init (gpointer g_class);
GType
gst_photography_get_type (void)
{
static GType gst_photography_type = 0;
if (!gst_photography_type) {
static const GTypeInfo gst_photography_info = {
sizeof (GstPhotographyInterface),
(GBaseInitFunc) gst_photography_iface_base_init, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gst_photography_iface_class_init, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
0,
0, /* n_preallocs */
NULL, /* instance_init */
};
gst_photography_type = g_type_register_static (G_TYPE_INTERFACE,
"GstPhotography", &gst_photography_info, 0);
}
return gst_photography_type;
}
static void
gst_photography_iface_base_init (GstPhotographyInterface * iface)
{
/* default virtual functions */
iface->get_ev_compensation = NULL;
iface->get_iso_speed = NULL;
iface->get_aperture = NULL;
iface->get_exposure = NULL;
iface->get_white_balance_mode = NULL;
iface->get_color_tone_mode = NULL;
iface->get_scene_mode = NULL;
iface->get_flash_mode = NULL;
iface->get_noise_reduction = NULL;
iface->get_zoom = NULL;
iface->get_flicker_mode = NULL;
iface->get_focus_mode = NULL;
iface->set_ev_compensation = NULL;
iface->set_iso_speed = NULL;
iface->set_aperture = NULL;
iface->set_exposure = NULL;
iface->set_white_balance_mode = NULL;
iface->set_color_tone_mode = NULL;
iface->set_scene_mode = NULL;
iface->set_flash_mode = NULL;
iface->set_noise_reduction = NULL;
iface->set_zoom = NULL;
iface->set_flicker_mode = NULL;
iface->set_focus_mode = NULL;
iface->get_capabilities = NULL;
iface->prepare_for_capture = NULL;
iface->set_autofocus = NULL;
iface->set_config = NULL;
iface->get_config = NULL;
}
#define GST_PHOTOGRAPHY_FUNC_TEMPLATE(function_name, param_type) \
gboolean \
gst_photography_set_ ## function_name (GstPhotography * photo, param_type param) \
{ \
GstPhotographyInterface *iface; \
g_return_val_if_fail (photo != NULL, FALSE); \
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo); \
if (iface->set_ ## function_name) { \
return iface->set_ ## function_name (photo, param); \
} \
return FALSE; \
} \
gboolean \
gst_photography_get_ ## function_name (GstPhotography * photo, param_type * param) \
{ \
GstPhotographyInterface *iface; \
g_return_val_if_fail (photo != NULL, FALSE); \
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo); \
if (iface->get_ ## function_name) { \
return iface->get_ ## function_name (photo, param); \
} \
return FALSE; \
}
/**
* gst_photography_set_ev_compensation:
* @photo: #GstPhotography interface of a #GstElement
* @ev_comp: ev compensation value to set
*
* Set the ev compensation value for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_ev_compensation:
* @photo: #GstPhotography interface of a #GstElement
* @ev_comp: ev compensation value to get
*
* Get the ev compensation value for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (ev_compensation, gfloat);
/**
* gst_photography_set_iso_speed:
* @photo: #GstPhotography interface of a #GstElement
* @iso_speed: ISO speed value to set
*
* Set the ISO value (light sensivity) for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_iso_speed:
* @photo: #GstPhotography interface of a #GstElement
* @iso_speed: ISO speed value to get
*
* Get the ISO value (light sensivity) for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (iso_speed, guint);
/**
* gst_photography_set_aperture:
* @photo: #GstPhotography interface of a #GstElement
* @aperture: aperture value to set
*
* Set the aperture value for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_aperture:
* @photo: #GstPhotography interface of a #GstElement
* @aperture: aperture value to get
*
* Get the aperture value for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (aperture, guint);
/**
* gst_photography_set_exposure:
* @photo: #GstPhotography interface of a #GstElement
* @exposure: exposure time to set
*
* Set the fixed exposure time (in us) for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_exposure:
* @photo: #GstPhotography interface of a #GstElement
* @exposure: exposure time to get
*
* Get the fixed exposure time (in us) for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (exposure, guint32);
/**
* gst_photography_set_white_balance_mode:
* @photo: #GstPhotography interface of a #GstElement
* @wb_mode: #GstPhotographyWhiteBalanceMode to set
*
* Set the white balance mode for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_white_balance_mode:
* @photo: #GstPhotography interface of a #GstElement
* @wb_mode: #GstPhotographyWhiteBalanceMode to get
*
* Get the white balance mode for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (white_balance_mode,
GstPhotographyWhiteBalanceMode);
/**
* gst_photography_set_color_tone_mode:
* @photo: #GstPhotography interface of a #GstElement
* @tone_mode: #GstPhotographyColorToneMode to set
*
* Set the color tone mode for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_color_tone_mode:
* @photo: #GstPhotography interface of a #GstElement
* @tone_mode: #GstPhotographyColorToneMode to get
*
* Get the color tone mode for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (color_tone_mode, GstPhotographyColorToneMode);
/**
* gst_photography_set_scene_mode:
* @photo: #GstPhotography interface of a #GstElement
* @scene_mode: #GstPhotographySceneMode to set
*
* Set the scene mode for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_scene_mode:
* @photo: #GstPhotography interface of a #GstElement
* @scene_mode: #GstPhotographySceneMode to get
*
* Get the scene mode for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (scene_mode, GstPhotographySceneMode);
/**
* gst_photography_set_flash_mode:
* @photo: #GstPhotography interface of a #GstElement
* @flash_mode: #GstPhotographyFlashMode to set
*
* Set the flash mode for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_flash_mode:
* @photo: #GstPhotography interface of a #GstElement
* @flash_mode: #GstPhotographyFlashMode to get
*
* Get the flash mode for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (flash_mode, GstPhotographyFlashMode);
/**
* gst_photography_set_noise_reduction:
* @photo: #GstPhotography interface of a #GstElement
* @noise_reduction: #GstPhotographyNoiseReductionMode to set
*
* Set the noise reduction mode for the #GstElement
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_noise_reduction:
* @photo: #GstPhotography interface of a #GstElement
* @noise_reduction: #GstPhotographyNoiseReductionMode to get
*
* Get the noise reduction mode for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (noise_reduction, GstPhotographyNoiseReduction);
/**
* gst_photography_set_zoom:
* @photo: #GstPhotography interface of a #GstElement
* @zoom: zoom value to set
*
* Set the zoom value for the #GstElement.
* E.g. 1.0 to get original image and 3.0 for 3x zoom and so on.
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_zoom:
* @photo: #GstPhotography interface of a #GstElement
* @zoom: zoom value to get
*
* Get the zoom value for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (zoom, gfloat);
/**
* gst_photography_set_flicker_mode:
* @photo: #GstPhotography interface of a #GstElement
* @flicker_mode: flicker mode value to set
*
* Set the flicker mode value for the #GstElement.
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_flicker_mode:
* @photo: #GstPhotography interface of a #GstElement
* @flicker_mode: flicker mode value to get
*
* Get the flicker mode value for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (flicker_mode,
GstPhotographyFlickerReductionMode);
/**
* gst_photography_set_focus_mode:
* @photo: #GstPhotography interface of a #GstElement
* @focus_mode: focus mode value to set
*
* Set the focus mode value for the #GstElement.
*
* Returns: %TRUE if setting the value succeeded, %FALSE otherwise
*/
/**
* gst_photography_get_focus_mode:
* @photo: #GstPhotography interface of a #GstElement
* @focus_mode: focus_mode value to get
*
* Get the focus mode value for the #GstElement
*
* Returns: %TRUE if getting the value succeeded, %FALSE otherwise
*/
GST_PHOTOGRAPHY_FUNC_TEMPLATE (focus_mode, GstPhotographyFocusMode);
/**
* gst_photography_get_capabilities:
* @photo: #GstPhotography interface of a #GstElement
*
* Get #GstPhotographyCaps bitmask value that indicates what photography
* interface features the #GstElement supports
*
* Returns: #GstPhotographyCaps value
*/
GstPhotographyCaps
gst_photography_get_capabilities (GstPhotography * photo)
{
GstPhotographyInterface *iface;
g_return_val_if_fail (photo != NULL, GST_PHOTOGRAPHY_CAPS_NONE);
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo);
if (iface->get_capabilities) {
return iface->get_capabilities (photo);
} else {
return GST_PHOTOGRAPHY_CAPS_NONE;
}
}
/**
* gst_photography_prepare_for_capture:
* @photo: #GstPhotography interface of a #GstElement
* @func: callback that is called after capturing has been prepared
* @capture_caps: #GstCaps defining the desired format of the captured image
* @user_data: user data that will be passed to the callback @func
*
* Start preparations for capture. Preparations can take indeterminate
* amount of time and @func callback is called after preparations are
* done. Image capture will begin after callback returns.
*
* Returns: %TRUE if preparations were started (caps were OK), otherwise %FALSE.
*/
gboolean
gst_photography_prepare_for_capture (GstPhotography * photo,
GstPhotographyCapturePrepared func, GstCaps * capture_caps,
gpointer user_data)
{
GstPhotographyInterface *iface;
gboolean ret = TRUE;
g_return_val_if_fail (photo != NULL, FALSE);
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo);
if (iface->prepare_for_capture) {
ret = iface->prepare_for_capture (photo, func, capture_caps, user_data);
}
return ret;
}
/**
* gst_photography_set_autofocus:
* @photo: #GstPhotography interface of a #GstElement
* @on: %TRUE to start autofocusing, %FALSE to stop autofocusing
*
* Start or stop autofocusing. %GST_PHOTOGRAPHY_AUTOFOCUS_DONE
* message is posted to bus when autofocusing has finished.
*/
void
gst_photography_set_autofocus (GstPhotography * photo, gboolean on)
{
GstPhotographyInterface *iface;
g_return_if_fail (photo != NULL);
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo);
if (iface->set_autofocus) {
iface->set_autofocus (photo, on);
}
}
/**
* gst_photography_set_config:
* @photo: #GstPhotography interface of a #GstElement
* @config: #GstPhotographySettings containg the configuration
*
* Set all configuration settings at once.
*
* Returns: TRUE if configuration was set successfully, otherwise FALSE.
*/
gboolean
gst_photography_set_config (GstPhotography * photo,
GstPhotographySettings * config)
{
GstPhotographyInterface *iface;
gboolean ret = FALSE;
g_return_val_if_fail (photo != NULL, FALSE);
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo);
if (iface->set_config) {
ret = iface->set_config (photo, config);
}
return ret;
}
/**
* gst_photography_get_config:
* @photo: #GstPhotography interface of a #GstElement
* @config: #GstPhotographySettings containg the configuration
*
* Get all configuration settings at once.
*
* Returns: TRUE if configuration was got successfully, otherwise FALSE.
*/
gboolean
gst_photography_get_config (GstPhotography * photo,
GstPhotographySettings * config)
{
GstPhotographyInterface *iface;
gboolean ret = FALSE;
g_return_val_if_fail (photo != NULL, FALSE);
iface = GST_PHOTOGRAPHY_GET_INTERFACE (photo);
if (iface->get_config) {
ret = iface->get_config (photo, config);
}
return ret;
}
/* Photography class initialization stuff */
static void
gst_photography_iface_class_init (gpointer g_class)
{
/* create interface signals and properties here. */
/* White balance */
g_object_interface_install_property (g_class,
g_param_spec_enum (GST_PHOTOGRAPHY_PROP_WB_MODE,
"White balance mode property",
"White balance affects the color temperature of the photo",
GST_TYPE_PHOTOGRAPHY_WHITE_BALANCE_MODE,
GST_PHOTOGRAPHY_WB_MODE_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Color tone */
g_object_interface_install_property (g_class,
g_param_spec_enum (GST_PHOTOGRAPHY_PROP_COLOR_TONE,
"Color tone mode property",
"Color tone setting changes color shading in the photo",
GST_TYPE_PHOTOGRAPHY_COLOR_TONE_MODE,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Scene mode */
g_object_interface_install_property (g_class,
g_param_spec_enum (GST_PHOTOGRAPHY_PROP_SCENE_MODE,
"Scene mode property",
"Scene mode works as a preset for different photo shooting mode settings",
GST_TYPE_PHOTOGRAPHY_SCENE_MODE,
GST_PHOTOGRAPHY_SCENE_MODE_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Flash mode */
g_object_interface_install_property (g_class,
g_param_spec_enum (GST_PHOTOGRAPHY_PROP_FLASH_MODE,
"Flash mode property",
"Flash mode defines how the flash light should be used",
GST_TYPE_PHOTOGRAPHY_FLASH_MODE,
GST_PHOTOGRAPHY_FLASH_MODE_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Flicker reduction mode */
g_object_interface_install_property (g_class,
g_param_spec_enum (GST_PHOTOGRAPHY_PROP_FLICKER_MODE,
"Flicker reduction mode property",
"Flicker reduction mode defines a line frequency for flickering prevention",
GST_TYPE_PHOTOGRAPHY_FLICKER_REDUCTION_MODE,
GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Focus mode */
g_object_interface_install_property (g_class,
g_param_spec_enum (GST_PHOTOGRAPHY_PROP_FOCUS_MODE,
"Focus mode property",
"Focus mode defines the range of focal lengths to use in autofocus search",
GST_TYPE_PHOTOGRAPHY_FOCUS_MODE,
GST_PHOTOGRAPHY_FOCUS_MODE_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Capabilities */
g_object_interface_install_property (g_class,
g_param_spec_ulong (GST_PHOTOGRAPHY_PROP_CAPABILITIES,
"Photo capabilities bitmask",
"Tells the photo capabilities of the device",
0, G_MAXULONG, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/* EV_compensation */
g_object_interface_install_property (g_class,
g_param_spec_float (GST_PHOTOGRAPHY_PROP_EV_COMP,
"EV compensation property",
"EV compensation affects the brightness of the image",
-2.5, 2.5, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* ISO value */
g_object_interface_install_property (g_class,
g_param_spec_uint (GST_PHOTOGRAPHY_PROP_ISO_SPEED,
"ISO speed property",
"ISO speed defines the light sensitivity (0 = auto)",
0, 6400, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Aperture */
g_object_interface_install_property (g_class,
g_param_spec_uint (GST_PHOTOGRAPHY_PROP_APERTURE,
"Aperture property",
"Aperture defines the size of lens opening (0 = auto)",
0, G_MAXUINT8, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Exposure */
g_object_interface_install_property (g_class,
g_param_spec_uint (GST_PHOTOGRAPHY_PROP_EXPOSURE_TIME,
"Exposure time in milliseconds",
"Exposure time defines how long the shutter will stay open (0 = auto)",
0, G_MAXUINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:image-capture-supported-caps:
*
* Query caps that describe supported formats for image capture. Sometimes
* element may support different formats for image capture than for video
* streaming.
*/
g_object_interface_install_property (g_class,
g_param_spec_boxed (GST_PHOTOGRAPHY_PROP_IMAGE_CAPTURE_SUPPORTED_CAPS,
"Image capture supported caps",
"Caps describing supported image capture formats", GST_TYPE_CAPS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:image-preview-supported-caps:
*
* Query caps that describe supported formats for preview image. Sometimes
* element may support different formats for preview image than for video
* streaming.
*/
g_object_interface_install_property (g_class,
g_param_spec_boxed (GST_PHOTOGRAPHY_PROP_IMAGE_PREVIEW_SUPPORTED_CAPS,
"Image preview supported caps",
"Caps describing supported image preview formats", GST_TYPE_CAPS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/* Zoom */
g_object_interface_install_property (g_class,
g_param_spec_float (GST_PHOTOGRAPHY_PROP_ZOOM,
"Zoom property",
"How much the resulted image will be zoomed",
1.0f, 10.0f, 1.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:color-temperature:
*
* Color temperature parameter for manual white balance.
* Control color temperature in Kelvin units.
*/
g_object_interface_install_property (g_class,
g_param_spec_uint (GST_PHOTOGRAPHY_PROP_COLOR_TEMPERATURE,
"Color temperature in Kelvin units",
"Color temperature in Kelvin units for manual white balance",
0, G_MAXUINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:white-point:
*
* White point parameter for manual white balance.
* Describes the color "white" as raw values.
*
* FIXME: check and document correct representation for white point
*/
g_object_interface_install_property (g_class,
g_param_spec_value_array (GST_PHOTOGRAPHY_PROP_WHITE_POINT,
"White point",
"Describe color white as raw values",
g_param_spec_uint ("raw-value", "Raw value",
"Raw value", 0, G_MAXUINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:analog-gain:
*
* Linear multiplicative value how much amplification is applied to the signal
* before A-D conversion.
*/
g_object_interface_install_property (g_class,
g_param_spec_float (GST_PHOTOGRAPHY_PROP_ANALOG_GAIN,
"Analog gain applied to the sensor",
"Analog gain applied to the sensor",
1.0f, G_MAXFLOAT, 1.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:lens-focus:
*
* Manual changing of lens focus in diopter units.
* Inteded use with GST_PHOTOGRAPHY_FOCUS_MODE_MANUAL focus mode, otherwise
* to be ignored.
*
*/
g_object_interface_install_property (g_class,
g_param_spec_float (GST_PHOTOGRAPHY_PROP_LENS_FOCUS,
"Manual lens focus",
"Focus point in diopter units",
0.0f, G_MAXFLOAT, 0.0f, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:min-exposure-time:
*
* Minimum exposure time for automatic exposure mode.
*/
g_object_interface_install_property (g_class,
g_param_spec_uint (GST_PHOTOGRAPHY_PROP_MIN_EXPOSURE_TIME,
"Minimum exposure time",
"Minimum exposure time for automatic exposure mode",
0, G_MAXUINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstPhotography:max-exposure-time:
*
* Maximum exposure time for automatic exposure mode.
*/
g_object_interface_install_property (g_class,
g_param_spec_uint (GST_PHOTOGRAPHY_PROP_MAX_EXPOSURE_TIME,
"Maximum exposure time",
"Maximum exposure time for automatic exposure mode",
0, G_MAXUINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/* Noise Reduction, Bayer an YCC noise reduction are enabled by default */
g_object_interface_install_property (g_class,
g_param_spec_flags (GST_PHOTOGRAPHY_PROP_NOISE_REDUCTION,
"Noise Reduction settings",
"Which noise reduction modes are enabled (0 = disabled)",
GST_TYPE_PHOTOGRAPHY_NOISE_REDUCTION,
0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}

View File

@ -0,0 +1,673 @@
/* GStreamer
*
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
*
* photography.h: photography interface for digital imaging
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PHOTOGRAPHY_H__
#define __GST_PHOTOGRAPHY_H__
#ifndef GST_USE_UNSTABLE_API
#warning "The GstPhotography interface is unstable API and may change in future."
#warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
#endif
#include <gst/gst.h>
#include <gst/interfaces/photography-prelude.h>
#include <gst/interfaces/photography-enumtypes.h>
G_BEGIN_DECLS
#define GST_TYPE_PHOTOGRAPHY \
(gst_photography_get_type ())
#define GST_PHOTOGRAPHY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PHOTOGRAPHY, GstPhotography))
#define GST_IS_PHOTOGRAPHY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PHOTOGRAPHY))
#define GST_PHOTOGRAPHY_GET_INTERFACE(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_PHOTOGRAPHY, GstPhotographyInterface))
/**
* GST_PHOTOGRAPHY_AUTOFOCUS_DONE:
*
* Name of custom GstMessage that will be posted to #GstBus when autofocusing
* is complete.
* This message contains following fields:
* <itemizedlist>
* <listitem>
* <para>
* #GstPhotographyFocusStatus
* <classname>&quot;status&quot;</classname>:
* Tells if focusing succeeded or failed.
* </para>
* </listitem>
* <listitem>
* <para>
* #G_TYPE_INT
* <classname>&quot;focus-window-rows&quot;</classname>:
* Tells number of focus matrix rows.
* </para>
* </listitem>
* <listitem>
* <para>
* #G_TYPE_INT
* <classname>&quot;focus-window-columns&quot;</classname>:
* Tells number of focus matrix columns.
* </para>
* </listitem>
* <listitem>
* <para>
* #G_TYPE_INT
* <classname>&quot;focus-window-mask&quot;</classname>:
* Bitmask containing rows x columns bits which mark the focus points in the
* focus matrix. Lowest bit (LSB) always represents the top-left corner of the
* focus matrix. This field is only valid when focusing status is SUCCESS.
* </para>
* </listitem>
* </itemizedlist>
*/
#define GST_PHOTOGRAPHY_AUTOFOCUS_DONE "autofocus-done"
/**
* GST_PHOTOGRAPHY_SHAKE_RISK:
*
* Name of custom GstMessage that is posted to #GstBus during autofocusing
* process. It is posted if there is change in the risk of captured image
* becoming "shaken" due to camera movement and too long exposure time.
*
* This message contains following fields:
* <itemizedlist>
* <listitem>
* <para>
* #GstPhotographyShakeRisk
* <classname>&quot;status&quot;</classname>:
* Tells risk level of capturing shaken image.
* </para>
* </listitem>
* </itemizedlist>
*/
#define GST_PHOTOGRAPHY_SHAKE_RISK "shake-risk"
/* Maximum white point values used in #GstPhotographySettings */
#define MAX_WHITE_POINT_VALUES 4
/* Interface property names */
#define GST_PHOTOGRAPHY_PROP_WB_MODE "white-balance-mode"
#define GST_PHOTOGRAPHY_PROP_COLOR_TONE "color-tone-mode"
#define GST_PHOTOGRAPHY_PROP_SCENE_MODE "scene-mode"
#define GST_PHOTOGRAPHY_PROP_FLASH_MODE "flash-mode"
#define GST_PHOTOGRAPHY_PROP_NOISE_REDUCTION "noise-reduction"
#define GST_PHOTOGRAPHY_PROP_FOCUS_STATUS "focus-status"
#define GST_PHOTOGRAPHY_PROP_CAPABILITIES "capabilities"
#define GST_PHOTOGRAPHY_PROP_SHAKE_RISK "shake-risk"
#define GST_PHOTOGRAPHY_PROP_EV_COMP "ev-compensation"
#define GST_PHOTOGRAPHY_PROP_ISO_SPEED "iso-speed"
#define GST_PHOTOGRAPHY_PROP_APERTURE "aperture"
#define GST_PHOTOGRAPHY_PROP_EXPOSURE_TIME "exposure-time"
#define GST_PHOTOGRAPHY_PROP_IMAGE_CAPTURE_SUPPORTED_CAPS \
"image-capture-supported-caps"
#define GST_PHOTOGRAPHY_PROP_IMAGE_PREVIEW_SUPPORTED_CAPS \
"image-preview-supported-caps"
#define GST_PHOTOGRAPHY_PROP_FLICKER_MODE "flicker-mode"
#define GST_PHOTOGRAPHY_PROP_FOCUS_MODE "focus-mode"
#define GST_PHOTOGRAPHY_PROP_ZOOM "zoom"
#define GST_PHOTOGRAPHY_PROP_COLOR_TEMPERATURE "color-temperature"
#define GST_PHOTOGRAPHY_PROP_WHITE_POINT "white-point"
#define GST_PHOTOGRAPHY_PROP_ANALOG_GAIN "analog-gain"
#define GST_PHOTOGRAPHY_PROP_EXPOSURE_MODE "exposure-mode"
#define GST_PHOTOGRAPHY_PROP_LENS_FOCUS "lens-focus"
#define GST_PHOTOGRAPHY_PROP_MIN_EXPOSURE_TIME "min-exposure-time"
#define GST_PHOTOGRAPHY_PROP_MAX_EXPOSURE_TIME "max-exposure-time"
/**
* GstPhotography:
*
* Opaque #GstPhotography data structure.
*/
typedef struct _GstPhotography GstPhotography;
/**
* GstPhotographyNoiseReduction:
* @GST_PHOTOGRAPHY_NOISE_REDUCTION_BAYER: Adaptive noise reduction on Bayer
* format
* @GST_PHOTOGRAPHY_NOISE_REDUCTION_YCC: reduces the noise on Y and 2-chroma
* images.
* @GST_PHOTOGRAPHY_NOISE_REDUCTION_TEMPORAL: Multi-frame adaptive NR,
* provided for the video mode
* @GST_PHOTOGRAPHY_NOISE_REDUCTION_FIXED: Fixed Pattern Noise refers to noise
* that does not change between frames. The noise is removed from the sensor
* image, by subtracting a previously-captured black image in memory.
* @GST_PHOTOGRAPHY_NOISE_REDUCTION_EXTRA: Extra Noise Reduction. In the case
* of high-ISO capturing, some noise remains after YCC NR. XNR reduces this
* remaining noise.
*
* Noise Reduction features of a photography capture or filter element.
*/
typedef enum
{
GST_PHOTOGRAPHY_NOISE_REDUCTION_BAYER = (1 << 0),
GST_PHOTOGRAPHY_NOISE_REDUCTION_YCC = (1 << 1),
GST_PHOTOGRAPHY_NOISE_REDUCTION_TEMPORAL = (1 << 2),
GST_PHOTOGRAPHY_NOISE_REDUCTION_FIXED = (1 << 3),
GST_PHOTOGRAPHY_NOISE_REDUCTION_EXTRA = (1 << 4)
} GstPhotographyNoiseReduction;
/**
* GstPhotographyWhiteBalanceMode:
* @GST_PHOTOGRAPHY_WB_MODE_AUTO: Choose white balance mode automatically
* @GST_PHOTOGRAPHY_WB_MODE_DAYLIGHT: Mode for daylight conditions
* @GST_PHOTOGRAPHY_WB_MODE_CLOUDY: Mode for cloudy conditions
* @GST_PHOTOGRAPHY_WB_MODE_SUNSET: Mode for sunset conditions
* @GST_PHOTOGRAPHY_WB_MODE_TUNGSTEN: Mode for tungsten lighting
* @GST_PHOTOGRAPHY_WB_MODE_FLUORESCENT: Mode for fluorescent lighting
* @GST_PHOTOGRAPHY_WB_MODE_MANUAL: Disable automatic white balance adjustment
* and keep current values.
* @GST_PHOTOGRAPHY_WB_MODE_WARM_FLUORESCENT: Mode for warm fluorescent lighting (Since: 1.2)
* @GST_PHOTOGRAPHY_WB_MODE_SHADE: Mode for shade lighting (Since: 1.2)
*
* Modes for white balance control.
*/
typedef enum
{
GST_PHOTOGRAPHY_WB_MODE_AUTO = 0,
GST_PHOTOGRAPHY_WB_MODE_DAYLIGHT,
GST_PHOTOGRAPHY_WB_MODE_CLOUDY,
GST_PHOTOGRAPHY_WB_MODE_SUNSET,
GST_PHOTOGRAPHY_WB_MODE_TUNGSTEN,
GST_PHOTOGRAPHY_WB_MODE_FLUORESCENT,
GST_PHOTOGRAPHY_WB_MODE_MANUAL,
GST_PHOTOGRAPHY_WB_MODE_WARM_FLUORESCENT,
GST_PHOTOGRAPHY_WB_MODE_SHADE
} GstPhotographyWhiteBalanceMode;
/**
* GstPhotographyColorToneMode:
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL: No effects
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_SEPIA: Sepia
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_NEGATIVE: Negative
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRAYSCALE: Grayscale
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_NATURAL: Natural
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_VIVID: Vivid
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_COLORSWAP: Colorswap
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_SOLARIZE: Solarize
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_OUT_OF_FOCUS: Out of focus
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKY_BLUE: Sky blue
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRASS_GREEN: Grass green
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKIN_WHITEN: Skin whiten
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_POSTERIZE: Posterize (Since: 1.2)
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_WHITEBOARD: Whiteboard (Since: 1.2)
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_BLACKBOARD: Blackboard (Since: 1.2)
* @GST_PHOTOGRAPHY_COLOR_TONE_MODE_AQUA: Aqua (Since: 1.2)
*
* Modes for special color effects.
*/
typedef enum
{
GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL = 0,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_SEPIA,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_NEGATIVE,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRAYSCALE,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_NATURAL,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_VIVID,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_COLORSWAP,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_SOLARIZE,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_OUT_OF_FOCUS,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKY_BLUE,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRASS_GREEN,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKIN_WHITEN,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_POSTERIZE,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_WHITEBOARD,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_BLACKBOARD,
GST_PHOTOGRAPHY_COLOR_TONE_MODE_AQUA
} GstPhotographyColorToneMode;
/**
* GstPhotographySceneMode:
* @GST_PHOTOGRAPHY_SCENE_MODE_MANUAL: Set individual options manually
* @GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP: Mode for close objects
* @GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT: Mode for portraits
* @GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE: Mode for landscapes
* @GST_PHOTOGRAPHY_SCENE_MODE_SPORT: Mode for scene with fast motion
* @GST_PHOTOGRAPHY_SCENE_MODE_NIGHT: Mode for night conditions
* @GST_PHOTOGRAPHY_SCENE_MODE_AUTO: Choose scene mode automatically
* @GST_PHOTOGRAPHY_SCENE_MODE_ACTION: Take photos of fast moving
* objects (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_NIGHT_PORTRAIT: Take people pictures
* at night (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_THEATRE: Take photos in a theater (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_BEACH: Take pictures on the beach (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_SNOW: Take pictures on the snow (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_SUNSET: Take sunset photos (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_STEADY_PHOTO: Avoid blurry pictures
* (for example, due to hand shake) (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_FIREWORKS: For shooting firework
* displays (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_PARTY: Take indoor low-light shot (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_CANDLELIGHT: Capture the naturally warm color
* of scenes lit by candles (Since: 1.2)
* @GST_PHOTOGRAPHY_SCENE_MODE_BARCODE: Applications are looking for
* a barcode (Since: 1.2)
*
* Each mode contains preset #GstPhotography options in order to produce
* good capturing result in certain scene.
*/
typedef enum
{
GST_PHOTOGRAPHY_SCENE_MODE_MANUAL = 0,
GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP,
GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT,
GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE,
GST_PHOTOGRAPHY_SCENE_MODE_SPORT,
GST_PHOTOGRAPHY_SCENE_MODE_NIGHT,
GST_PHOTOGRAPHY_SCENE_MODE_AUTO,
GST_PHOTOGRAPHY_SCENE_MODE_ACTION,
GST_PHOTOGRAPHY_SCENE_MODE_NIGHT_PORTRAIT,
GST_PHOTOGRAPHY_SCENE_MODE_THEATRE,
GST_PHOTOGRAPHY_SCENE_MODE_BEACH,
GST_PHOTOGRAPHY_SCENE_MODE_SNOW,
GST_PHOTOGRAPHY_SCENE_MODE_SUNSET,
GST_PHOTOGRAPHY_SCENE_MODE_STEADY_PHOTO,
GST_PHOTOGRAPHY_SCENE_MODE_FIREWORKS,
GST_PHOTOGRAPHY_SCENE_MODE_PARTY,
GST_PHOTOGRAPHY_SCENE_MODE_CANDLELIGHT,
GST_PHOTOGRAPHY_SCENE_MODE_BARCODE
} GstPhotographySceneMode;
/**
* GstPhotographyFlashMode:
* @GST_PHOTOGRAPHY_FLASH_MODE_AUTO: Fire flash automatically according to
* lighting conditions.
* @GST_PHOTOGRAPHY_FLASH_MODE_OFF: Never fire flash
* @GST_PHOTOGRAPHY_FLASH_MODE_ON: Always fire flash
* @GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN: Fill in flash
* @GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE: Flash mode for reducing chance of
* capturing red eyes
*
* Modes for flash control.
*/
typedef enum
{
GST_PHOTOGRAPHY_FLASH_MODE_AUTO = 0,
GST_PHOTOGRAPHY_FLASH_MODE_OFF,
GST_PHOTOGRAPHY_FLASH_MODE_ON,
GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN,
GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE
} GstPhotographyFlashMode;
/**
* GstPhotographyFocusStatus:
* @GST_PHOTOGRAPHY_FOCUS_STATUS_NONE: No status available
* @GST_PHOTOGRAPHY_FOCUS_STATUS_RUNNING: Focusing is ongoing
* @GST_PHOTOGRAPHY_FOCUS_STATUS_FAIL: Focusing failed
* @GST_PHOTOGRAPHY_FOCUS_STATUS_SUCCESS: Focusing succeeded
*
* Status of the focusing operation, used in #GST_PHOTOGRAPHY_AUTOFOCUS_DONE
* message.
*/
typedef enum
{
GST_PHOTOGRAPHY_FOCUS_STATUS_NONE = 0,
GST_PHOTOGRAPHY_FOCUS_STATUS_RUNNING,
GST_PHOTOGRAPHY_FOCUS_STATUS_FAIL,
GST_PHOTOGRAPHY_FOCUS_STATUS_SUCCESS
} GstPhotographyFocusStatus;
/**
* GstPhotographyCaps:
*
* Bitmask that indicates which #GstPhotography interface features an instance
* supports.
*/
typedef enum
{
GST_PHOTOGRAPHY_CAPS_NONE = (0 << 0),
GST_PHOTOGRAPHY_CAPS_EV_COMP = (1 << 0),
GST_PHOTOGRAPHY_CAPS_ISO_SPEED = (1 << 1),
GST_PHOTOGRAPHY_CAPS_WB_MODE = (1 << 2),
GST_PHOTOGRAPHY_CAPS_TONE = (1 << 3),
GST_PHOTOGRAPHY_CAPS_SCENE = (1 << 4),
GST_PHOTOGRAPHY_CAPS_FLASH = (1 << 5),
GST_PHOTOGRAPHY_CAPS_ZOOM = (1 << 6),
GST_PHOTOGRAPHY_CAPS_FOCUS = (1 << 7),
GST_PHOTOGRAPHY_CAPS_APERTURE = (1 << 8),
GST_PHOTOGRAPHY_CAPS_EXPOSURE = (1 << 9),
GST_PHOTOGRAPHY_CAPS_SHAKE = (1 << 10),
GST_PHOTOGRAPHY_CAPS_WHITE_BALANCE = (1 << 11),
GST_PHOTOGRAPHY_CAPS_NOISE_REDUCTION = (1 << 12),
GST_PHOTOGRAPHY_CAPS_FLICKER_REDUCTION = (1 << 13),
GST_PHOTOGRAPHY_CAPS_ALL = (~0)
} GstPhotographyCaps;
/**
* GstPhotographyShakeRisk:
* @GST_PHOTOGRAPHY_SHAKE_RISK_LOW: Low risk
* @GST_PHOTOGRAPHY_SHAKE_RISK_MEDIUM: Medium risk
* @GST_PHOTOGRAPHY_SHAKE_RISK_HIGH: High risk
*
* Risk level of captured image becoming "shaken" due to camera movement and
* too long exposure time. Used in #GST_PHOTOGRAPHY_SHAKE_RISK #GstMessage.
*/
typedef enum
{
GST_PHOTOGRAPHY_SHAKE_RISK_LOW = 0,
GST_PHOTOGRAPHY_SHAKE_RISK_MEDIUM,
GST_PHOTOGRAPHY_SHAKE_RISK_HIGH,
} GstPhotographyShakeRisk;
/**
* GstPhotographyFlickerReductionMode:
* @GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF: Disable flicker reduction
* @GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ: 50Hz flicker reduction
* @GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ: 60Hz flicker reduction
* @GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO: Choose mode automatically
*
* Reduce flicker in video caused by light source fluctuation.
*/
typedef enum
{
GST_PHOTOGRAPHY_FLICKER_REDUCTION_OFF = 0,
GST_PHOTOGRAPHY_FLICKER_REDUCTION_50HZ,
GST_PHOTOGRAPHY_FLICKER_REDUCTION_60HZ,
GST_PHOTOGRAPHY_FLICKER_REDUCTION_AUTO,
} GstPhotographyFlickerReductionMode;
/**
* GstPhotographyFocusMode:
* @GST_PHOTOGRAPHY_FOCUS_MODE_AUTO: Choose focus mode automatically
* @GST_PHOTOGRAPHY_FOCUS_MODE_MACRO: Mode for focusing objects close to lens
* @GST_PHOTOGRAPHY_FOCUS_MODE_PORTRAIT: Mode for portraits
* @GST_PHOTOGRAPHY_FOCUS_MODE_INFINITY: Mode for landscapes and far away objects
* @GST_PHOTOGRAPHY_FOCUS_MODE_HYPERFOCAL: Mode for maximum depth of field, keeping
* focus acceptable both in infinify and as close objects as possible
* @GST_PHOTOGRAPHY_FOCUS_MODE_EXTENDED: Extended focus mode
* @GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL: Continuous autofocus mode
* @GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_EXTENDED: Extended continuous
* autofocus mode
* @GST_PHOTOGRAPHY_FOCUS_MODE_MANUAL: Disable automatic focusing
* and keep current value. #GstPhotography:lens-focus property can
* be used to change focus manually.
*
* Choose mode for focusing algorithm.
*/
typedef enum {
GST_PHOTOGRAPHY_FOCUS_MODE_AUTO = 0,
GST_PHOTOGRAPHY_FOCUS_MODE_MACRO,
GST_PHOTOGRAPHY_FOCUS_MODE_PORTRAIT,
GST_PHOTOGRAPHY_FOCUS_MODE_INFINITY,
GST_PHOTOGRAPHY_FOCUS_MODE_HYPERFOCAL,
GST_PHOTOGRAPHY_FOCUS_MODE_EXTENDED,
GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL,
GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_EXTENDED,
GST_PHOTOGRAPHY_FOCUS_MODE_MANUAL
} GstPhotographyFocusMode;
/**
* GstPhotographyExposureMode:
* @GST_PHOTOGRAPHY_EXPOSURE_MODE_AUTO: Adjust exposure automatically
* @GST_PHOTOGRAPHY_EXPOSURE_MODE_MANUAL: Disable automatic exposure adjustment
* and keep current values.
*
*/
typedef enum {
GST_PHOTOGRAPHY_EXPOSURE_MODE_AUTO = 0,
GST_PHOTOGRAPHY_EXPOSURE_MODE_MANUAL
} GstPhotographyExposureMode;
/**
* GstPhotographySettings:
*
* Structure containing all #GstPhotography settings, used to set all
* settings in one call with @gst_photography_set_config().
*/
typedef struct
{
GstPhotographyWhiteBalanceMode wb_mode;
GstPhotographyColorToneMode tone_mode;
GstPhotographySceneMode scene_mode;
GstPhotographyFlashMode flash_mode;
guint32 exposure_time;
guint aperture;
gfloat ev_compensation;
guint iso_speed;
gfloat zoom;
GstPhotographyFlickerReductionMode flicker_mode;
GstPhotographyFocusMode focus_mode;
GstPhotographyNoiseReduction noise_reduction;
GstPhotographyExposureMode exposure_mode;
guint color_temperature;
guint white_point[MAX_WHITE_POINT_VALUES];
gfloat analog_gain;
gfloat lens_focus;
guint min_exposure_time;
guint max_exposure_time;
/* FIXME: add padding? */
} GstPhotographySettings;
/**
* GstPhotographyCapturePrepared:
* @data: user data that has been given, when registering the callback
* @configured_caps: #GstCaps defining the configured capture format.
* Ownership of these caps stays in the element.
*
* This callback will be called when the element has finished preparations
* and is ready for image capture. The next buffer that element produces
* will be of @configured_caps format, so this callback allows the application
* to e.g. reconfigure capsfilters in pipeline if any.
*/
typedef void (*GstPhotographyCapturePrepared) (gpointer data, const GstCaps *configured_caps);
/**
* GstPhotographyInterface:
* @parent: parent interface type.
* @get_ev_compensation: vmethod to get ev exposure compensation value
* @get_iso_speed: vmethod to get iso speed (light sensitivity) value
* @get_aperture: vmethod to get aperture value
* @get_exposure: vmethod to get exposure time value
* @get_white_balance_mode: vmethod to get white balance mode value
* @get_color_tone_mode: vmethod to get color tone mode value
* @get_scene_mode: vmethod to get scene mode value
* @get_flash_mode: vmethod to get flash mode value
* @get_noise_reduction: vmethod to get noise reduction mode value
* @get_zoom: vmethod to get zoom factor value
* @set_ev_compensation: vmethod to set ev exposure compensation value
* @set_iso_speed: vmethod to set iso speed (light sensitivity) value
* @set_aperture: vmethod to set aperture value
* @set_exposure: vmethod to set exposure time value
* @set_white_balance_mode: vmethod to set white balance mode value
* @set_color_tone_mode: vmethod to set color tone mode value
* @set_scene_mode: vmethod to set scene mode value
* @set_flash_mode: vmethod to set flash mode value
* @set_noise_reduction: vmethod to set noise reduction mode value
* @set_zoom: vmethod to set zoom factor value
* @get_capabilities: vmethod to get supported capabilities of the interface
* @prepare_for_capture: vmethod to tell the element to prepare for capturing
* @set_autofocus: vmethod to set autofocus on/off
* @set_config: vmethod to set all configuration parameters at once
* @get_config: vmethod to get all configuration parameters at once
* @get_image_capture_supported_caps: vmethod to get caps describing supported image capture formats
*
* #GstPhotographyInterface interface.
*/
typedef struct _GstPhotographyInterface
{
GTypeInterface parent;
/* virtual functions */
gboolean (*get_ev_compensation) (GstPhotography * photo, gfloat * ev_comp);
gboolean (*get_iso_speed) (GstPhotography * photo, guint * iso_speed);
gboolean (*get_aperture) (GstPhotography * photo, guint * aperture);
gboolean (*get_exposure) (GstPhotography * photo, guint32 * exposure);
gboolean (*get_white_balance_mode) (GstPhotography * photo, GstPhotographyWhiteBalanceMode * wb_mode);
gboolean (*get_color_tone_mode) (GstPhotography * photo, GstPhotographyColorToneMode * tone_mode);
gboolean (*get_scene_mode) (GstPhotography * photo, GstPhotographySceneMode * scene_mode);
gboolean (*get_flash_mode) (GstPhotography * photo, GstPhotographyFlashMode * flash_mode);
gboolean (*get_zoom) (GstPhotography * photo, gfloat * zoom);
gboolean (*get_flicker_mode) (GstPhotography * photo, GstPhotographyFlickerReductionMode * flicker_mode);
gboolean (*get_focus_mode) (GstPhotography * photo, GstPhotographyFocusMode * focus_mode);
gboolean (*set_ev_compensation) (GstPhotography * photo, gfloat ev_comp);
gboolean (*set_iso_speed) (GstPhotography * photo, guint iso_speed);
gboolean (*set_aperture) (GstPhotography * photo, guint aperture);
gboolean (*set_exposure) (GstPhotography * photo, guint32 exposure);
gboolean (*set_white_balance_mode) (GstPhotography * photo, GstPhotographyWhiteBalanceMode wb_mode);
gboolean (*set_color_tone_mode) (GstPhotography * photo, GstPhotographyColorToneMode tone_mode);
gboolean (*set_scene_mode) (GstPhotography * photo, GstPhotographySceneMode scene_mode);
gboolean (*set_flash_mode) (GstPhotography * photo, GstPhotographyFlashMode flash_mode);
gboolean (*set_zoom) (GstPhotography * photo, gfloat zoom);
gboolean (*set_flicker_mode) (GstPhotography * photo, GstPhotographyFlickerReductionMode flicker_mode);
gboolean (*set_focus_mode) (GstPhotography * photo, GstPhotographyFocusMode focus_mode);
GstPhotographyCaps (*get_capabilities) (GstPhotography * photo);
gboolean (*prepare_for_capture) (GstPhotography * photo, GstPhotographyCapturePrepared func, GstCaps *capture_caps, gpointer user_data);
void (*set_autofocus) (GstPhotography * photo, gboolean on);
gboolean (*set_config) (GstPhotography * photo, GstPhotographySettings * config);
gboolean (*get_config) (GstPhotography * photo, GstPhotographySettings * config);
gboolean (*get_noise_reduction) (GstPhotography * photo, GstPhotographyNoiseReduction * noise_reduction);
gboolean (*set_noise_reduction) (GstPhotography * photo, GstPhotographyNoiseReduction noise_reduction);
/* FIXME: remove padding, not needed for interfaces */
/*< private > */
gpointer _gst_reserved[GST_PADDING];
} GstPhotographyInterface;
GST_PHOTOGRAPHY_API
GType gst_photography_get_type (void);
/* virtual class function wrappers */
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_ev_compensation (GstPhotography * photo,
gfloat * ev_comp);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_iso_speed (GstPhotography * photo,
guint * iso_speed);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_aperture (GstPhotography * photo,
guint * aperture);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_exposure (GstPhotography * photo,
guint32 * exposure);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_white_balance_mode (GstPhotography * photo,
GstPhotographyWhiteBalanceMode * wb_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_color_tone_mode (GstPhotography * photo,
GstPhotographyColorToneMode * tone_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_scene_mode (GstPhotography * photo,
GstPhotographySceneMode * scene_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_flash_mode (GstPhotography * photo,
GstPhotographyFlashMode * flash_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_noise_reduction (GstPhotography * photo,
GstPhotographyNoiseReduction * noise_reduction);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_zoom (GstPhotography * photo, gfloat * zoom);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_flicker_mode (GstPhotography * photo,
GstPhotographyFlickerReductionMode * mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_focus_mode (GstPhotography * photo,
GstPhotographyFocusMode * mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_ev_compensation (GstPhotography * photo,
gfloat ev_comp);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_iso_speed (GstPhotography * photo,
guint iso_speed);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_aperture (GstPhotography * photo, guint aperture);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_exposure (GstPhotography * photo, guint exposure);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_white_balance_mode (GstPhotography * photo,
GstPhotographyWhiteBalanceMode wb_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_color_tone_mode (GstPhotography * photo,
GstPhotographyColorToneMode tone_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_scene_mode (GstPhotography * photo,
GstPhotographySceneMode scene_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_flash_mode (GstPhotography * photo,
GstPhotographyFlashMode flash_mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_noise_reduction (GstPhotography * photo,
GstPhotographyNoiseReduction noise_reduction);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_zoom (GstPhotography * photo, gfloat zoom);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_flicker_mode (GstPhotography * photo,
GstPhotographyFlickerReductionMode mode);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_focus_mode (GstPhotography * photo,
GstPhotographyFocusMode mode);
GST_PHOTOGRAPHY_API
GstPhotographyCaps gst_photography_get_capabilities (GstPhotography * photo);
GST_PHOTOGRAPHY_API
gboolean gst_photography_prepare_for_capture (GstPhotography * photo,
GstPhotographyCapturePrepared func,
GstCaps *capture_caps,
gpointer user_data);
GST_PHOTOGRAPHY_API
gboolean gst_photography_set_config (GstPhotography * photo,
GstPhotographySettings * config);
GST_PHOTOGRAPHY_API
gboolean gst_photography_get_config (GstPhotography * photo,
GstPhotographySettings * config);
GST_PHOTOGRAPHY_API
void gst_photography_set_autofocus (GstPhotography * photo, gboolean on);
G_END_DECLS
#endif /* __GST_PHOTOGRAPHY_H__ */

View File

@ -0,0 +1,28 @@
plugin_LTLIBRARIES = libgstcamerabin.la
libgstcamerabin_la_SOURCES = gstviewfinderbin.c \
gstdigitalzoom.c \
camerabingeneral.c \
gstwrappercamerabinsrc.c \
gstcamerabin2.c \
gstplugin.c
libgstcamerabin_la_CFLAGS = \
$(GST_PLUGINS_BAD_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) $(GST_CFLAGS) \
-DGST_USE_UNSTABLE_API
libgstcamerabin_la_LIBADD = \
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-$(GST_API_VERSION).la \
$(top_builddir)/gst-libs/gst/basecamerabinsrc/libgstbasecamerabinsrc-$(GST_API_VERSION).la \
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_API_VERSION) -lgstapp-$(GST_API_VERSION) -lgstpbutils-$(GST_API_VERSION) \
$(GST_BASE_LIBS) $(GST_LIBS)
libgstcamerabin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstviewfinderbin.h \
camerabingeneral.h \
gstdigitalzoom.h \
gstwrappercamerabinsrc.h \
gstcamerabin2.h

1165
gst/camerabin2/Makefile.in Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,260 @@
/*
* GStreamer
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:camerabingeneral
* @title: GstCameraBin2
* @short_description: helper functions for #GstCameraBin2 and it's modules
*
* Common helper functions for #GstCameraBin2, #GstCameraBin2Image and
* #GstCameraBin2Video.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <glib.h>
#include <gst/basecamerabinsrc/gstbasecamerasrc.h>
#include <gst/gst-i18n-plugin.h>
#include "camerabingeneral.h"
/**
* gst_camerabin_add_element:
* @bin: add an element to this bin
* @new_elem: new element to be added
*
* Adds given element to given @bin. Looks for an unconnected src pad
* from the @bin and links the element to it. Raises an error if adding
* or linking failed. Unrefs the element in the case of an error.
*
* Returns: %TRUE if adding and linking succeeded, %FALSE otherwise.
*/
gboolean
gst_camerabin_add_element (GstBin * bin, GstElement * new_elem)
{
return gst_camerabin_add_element_full (bin, NULL, new_elem, NULL);
}
/**
* gst_camerabin_add_element_full:
* @bin: add an element to this bin
* @srcpad: src pad name, or NULL for any
* @new_elem: new element to be added
* @dstpad: dst pad name, or NULL for any
*
* Adds given element to given @bin. Looks for an unconnected src pad
* (with name @srcpad, if specified) from the @bin and links the element
* to it. Raises an error if adding or linking failed. Unrefs the element
* in the case of an error.
*
* Returns: %TRUE if adding and linking succeeded, %FALSE otherwise.
*/
gboolean
gst_camerabin_add_element_full (GstBin * bin, const gchar * srcpad,
GstElement * new_elem, const gchar * dstpad)
{
gboolean ret;
g_return_val_if_fail (bin, FALSE);
g_return_val_if_fail (new_elem, FALSE);
ret = gst_camerabin_try_add_element (bin, srcpad, new_elem, dstpad);
if (!ret) {
gchar *elem_name = gst_element_get_name (new_elem);
GST_ELEMENT_ERROR (bin, CORE, NEGOTIATION, (NULL),
("linking %s failed", elem_name));
g_free (elem_name);
gst_object_unref (new_elem);
}
return ret;
}
/**
* gst_camerabin_try_add_element:
* @bin: tries adding an element to this bin
* @srcpad: src pad name, or NULL for any
* @new_elem: new element to be added
* @dstpad: dst pad name, or NULL for any
*
* Adds given element to given @bin. Looks for an unconnected src pad
* (with name @srcpad, if specified) from the @bin and links the element to
* it.
*
* Returns: %TRUE if adding and linking succeeded, %FALSE otherwise.
*/
gboolean
gst_camerabin_try_add_element (GstBin * bin, const gchar * srcpad,
GstElement * new_elem, const gchar * dstpad)
{
GstPad *bin_pad;
GstElement *bin_elem;
gboolean ret = TRUE;
g_return_val_if_fail (bin, FALSE);
g_return_val_if_fail (new_elem, FALSE);
/* Get pads for linking */
bin_pad = gst_bin_find_unlinked_pad (bin, GST_PAD_SRC);
/* Add to bin */
gst_bin_add (GST_BIN (bin), new_elem);
/* Link, if unconnected pad was found, otherwise just add it to bin */
if (bin_pad) {
GST_DEBUG_OBJECT (bin, "linking %s to %s:%s", GST_OBJECT_NAME (new_elem),
GST_DEBUG_PAD_NAME (bin_pad));
bin_elem = gst_pad_get_parent_element (bin_pad);
gst_object_unref (bin_pad);
if (!gst_element_link_pads_full (bin_elem, srcpad, new_elem, dstpad,
GST_PAD_LINK_CHECK_CAPS)) {
gst_object_ref (new_elem);
gst_bin_remove (bin, new_elem);
ret = FALSE;
}
gst_object_unref (bin_elem);
} else {
GST_INFO_OBJECT (bin, "no unlinked source pad in bin");
}
return ret;
}
/**
* gst_camerabin_create_and_add_element:
* @bin: tries adding an element to this bin
* @elem_name: name of the element to be created
* @instance_name: name of the instance of the element to be created
*
* Creates an element according to given name and
* adds it to given @bin. Looks for an unconnected src pad
* from the @bin and links the element to it.
*
* Returns: pointer to the new element if successful, NULL otherwise.
*/
GstElement *
gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name,
const gchar * instance_name)
{
GstElement *new_elem;
g_return_val_if_fail (bin, FALSE);
g_return_val_if_fail (elem_name, FALSE);
new_elem = gst_element_factory_make (elem_name, instance_name);
if (!new_elem) {
GST_ELEMENT_ERROR (bin, CORE, MISSING_PLUGIN,
(_("Missing element '%s' - check your GStreamer installation."),
elem_name), (NULL));
} else if (!gst_camerabin_add_element (bin, new_elem)) {
new_elem = NULL;
}
return new_elem;
}
/* try to change the state of an element. This function returns the element
* when the state change could be performed. When this function returns NULL
* an error occured and the element is unreffed. */
static GstElement *
try_element (GstElement * bin, GstElement * element)
{
GstStateChangeReturn ret;
if (element) {
ret = gst_element_set_state (element, GST_STATE_READY);
if (ret == GST_STATE_CHANGE_FAILURE) {
GST_DEBUG_OBJECT (bin, "failed state change..");
gst_element_set_state (element, GST_STATE_NULL);
gst_object_unref (element);
element = NULL;
}
}
return element;
}
GstElement *
gst_camerabin_setup_default_element (GstBin * bin, GstElement * user_elem,
const gchar * auto_elem_name, const gchar * default_elem_name,
const gchar * instance_name)
{
GstElement *elem;
if (user_elem) {
GST_DEBUG_OBJECT (bin, "trying configured element");
elem = try_element (GST_ELEMENT_CAST (bin), gst_object_ref (user_elem));
} else {
/* only try fallback if no specific sink was chosen */
GST_DEBUG_OBJECT (bin, "trying %s", auto_elem_name);
elem = gst_element_factory_make (auto_elem_name, instance_name);
elem = try_element (GST_ELEMENT_CAST (bin), elem);
if (elem == NULL) {
/* if default sink from config.h is different then try it too */
if (strcmp (default_elem_name, auto_elem_name)) {
GST_DEBUG_OBJECT (bin, "trying %s", default_elem_name);
elem = gst_element_factory_make (default_elem_name, instance_name);
elem = try_element (GST_ELEMENT_CAST (bin), elem);
}
}
}
return elem;
}
/**
* gst_camerabin_remove_elements_from_bin:
* @bin: removes all elements from this bin
*
* Removes all elements from this @bin.
*/
void
gst_camerabin_remove_elements_from_bin (GstBin * bin)
{
GstIterator *iter = NULL;
GValue value = { 0 };
GstElement *elem = NULL;
gboolean done = FALSE;
iter = gst_bin_iterate_elements (bin);
while (!done) {
switch (gst_iterator_next (iter, &value)) {
case GST_ITERATOR_OK:
elem = (GstElement *) g_value_get_object (&value);
gst_bin_remove (bin, elem);
gst_element_set_state (GST_ELEMENT (elem), GST_STATE_NULL);
/* Iterator increased the element refcount, so unref */
g_value_unset (&value);
break;
case GST_ITERATOR_RESYNC:
gst_iterator_resync (iter);
break;
case GST_ITERATOR_ERROR:
GST_WARNING_OBJECT (bin, "error in iterating elements");
done = TRUE;
break;
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
}
gst_iterator_free (iter);
}

View File

@ -0,0 +1,37 @@
/*
* GStreamer
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __CAMERABIN_GENERAL_H_
#define __CAMERABIN_GENERAL_H_
#include <gst/gst.h>
gboolean gst_camerabin_try_add_element (GstBin * bin, const gchar * srcpad, GstElement * new_elem, const gchar * dstpad);
gboolean gst_camerabin_add_element (GstBin * bin, GstElement * new_elem);
gboolean gst_camerabin_add_element_full (GstBin * bin, const gchar * srcpad, GstElement * new_elem, const gchar * dstpad);
GstElement *gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name, const gchar * instance_name);
GstElement * gst_camerabin_setup_default_element (GstBin * bin, GstElement *user_elem, const gchar *auto_elem_name, const gchar *default_elem_name,
const gchar * instance_elem_name);
void gst_camerabin_remove_elements_from_bin (GstBin * bin);
#endif /* #ifndef __CAMERABIN_GENERAL_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,168 @@
/* GStreamer
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _GST_CAMERA_BIN2_H_
#define _GST_CAMERA_BIN2_H_
#include <gst/gst.h>
#include <gst/pbutils/encoding-profile.h>
G_BEGIN_DECLS
/* to keep code mergeable */
#define GstCameraBin2 GstCameraBin
#define GstCameraBin2Class GstCameraBinClass
#define GST_TYPE_CAMERA_BIN2 (gst_camera_bin2_get_type())
#define GST_CAMERA_BIN2(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMERA_BIN2,GstCameraBin2))
#define GST_CAMERA_BIN2_CAST(obj) ((GstCameraBin2 *) obj)
#define GST_CAMERA_BIN2_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMERA_BIN2,GstCameraBin2Class))
#define GST_IS_CAMERA_BIN2(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERA_BIN2))
#define GST_IS_CAMERA_BIN2_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERA_BIN2))
typedef enum
{
/* matches GstEncFlags GST_ENC_FLAG_NO_AUDIO_CONVERSION in encodebin */
GST_CAM_FLAG_NO_AUDIO_CONVERSION = (1 << 0),
/* matches GstEncFlags GST_ENC_FLAG_NO_VIDEO_CONVERSION in encodebin */
GST_CAM_FLAG_NO_VIDEO_CONVERSION = (1 << 1),
/* maps to 'disable-converters' property in viewfinderbin */
GST_CAM_FLAG_NO_VIEWFINDER_CONVERSION = (1 << 2),
/* maps to GstEncFlags GST_ENC_FLAG_NO_VIDEO_CONVERSION in the image bin's
* encodebin */
GST_CAM_FLAG_NO_IMAGE_CONVERSION = (1 << 3)
} GstCamFlags;
typedef enum _GstCameraBinVideoState
{
GST_CAMERA_BIN_VIDEO_IDLE=0,
GST_CAMERA_BIN_VIDEO_STARTING=1,
GST_CAMERA_BIN_VIDEO_RECORDING=2,
GST_CAMERA_BIN_VIDEO_FINISHING=3
} GstCameraBinVideoState;
typedef struct _GstCameraBin2 GstCameraBin2;
typedef struct _GstCameraBin2Class GstCameraBin2Class;
struct _GstCameraBin2
{
GstPipeline pipeline;
GstElement *src;
GstElement *user_src;
gulong src_capture_notify_id;
GstElement *video_encodebin;
gulong video_encodebin_signal_id;
GstElement *videosink;
GstElement *videobin_capsfilter;
GstElement *viewfinderbin;
GstElement *viewfinderbin_queue;
GstElement *viewfinderbin_capsfilter;
GstElement *image_encodebin;
gulong image_encodebin_signal_id;
GstElement *imagesink;
GstElement *imagebin_capsfilter;
GstElement *video_filter;
GstElement *image_filter;
GstElement *viewfinder_filter;
GstElement *audio_filter;
GstElement *user_video_filter;
GstElement *user_image_filter;
GstElement *user_viewfinder_filter;
GstElement *user_audio_filter;
GstElement *audio_src;
GstElement *user_audio_src;
GstElement *audio_volume;
GstElement *audio_capsfilter;
gint processing_counter; /* atomic int */
/* Index of the auto incrementing file index for captures */
gint capture_index;
GMutex image_capture_mutex;
/* stores list of image locations to be pushed to the image sink
* as file location change notifications, they are pushed before
* each buffer capture */
GSList *image_location_list;
/* Store also tags and push them before each captured image */
GSList *image_tags_list;
/*
* Similar to above, but used for giving names to previews
*
* Need to protect with a mutex as this list is used when the
* camera-source posts a preview image. As we have no control
* on how the camera-source will behave (we can only tell how
* it should), the preview location list might be used in an
* inconsistent way.
* One example is the camera-source posting a preview image after
* camerabin2 was put to ready, when this preview list will be
* freed and set to NULL. Concurrent access might lead to crashes in
* this situation. (Concurrency from the state-change freeing the
* list and the message handling function looking at preview names)
*/
GSList *preview_location_list;
GMutex preview_list_mutex;
gboolean video_profile_switch;
gboolean image_profile_switch;
gboolean audio_drop_eos;
gboolean audio_send_newseg;
GMutex video_capture_mutex;
GCond video_state_cond;
GstCameraBinVideoState video_state;
/* properties */
gint mode;
gchar *location;
gboolean post_previews;
GstCaps *preview_caps;
GstElement *preview_filter;
GstEncodingProfile *video_profile;
GstEncodingProfile *image_profile;
gfloat zoom;
gfloat max_zoom;
GstCamFlags flags;
gboolean elements_created;
};
struct _GstCameraBin2Class
{
GstPipelineClass pipeline_class;
/* Action signals */
void (*start_capture) (GstCameraBin2 * camera);
void (*stop_capture) (GstCameraBin2 * camera);
};
GType gst_camera_bin2_get_type (void);
gboolean gst_camera_bin2_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif

View File

@ -0,0 +1,386 @@
/*
* GStreamer
* Copyright (C) 2015 Thiago Santos <thiagoss@osg.samsung.com>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-digitalzoom
* @title: digitalzoom
*
* Does digital zooming by cropping and scaling an image.
*
* It is a bin that contains the internal pipeline:
* videocrop ! videoscale ! capsfilter
*
* It keeps monitoring the input caps and when it is set/updated
* the capsfilter gets set the same caps to guarantee that the same
* input resolution is provided as output.
*
* Exposes the 'zoom' property as a float to allow setting the amount
* of zoom desired. Zooming is done in the center.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gst/gst-i18n-plugin.h>
#include "gstdigitalzoom.h"
enum
{
PROP_0,
PROP_ZOOM
};
GST_DEBUG_CATEGORY (digital_zoom_debug);
#define GST_CAT_DEFAULT digital_zoom_debug
#define gst_digital_zoom_parent_class parent_class
G_DEFINE_TYPE (GstDigitalZoom, gst_digital_zoom, GST_TYPE_BIN);
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static void
gst_digital_zoom_update_crop (GstDigitalZoom * self, GstCaps * caps)
{
gint w2_crop = 0, h2_crop = 0;
gint left = 0;
gint right = 0;
gint top = 0;
gint bottom = 0;
gint width, height;
gfloat zoom;
GstStructure *structure;
if (caps == NULL || gst_caps_is_any (caps)) {
g_object_set (self->capsfilter, "caps", NULL, NULL);
return;
}
structure = gst_caps_get_structure (caps, 0);
gst_structure_get (structure, "width", G_TYPE_INT, &width, "height",
G_TYPE_INT, &height, NULL);
zoom = self->zoom;
if (self->videocrop) {
/* Update capsfilters to apply the zoom */
GST_INFO_OBJECT (self, "zoom: %f, orig size: %dx%d", zoom, width, height);
if (zoom != 1.0) {
w2_crop = (width - (gint) (width * 1.0 / zoom)) / 2;
h2_crop = (height - (gint) (height * 1.0 / zoom)) / 2;
left += w2_crop;
right += w2_crop;
top += h2_crop;
bottom += h2_crop;
/* force number of pixels cropped from left to be even, to avoid slow code
* path on videoscale */
left &= 0xFFFE;
}
GST_INFO_OBJECT (self,
"sw cropping: left:%d, right:%d, top:%d, bottom:%d", left, right, top,
bottom);
g_object_set (self->videocrop, "left", left, "right", right, "top",
top, "bottom", bottom, NULL);
}
}
static void
gst_digital_zoom_update_zoom (GstDigitalZoom * self)
{
GstCaps *caps = NULL;
if (!self->elements_created)
return;
g_object_get (self->capsfilter, "caps", &caps, NULL);
if (caps) {
gst_digital_zoom_update_crop (self, caps);
gst_caps_unref (caps);
}
}
static void
gst_digital_zoom_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (object);
switch (prop_id) {
case PROP_ZOOM:
self->zoom = g_value_get_float (value);
GST_DEBUG_OBJECT (self, "Setting zoom: %f", self->zoom);
gst_digital_zoom_update_zoom (self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
break;
}
}
static void
gst_digital_zoom_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (object);
switch (prop_id) {
case PROP_ZOOM:
g_value_set_float (value, self->zoom);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);
break;
}
}
static gboolean
gst_digital_zoom_sink_query (GstPad * sink, GstObject * parent,
GstQuery * query)
{
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (parent);
switch (GST_QUERY_TYPE (query)) {
/* for caps related queries we want to skip videocrop ! videoscale
* as the digital zoom preserves input dimensions */
case GST_QUERY_CAPS:
case GST_QUERY_ACCEPT_CAPS:
if (self->elements_created)
return gst_pad_peer_query (self->srcpad, query);
/* fall through */
default:
return gst_pad_query_default (sink, parent, query);
}
}
static gboolean
gst_digital_zoom_src_query (GstPad * sink, GstObject * parent, GstQuery * query)
{
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (parent);
switch (GST_QUERY_TYPE (query)) {
/* for caps related queries we want to skip videocrop ! videoscale
* as the digital zoom preserves input dimensions */
case GST_QUERY_CAPS:
case GST_QUERY_ACCEPT_CAPS:
if (self->elements_created)
return gst_pad_peer_query (self->sinkpad, query);
/* fall through */
default:
return gst_pad_query_default (sink, parent, query);
}
}
static gboolean
gst_digital_zoom_sink_event (GstPad * sink, GstObject * parent,
GstEvent * event)
{
gboolean ret;
gboolean is_caps;
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (parent);
GstCaps *old_caps = NULL;
GstCaps *caps = NULL;
is_caps = GST_EVENT_TYPE (event) == GST_EVENT_CAPS;
if (is_caps) {
gst_event_parse_caps (event, &caps);
g_object_get (self->capsfilter, "caps", &old_caps, NULL);
g_object_set (self->capsfilter, "caps", caps, NULL);
gst_digital_zoom_update_crop (self, caps);
}
ret = gst_pad_event_default (sink, parent, event);
if (is_caps) {
if (!ret) {
gst_digital_zoom_update_crop (self, old_caps);
g_object_set (self->capsfilter, "caps", old_caps, NULL);
}
if (old_caps)
gst_caps_unref (old_caps);
}
return ret;
}
static void
gst_digital_zoom_dispose (GObject * object)
{
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (object);
if (self->capsfilter_sinkpad) {
gst_object_unref (self->capsfilter_sinkpad);
self->capsfilter_sinkpad = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_digital_zoom_init (GstDigitalZoom * self)
{
GstPadTemplate *tmpl;
tmpl = gst_static_pad_template_get (&src_template);
self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", tmpl);
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
gst_object_unref (tmpl);
tmpl = gst_static_pad_template_get (&sink_template);
self->sinkpad = gst_ghost_pad_new_no_target_from_template ("sink", tmpl);
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
gst_object_unref (tmpl);
gst_pad_set_event_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_digital_zoom_sink_event));
gst_pad_set_query_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_digital_zoom_sink_query));
gst_pad_set_query_function (self->srcpad,
GST_DEBUG_FUNCPTR (gst_digital_zoom_src_query));
self->zoom = 1;
}
static GstElement *
zoom_create_element (GstDigitalZoom * self, const gchar * element_name,
const gchar * name)
{
GstElement *element;
element = gst_element_factory_make (element_name, name);
if (element == NULL) {
GST_ELEMENT_ERROR (self, CORE, MISSING_PLUGIN,
(_("Missing element '%s' - check your GStreamer installation."),
element_name), (NULL));
}
return element;
}
static gboolean
gst_digital_zoom_create_elements (GstDigitalZoom * self)
{
GstPad *pad;
if (self->elements_created)
return TRUE;
self->videocrop = zoom_create_element (self, "videocrop", "zoom-videocrop");
if (self->videocrop == NULL)
return FALSE;
if (!gst_bin_add (GST_BIN_CAST (self), self->videocrop))
return FALSE;
self->videoscale =
zoom_create_element (self, "videoscale", "zoom-videoscale");
if (self->videoscale == NULL)
return FALSE;
if (!gst_bin_add (GST_BIN_CAST (self), self->videoscale))
return FALSE;
self->capsfilter =
zoom_create_element (self, "capsfilter", "zoom-capsfilter");
if (self->capsfilter == NULL)
return FALSE;
if (!gst_bin_add (GST_BIN_CAST (self), self->capsfilter))
return FALSE;
if (!gst_element_link_pads_full (self->videocrop, "src", self->videoscale,
"sink", GST_PAD_LINK_CHECK_CAPS))
return FALSE;
if (!gst_element_link_pads_full (self->videoscale, "src", self->capsfilter,
"sink", GST_PAD_LINK_CHECK_CAPS))
return FALSE;
pad = gst_element_get_static_pad (self->videocrop, "sink");
gst_ghost_pad_set_target (GST_GHOST_PAD (self->sinkpad), pad);
gst_object_unref (pad);
pad = gst_element_get_static_pad (self->capsfilter, "src");
gst_ghost_pad_set_target (GST_GHOST_PAD (self->srcpad), pad);
gst_object_unref (pad);
self->capsfilter_sinkpad =
gst_element_get_static_pad (self->capsfilter, "sink");
self->elements_created = TRUE;
return TRUE;
}
static GstStateChangeReturn
gst_digital_zoom_change_state (GstElement * element, GstStateChange trans)
{
GstDigitalZoom *self = GST_DIGITAL_ZOOM_CAST (element);
switch (trans) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!gst_digital_zoom_create_elements (self)) {
return GST_STATE_CHANGE_FAILURE;
}
break;
default:
break;
}
return GST_ELEMENT_CLASS (parent_class)->change_state (element, trans);
}
static void
gst_digital_zoom_class_init (GstDigitalZoomClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = G_OBJECT_CLASS (klass);
gstelement_class = GST_ELEMENT_CLASS (klass);
gobject_class->dispose = gst_digital_zoom_dispose;
gobject_class->set_property = gst_digital_zoom_set_property;
gobject_class->get_property = gst_digital_zoom_get_property;
/* g_object_class_install_property .... */
g_object_class_install_property (gobject_class, PROP_ZOOM,
g_param_spec_float ("zoom", "Zoom",
"Digital zoom level to be used", 1.0, G_MAXFLOAT, 1.0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gstelement_class->change_state = gst_digital_zoom_change_state;
GST_DEBUG_CATEGORY_INIT (digital_zoom_debug, "digitalzoom",
0, "digital zoom");
gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
gst_element_class_add_static_pad_template (gstelement_class, &src_template);
gst_element_class_set_static_metadata (gstelement_class,
"Digital zoom bin", "Generic/Video",
"Digital zoom bin", "Thiago Santos <thiagoss@osg.samsung.com>");
}

View File

@ -0,0 +1,79 @@
/*
* GStreamer
* Copyright (C) 2015 Thiago Santos <thiagoss@osg.samsung.com>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_DIGITAL_ZOOM_H__
#define __GST_DIGITAL_ZOOM_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_DIGITAL_ZOOM \
(gst_digital_zoom_get_type())
#define GST_DIGITAL_ZOOM(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DIGITAL_ZOOM,GstDigitalZoom))
#define GST_DIGITAL_ZOOM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DIGITAL_ZOOM,GstDigitalZoomClass))
#define GST_IS_DIGITAL_ZOOM(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DIGITAL_ZOOM))
#define GST_IS_DIGITAL_ZOOM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DIGITAL_ZOOM))
#define GST_DIGITAL_ZOOM_CAST(d) ((GstDigitalZoom *)(d))
GType gst_digital_zoom_get_type (void);
typedef struct _GstDigitalZoom GstDigitalZoom;
typedef struct _GstDigitalZoomClass GstDigitalZoomClass;
/**
* GstDigitalZoom:
*
*/
struct _GstDigitalZoom
{
GstBin parent;
GstPad *srcpad;
GstPad *sinkpad;
gboolean elements_created;
GstElement *videocrop;
GstElement *videoscale;
GstElement *capsfilter;
GstPad *capsfilter_sinkpad;
gfloat zoom;
};
/**
* GstDigitalZoomClass:
*
*/
struct _GstDigitalZoomClass
{
GstBinClass parent;
};
G_END_DECLS
#endif /* __GST_DIGITAL_ZOOM_H__ */

View File

@ -0,0 +1,46 @@
/* GStreamer
* Copyright (C) <2010> Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* gstplugin.c: camerabin2 plugin registering
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstviewfinderbin.h"
#include "gstwrappercamerabinsrc.h"
#include "gstcamerabin2.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_viewfinder_bin_plugin_init (plugin))
return FALSE;
if (!gst_wrapper_camera_bin_src_plugin_init (plugin))
return FALSE;
if (!gst_camera_bin2_plugin_init (plugin))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
camerabin, "Take image snapshots and record movies from camera",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View File

@ -0,0 +1,369 @@
/* GStreamer
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-gstviewfinderbin
* @title: gstviewfinderbin
*
* The gstviewfinderbin element is a displaying element for camerabin2.
*
* ## Example launch line
* |[
* gst-launch-1.0 -v videotestsrc ! viewfinderbin
* ]|
* Feeds the viewfinderbin with video test data.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstviewfinderbin.h"
#include "camerabingeneral.h"
#include <gst/pbutils/pbutils.h>
#include <gst/gst-i18n-plugin.h>
GST_DEBUG_CATEGORY_STATIC (gst_viewfinder_bin_debug);
#define GST_CAT_DEFAULT gst_viewfinder_bin_debug
enum
{
PROP_0,
PROP_VIDEO_SINK,
PROP_DISABLE_CONVERTERS
};
#define DEFAULT_DISABLE_CONVERTERS FALSE
/* pad templates */
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw(ANY)")
);
/* class initialization */
#define gst_viewfinder_bin_parent_class parent_class
G_DEFINE_TYPE (GstViewfinderBin, gst_viewfinder_bin, GST_TYPE_BIN);
static void gst_viewfinder_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * spec);
static void gst_viewfinder_bin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * spec);
static void
gst_viewfinder_bin_set_video_sink (GstViewfinderBin * vfbin, GstElement * sink);
/* Element class functions */
static GstStateChangeReturn
gst_viewfinder_bin_change_state (GstElement * element, GstStateChange trans);
static void
gst_viewfinder_bin_dispose (GObject * object)
{
GstViewfinderBin *viewfinderbin = GST_VIEWFINDER_BIN_CAST (object);
if (viewfinderbin->user_video_sink) {
gst_object_unref (viewfinderbin->user_video_sink);
viewfinderbin->user_video_sink = NULL;
}
if (viewfinderbin->video_sink) {
gst_object_unref (viewfinderbin->video_sink);
viewfinderbin->video_sink = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose ((GObject *) viewfinderbin);
}
static void
gst_viewfinder_bin_class_init (GstViewfinderBinClass * klass)
{
GObjectClass *gobject_klass;
GstElementClass *element_class;
gobject_klass = (GObjectClass *) klass;
element_class = GST_ELEMENT_CLASS (klass);
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_viewfinder_bin_change_state);
gobject_klass->dispose = gst_viewfinder_bin_dispose;
gobject_klass->set_property = gst_viewfinder_bin_set_property;
gobject_klass->get_property = gst_viewfinder_bin_get_property;
g_object_class_install_property (gobject_klass, PROP_VIDEO_SINK,
g_param_spec_object ("video-sink", "Video Sink",
"the video output element to use (NULL = default)",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_klass, PROP_DISABLE_CONVERTERS,
g_param_spec_boolean ("disable-converters", "Disable conversion elements",
"If video converters should be disabled (must be set on NULL)",
DEFAULT_DISABLE_CONVERTERS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_static_pad_template (element_class, &sink_template);
gst_element_class_set_static_metadata (element_class, "Viewfinder Bin",
"Sink/Video", "Viewfinder Bin used in camerabin2",
"Thiago Santos <thiago.sousa.santos@collabora.com>");
}
static void
gst_viewfinder_bin_init (GstViewfinderBin * viewfinderbin)
{
GstPadTemplate *templ = gst_static_pad_template_get (&sink_template);
viewfinderbin->ghostpad = gst_ghost_pad_new_no_target_from_template ("sink",
templ);
gst_object_unref (templ);
gst_element_add_pad (GST_ELEMENT_CAST (viewfinderbin),
viewfinderbin->ghostpad);
viewfinderbin->disable_converters = DEFAULT_DISABLE_CONVERTERS;
}
static gboolean
gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin)
{
GstElement *csp = NULL;
GstElement *videoscale = NULL;
GstPad *firstpad = NULL;
const gchar *missing_element_name;
gboolean newsink = FALSE;
gboolean updated_converters = FALSE;
GST_DEBUG_OBJECT (vfbin, "Creating internal elements");
/* First check if we need to add/replace the internal sink */
if (vfbin->video_sink) {
if (vfbin->user_video_sink && vfbin->video_sink != vfbin->user_video_sink) {
gst_bin_remove (GST_BIN_CAST (vfbin), vfbin->video_sink);
gst_object_unref (vfbin->video_sink);
vfbin->video_sink = NULL;
}
}
if (!vfbin->video_sink) {
if (vfbin->user_video_sink)
vfbin->video_sink = gst_object_ref (vfbin->user_video_sink);
else {
vfbin->video_sink = gst_element_factory_make ("autovideosink",
"vfbin-sink");
if (!vfbin->video_sink) {
missing_element_name = "autovideosink";
goto missing_element;
}
}
gst_bin_add (GST_BIN_CAST (vfbin), gst_object_ref (vfbin->video_sink));
newsink = TRUE;
}
/* check if we want add/remove the conversion elements */
if (vfbin->elements_created && vfbin->disable_converters) {
/* remove the elements, user doesn't want them */
gst_ghost_pad_set_target (GST_GHOST_PAD (vfbin->ghostpad), NULL);
csp = gst_bin_get_by_name (GST_BIN_CAST (vfbin), "vfbin-csp");
videoscale = gst_bin_get_by_name (GST_BIN_CAST (vfbin), "vfbin-videoscale");
gst_bin_remove (GST_BIN_CAST (vfbin), csp);
gst_bin_remove (GST_BIN_CAST (vfbin), videoscale);
gst_object_unref (csp);
gst_object_unref (videoscale);
updated_converters = TRUE;
} else if (!vfbin->elements_created && !vfbin->disable_converters) {
gst_ghost_pad_set_target (GST_GHOST_PAD (vfbin->ghostpad), NULL);
/* add the elements, user wants them */
csp = gst_element_factory_make ("videoconvert", "vfbin-csp");
if (!csp) {
missing_element_name = "videoconvert";
goto missing_element;
}
gst_bin_add (GST_BIN_CAST (vfbin), csp);
videoscale = gst_element_factory_make ("videoscale", "vfbin->videoscale");
if (!videoscale) {
missing_element_name = "videoscale";
goto missing_element;
}
gst_bin_add (GST_BIN_CAST (vfbin), videoscale);
gst_element_link_pads_full (csp, "src", videoscale, "sink",
GST_PAD_LINK_CHECK_NOTHING);
vfbin->elements_created = TRUE;
GST_DEBUG_OBJECT (vfbin, "Elements succesfully created and linked");
updated_converters = TRUE;
}
/* otherwise, just leave it as is */
/* if sink was replaced -> link it to the internal converters */
if (newsink && !vfbin->disable_converters) {
gboolean unref = FALSE;
if (!videoscale) {
videoscale = gst_bin_get_by_name (GST_BIN_CAST (vfbin),
"vfbin-videscale");
unref = TRUE;
}
if (!gst_element_link_pads_full (videoscale, "src", vfbin->video_sink,
"sink", GST_PAD_LINK_CHECK_CAPS)) {
GST_ELEMENT_ERROR (vfbin, CORE, NEGOTIATION, (NULL),
("linking videoscale and viewfindersink failed"));
}
if (unref)
gst_object_unref (videoscale);
videoscale = NULL;
}
/* Check if we need a new ghostpad target */
if (updated_converters || (newsink && vfbin->disable_converters)) {
if (vfbin->disable_converters) {
firstpad = gst_element_get_static_pad (vfbin->video_sink, "sink");
} else {
/* csp should always exist at this point */
firstpad = gst_element_get_static_pad (csp, "sink");
}
}
/* need to change the ghostpad target if firstpad is set */
if (firstpad) {
if (!gst_ghost_pad_set_target (GST_GHOST_PAD (vfbin->ghostpad), firstpad))
goto error;
gst_object_unref (firstpad);
firstpad = NULL;
}
return TRUE;
missing_element:
gst_element_post_message (GST_ELEMENT_CAST (vfbin),
gst_missing_element_message_new (GST_ELEMENT_CAST (vfbin),
missing_element_name));
GST_ELEMENT_ERROR (vfbin, CORE, MISSING_PLUGIN,
(_("Missing element '%s' - check your GStreamer installation."),
missing_element_name), (NULL));
goto error;
error:
GST_WARNING_OBJECT (vfbin, "Creating internal elements failed");
if (firstpad)
gst_object_unref (firstpad);
return FALSE;
}
static GstStateChangeReturn
gst_viewfinder_bin_change_state (GstElement * element, GstStateChange trans)
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstViewfinderBin *vfbin = GST_VIEWFINDER_BIN_CAST (element);
switch (trans) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!gst_viewfinder_bin_create_elements (vfbin)) {
return GST_STATE_CHANGE_FAILURE;
}
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, trans);
switch (trans) {
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
}
static void
gst_viewfinder_bin_set_video_sink (GstViewfinderBin * vfbin, GstElement * sink)
{
GST_INFO_OBJECT (vfbin, "Setting video sink to %" GST_PTR_FORMAT, sink);
if (vfbin->user_video_sink != sink) {
if (vfbin->user_video_sink) {
gst_object_unref (vfbin->user_video_sink);
}
vfbin->user_video_sink = sink;
if (sink)
gst_object_ref (sink);
}
}
static void
gst_viewfinder_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstViewfinderBin *vfbin = GST_VIEWFINDER_BIN_CAST (object);
switch (prop_id) {
case PROP_VIDEO_SINK:
gst_viewfinder_bin_set_video_sink (vfbin, g_value_get_object (value));
break;
case PROP_DISABLE_CONVERTERS:
vfbin->disable_converters = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_viewfinder_bin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstViewfinderBin *vfbin = GST_VIEWFINDER_BIN_CAST (object);
switch (prop_id) {
case PROP_VIDEO_SINK:
g_value_set_object (value, vfbin->video_sink);
break;
case PROP_DISABLE_CONVERTERS:
g_value_set_boolean (value, vfbin->disable_converters);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
gboolean
gst_viewfinder_bin_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_viewfinder_bin_debug, "viewfinderbin", 0,
"ViewFinderBin");
return gst_element_register (plugin, "viewfinderbin", GST_RANK_NONE,
gst_viewfinder_bin_get_type ());
}

View File

@ -0,0 +1,60 @@
/* GStreamer
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _GST_VIEWFINDER_BIN_H_
#define _GST_VIEWFINDER_BIN_H_
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_VIEWFINDER_BIN (gst_viewfinder_bin_get_type())
#define GST_VIEWFINDER_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIEWFINDER_BIN,GstViewfinderBin))
#define GST_VIEWFINDER_BIN_CAST(obj) ((GstViewfinderBin *) obj)
#define GST_VIEWFINDER_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIEWFINDER_BIN,GstViewfinderBinClass))
#define GST_IS_VIEWFINDER_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIEWFINDER_BIN))
#define GST_IS_VIEWFINDER_BIN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIEWFINDER_BIN))
typedef struct _GstViewfinderBin GstViewfinderBin;
typedef struct _GstViewfinderBinClass GstViewfinderBinClass;
struct _GstViewfinderBin
{
GstBin bin;
GstPad *ghostpad;
GstElement *video_sink;
GstElement *user_video_sink;
gboolean elements_created;
gboolean disable_converters;
};
struct _GstViewfinderBinClass
{
GstBinClass bin_class;
};
GType gst_viewfinder_bin_get_type (void);
gboolean gst_viewfinder_bin_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,131 @@
/*
* GStreamer
* Copyright (C) 2010 Texas Instruments, Inc
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_WRAPPER_CAMERA_BIN_SRC_H__
#define __GST_WRAPPER_CAMERA_BIN_SRC_H__
#include <gst/gst.h>
#include <gst/basecamerabinsrc/gstbasecamerasrc.h>
#include <gst/basecamerabinsrc/gstcamerabinpreview.h>
#include "camerabingeneral.h"
G_BEGIN_DECLS
#define GST_TYPE_WRAPPER_CAMERA_BIN_SRC \
(gst_wrapper_camera_bin_src_get_type())
#define GST_WRAPPER_CAMERA_BIN_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WRAPPER_CAMERA_BIN_SRC,GstWrapperCameraBinSrc))
#define GST_WRAPPER_CAMERA_BIN_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_WRAPPER_CAMERA_BIN_SRC,GstWrapperCameraBinSrcClass))
#define GST_IS_WRAPPER_CAMERA_BIN_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WRAPPER_CAMERA_BIN_SRC))
#define GST_IS_WRAPPER_CAMERA_BIN_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WRAPPER_CAMERA_BIN_SRC))
GType gst_wrapper_camera_bin_src_get_type (void);
typedef struct _GstWrapperCameraBinSrc GstWrapperCameraBinSrc;
typedef struct _GstWrapperCameraBinSrcClass GstWrapperCameraBinSrcClass;
enum GstVideoRecordingStatus {
GST_VIDEO_RECORDING_STATUS_DONE,
GST_VIDEO_RECORDING_STATUS_STARTING,
GST_VIDEO_RECORDING_STATUS_RUNNING,
GST_VIDEO_RECORDING_STATUS_FINISHING
};
/**
* GstWrapperCameraBinSrc:
*
*/
struct _GstWrapperCameraBinSrc
{
GstBaseCameraSrc parent;
GstCameraBinMode mode;
GstPad *srcfilter_pad;
GstPad *vfsrc;
GstPad *imgsrc;
GstPad *vidsrc;
/* video recording controls */
gint video_rec_status;
/* image capture controls */
gint image_capture_count;
/* source elements */
GstElement *src_vid_src;
GstElement *video_filter;
GstElement *src_filter;
GstElement *digitalzoom;
/* Pad from our last element that is linked
* with the output pads */
GstPad *src_pad;
GstPad *video_tee_vf_pad;
GstPad *video_tee_sink;
gboolean elements_created;
gulong src_event_probe_id;
gulong src_max_zoom_signal_id;
gulong image_capture_probe;
gulong video_capture_probe;
/* Application configurable elements */
GstElement *app_vid_src;
GstElement *app_vid_filter;
/* Caps that videosrc supports */
GstCaps *allowed_caps;
/* Optional crop for frames. Used to crop frames e.g.
due to wrong aspect ratio. Done before the crop related to zooming. */
GstElement *src_crop;
/* Caps applied to capsfilters when in view finder mode */
GstCaps *view_finder_caps;
/* Caps applied to capsfilters when taking still image */
GstCaps *image_capture_caps;
gboolean image_renegotiate;
gboolean video_renegotiate;
};
/**
* GstWrapperCameraBinSrcClass:
*
*/
struct _GstWrapperCameraBinSrcClass
{
GstBaseCameraSrcClass parent;
};
gboolean gst_wrapper_camera_bin_src_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_WRAPPER_CAMERA_BIN_SRC_H__ */

View File

@ -0,0 +1,19 @@
camerabin_sources = [
'gstdigitalzoom.c',
'gstviewfinderbin.c',
'camerabingeneral.c',
'gstwrappercamerabinsrc.c',
'gstcamerabin2.c',
'gstplugin.c',
]
gstcamerabin = library('gstcamerabin',
camerabin_sources,
c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'],
include_directories : [configinc, libsinc],
link_with : gstbasecamerabin,
dependencies : [gstbasecamerabin_dep, gstphotography_dep, gsttag_dep, gstapp_dep, gstpbutils_dep, gstbase_dep],
install : true,
install_dir : plugins_install_dir,
)
pkgconfig.generate(gstcamerabin, install_dir : plugins_pkgconfig_install_dir)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
GST_CAMERABIN_UI_FILES = gst-camera2.ui
AM_CPPFLAGS = -DCAMERA_APPS_UIDIR=\""$(srcdir)"\"
if HAVE_GTK3
GST_CAMERABIN_GTK_EXAMPLES = gst-camera2
gst_camera2_SOURCES = gst-camera2.h gst-camera2.c
gst_camera2_CFLAGS = \
$(GST_PLUGINS_BAD_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
$(GTK3_CFLAGS) \
$(GMODULE_EXPORT_CFLAGS) \
-DGST_USE_UNSTABLE_API
gst_camera2_LDADD = \
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_API_VERSION@.la \
$(top_builddir)/gst-libs/gst/basecamerabinsrc/libgstbasecamerabinsrc-@GST_API_VERSION@.la \
$(GST_PLUGINS_BAD_LIBS) \
$(GST_PLUGINS_BASE_LIBS) \
-lgstpbutils-@GST_API_VERSION@ \
-lgstvideo-@GST_API_VERSION@ \
$(GST_LIBS) \
$(GTK3_LIBS) \
$(GMODULE_EXPORT_LIBS)
noinst_DATA = $(GST_CAMERABIN_UI_FILES)
else
GST_CAMERABIN_GTK_EXAMPLES =
endif
if HAVE_X11
GST_CAMERABIN_X11_EXAMPLES = gst-camerabin2-test
gst_camerabin2_test_SOURCES = gst-camerabin2-test.c
gst_camerabin2_test_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLUGINS_BAD_CFLAGS)
gst_camerabin2_test_LDADD = \
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_API_VERSION@.la \
$(GST_PLUGINS_BASE_LIBS) \
-lgstpbutils-@GST_API_VERSION@ \
-lgstvideo-@GST_API_VERSION@ \
$(GST_BASE_LIBS) \
$(GST_LIBS) \
$(X11_LIBS)
else
GST_CAMERABIN_X11_EXAMPLES =
endif
noinst_PROGRAMS = $(GST_CAMERABIN_GTK_EXAMPLES) $(GST_CAMERABIN_X11_EXAMPLES)
EXTRA_DIST = $(GST_CAMERABIN_UI_FILES)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,338 @@
/*
* GStreamer
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* This is a demo application to test the camerabin element.
* If you have question don't hesitate in contact me edgard.lima@gmail.com
*/
/*
* Includes
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gst-camera2.h"
#include <string.h>
#include <gst/pbutils/encoding-profile.h>
#include <gst/gst.h>
#include <gst/video/videooverlay.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#define UI_FILE CAMERA_APPS_UIDIR G_DIR_SEPARATOR_S "gst-camera2.ui"
static GstElement *camera;
static GtkBuilder *builder;
static GtkWidget *ui_main_window;
typedef struct
{
const gchar *name;
GstEncodingProfile *(*create_profile) ();
} GstCameraVideoFormat;
static GstEncodingProfile *
create_ogg_profile (void)
{
GstEncodingContainerProfile *container;
GstCaps *caps = NULL;
caps = gst_caps_new_empty_simple ("application/ogg");
container = gst_encoding_container_profile_new ("ogg", NULL, caps, NULL);
gst_caps_unref (caps);
caps = gst_caps_new_empty_simple ("video/x-theora");
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
gst_encoding_video_profile_new (caps, NULL, NULL, 1));
gst_caps_unref (caps);
caps = gst_caps_new_empty_simple ("audio/x-vorbis");
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
gst_encoding_audio_profile_new (caps, NULL, NULL, 1));
gst_caps_unref (caps);
return (GstEncodingProfile *) container;
}
static GstEncodingProfile *
create_webm_profile (void)
{
GstEncodingContainerProfile *container;
GstCaps *caps = NULL;
caps = gst_caps_new_empty_simple ("video/webm");
container = gst_encoding_container_profile_new ("webm", NULL, caps, NULL);
gst_caps_unref (caps);
caps = gst_caps_new_empty_simple ("video/x-vp8");
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
gst_encoding_video_profile_new (caps, NULL, NULL, 1));
gst_caps_unref (caps);
caps = gst_caps_new_empty_simple ("audio/x-vorbis");
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
gst_encoding_audio_profile_new (caps, NULL, NULL, 1));
gst_caps_unref (caps);
return (GstEncodingProfile *) container;
}
static GstEncodingProfile *
create_mp4_profile (void)
{
GstEncodingContainerProfile *container;
GstCaps *caps = NULL;
caps =
gst_caps_new_simple ("video/quicktime", "variant", G_TYPE_STRING, "iso",
NULL);
container = gst_encoding_container_profile_new ("mp4", NULL, caps, NULL);
gst_caps_unref (caps);
caps = gst_caps_new_empty_simple ("video/x-h264");
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
gst_encoding_video_profile_new (caps, NULL, NULL, 1));
gst_caps_unref (caps);
caps = gst_caps_new_simple ("audio/mpeg", "version", G_TYPE_INT, 4, NULL);
gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *)
gst_encoding_audio_profile_new (caps, NULL, NULL, 1));
gst_caps_unref (caps);
return (GstEncodingProfile *) container;
}
GstCameraVideoFormat formats[] = {
{"ogg (theora/vorbis)", create_ogg_profile}
,
{"webm (vp8/vorbis)", create_webm_profile}
,
{"mp4 (h264+aac)", create_mp4_profile}
,
{NULL, NULL}
};
void
on_mainWindow_delete_event (GtkWidget * widget, GdkEvent * event, gpointer data)
{
gtk_main_quit ();
}
void
on_captureButton_clicked (GtkButton * button, gpointer user_data)
{
g_signal_emit_by_name (camera, "start-capture", NULL);
}
void
on_stopCaptureButton_clicked (GtkButton * button, gpointer user_data)
{
g_signal_emit_by_name (camera, "stop-capture", NULL);
}
void
on_imageRButton_toggled (GtkToggleButton * button, gpointer user_data)
{
if (gtk_toggle_button_get_active (button)) {
g_object_set (camera, "mode", 1, NULL); /* Image mode */
}
}
void
on_videoRButton_toggled (GtkToggleButton * button, gpointer user_data)
{
if (gtk_toggle_button_get_active (button)) {
g_object_set (camera, "mode", 2, NULL); /* Video mode */
}
}
void
on_viewfinderArea_realize (GtkWidget * widget, gpointer data)
{
gdk_window_ensure_native (gtk_widget_get_window (widget));
}
void
on_formatComboBox_changed (GtkWidget * widget, gpointer data)
{
GstEncodingProfile *profile = NULL;
gint index = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
if (formats[index].create_profile) {
profile = formats[index].create_profile ();
}
g_return_if_fail (profile != NULL);
gst_element_set_state (camera, GST_STATE_NULL);
g_object_set (camera, "video-profile", profile, NULL);
gst_encoding_profile_unref (profile);
if (GST_STATE_CHANGE_FAILURE == gst_element_set_state (camera,
GST_STATE_PLAYING)) {
GtkWidget *dialog =
gtk_message_dialog_new (GTK_WINDOW (ui_main_window), GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
"Could not initialize camerabin with the "
"selected format. Your system might not have the required plugins installed.\n"
"Please select another format.");
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
}
void
on_zoomScale_value_changed (GtkWidget * widget, gpointer data)
{
g_object_set (camera, "zoom",
(gfloat) gtk_range_get_value (GTK_RANGE (widget)), NULL);
}
static GstBusSyncReply
bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data)
{
GtkWidget *ui_drawing;
if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
return GST_BUS_PASS;
if (!gst_message_has_name (message, "prepare-window-handle"))
return GST_BUS_PASS;
/* FIXME: make sure to get XID in main thread */
ui_drawing = GTK_WIDGET (gtk_builder_get_object (builder, "viewfinderArea"));
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (message->src),
GDK_WINDOW_XID (gtk_widget_get_window (ui_drawing)));
gst_message_unref (message);
return GST_BUS_DROP;
}
static gboolean
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_WARNING:{
GError *err;
gchar *debug;
gst_message_parse_warning (message, &err, &debug);
g_print ("Warning: %s\n", err->message);
g_error_free (err);
g_free (debug);
break;
}
case GST_MESSAGE_ERROR:{
GError *err = NULL;
gchar *debug = NULL;
gst_message_parse_error (message, &err, &debug);
g_print ("Error: %s : %s\n", err->message, debug);
g_error_free (err);
g_free (debug);
gtk_main_quit ();
break;
}
case GST_MESSAGE_EOS:
/* end-of-stream */
g_print ("Eos\n");
gtk_main_quit ();
break;
case GST_MESSAGE_ELEMENT:
{
//handle_element_message (message);
break;
}
default:
/* unhandled message */
break;
}
return TRUE;
}
static gboolean
init_gtkwidgets_data (void)
{
gint i;
GtkComboBoxText *combobox =
GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder, "formatComboBox"));
/* init formats combobox */
i = 0;
while (formats[i].name) {
gtk_combo_box_text_append_text (combobox, formats[i].name);
i++;
}
/* default to the first one -> ogg */
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
return TRUE;
}
int
main (int argc, char *argv[])
{
GError *error = NULL;
GstBus *bus;
/* FIXME: add support for Gdk Wayland backend, code currently assumes X11 */
if (g_getenv ("GDK_BACKEND") == NULL)
g_setenv ("GDK_BACKEND", "x11", TRUE);
gst_init (&argc, &argv);
gtk_init (&argc, &argv);
builder = gtk_builder_new ();
if (!gtk_builder_add_from_file (builder, UI_FILE, &error)) {
g_warning ("Error: %s", error->message);
g_error_free (error);
return 1;
}
camera = gst_element_factory_make ("camerabin", "camera");
bus = gst_pipeline_get_bus (GST_PIPELINE (camera));
gst_bus_add_watch (bus, bus_callback, NULL);
gst_bus_set_sync_handler (bus, bus_sync_callback, NULL, NULL);
gst_object_unref (bus);
if (!init_gtkwidgets_data ()) {
goto error;
}
ui_main_window = GTK_WIDGET (gtk_builder_get_object (builder, "mainWindow"));
gtk_builder_connect_signals (builder, NULL);
gtk_widget_show_all (ui_main_window);
gst_element_set_state (camera, GST_STATE_PLAYING);
gtk_main ();
error:
gst_element_set_state (camera, GST_STATE_NULL);
gst_object_unref (camera);
return 0;
}

View File

@ -0,0 +1,54 @@
/*
* GStreamer
* Copyright (C) 2008 Nokia Corporation <multimedia@maemo.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* This is a demo application to test the camerabin element.
* If you have question don't hesitate in contact me edgard.lima@gmail.com
*/
#ifndef __GST_CAMERA_BIN_H__
#define __GST_CAMERA_BIN_H__
#include <gtk/gtk.h>
void
on_mainWindow_delete_event (GtkWidget * widget, GdkEvent * event, gpointer data);
void
on_captureButton_clicked (GtkButton * button, gpointer user_data);
void
on_stopCaptureButton_clicked (GtkButton * button, gpointer user_data);
void
on_imageRButton_toggled (GtkToggleButton * button, gpointer user_data);
void
on_videoRButton_toggled (GtkToggleButton * button, gpointer user_data);
void
on_viewfinderArea_realize (GtkWidget * widget, gpointer data);
void
on_formatComboBox_changed (GtkWidget * widget, gpointer data);
void
on_zoomScale_value_changed (GtkWidget * widget, gpointer data);
#endif /* __GST_CAMERA_BIN_H__ */

View File

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkAdjustment" id="zoomadjustment">
<property name="lower">1</property>
<property name="upper">10</property>
<property name="value">1</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">1</property>
</object>
<object class="GtkWindow" id="mainWindow">
<property name="can_focus">False</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<signal name="delete-event" handler="on_mainWindow_delete_event" swapped="no"/>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkRadioButton" id="imageRButton">
<property name="label" translatable="yes">Image</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_imageRButton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="videoRButton">
<property name="label" translatable="yes">Video</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">imageRButton</property>
<signal name="toggled" handler="on_videoRButton_toggled" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="viewfinderArea">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="realize" handler="on_viewfinderArea_realize" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Actions</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="captureButton">
<property name="label" translatable="yes">Capture</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_captureButton_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="stopCaptureButton">
<property name="label" translatable="yes">Stop Capture</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_stopCaptureButton_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Video format</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="formatComboBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="changed" handler="on_formatComboBox_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Zoom</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkScale" id="zoomScale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">zoomadjustment</property>
<property name="fill_level">10</property>
<property name="round_digits">1</property>
<property name="value_pos">right</property>
<signal name="value-changed" handler="on_zoomScale_value_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
gtk_dep = dependency('gtk+-3.0', required : get_option('examples'))
gdk_x11_dep = dependency('gdk-x11-3.0', required : get_option('examples'))
if gtk_dep.found() and gdk_x11_dep.found()
camera2_args = [
'-DGST_USE_UNSTABLE_API',
'-DCAMERA_APPS_UIDIR="@0@"'.format(meson.current_source_dir()),
cc.get_supported_link_arguments('-fvisibility=default'),
]
gmodule_export_dep = dependency('gmodule-export-2.0')
executable('gst-camera2', 'gst-camera2.c',
include_directories : [configinc],
dependencies : [gstphotography_dep, gtk_dep, gdk_x11_dep, gst_dep, gstvideo_dep, gstpbutils_dep, gmodule_export_dep],
c_args : gst_plugins_bad_args + camera2_args,
install: false)
endif
x11_dep = dependency('x11', required : get_option('examples'))
if x11_dep.found()
executable('gst-camerabin2-test', 'gst-camerabin2-test.c',
include_directories : [configinc],
dependencies : [gstphotography_dep, x11_dep, gst_dep, gstvideo_dep, gstpbutils_dep],
c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'],
install: false)
endif