Commit 67415fc4 authored by Thiago Santos's avatar Thiago Santos

camerabin2: viewfinderbin: Adds viewfinderbin element

Adds viewfinder bin element, one of the modules of camerabin2
that is responsible for displaying the video from the camera.

For now it is only a bin with ffmpegcolorspace ! videoscale !
 autovideosink
parent 5c097c44
......@@ -293,6 +293,7 @@ AG_GST_CHECK_PLUGIN(audioparsers)
AG_GST_CHECK_PLUGIN(autoconvert)
AG_GST_CHECK_PLUGIN(bayer)
AG_GST_CHECK_PLUGIN(camerabin)
AG_GST_CHECK_PLUGIN(camerabin2)
AG_GST_CHECK_PLUGIN(cdxaparse)
AG_GST_CHECK_PLUGIN(coloreffects)
AG_GST_CHECK_PLUGIN(colorspace)
......@@ -1719,6 +1720,7 @@ gst/audioparsers/Makefile
gst/autoconvert/Makefile
gst/bayer/Makefile
gst/camerabin/Makefile
gst/camerabin2/Makefile
gst/cdxaparse/Makefile
gst/colorspace/Makefile
gst/coloreffects/Makefile
......
plugin_LTLIBRARIES = libgstcamerabin2.la
libgstcamerabin2_la_SOURCES = gstviewfinderbin.c
libgstcamerabin2_la_CFLAGS = \
$(GST_PLUGINS_BAD_CFLAGS) \
$(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstcamerabin2_la_LIBADD = \
$(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS)
libgstcamerabin2_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstcamerabin2_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstviewfinderbin.h
/* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-gstviewfinderbin
*
* The gstviewfinderbin element does FIXME stuff.
*
* <refsect2>
* <title>Example launch line</title>
* |[
* gst-launch -v videotestsrc ! viewfinderbin
* ]|
* FIXME Describe what the pipeline does.
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstviewfinderbin.h"
/* prototypes */
enum
{
PROP_0
};
/* pad templates */
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv; video/x-raw-rgb")
);
/* class initialization */
GST_BOILERPLATE (GstViewfinderBin, gst_viewfinder_bin, GstBin, GST_TYPE_BIN);
/* Element class functions */
static GstStateChangeReturn
gst_viewfinder_bin_change_state (GstElement * element, GstStateChange trans);
static void
gst_viewfinder_bin_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "Viewfinder Bin",
"Sink/Video", "Viewfinder Bin used in camerabin2",
"Thiago Santos <thiago.sousa.santos@collabora.co.uk>");
}
static void
gst_viewfinder_bin_class_init (GstViewfinderBinClass * klass)
{
GstElementClass *element_class;
element_class = GST_ELEMENT_CLASS (klass);
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_viewfinder_bin_change_state);
}
static void
gst_viewfinder_bin_init (GstViewfinderBin * viewfinderbin,
GstViewfinderBinClass * viewfinderbin_class)
{
viewfinderbin->ghostpad = gst_ghost_pad_new_no_target_from_template ("sink",
gst_static_pad_template_get (&sink_template));
gst_element_add_pad (GST_ELEMENT_CAST (viewfinderbin),
viewfinderbin->ghostpad);
}
static gboolean
gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin)
{
GstElement *csp;
GstElement *videoscale;
GstElement *sink;
GstPad *pad = NULL;
if (vfbin->elements_created)
return TRUE;
/* create elements */
csp = gst_element_factory_make ("ffmpegcolorspace", "vfbin-csp");
if (!csp)
goto error;
videoscale = gst_element_factory_make ("videoscale", "vfbin-videoscale");
if (!videoscale)
goto error;
sink = gst_element_factory_make ("autovideosink", "vfbin-sink");
if (!sink)
goto error;
/* add and link */
gst_bin_add_many (GST_BIN_CAST (vfbin), csp, videoscale, sink, NULL);
if (!gst_element_link_many (csp, videoscale, sink, NULL))
goto error;
/* add ghostpad */
pad = gst_element_get_static_pad (csp, "sink");
if (!gst_ghost_pad_set_target (GST_GHOST_PAD (vfbin->ghostpad), pad))
goto error;
vfbin->elements_created = TRUE;
return TRUE;
error:
if (pad)
gst_object_unref (pad);
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 gboolean
plugin_init (GstPlugin * plugin)
{
gst_element_register (plugin, "viewfinderbin", GST_RANK_NONE,
gst_viewfinder_bin_get_type ());
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"viewfinderbin", "viewfinder bin of camerabin2",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
/* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, 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;
gboolean elements_created;
};
struct _GstViewfinderBinClass
{
GstBinClass bin_class;
};
GType gst_viewfinder_bin_get_type (void);
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment