2002-08-11 11:29:39 +00:00
|
|
|
#include <stdlib.h>
|
2002-03-30 17:06:26 +00:00
|
|
|
#include <glib.h>
|
2002-01-04 21:39:32 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
void play (GtkButton *button, gpointer data)
|
|
|
|
{
|
2002-02-02 13:59:13 +00:00
|
|
|
g_signal_emit_by_name(G_OBJECT(data), "play", NULL, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void reset (GtkButton *button, gpointer data)
|
|
|
|
{
|
2002-02-02 13:59:13 +00:00
|
|
|
g_signal_emit_by_name(G_OBJECT(data), "reset", NULL, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
guint channels;
|
|
|
|
GtkWidget *window, *vbox, *play_button, *reset_button, *quit_button;
|
2002-01-22 04:44:21 +00:00
|
|
|
GstElement *src, *mad, *pod, *osssink, *pipeline;
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc!=2) {
|
|
|
|
g_print("usage: %s <mp3-filename>\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
2002-04-11 20:42:26 +00:00
|
|
|
src = gst_element_factory_make("filesrc", "filesrc");
|
|
|
|
mad = gst_element_factory_make("mad", "mad");
|
|
|
|
pod = gst_element_factory_make("playondemand", "playondemand");
|
|
|
|
osssink = gst_element_factory_make("osssink", "osssink");
|
2002-01-04 21:39:32 +00:00
|
|
|
|
2002-01-22 04:44:21 +00:00
|
|
|
g_object_set(G_OBJECT(src), "location", argv[1], NULL);
|
|
|
|
g_object_set(G_OBJECT(osssink), "fragment", 0x00180008, NULL);
|
|
|
|
g_object_get(G_OBJECT(osssink), "channels", &channels, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
pipeline = gst_pipeline_new("app");
|
|
|
|
|
2002-01-22 04:44:21 +00:00
|
|
|
gst_bin_add(GST_BIN(pipeline), src);
|
2002-01-04 21:39:32 +00:00
|
|
|
gst_bin_add(GST_BIN(pipeline), mad);
|
|
|
|
gst_bin_add(GST_BIN(pipeline), pod);
|
|
|
|
gst_bin_add(GST_BIN(pipeline), osssink);
|
|
|
|
|
2002-04-10 17:41:33 +00:00
|
|
|
gst_element_connect(src, mad);
|
|
|
|
gst_element_connect(pod, osssink);
|
|
|
|
gst_element_connect(mad, pod);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
/* initialize gui elements ... */
|
|
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
play_button = gtk_button_new_with_label("play");
|
|
|
|
reset_button = gtk_button_new_with_label("reset");
|
|
|
|
quit_button = gtk_button_new_with_label("quit");
|
|
|
|
|
|
|
|
/* do the packing stuff ... */
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(window), 96, 96);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), play_button, FALSE, FALSE, 2);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), reset_button, FALSE, FALSE, 2);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), quit_button, FALSE, FALSE, 2);
|
|
|
|
|
|
|
|
/* connect things ... */
|
2002-01-22 04:44:21 +00:00
|
|
|
g_signal_connect(G_OBJECT(play_button), "clicked", G_CALLBACK(play), pod);
|
|
|
|
g_signal_connect(G_OBJECT(reset_button), "clicked", G_CALLBACK(reset), pod);
|
|
|
|
g_signal_connect(G_OBJECT(quit_button), "clicked", gtk_main_quit, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
/* show the gui. */
|
|
|
|
gtk_widget_show(play_button);
|
|
|
|
gtk_widget_show(reset_button);
|
|
|
|
gtk_widget_show(quit_button);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
gtk_widget_show(window);
|
|
|
|
gtk_idle_add((GtkFunction)gst_bin_iterate, pipeline);
|
|
|
|
|
|
|
|
gtk_main();
|
2002-02-02 13:59:13 +00:00
|
|
|
|
|
|
|
return 0;
|
2002-01-04 21:39:32 +00:00
|
|
|
}
|