gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
configure.ac: Put DEFAULT_AUDIOSINK in config.h and use whereever possible. (Fixes #165997)
Original commit message from CVS:
* configure.ac: Put DEFAULT_AUDIOSINK in config.h and use
whereever possible. (Fixes #165997)
* examples/capsfilter/capsfilter1.c: (main):
* examples/dynparams/filter.c: (create_ui):
* examples/seeking/cdparanoia.c: (get_track_info), (main):
* examples/seeking/chained.c: (main):
* examples/seeking/seek.c: (make_mod_pipeline), (make_dv_pipeline),
(make_wav_pipeline), (make_flac_pipeline), (make_sid_pipeline),
(make_vorbis_pipeline), (make_mp3_pipeline), (make_avi_pipeline),
(make_mpeg_pipeline), (make_mpegnt_pipeline):
* examples/seeking/spider_seek.c: (make_spider_pipeline):
* examples/switch/switcher.c: (main):
* ext/dv/demo-play.c: (main):
* ext/faad/gstfaad.c: (gst_faad_change_state):
* ext/mad/gstmad.c: (gst_mad_chain):
* ext/smoothwave/demo-osssrc.c: (main):
* gst-libs/gst/gconf/gconf.c: (gst_gconf_set_string),
(gst_gconf_render_bin_from_description),
(gst_gconf_get_default_audio_sink),
(gst_gconf_get_default_video_sink),
(gst_gconf_get_default_audio_src),
(gst_gconf_get_default_video_src),
(gst_gconf_get_default_visualization_element):
* gst/level/demo.c: (main):
* gst/level/plot.c: (main):
* gst/playback/gstplaybin.c: (gen_video_element),
(gen_audio_element):
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/playondemand/demo-mp3.c: (setup_pipeline):
* gst/sine/demo-dparams.c: (main):
* gst/spectrum/demo-osssrc.c: (main):
* gst/speed/demo-mp3.c: (main):
* gst/volume/demo.c: (main):
* testsuite/embed/embed.c: (main):
2005-02-02 08:14:01 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2007-07-18 07:35:32 +00:00
|
|
|
|
2009-10-07 11:03:20 +00:00
|
|
|
#include <stdio.h>
|
2007-07-18 07:35:32 +00:00
|
|
|
#include <stdlib.h>
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2002-01-04 21:36:18 +00:00
|
|
|
#include <gst/gst.h>
|
2004-10-22 20:09:55 +00:00
|
|
|
#include <gtk/gtk.h>
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2008-05-16 17:50:20 +00:00
|
|
|
#ifndef DEFAULT_AUDIOSRC
|
2006-05-20 22:42:15 +00:00
|
|
|
#define DEFAULT_AUDIOSRC "alsasrc"
|
2008-05-16 17:50:20 +00:00
|
|
|
#endif
|
|
|
|
|
2007-09-18 13:55:06 +00:00
|
|
|
static guint spect_height = 64;
|
|
|
|
static guint spect_bands = 256;
|
|
|
|
static gfloat height_scale = 1.0;
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2006-05-26 22:35:00 +00:00
|
|
|
static GtkWidget *drawingarea = NULL;
|
2008-08-10 19:35:05 +00:00
|
|
|
static GstClock *sync_clock = NULL;
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2006-05-20 22:42:15 +00:00
|
|
|
static void
|
2010-10-12 09:37:40 +00:00
|
|
|
on_window_destroy (GObject * object, gpointer user_data)
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
{
|
|
|
|
drawingarea = NULL;
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
|
|
|
|
2008-08-10 19:35:05 +00:00
|
|
|
static gboolean
|
2007-09-18 13:55:06 +00:00
|
|
|
on_configure_event (GtkWidget * widget, GdkEventConfigure * event,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GstElement *spectrum = GST_ELEMENT (user_data);
|
|
|
|
|
|
|
|
/*GST_INFO ("%d x %d", event->width, event->height); */
|
|
|
|
spect_height = event->height;
|
|
|
|
height_scale = event->height / 64.0;
|
|
|
|
spect_bands = event->width;
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, NULL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
/* draw frequency spectrum as a bunch of bars */
|
|
|
|
static void
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
draw_spectrum (gfloat * data)
|
2004-10-22 20:09:55 +00:00
|
|
|
{
|
|
|
|
gint i;
|
2007-09-18 13:55:06 +00:00
|
|
|
GdkRectangle rect = { 0, 0, spect_bands, spect_height };
|
2010-07-24 08:19:37 +00:00
|
|
|
cairo_t *cr;
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
|
|
|
|
if (!drawingarea)
|
|
|
|
return;
|
2004-10-22 20:09:55 +00:00
|
|
|
|
2010-06-26 18:12:25 +00:00
|
|
|
gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect);
|
2010-07-24 08:19:37 +00:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window (drawingarea));
|
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
|
|
cairo_rectangle (cr, 0, 0, spect_bands, spect_height);
|
|
|
|
cairo_fill (cr);
|
2010-08-02 20:15:56 +00:00
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
2007-09-18 13:55:06 +00:00
|
|
|
for (i = 0; i < spect_bands; i++) {
|
2010-07-24 08:19:37 +00:00
|
|
|
cairo_rectangle (cr, i, -data[i], 1, spect_height + data[i]);
|
|
|
|
cairo_fill (cr);
|
2004-10-22 20:09:55 +00:00
|
|
|
}
|
2010-07-24 08:29:01 +00:00
|
|
|
cairo_destroy (cr);
|
|
|
|
|
2010-06-26 18:12:25 +00:00
|
|
|
gdk_window_end_paint (gtk_widget_get_window (drawingarea));
|
2004-10-22 20:09:55 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 19:35:05 +00:00
|
|
|
/* process delayed message */
|
|
|
|
static gboolean
|
2009-01-27 21:09:05 +00:00
|
|
|
delayed_idle_spectrum_update (gpointer user_data)
|
2008-08-10 19:35:05 +00:00
|
|
|
{
|
|
|
|
draw_spectrum ((gfloat *) user_data);
|
|
|
|
g_free (user_data);
|
2009-01-27 21:09:05 +00:00
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
delayed_spectrum_update (GstClock * sync_clock, GstClockTime time,
|
|
|
|
GstClockID id, gpointer user_data)
|
|
|
|
{
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (time))
|
|
|
|
g_idle_add (delayed_idle_spectrum_update, user_data);
|
|
|
|
else
|
|
|
|
g_free (user_data);
|
2008-08-10 19:35:05 +00:00
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
/* receive spectral data from element message */
|
2008-08-10 19:35:05 +00:00
|
|
|
static gboolean
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
message_handler (GstBus * bus, GstMessage * message, gpointer data)
|
|
|
|
{
|
|
|
|
if (message->type == GST_MESSAGE_ELEMENT) {
|
|
|
|
const GstStructure *s = gst_message_get_structure (message);
|
|
|
|
const gchar *name = gst_structure_get_name (s);
|
|
|
|
|
|
|
|
if (strcmp (name, "spectrum") == 0) {
|
2008-08-10 19:35:05 +00:00
|
|
|
GstElement *spectrum = GST_ELEMENT (GST_MESSAGE_SRC (message));
|
|
|
|
GstClockTime timestamp, duration;
|
|
|
|
GstClockTime waittime = GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
if (gst_structure_get_clock_time (s, "running-time", ×tamp) &&
|
|
|
|
gst_structure_get_clock_time (s, "duration", &duration)) {
|
|
|
|
/* wait for middle of buffer */
|
|
|
|
waittime = timestamp + duration / 2;
|
|
|
|
} else if (gst_structure_get_clock_time (s, "endtime", ×tamp)) {
|
|
|
|
waittime = timestamp;
|
|
|
|
}
|
|
|
|
if (GST_CLOCK_TIME_IS_VALID (waittime)) {
|
|
|
|
GstClockID clock_id;
|
|
|
|
GstClockTime basetime = gst_element_get_base_time (spectrum);
|
|
|
|
gfloat *spect = g_new (gfloat, spect_bands);
|
|
|
|
const GValue *list;
|
|
|
|
const GValue *value;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
list = gst_structure_get_value (s, "magnitude");
|
|
|
|
for (i = 0; i < spect_bands; ++i) {
|
|
|
|
value = gst_value_list_get_value (list, i);
|
|
|
|
spect[i] = height_scale * g_value_get_float (value);
|
|
|
|
}
|
|
|
|
|
|
|
|
clock_id =
|
|
|
|
gst_clock_new_single_shot_id (sync_clock, waittime + basetime);
|
|
|
|
gst_clock_id_wait_async (clock_id, delayed_spectrum_update,
|
|
|
|
(gpointer) spect);
|
|
|
|
gst_clock_id_unref (clock_id);
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2002-01-04 21:36:18 +00:00
|
|
|
GstElement *bin;
|
gst/spectrum/Makefile.am: Link to base libraries
Original commit message from CVS:
* gst/spectrum/Makefile.am:
Link to base libraries
* gst/spectrum/demo-osssrc.c: (main):
use new threshhold property
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_set_sink_caps),
(gst_spectrum_get_sink_caps), (gst_spectrum_chain),
(gst_spectrum_change_state):
* gst/spectrum/gstspectrum.h:
Use gst_adapter, support multiple-channels, add threshold property for
result, add docs, fix resulting spectrum range (was including mirrored
results)
2006-05-21 16:23:23 +00:00
|
|
|
GstElement *src, *spectrum, *sink;
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
GstBus *bus;
|
2002-01-04 21:36:18 +00:00
|
|
|
GtkWidget *appwindow;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_init (&argc, &argv);
|
2004-10-22 20:09:55 +00:00
|
|
|
gtk_init (&argc, &argv);
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2004-10-22 20:09:55 +00:00
|
|
|
bin = gst_pipeline_new ("bin");
|
2002-01-04 21:36:18 +00:00
|
|
|
|
configure.ac: Put DEFAULT_AUDIOSINK in config.h and use whereever possible. (Fixes #165997)
Original commit message from CVS:
* configure.ac: Put DEFAULT_AUDIOSINK in config.h and use
whereever possible. (Fixes #165997)
* examples/capsfilter/capsfilter1.c: (main):
* examples/dynparams/filter.c: (create_ui):
* examples/seeking/cdparanoia.c: (get_track_info), (main):
* examples/seeking/chained.c: (main):
* examples/seeking/seek.c: (make_mod_pipeline), (make_dv_pipeline),
(make_wav_pipeline), (make_flac_pipeline), (make_sid_pipeline),
(make_vorbis_pipeline), (make_mp3_pipeline), (make_avi_pipeline),
(make_mpeg_pipeline), (make_mpegnt_pipeline):
* examples/seeking/spider_seek.c: (make_spider_pipeline):
* examples/switch/switcher.c: (main):
* ext/dv/demo-play.c: (main):
* ext/faad/gstfaad.c: (gst_faad_change_state):
* ext/mad/gstmad.c: (gst_mad_chain):
* ext/smoothwave/demo-osssrc.c: (main):
* gst-libs/gst/gconf/gconf.c: (gst_gconf_set_string),
(gst_gconf_render_bin_from_description),
(gst_gconf_get_default_audio_sink),
(gst_gconf_get_default_video_sink),
(gst_gconf_get_default_audio_src),
(gst_gconf_get_default_video_src),
(gst_gconf_get_default_visualization_element):
* gst/level/demo.c: (main):
* gst/level/plot.c: (main):
* gst/playback/gstplaybin.c: (gen_video_element),
(gen_audio_element):
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/playondemand/demo-mp3.c: (setup_pipeline):
* gst/sine/demo-dparams.c: (main):
* gst/spectrum/demo-osssrc.c: (main):
* gst/speed/demo-mp3.c: (main):
* gst/volume/demo.c: (main):
* testsuite/embed/embed.c: (main):
2005-02-02 08:14:01 +00:00
|
|
|
src = gst_element_factory_make (DEFAULT_AUDIOSRC, "src");
|
2006-05-20 22:42:15 +00:00
|
|
|
|
2004-10-22 20:09:55 +00:00
|
|
|
spectrum = gst_element_factory_make ("spectrum", "spectrum");
|
2007-09-18 13:55:06 +00:00
|
|
|
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
"message", TRUE, NULL);
|
2006-05-20 22:42:15 +00:00
|
|
|
|
2004-10-22 20:09:55 +00:00
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
2002-01-04 21:36:18 +00:00
|
|
|
|
gst/spectrum/Makefile.am: Link to base libraries
Original commit message from CVS:
* gst/spectrum/Makefile.am:
Link to base libraries
* gst/spectrum/demo-osssrc.c: (main):
use new threshhold property
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_set_sink_caps),
(gst_spectrum_get_sink_caps), (gst_spectrum_chain),
(gst_spectrum_change_state):
* gst/spectrum/gstspectrum.h:
Use gst_adapter, support multiple-channels, add threshold property for
result, add docs, fix resulting spectrum range (was including mirrored
results)
2006-05-21 16:23:23 +00:00
|
|
|
gst_bin_add_many (GST_BIN (bin), src, spectrum, sink, NULL);
|
|
|
|
if (!gst_element_link_many (src, spectrum, sink, NULL)) {
|
2007-09-18 13:55:06 +00:00
|
|
|
fprintf (stderr, "can't link elements\n");
|
2006-05-20 22:42:15 +00:00
|
|
|
exit (1);
|
|
|
|
}
|
2002-01-04 21:36:18 +00:00
|
|
|
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
bus = gst_element_get_bus (bin);
|
|
|
|
gst_bus_add_watch (bus, message_handler, NULL);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
|
2008-08-10 19:35:05 +00:00
|
|
|
sync_clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
|
|
|
|
|
2004-10-22 20:09:55 +00:00
|
|
|
appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
gst/spectrum/: port to use message to get results, cleanly exit when closing the window
Original commit message from CVS:
* gst/spectrum/demo-audiotest.c: (on_window_destroy),
(draw_spectrum), (message_handler), (main):
* gst/spectrum/demo-osssrc.c: (on_window_destroy), (draw_spectrum),
(message_handler), (main):
port to use message to get results, cleanly exit when closing the window
* gst/spectrum/gstspectrum.c: (gst_spectrum_class_init),
(gst_spectrum_init), (gst_spectrum_dispose),
(gst_spectrum_set_property), (gst_spectrum_get_property),
(gst_spectrum_set_caps), (gst_spectrum_start),
(gst_spectrum_message_new), (gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
port to derive from basetransform and send results via messages
(like level element)
2006-06-16 09:49:07 +00:00
|
|
|
g_signal_connect (G_OBJECT (appwindow), "destroy",
|
|
|
|
G_CALLBACK (on_window_destroy), NULL);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
drawingarea = gtk_drawing_area_new ();
|
2007-09-18 13:55:06 +00:00
|
|
|
gtk_widget_set_size_request (drawingarea, spect_bands, spect_height);
|
|
|
|
g_signal_connect (G_OBJECT (drawingarea), "configure-event",
|
|
|
|
G_CALLBACK (on_configure_event), (gpointer) spectrum);
|
2004-10-22 20:09:55 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (appwindow), drawingarea);
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_widget_show_all (appwindow);
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2006-05-20 22:42:15 +00:00
|
|
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_main ();
|
2006-05-20 22:42:15 +00:00
|
|
|
gst_element_set_state (bin, GST_STATE_NULL);
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2008-08-10 19:35:05 +00:00
|
|
|
gst_object_unref (sync_clock);
|
2006-05-20 22:42:15 +00:00
|
|
|
gst_object_unref (bin);
|
2002-01-04 21:36:18 +00:00
|
|
|
|
2006-05-20 22:42:15 +00:00
|
|
|
return 0;
|
2002-01-04 21:36:18 +00:00
|
|
|
}
|