gst/synaesthesia/: Added docs (not yet added to gst-plugins-ugl/docs/plugins as plugin is not built by default). Fixe...

Original commit message from CVS:
* gst/synaesthesia/Makefile.am:
* gst/synaesthesia/gstsynaesthesia.c:
(gst_synaesthesia_class_init), (gst_synaesthesia_init),
(gst_synaesthesia_sink_setcaps), (gst_synaesthesia_src_getcaps),
(gst_synaesthesia_chain), (plugin_init):
* gst/synaesthesia/synaescope.c:
* gst/synaesthesia/synaescope.h:
Added docs (not yet added to gst-plugins-ugl/docs/plugins as plugin is not
built by default). Fixed Makefile.am. Fixed license headers (its GPL as it
is derived from GPL code). Fixed GST_SYNAESTHESIA_CLASS macro. Added
GST_DEBUG_FUNCPTR. Reflowed _setcaps. Updated pad setup in _init. Fix
possible leak in _chain. (#356882)
This commit is contained in:
Stefan Kost 2007-02-09 07:48:50 +00:00
parent f8d7045fc8
commit 228c0d94c5
5 changed files with 112 additions and 50 deletions

View file

@ -1,3 +1,18 @@
2007-02-09 Stefan Kost <ensonic@users.sf.net>
* gst/synaesthesia/Makefile.am:
* gst/synaesthesia/gstsynaesthesia.c:
(gst_synaesthesia_class_init), (gst_synaesthesia_init),
(gst_synaesthesia_sink_setcaps), (gst_synaesthesia_src_getcaps),
(gst_synaesthesia_chain), (plugin_init):
* gst/synaesthesia/synaescope.c:
* gst/synaesthesia/synaescope.h:
Added docs (not yet added to gst-plugins-ugl/docs/plugins as plugin is not
built by default). Fixed Makefile.am. Fixed license headers (its GPL as it
is derived from GPL code). Fixed GST_SYNAESTHESIA_CLASS macro. Added
GST_DEBUG_FUNCPTR. Reflowed _setcaps. Updated pad setup in _init. Fix
possible leak in _chain. (#356882)
2007-02-08 Tim-Philipp Müller <tim at centricular dot net> 2007-02-08 Tim-Philipp Müller <tim at centricular dot net>
* gst/asfdemux/asfheaders.c: * gst/asfdemux/asfheaders.c:

View file

@ -4,8 +4,8 @@ libgstsynaesthesia_la_SOURCES = gstsynaesthesia.c synaescope.c
noinst_HEADERS = synaescope.h noinst_HEADERS = synaescope.h
libgstsynaesthesia_la_CFLAGS = $(GST_CFLAGS) libgstsynaesthesia_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstsynaesthesia_la_LIBADD = $(GST_BASE_LIBS) libgstsynaesthesia_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
libgstsynaesthesia_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstsynaesthesia_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
EXTRA_DIST = README EXTRA_DIST = README

View file

@ -1,20 +1,37 @@
/* gstsynaesthesia.c: implementation of synaesthesia drawing element /* gstsynaesthesia.c: implementation of synaesthesia drawing element
* Copyright (C) <2001> Richard Boulton <richard@tartarus.org> * Copyright (C) <2001> Richard Boulton <richard@tartarus.org>
* *
* This library is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
* modify it under the terms of the GNU Library General Public * it under the terms of the GNU General Public License as published by
* License as published by the Free Software Foundation; either * the Free Software Foundation; either version 2 of the License, or
* version 2 of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Library General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public * You should have received a copy of the GNU General Public License
* License along with this library; if not, write to the * along with this program; if not, write to the Free Software
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Boston, MA 02111-1307, USA. */
/**
* SECTION:element-synaesthesia
* @see_also: goom
*
* <refsect2>
* <para>
* Synaesthesia is an audio visualisation element. It creates glitter and
* pulsating fog based on the incomming audio signal.
* </para>
* <title>Example launch line</title>
* <para>
* <programlisting>
* gst-launch -v audiotestsrc ! audioconvert ! synaesthesia ! ximagesink
* gst-launch -v audiotestsrc ! audioconvert ! synaesthesia ! ffmpegcolorspace ! xvimagesink
* </programlisting>
* </para>
* </refsect2>
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -32,10 +49,10 @@
#define SYNAES_WIDTH 320 #define SYNAES_WIDTH 320
#define SYNAES_HEIGHT 200 #define SYNAES_HEIGHT 200
#define GST_TYPE_SYNAESTHESIA (gst_synaesthesia_get_type()) #define GST_TYPE_SYNAESTHESIA (gst_synaesthesia_get_type())
#define GST_SYNAESTHESIA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SYNAESTHESIA,GstSynaesthesia)) #define GST_SYNAESTHESIA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SYNAESTHESIA,GstSynaesthesia))
#define GST_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SYNAESTHESIA,GstSynaesthesia)) #define GST_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SYNAESTHESIA,GstSynaesthesiaClass))
#define GST_IS_SYNAESTHESIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SYNAESTHESIA)) #define GST_IS_SYNAESTHESIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SYNAESTHESIA))
#define GST_IS_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SYNAESTHESIA)) #define GST_IS_SYNAESTHESIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SYNAESTHESIA))
typedef struct _GstSynaesthesia GstSynaesthesia; typedef struct _GstSynaesthesia GstSynaesthesia;
@ -169,10 +186,11 @@ gst_synaesthesia_class_init (GstSynaesthesiaClass * klass)
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
gstelement_class->change_state = gst_synaesthesia_change_state;
gobject_class->dispose = gst_synaesthesia_dispose; gobject_class->dispose = gst_synaesthesia_dispose;
gobject_class->finalize = gst_synaesthesia_finalize; gobject_class->finalize = gst_synaesthesia_finalize;
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_synaesthesia_change_state);
} }
static void static void
@ -180,22 +198,20 @@ gst_synaesthesia_init (GstSynaesthesia * synaesthesia)
{ {
/* create the sink and src pads */ /* create the sink and src pads */
synaesthesia->sinkpad = synaesthesia->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get gst_pad_new_from_static_template (&gst_synaesthesia_sink_template,
(&gst_synaesthesia_sink_template), "sink"); "sink");
synaesthesia->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_synaesthesia_src_template), "src");
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->sinkpad);
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->srcpad);
gst_pad_set_chain_function (synaesthesia->sinkpad, gst_synaesthesia_chain); gst_pad_set_chain_function (synaesthesia->sinkpad, gst_synaesthesia_chain);
gst_pad_set_setcaps_function (synaesthesia->sinkpad, gst_pad_set_setcaps_function (synaesthesia->sinkpad,
gst_synaesthesia_sink_setcaps); gst_synaesthesia_sink_setcaps);
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->sinkpad);
synaesthesia->srcpad =
gst_pad_new_from_static_template (&gst_synaesthesia_src_template, "src");
gst_pad_set_getcaps_function (synaesthesia->srcpad, gst_pad_set_getcaps_function (synaesthesia->srcpad,
gst_synaesthesia_src_getcaps); gst_synaesthesia_src_getcaps);
gst_pad_set_setcaps_function (synaesthesia->srcpad, gst_pad_set_setcaps_function (synaesthesia->srcpad,
gst_synaesthesia_src_setcaps); gst_synaesthesia_src_setcaps);
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->srcpad);
synaesthesia->adapter = gst_adapter_new (); synaesthesia->adapter = gst_adapter_new ();
@ -247,21 +263,33 @@ gst_synaesthesia_sink_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure; GstStructure *structure;
gint channels; gint channels;
gint rate; gint rate;
gboolean res = TRUE;
synaesthesia = GST_SYNAESTHESIA (gst_pad_get_parent (pad)); synaesthesia = GST_SYNAESTHESIA (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_int (structure, "channels", &channels) || if (!gst_structure_get_int (structure, "channels", &channels) ||
!gst_structure_get_int (structure, "rate", &rate)) { !gst_structure_get_int (structure, "rate", &rate))
return GST_PAD_LINK_REFUSED; goto missing_caps_details;
}
if (synaesthesia->channels != 2) if (synaesthesia->channels != 2)
return GST_PAD_LINK_REFUSED; goto wrong_channels;
synaesthesia->sample_rate = rate; synaesthesia->sample_rate = rate;
return TRUE; done:
gst_object_unref (synaesthesia);
return res;
/* Errors */
missing_caps_details:
GST_WARNING ("missing channels or rate in the caps");
res = FALSE;
goto done;
wrong_channels:
GST_WARNING ("channesl must be 2, but are %d", channels);
res = FALSE;
goto done;
} }
static GstCaps * static GstCaps *
@ -283,8 +311,6 @@ gst_synaesthesia_src_getcaps (GstPad * pad)
"width", G_TYPE_INT, synaesthesia->width, "width", G_TYPE_INT, synaesthesia->width,
"height", G_TYPE_INT, synaesthesia->height, "height", G_TYPE_INT, synaesthesia->height,
"framerate", GST_TYPE_FRACTION, (gint) synaesthesia->fps, 1, NULL); "framerate", GST_TYPE_FRACTION, (gint) synaesthesia->fps, 1, NULL);
//gst_structure_set (structure, "width", G_TYPE_INT, SYNAES_WIDTH, "height",
// G_TYPE_INT, SYNAES_HEIGHT, NULL);
} }
gst_object_unref (synaesthesia); gst_object_unref (synaesthesia);
@ -391,7 +417,7 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
/* no buffer allocated, we don't care why. */ /* no buffer allocated, we don't care why. */
if (ret != GST_FLOW_OK) if (ret != GST_FLOW_OK)
return ret; goto done;
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (outbuf) =
synaesthesia->audio_basetime + synaesthesia->audio_basetime +
@ -409,6 +435,7 @@ gst_synaesthesia_chain (GstPad * pad, GstBuffer * buffer)
synaesthesia->channels * sizeof (gint16)); synaesthesia->channels * sizeof (gint16));
} }
done:
gst_object_unref (synaesthesia); gst_object_unref (synaesthesia);
return ret; return ret;

View file

@ -1,22 +1,22 @@
/* synaescope.cpp /* synaescope.cpp
* Copyright (C) 1999,2002 Richard Boulton <richard@tartarus.org> * Copyright (C) 1999,2002 Richard Boulton <richard@tartarus.org>
* *
* Much code copied from Synaesthesia - a program to display sound * Much code copied from Synaesthesia - a program to display sound
* graphically, by Paul Francis Harrison <pfh@yoyo.cc.monash.edu.au> * graphically, by Paul Francis Harrison <pfh@yoyo.cc.monash.edu.au>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H

View file

@ -1,3 +1,23 @@
/* synaescope.h
* Copyright (C) 1999,2002 Richard Boulton <richard@tartarus.org>
*
* Much code copied from Synaesthesia - a program to display sound
* graphically, by Paul Francis Harrison <pfh@yoyo.cc.monash.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _SYNAESCOPE_H #ifndef _SYNAESCOPE_H
#define _SYNAESCOPE_H #define _SYNAESCOPE_H