2003-07-25 10:50:48 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2002 Andy Wingo <wingo at pobox dot com>
|
|
|
|
*
|
|
|
|
* 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
|
2002-08-11 11:45:07 +00:00
|
|
|
#include <stdlib.h>
|
2002-01-04 21:41:29 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2005-02-15 11:05:35 +00:00
|
|
|
static GtkWidget *poslabel; /* NULL */
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
void
|
|
|
|
set_speed (GtkAdjustment * adj, gpointer data)
|
2002-01-04 21:41:29 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstElement *speed = GST_ELEMENT (data);
|
|
|
|
|
|
|
|
g_object_set (speed, "speed", adj->value, NULL);
|
2002-01-04 21:41:29 +00:00
|
|
|
}
|
|
|
|
|
2005-02-15 11:05:35 +00:00
|
|
|
static gboolean
|
|
|
|
time_tick_cb (GstElement * audiosink)
|
|
|
|
{
|
|
|
|
GstFormat format = GST_FORMAT_TIME;
|
|
|
|
guint64 total, pos;
|
|
|
|
|
|
|
|
if (gst_element_query (audiosink, GST_QUERY_TOTAL, &format, &total)
|
|
|
|
&& gst_element_query (audiosink, GST_QUERY_POSITION, &format, &pos)) {
|
|
|
|
guint t_min, t_sec, p_min, p_sec;
|
|
|
|
gchar *s;
|
|
|
|
|
|
|
|
t_min = (guint) (total / (GST_SECOND * 60));
|
|
|
|
t_sec = (guint) ((total % (GST_SECOND * 60)) / GST_SECOND);
|
|
|
|
p_min = (guint) (pos / (GST_SECOND * 60));
|
|
|
|
p_sec = (guint) ((pos % (GST_SECOND * 60)) / GST_SECOND);
|
|
|
|
|
|
|
|
s = g_strdup_printf ("%u:%02u / %u:%02u", p_min, p_sec, t_min, t_sec);
|
|
|
|
gtk_label_set_text (GTK_LABEL (poslabel), s);
|
|
|
|
g_free (s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE; /* call again */
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
2002-01-04 21:41:29 +00:00
|
|
|
{
|
2005-02-15 11:05:35 +00:00
|
|
|
GtkWidget *window, *vbox, *hscale, *button, *hbbox;
|
2005-02-10 15:06:13 +00:00
|
|
|
GstElement *filesrc, *mad, *audioconvert, *speed, *audiosink, *pipeline;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
g_print ("usage: %s <your.mp3>\n", argv[0]);
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
2005-02-15 11:05:35 +00:00
|
|
|
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 400, 80);
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
2005-02-15 11:05:35 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
|
|
|
hscale = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 0.1, 4.0,
|
2004-03-15 19:32:27 +00:00
|
|
|
0.1, 0.0, 0.0)));
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
|
2005-02-15 11:05:35 +00:00
|
|
|
hbbox = gtk_hbutton_box_new ();
|
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
2005-02-15 11:05:35 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (hbbox), button);
|
|
|
|
poslabel = gtk_label_new (NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), poslabel, FALSE, FALSE, 2);
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 2);
|
2005-02-15 11:05:35 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbbox, FALSE, FALSE, 6);
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
filesrc = gst_element_factory_make ("filesrc", "filesrc");
|
|
|
|
mad = gst_element_factory_make ("mad", "mad");
|
2005-02-10 15:06:13 +00:00
|
|
|
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert0");
|
2004-03-14 22:34:33 +00:00
|
|
|
speed = gst_element_factory_make ("speed", "speed");
|
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
|
|
|
audiosink = gst_element_factory_make (DEFAULT_AUDIOSINK, "audiosink");
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-02-15 11:05:35 +00:00
|
|
|
g_signal_connect (gtk_range_get_adjustment (GTK_RANGE (hscale)),
|
|
|
|
"value_changed", G_CALLBACK (set_speed), speed);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("app");
|
2005-02-10 15:06:13 +00:00
|
|
|
gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, audioconvert, speed,
|
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
|
|
|
audiosink, NULL);
|
2005-02-10 15:06:13 +00:00
|
|
|
gst_element_link_many (filesrc, mad, audioconvert, speed, audiosink, NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
|
|
|
|
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
|
2005-02-15 11:05:35 +00:00
|
|
|
gtk_widget_show_all (window);
|
|
|
|
|
|
|
|
g_idle_add ((GSourceFunc) gst_bin_iterate, pipeline);
|
|
|
|
g_timeout_add (200, (GSourceFunc) time_tick_cb, audiosink);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
2005-02-15 11:05:35 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (pipeline));
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
return 0;
|
2002-01-04 21:41:29 +00:00
|
|
|
}
|