[aravis/gst] gst: WIP.



commit abdc5d855461f3d3f0fad74d17a9eface2eba5b2
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Thu Apr 15 14:33:42 2010 +0200

    gst: WIP.

 Makefile.am     |    2 +-
 configure.ac    |   21 ++-
 gst/Makefile.am |   28 +++
 gst/arvgst.c    |  551 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gst/arvgst.h    |   68 +++++++
 5 files changed, 668 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9d226e5..ba93c6f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
 
 DISTCHECK_CONFIGURE_FLAGS = --enable-introspection
 
-SUBDIRS = src po
+SUBDIRS = src gst po
 
 aravisdocdir = ${prefix}/doc/aravis
 aravisdoc_DATA = 	\
diff --git a/configure.ac b/configure.ac
index ae54054..b5d46d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,14 @@ IT_PROG_INTLTOOL([0.31.2])
 
 LT_INIT()
 
-AC_ARG_ENABLE(cairo, [  --enable-cairo          Enable cairo support], [enable_cairo=$enableval], [enable_cairo=no])
+AC_ARG_ENABLE(cairo,
+	      [  --enable-cairo          Enable cairo support],
+	      [enable_cairo=$enableval],
+	      [enable_cairo=no])
+AC_ARG_ENABLE(gstreamer,
+	      [  --enable-gstreamer      Enable gstreamer support],
+	      [enable_gstreamer=$enableval],
+	      [enable_gstreamer=no])
 
 PKG_PROG_PKG_CONFIG([0.14])
 
@@ -44,6 +51,16 @@ if test "x$enable_cairo" = "xyes"; then
 fi
 AM_CONDITIONAL(ARAVIS_WITH_CAIRO, test "x$with_cairo" = "xyes")
 
+with_gstreamer=no
+if test "x$enable_gstreamer" = "xyes"; then
+	PKG_CHECK_MODULES([GSTREAMER],   [gstreamer-base-0.10 >= 0.10],
+			  [AC_DEFINE([ARAVIS_WITH_GSTREAMER], [1], [Cairo support])
+			  ARAVIS_REQUIRES+=" [gstreamer-base-0.10 >= 0.10]"
+			  with_gstreamer=yes],
+			  [echo -n])
+fi
+AM_CONDITIONAL(ARAVIS_WITH_GSTREAMER, test "x$with_gstreamer" = "xyes")
+
 PKG_CHECK_MODULES(ARAVIS, $ARAVIS_REQUIRES)
 
 AC_SUBST(ARAVIS_CFLAGS)
@@ -56,6 +73,7 @@ GOBJECT_INTROSPECTION_CHECK([0.6.7])
 AC_CONFIG_FILES([
 Makefile
 src/Makefile
+gst/Makefile
 po/Makefile.in
 aravis.pc
 ])
@@ -65,6 +83,7 @@ echo ""
 echo "Configuration:"
 echo ""
 echo "	Cairo support:		$with_cairo"
+echo "	Gstreamer support:	$with_gstreamer"
 echo "	Compiler:		${CC}"
 echo "	Compiler flags:		${ARAVIS_CFLAGS}"
 echo ""
diff --git a/gst/Makefile.am b/gst/Makefile.am
new file mode 100644
index 0000000..bd8ffc8
--- /dev/null
+++ b/gst/Makefile.am
@@ -0,0 +1,28 @@
+INCLUDES = \
+	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+	-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
+	-DPACKAGE_DATA_DIR=\""$(datadir)"\" $(ARAVIS_CFLAGS) \
+	-DG_LOG_DOMAIN=\"Aravis\"
+
+AM_CFLAGS =\
+	 -Wall\
+	 -Werror \
+	 -g \
+	 -O0
+
+if ARAVIS_WITH_GSTREAMER
+
+lib_LTLIBRARIES = libaravis-gst.la
+
+libaravis_gst_la_LIBADD =			\
+	$(ARAVIS_LIBS)
+
+libaravis_gst_la_SOURCES =			\
+	arvgst.c
+
+libaravis_gst_la_HEADERS =			\
+	arvgst.h
+
+libaravis_gst_ladir = $(includedir)/aravis
+
+endif
diff --git a/gst/arvgst.c b/gst/arvgst.c
new file mode 100644
index 0000000..b4d5c12
--- /dev/null
+++ b/gst/arvgst.c
@@ -0,0 +1,551 @@
+/*
+ * Copyright © 2006 Eric Jonas <jonas mit edu>
+ * Copyright © 2006 Antoine Tremblay <hexa00 gmail com>
+ * Copyright © 2010 United States Government, Joshua M. Doe <joshua doe us army mil>
+ * Copyright © 2010 Emmanuel Pacaud <emmanuel gnome 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * SECTION:element-aravissrc
+ *
+ * Source using the Aravis vision library (GigE Vision cameras)
+ * 
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v aravissrc ! ffmpegcolorspace ! autovideosink
+ * ]|
+ * </refsect2>
+ */
+
+#include "arvgst.h"
+#include <time.h>
+#include <string.h>
+
+GST_DEBUG_CATEGORY (aravis_debug);
+#define GST_CAT_DEFAULT aravis_debug
+
+static GstElementDetails aravis_details =
+GST_ELEMENT_DETAILS ("Aravis Video Source",
+    "Source/Video",
+    "Aravis based source, supports GigE Vision cameras",
+    "Emmanuel Pacaud <emmanuel gnome org>");
+
+enum
+{
+  PROP_0
+};
+
+GST_BOILERPLATE (GstAravis, gst_aravis, GstPushSrc, GST_TYPE_PUSH_SRC);
+
+/* GObject virtual methods */
+static void 	gst_aravis_dispose 		(GObject * object);
+static void 	gst_aravis_set_property 	(GObject * object, guint prop_id,
+						 const GValue * value, GParamSpec * pspec);
+static void 	gst_aravis_get_property 	(GObject * object, guint prop_id,
+						 GValue * value, GParamSpec * pspec);
+
+/* GstBaseSrc virtual methods */
+static GstCaps *	gst_aravis_get_caps 	(GstBaseSrc * bsrc);
+static gboolean 	gst_aravis_set_caps 	(GstBaseSrc * bsrc, GstCaps * caps);
+/*static void gst_aravis_src_fixate (GstPad * pad, GstCaps * caps);*/
+static void 		gst_aravis_get_times 	(GstBaseSrc * basesrc,
+						 GstBuffer * buffer, GstClockTime * start, GstClockTime * end);
+static gboolean 	gst_aravis_start 	(GstBaseSrc * src);
+static gboolean 	gst_aravis_stop 	(GstBaseSrc * src);
+
+/* GstPushSrc virtual methods */
+static GstFlowReturn gst_aravis_create (GstPushSrc * psrc, GstBuffer ** buffer);
+
+/* GstAravis methods */
+static gboolean gst_aravis_parse_caps (const GstCaps * caps, gint * width, gint * height);
+
+/*static gboolean gst_aravis_set_caps_color (GstStructure * gs, gint bpp, gint depth);*/
+/*static gboolean gst_aravis_set_caps_framesize (GstStructure * gs, gint width,*/
+/*    gint height);*/
+
+static GstCaps *gst_aravis_get_all_aravis_caps ();
+static GstCaps *gst_aravis_get_cam_caps (GstAravis * src);
+
+/*static void _____BEGIN_FUNCTIONS_____();*/
+
+static void
+gst_aravis_base_init (gpointer g_class)
+{
+	GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+	gst_element_class_set_details (element_class, &aravis_details);
+
+	gst_element_class_add_pad_template (element_class,
+					    gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+								  gst_aravis_get_all_aravis_caps ()));
+
+}
+
+static void
+gst_aravis_class_init (GstAravisClass * klass)
+{
+	GObjectClass *gobject_class;
+	GstBaseSrcClass *gstbasesrc_class;
+	GstPushSrcClass *gstpushsrc_class;
+	GstElementClass *gstelement_class;
+
+	gobject_class = (GObjectClass *) klass;
+	gstbasesrc_class = (GstBaseSrcClass *) klass;
+	gstpushsrc_class = (GstPushSrcClass *) klass;
+	gstelement_class = (GstElementClass *) klass;
+
+	gobject_class->dispose = gst_aravis_dispose;
+	gobject_class->set_property = gst_aravis_set_property;
+	gobject_class->get_property = gst_aravis_get_property;
+
+	gstbasesrc_class->get_caps = gst_aravis_get_caps;
+	gstbasesrc_class->set_caps = gst_aravis_set_caps;
+
+	gstbasesrc_class->get_times = gst_aravis_get_times;
+	gstpushsrc_class->create = gst_aravis_create;
+	gstbasesrc_class->start = gst_aravis_start;
+	gstbasesrc_class->stop = gst_aravis_stop;
+}
+
+static void
+gst_aravis_init (GstAravis *src, GstAravisClass *g_class)
+{
+	GstPad *srcpad = GST_BASE_SRC_PAD (src);
+
+	gst_base_src_set_live (GST_BASE_SRC (src), TRUE);
+	gst_pad_use_fixed_caps (srcpad);
+
+	src->caps = gst_aravis_get_all_aravis_caps ();
+	src->timestamp_offset = 0;
+	src->n_frames = 0;
+	src->device_name = NULL;
+}
+
+static void
+gst_aravis_dispose (GObject * object)
+{
+        GstAravis *src = GST_ARAVIS (object);
+
+        g_free (src->device_name);
+        src->device_name = NULL;
+
+        G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+gst_aravis_set_property (GObject * object, guint prop_id,
+			 const GValue * value, GParamSpec * pspec)
+{
+	switch (prop_id) {
+		default:
+			break;
+	}
+}
+
+static void
+gst_aravis_get_property (GObject * object, guint prop_id, GValue * value,
+			 GParamSpec * pspec)
+{
+	switch (prop_id) {
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+			break;
+	}
+}
+
+static GstCaps *
+gst_aravis_get_caps (GstBaseSrc * bsrc)
+{
+	GstAravis *gsrc;
+
+	gsrc = GST_ARAVIS (bsrc);
+
+	g_return_val_if_fail (gsrc->caps, NULL);
+
+	return gst_caps_copy (gsrc->caps);
+}
+
+
+static gboolean
+gst_aravis_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
+{
+	gboolean res = TRUE;
+	GstAravis *aravis;
+	gint width, height;
+
+	aravis = GST_ARAVIS (bsrc);
+
+	if (aravis->caps)
+		gst_caps_unref (aravis->caps);
+
+	aravis->caps = gst_aravis_get_cam_caps(aravis);
+
+	res = gst_aravis_parse_caps (aravis->caps, &width, &height);
+
+	if (res) {
+		aravis->width = width;
+		aravis->height = height;
+	}
+
+	return res;
+}
+
+static void
+gst_aravis_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
+		      GstClockTime * start, GstClockTime * end)
+{
+	/* for live sources, sync on the timestamp of the buffer */
+	if (gst_base_src_is_live (basesrc)) {
+		GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
+
+		if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
+			/* get duration to calculate end time */
+			GstClockTime duration = GST_BUFFER_DURATION (buffer);
+
+			if (GST_CLOCK_TIME_IS_VALID (duration)) {
+				*end = timestamp + duration;
+			}
+			*start = timestamp;
+		}
+	} else {
+		*start = -1;
+		*end = -1;
+	}
+}
+
+static GstFlowReturn
+gst_aravis_create (GstPushSrc * psrc, GstBuffer ** buffer)
+{
+  GstAravis *src;
+  gpointer data;
+  GstCaps *caps;
+  GstFlowReturn res = GST_FLOW_OK;
+
+  src = GST_ARAVIS (psrc);
+
+  data = g_malloc (src->width * src->height);
+
+#if 0
+  GST_INFO_OBJECT(src, "Examining buffer %d", src->cumbufnum);
+  rval=imgSessionExamineBuffer2(src->sid, src->cumbufnum, &newval, &bufaddr);
+  if (rval) {
+          GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
+                  ("failed to examine buffer %d", src->cumbufnum), ("failed to examine buffer %d", src->cumbufnum));
+          goto error;
+  }
+
+  memcpy (data, (guchar *) bufaddr,
+      src->framesize);
+
+  imgSessionReleaseBuffer(src->sid);
+  GST_INFO_OBJECT(src, "Releasing buffer %d", newval);
+#endif
+
+  *buffer = gst_buffer_new ();
+  GST_BUFFER_DATA (*buffer) = data;
+  GST_BUFFER_MALLOCDATA (*buffer) = data;
+  GST_BUFFER_SIZE (*buffer) = src->width * src->height;
+
+  caps = gst_pad_get_caps (GST_BASE_SRC_PAD (psrc));
+  gst_buffer_set_caps (*buffer, caps);
+  gst_caps_unref (caps);
+
+  //GST_BUFFER_TIMESTAMP (outbuf) = src->timestamp_offset + src->running_time;
+  //if (src->rate_numerator != 0) {
+  //  GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
+  //      src->rate_denominator, src->rate_numerator);
+  //}
+
+/*  dropped = newval - src->cumbufnum;*/
+/*  if(dropped) {*/
+/*          src->n_dropped_frames += dropped;*/
+/*          GST_WARNING_OBJECT(src, "Dropped %d frames (%d total)",dropped,src->n_dropped_frames);*/
+/*  }*/
+
+/*  src->cumbufnum = newval + 1;*/
+/*  src->n_frames++;*/
+  //if (src->rate_numerator != 0) {
+  //  src->running_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
+  //      src->rate_denominator, src->rate_numerator);
+  //}
+
+  return res;
+
+/*error:*/
+/*  {*/
+/*    return GST_FLOW_ERROR;*/
+/*  }*/
+}
+
+
+static gboolean
+gst_aravis_parse_caps (const GstCaps * caps,
+		       gint * width,
+		       gint * height)
+{
+	const GstStructure *structure;
+	GstPadLinkReturn ret;
+
+	if (gst_caps_get_size (caps) < 1)
+		return FALSE;
+
+	structure = gst_caps_get_structure (caps, 0);
+
+	ret = gst_structure_get_int (structure, "width", width);
+	ret &= gst_structure_get_int (structure, "height", height);
+
+	return ret;
+}
+
+/* Set color on caps */
+/*static gboolean*/
+/*gst_aravis_set_caps_color (GstStructure * gs, gint bpp, gint depth)*/
+/*{*/
+/*  gboolean ret = TRUE;*/
+
+/*  gst_structure_set_name (gs, "video/x-raw-gray");*/
+/*  gst_structure_set (gs,*/
+/*      "bpp", G_TYPE_INT, bpp,*/
+/*          "depth", G_TYPE_INT, depth, NULL);*/
+/*  if(depth>8)*/
+/*          gst_structure_set(gs, "endianness", G_TYPE_INT, G_LITTLE_ENDIAN,NULL);*/
+
+/*  return ret;*/
+/*}*/
+
+
+/*static gboolean*/
+/*gst_aravis_set_caps_framesize (GstStructure * gs, gint width, gint height)*/
+/*{*/
+/*  gst_structure_set (gs,*/
+/*      "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);*/
+/*  return TRUE;*/
+/*}*/
+
+GstCaps *
+gst_aravis_get_all_aravis_caps ()
+{
+	GstCaps *gcaps;
+	GstStructure *gs;
+
+	gcaps = gst_caps_new_empty ();
+
+	gs = gst_structure_empty_new ("video");
+	gst_structure_set_name (gs, "video/x-raw-gray");
+	gst_structure_set (gs,
+			   "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+			   "height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+			   "bpp", G_TYPE_INT, 8,
+			   "depth", G_TYPE_INT, 8,
+			   "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
+	gst_caps_append_structure (gcaps, gs);
+
+	return gcaps;
+}
+
+GstCaps *
+gst_aravis_get_cam_caps (GstAravis * src)
+{
+  GstCaps *gcaps = NULL;
+/*  Int32 rval;*/
+/*  uInt32 val;*/
+/*  gint width, height, depth, bpp;*/
+  GstStructure *gs;
+
+  gcaps = gst_caps_new_empty ();
+
+/*  if (!src->iid) {*/
+/*    GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Camera interface not open"),*/
+/*        ("Camera interface not open"));*/
+/*    goto error;*/
+/*  }*/
+
+/*  rval &= imgGetAttribute(src->iid, IMG_ATTR_BITSPERPIXEL, &val);*/
+/*  bpp = val;*/
+/*  rval &= imgGetAttribute(src->iid, IMG_ATTR_BYTESPERPIXEL, &val);*/
+/*  depth = val*8;*/
+/*  rval &= imgGetAttribute(src->iid, IMG_ATTR_ROI_WIDTH, &val);*/
+/*  width = val;*/
+/*  rval &= imgGetAttribute(src->iid, IMG_ATTR_ROI_HEIGHT, &val);*/
+/*  height = val;*/
+
+/*  if (rval) {*/
+/*          GST_ELEMENT_ERROR (src, STREAM, FAILED,*/
+/*                  ("attempt to read attributes failed"),*/
+/*                  ("attempt to read attributes failed"));*/
+/*          goto error;*/
+/*  }*/
+
+  gs = gst_structure_empty_new ("video");
+/*  if (!gst_aravis_set_caps_color(gs, bpp, depth) ||*/
+/*          !gst_aravis_set_caps_framesize(gs, width, height)) {*/
+/*    GST_ELEMENT_ERROR (src, STREAM, FAILED,*/
+/*        ("attempt to set caps %dx%dx%d (%d) failed", width,height,depth, bpp),*/
+/*        ("attempt to set caps %dx%dx%d (%d) failed", width,height,depth, bpp));*/
+/*    goto error;*/
+/*  }*/
+
+  gst_structure_set(gs, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
+
+  gst_caps_append_structure (gcaps, gs);
+
+  return gcaps;
+
+/*error:*/
+
+/*  if (gcaps) {*/
+/*    gst_caps_unref (gcaps);*/
+/*  }*/
+
+/*  return NULL;*/
+}
+
+static gboolean
+gst_aravis_start (GstBaseSrc * src)
+{
+  GstAravis* filter = GST_ARAVIS(src);
+/*  Int32 rval;*/
+/*  gint i;*/
+
+  GST_LOG_OBJECT (filter, "Opening camera interface: %s", filter->device_name);
+
+/*  filter->iid = 0;*/
+/*  filter->sid = 0;*/
+
+/*  rval=imgInterfaceOpen(filter->device_name,&(filter->iid));*/
+
+/*  if (rval) {*/
+/*          GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to open camera interface"),*/
+/*                  ("Failed to open camera interface %d", filter->iid));*/
+/*          goto error;*/
+/*  }*/
+
+  GST_LOG_OBJECT (filter, "Opening camera session: %s", filter->device_name);
+
+/*  rval=imgSessionOpen(filter->iid, &(filter->sid));*/
+/*  if (rval) {*/
+/*          GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to open camera session"),*/
+/*                  ("Failed to open camera session %d", filter->sid));*/
+/*          goto error;*/
+/*  }*/
+
+/*  GST_LOG_OBJECT (filter, "Creating ring with %d buffers", filter->bufsize);*/
+
+/*  filter->buflist = g_new(guint32*, filter->bufsize);*/
+/*  for(i=0;i<filter->bufsize;i++) {*/
+/*          filter->buflist[i] = 0;*/
+/*  }*/
+/*  rval=imgRingSetup(filter->sid, filter->bufsize, (void**)(filter->buflist), 0, FALSE);*/
+/*  if(rval) {*/
+/*          GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to create ring buffer"),*/
+/*                  ("Failed to create ring buffer with %d buffers", filter->bufsize));*/
+/*          goto error;*/
+/*  }*/
+
+  //GST_LOG_OBJECT (filter, "Registering callback functions");
+  //rval=imgSessionWaitSignalAsync2(filter->sid, IMG_SIGNAL_STATUS, IMG_BUF_COMPLETE, IMG_SIGNAL_STATE_RISING, Imaq_BUF_COMPLETE, filter);
+  //if(rval) {
+         // GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Failed to register BUF_COMPLETE callback"),
+                //  ("Failed to register BUF_COMPLETE callback"));
+         // goto error;
+  //}
+
+  GST_LOG_OBJECT (filter, "Starting acquisition");
+
+/*  rval=imgSessionStartAcquisition(filter->sid);*/
+
+/*  i = 0;*/
+/*  while (rval != 0 && i++ < 5) {*/
+/*          g_usleep (50000);*/
+/*          if (rval=imgSessionStartAcquisition(filter->sid)) {*/
+/*                  if (rval != 0) {*/
+/*                          GST_LOG_OBJECT (src, "camera is still off , retrying");*/
+/*                  }*/
+/*          }*/
+/*  }*/
+
+/*  if (i >= 5) {*/
+/*          GST_ELEMENT_ERROR (filter, RESOURCE, FAILED,*/
+/*                  ("Camera doesn't seem to want to turn on!"),*/
+/*                  ("Camera doesn't seem to want to turn on!"));*/
+/*          goto error;*/
+/*  }*/
+
+  GST_LOG_OBJECT (src, "got transmision status ON");
+
+  return TRUE;
+
+/*error:*/
+
+/*  if(filter->sid)*/
+/*          imgClose(filter->sid,TRUE);*/
+/*  filter->sid = 0;*/
+/*  if(filter->iid)*/
+/*          imgClose(filter->iid,TRUE);*/
+/*  filter->iid = 0;*/
+
+/*  return FALSE;;*/
+
+}
+
+
+gboolean gst_aravis_stop( GstBaseSrc * src )
+{
+        GstAravis* filter = GST_ARAVIS(src);
+/*        Int32 rval;*/
+
+/*        rval=imgSessionStopAcquisition(filter->sid);*/
+/*        if (rval) {*/
+/*                GST_ELEMENT_ERROR (filter, RESOURCE, FAILED, ("Unable to stop transmision"),*/
+/*                        ("Unable to stop transmision"));*/
+/*        }*/
+
+/*        if(filter->sid)*/
+/*                imgClose(filter->sid,TRUE);*/
+/*        filter->sid = 0;*/
+/*        if(filter->iid)*/
+/*                imgClose(filter->iid,TRUE);*/
+/*        filter->iid = 0;*/
+
+        GST_DEBUG_OBJECT (filter, "Capture stoped");
+
+        return TRUE;
+}
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+        GST_DEBUG_CATEGORY_INIT (aravis_debug, "aravis", 0, "Aravis interface");
+
+        return gst_element_register (plugin, "aravissrc", GST_RANK_NONE, GST_TYPE_ARAVIS);
+
+}
+
+/*GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,*/
+/*                   GST_VERSION_MINOR,*/
+/*                   "aravis",*/
+/*                   "Aravis Video Source",*/
+/*                   plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)*/
+#define PACKAGE "ArvGst"
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+		   GST_VERSION_MINOR,
+		   "aravis",
+		   "Aravis Video Source",
+		   plugin_init, "0.1", "LGPLv2+", "GstArv", "Origin")
diff --git a/gst/arvgst.h b/gst/arvgst.h
new file mode 100644
index 0000000..ba9df79
--- /dev/null
+++ b/gst/arvgst.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2006 Eric Jonas <jonas mit edu>
+ * Copyright © 2006 Antoine Tremblay <hexa00 gmail com>
+ * Copyright © 2010 United States Government, Joshua M. Doe <joshua doe us army mil>
+ * Copyright © 2010 Emmanuel Pacaud <emmanuel gnome 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ARV_GST_H
+#define ARV_GST_H
+
+#include <gst/gst.h>
+#include <gst/base/gstpushsrc.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_ARAVIS 		(gst_niimaq_get_type())
+#define GST_ARAVIS(obj)			(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ARAVIS,GstAravis))
+#define GST_ARAVIS_CLASS(klass) 	(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ARAVIS,GstAravis))
+#define GST_IS_ARAVIS(obj) 		(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ARAVIS))
+#define GST_IS_ARAVIS_CLASS(obj)	(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ARAVIS))
+
+typedef struct _GstAravis GstAravis;
+typedef struct _GstAravisClass GstAravisClass;
+
+struct _GstAravis {
+	GstPushSrc element;
+
+	/* video state */
+	gint width;
+	gint height;
+	gint depth;
+	gint bpp;
+	gint framesize;
+
+	/* private */
+	gint64 timestamp_offset;              /* base offset */
+	GstClockTime running_time;            /* total running time */
+	gint64 n_frames;                      /* total frames sent */
+
+	gchar *device_name;
+
+	GstCaps *caps;
+};
+
+struct _GstAravisClass {
+	GstPushSrcClass parent_class;
+};
+
+GType gst_niimaq_get_type (void);
+
+G_END_DECLS
+
+#endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]