2001-12-22 23:26:33 +00:00
|
|
|
/* gstchart.c: implementation of chart drawing element
|
|
|
|
* Copyright (C) <2001> Richard Boulton <richard@tartarus.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.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-11-07 12:47:02 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
#include <gst/gst.h>
|
2003-07-06 20:49:52 +00:00
|
|
|
#include <gst/video/video.h>
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
#define GST_TYPE_CHART (gst_chart_get_type())
|
|
|
|
#define GST_CHART(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CHART,GstChart))
|
|
|
|
#define GST_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CHART,GstChart))
|
|
|
|
#define GST_IS_CHART(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CHART))
|
2006-09-16 22:14:36 +00:00
|
|
|
#define GST_IS_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CHART))
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
typedef struct _GstChart GstChart;
|
|
|
|
typedef struct _GstChartClass GstChartClass;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
struct _GstChart
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
GstElement element;
|
|
|
|
|
|
|
|
/* pads */
|
2004-03-14 22:34:33 +00:00
|
|
|
GstPad *sinkpad, *srcpad;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/* the timestamp of the next frame */
|
2001-12-22 23:26:33 +00:00
|
|
|
guint64 next_time;
|
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/* video state */
|
2001-12-22 23:26:33 +00:00
|
|
|
gint bpp;
|
|
|
|
gint depth;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
gint samplerate;
|
2004-03-15 19:32:27 +00:00
|
|
|
gdouble framerate; /* desired frame rate */
|
|
|
|
gint samples_between_frames; /* number of samples between start of successive frames */
|
|
|
|
gint samples_since_last_frame; /* number of samples between start of successive frames */
|
2001-12-22 23:26:33 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
struct _GstChartClass
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
GstElementClass parent_class;
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GType gst_chart_get_type (void);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* elementfactory information */
|
2006-04-25 21:56:38 +00:00
|
|
|
static const GstElementDetails gst_chart_details =
|
2006-04-06 11:35:26 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Chart drawer",
|
|
|
|
"Visualization",
|
|
|
|
"Takes frames of data and outputs video frames of a chart of data",
|
|
|
|
"Richard Boulton <richard@tartarus.org>");
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
/* signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-22 23:26:33 +00:00
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB_16)
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"signed = (boolean) TRUE, "
|
|
|
|
"width = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"rate = (int) [ 8000, 96000 ], " "channels = (int) 1")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static void gst_chart_base_init (gpointer g_class);
|
|
|
|
static void gst_chart_class_init (GstChartClass * klass);
|
|
|
|
static void gst_chart_init (GstChart * chart);
|
|
|
|
|
|
|
|
static void gst_chart_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_chart_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
static void gst_chart_chain (GstPad * pad, GstData * _data);
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
|
|
|
gst_chart_sinkconnect (GstPad * pad, const GstCaps * caps);
|
|
|
|
static GstPadLinkReturn
|
|
|
|
gst_chart_srcconnect (GstPad * pad, const GstCaps * caps);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2002-01-13 22:27:25 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_chart_get_type (void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
static const GTypeInfo info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstChartClass),
|
2003-11-01 11:56:28 +00:00
|
|
|
gst_chart_base_init,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_chart_class_init,
|
2001-12-22 23:26:33 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstChart),
|
2001-12-22 23:26:33 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_chart_init,
|
2001-12-22 23:26:33 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
type = g_type_register_static (GST_TYPE_ELEMENT, "GstChart", &info, 0);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2003-11-01 11:56:28 +00:00
|
|
|
static void
|
|
|
|
gst_chart_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&src_factory));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sink_factory));
|
2003-11-01 11:56:28 +00:00
|
|
|
gst_element_class_set_details (element_class, &gst_chart_details);
|
|
|
|
}
|
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_class_init (GstChartClass * klass)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2006-04-08 21:48:01 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_chart_set_property;
|
|
|
|
gobject_class->get_property = gst_chart_get_property;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_init (GstChart * chart)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
/* create the sink and src pads */
|
2004-03-14 22:34:33 +00:00
|
|
|
chart->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
|
|
|
|
"sink");
|
|
|
|
chart->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&src_factory),
|
|
|
|
"src");
|
2001-12-22 23:26:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (chart), chart->sinkpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (chart), chart->srcpad);
|
|
|
|
|
|
|
|
gst_pad_set_chain_function (chart->sinkpad, gst_chart_chain);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_pad_set_link_function (chart->sinkpad, gst_chart_sinkconnect);
|
Update libvisual to 0.1.7. Link in the debug handling to gstreamer
Original commit message from CVS:
* configure.ac:
* ext/libvisual/visual.c: (gst_visual_get_type),
(libvisual_log_handler), (gst_visual_getcaps),
(gst_visual_srclink), (gst_visual_change_state), (make_valid_name),
(plugin_init):
Update libvisual to 0.1.7. Link in the debug handling to gstreamer
* ext/smoothwave/Makefile.am:
* ext/smoothwave/demo-osssrc.c: (main):
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_class_init),
(gst_smoothwave_init), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain), (gst_sw_change_state),
(plugin_init):
* ext/smoothwave/gstsmoothwave.h:
Make gstsmoothwave a working element in the 20th century.
* gst/chart/gstchart.c: (gst_chart_init), (gst_chart_srcconnect):
Fix incorrect link function
2004-11-12 17:37:49 +00:00
|
|
|
gst_pad_set_link_function (chart->srcpad, gst_chart_srcconnect);
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
chart->next_time = 0;
|
|
|
|
|
2002-03-19 04:10:06 +00:00
|
|
|
/* reset the initial video state */
|
2001-12-22 23:26:33 +00:00
|
|
|
chart->bpp = 16;
|
|
|
|
chart->depth = 16;
|
2002-01-13 22:27:25 +00:00
|
|
|
chart->width = 256;
|
|
|
|
chart->height = 128;
|
2001-12-22 23:26:33 +00:00
|
|
|
|
|
|
|
chart->samplerate = -1;
|
2004-03-15 19:32:27 +00:00
|
|
|
chart->framerate = 25; /* desired frame rate */
|
|
|
|
chart->samples_between_frames = 0; /* number of samples between start of successive frames */
|
2001-12-22 23:26:33 +00:00
|
|
|
chart->samples_since_last_frame = 0;
|
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_sinkconnect (GstPad * pad, const GstCaps * caps)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GstChart *chart;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
chart = GST_CHART (gst_pad_get_parent (pad));
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "rate", &chart->samplerate);
|
2001-12-22 23:26:33 +00:00
|
|
|
chart->samples_between_frames = chart->samplerate / chart->framerate;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("CHART: new sink caps: rate %d", chart->samplerate);
|
2002-03-19 04:10:06 +00:00
|
|
|
/*gst_chart_sync_parms (chart); */
|
|
|
|
/* */
|
2003-01-10 10:22:25 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_srcconnect (GstPad * pad, const GstCaps * caps)
|
2003-07-06 20:49:52 +00:00
|
|
|
{
|
|
|
|
GstChart *chart;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
chart = GST_CHART (gst_pad_get_parent (pad));
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
Update libvisual to 0.1.7. Link in the debug handling to gstreamer
Original commit message from CVS:
* configure.ac:
* ext/libvisual/visual.c: (gst_visual_get_type),
(libvisual_log_handler), (gst_visual_getcaps),
(gst_visual_srclink), (gst_visual_change_state), (make_valid_name),
(plugin_init):
Update libvisual to 0.1.7. Link in the debug handling to gstreamer
* ext/smoothwave/Makefile.am:
* ext/smoothwave/demo-osssrc.c: (main):
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_class_init),
(gst_smoothwave_init), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain), (gst_sw_change_state),
(plugin_init):
* ext/smoothwave/gstsmoothwave.h:
Make gstsmoothwave a working element in the 20th century.
* gst/chart/gstchart.c: (gst_chart_init), (gst_chart_srcconnect):
Fix incorrect link function
2004-11-12 17:37:49 +00:00
|
|
|
if (!gst_structure_get_double (structure, "framerate", &chart->framerate) ||
|
|
|
|
!gst_structure_get_int (structure, "width", &chart->width) ||
|
|
|
|
!gst_structure_get_int (structure, "height", &chart->height))
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
2003-07-06 20:49:52 +00:00
|
|
|
|
Update libvisual to 0.1.7. Link in the debug handling to gstreamer
Original commit message from CVS:
* configure.ac:
* ext/libvisual/visual.c: (gst_visual_get_type),
(libvisual_log_handler), (gst_visual_getcaps),
(gst_visual_srclink), (gst_visual_change_state), (make_valid_name),
(plugin_init):
Update libvisual to 0.1.7. Link in the debug handling to gstreamer
* ext/smoothwave/Makefile.am:
* ext/smoothwave/demo-osssrc.c: (main):
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_class_init),
(gst_smoothwave_init), (gst_smoothwave_dispose), (gst_sw_sinklink),
(gst_sw_srclink), (gst_smoothwave_chain), (gst_sw_change_state),
(plugin_init):
* ext/smoothwave/gstsmoothwave.h:
Make gstsmoothwave a working element in the 20th century.
* gst/chart/gstchart.c: (gst_chart_init), (gst_chart_srcconnect):
Fix incorrect link function
2004-11-12 17:37:49 +00:00
|
|
|
chart->samples_between_frames = chart->samplerate / chart->framerate;
|
2003-07-06 20:49:52 +00:00
|
|
|
GST_DEBUG ("CHART: new src caps: framerate %f, %dx%d",
|
2004-03-14 22:34:33 +00:00
|
|
|
chart->framerate, chart->width, chart->height);
|
2003-07-06 20:49:52 +00:00
|
|
|
|
|
|
|
return GST_PAD_LINK_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
draw_chart_16bpp (guchar * output, gint width, gint height,
|
|
|
|
gint16 * src_data, gint src_size)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
gint i;
|
|
|
|
guint16 *colstart;
|
|
|
|
gint16 *in;
|
|
|
|
|
|
|
|
GST_DEBUG
|
|
|
|
("CHART: drawing frame to %p, width = %d, height = %d, src_data = %p, src_size = %d",
|
|
|
|
output, width, height, src_data, src_size);
|
|
|
|
|
|
|
|
for (colstart = (guint16 *) output, in = (gint16 *) src_data, i = 0;
|
|
|
|
i < width; colstart++, in++, i++) {
|
|
|
|
guint16 *pos = colstart;
|
|
|
|
gint h1;
|
|
|
|
|
|
|
|
h1 = (((gint) (*in)) * height / (1 << 16)) + height / 2;
|
|
|
|
if (h1 >= height)
|
|
|
|
h1 = height;
|
|
|
|
|
|
|
|
if (h1 < height / 2) {
|
|
|
|
while (pos < colstart + h1 * width) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*pos = 0x0000;
|
|
|
|
pos += width;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
while (pos < colstart + height / 2 * width) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*pos = 0x07e0;
|
|
|
|
pos += width;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
while (pos < colstart + height * width) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*pos = 0x0000;
|
|
|
|
pos += width;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (pos < colstart + height / 2 * width) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*pos = 0x0000;
|
|
|
|
pos += width;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
while (pos < colstart + h1 * width) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*pos = 0x07e0;
|
|
|
|
pos += width;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
while (pos < colstart + height * width) {
|
2004-03-15 19:32:27 +00:00
|
|
|
*pos = 0x0000;
|
|
|
|
pos += width;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_chain (GstPad * pad, GstData * _data)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2003-10-08 16:08:19 +00:00
|
|
|
GstBuffer *bufin = GST_BUFFER (_data);
|
2001-12-22 23:26:33 +00:00
|
|
|
GstChart *chart;
|
|
|
|
GstBuffer *bufout;
|
|
|
|
guint32 samples_in;
|
|
|
|
guint32 sizeout;
|
|
|
|
gint16 *datain;
|
|
|
|
guchar *dataout;
|
|
|
|
|
|
|
|
g_return_if_fail (bufin != NULL);
|
|
|
|
g_return_if_fail (pad != NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (GST_IS_CHART (GST_OBJECT_PARENT (pad)));
|
|
|
|
chart = GST_CHART (GST_OBJECT_PARENT (pad));
|
2001-12-22 23:26:33 +00:00
|
|
|
g_return_if_fail (chart != NULL);
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("CHART: chainfunc called");
|
2001-12-22 23:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
samples_in = GST_BUFFER_SIZE (bufin) / sizeof (gint16);
|
2001-12-22 23:26:33 +00:00
|
|
|
datain = (gint16 *) (GST_BUFFER_DATA (bufin));
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("input buffer has %d samples", samples_in);
|
2001-12-22 23:26:33 +00:00
|
|
|
if (chart->next_time <= GST_BUFFER_TIMESTAMP (bufin)) {
|
|
|
|
chart->next_time = GST_BUFFER_TIMESTAMP (bufin);
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("in: %" G_GINT64_FORMAT, GST_BUFFER_TIMESTAMP (bufin));
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chart->samples_since_last_frame += samples_in;
|
|
|
|
if (chart->samples_between_frames <= chart->samples_since_last_frame) {
|
2004-03-14 22:34:33 +00:00
|
|
|
chart->samples_since_last_frame = 0;
|
|
|
|
|
|
|
|
/* get data to draw into buffer */
|
|
|
|
if (samples_in >= chart->width) {
|
|
|
|
/* make a new buffer for the output */
|
|
|
|
bufout = gst_buffer_new ();
|
|
|
|
sizeout = chart->bpp / 8 * chart->width * chart->height;
|
|
|
|
dataout = g_malloc (sizeout);
|
|
|
|
GST_BUFFER_SIZE (bufout) = sizeout;
|
|
|
|
GST_BUFFER_DATA (bufout) = dataout;
|
|
|
|
GST_DEBUG ("CHART: made new buffer: size %d, width %d, height %d",
|
2004-03-15 19:32:27 +00:00
|
|
|
sizeout, chart->width, chart->height);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
/* take data and draw to new buffer */
|
|
|
|
/* FIXME: call different routines for different properties */
|
|
|
|
draw_chart_16bpp (dataout, chart->width, chart->height, (gint16 *) datain,
|
2004-03-15 19:32:27 +00:00
|
|
|
samples_in);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (bufin);
|
|
|
|
|
|
|
|
/* set timestamp */
|
|
|
|
GST_BUFFER_TIMESTAMP (bufout) = chart->next_time;
|
|
|
|
|
|
|
|
GST_DEBUG ("CHART: outputting buffer");
|
|
|
|
/* output buffer */
|
|
|
|
GST_BUFFER_FLAG_SET (bufout, GST_BUFFER_READONLY);
|
|
|
|
gst_pad_push (chart->srcpad, GST_DATA (bufout));
|
|
|
|
}
|
2001-12-22 23:26:33 +00:00
|
|
|
} else {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("CHART: skipping buffer");
|
|
|
|
gst_buffer_unref (bufin);
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
GST_DEBUG ("CHART: exiting chainfunc");
|
2001-12-22 23:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GstChart *chart;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_CHART (object));
|
|
|
|
chart = GST_CHART (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_chart_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
|
|
|
GstChart *chart;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_CHART (object));
|
|
|
|
chart = GST_CHART (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2001-12-22 23:26:33 +00:00
|
|
|
{
|
2003-11-01 11:56:28 +00:00
|
|
|
if (!gst_element_register (plugin, "chart", GST_RANK_NONE, GST_TYPE_CHART))
|
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-22 23:26:33 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"chart",
|
|
|
|
"Takes frames of data and outputs video frames of a chart of data",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|