2000-01-30 10:44:33 +00:00
|
|
|
#include <gnome.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
extern gboolean _gst_plugin_spew;
|
|
|
|
|
|
|
|
static gboolean playing = TRUE;
|
|
|
|
|
2000-12-30 01:53:05 +00:00
|
|
|
void eof(GstElement *src) {
|
2000-01-30 10:44:33 +00:00
|
|
|
DEBUG("have EOF\n");
|
|
|
|
playing = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc,char *argv[]) {
|
|
|
|
GstElement *bin;
|
|
|
|
GstElementFactory *srcfactory;
|
|
|
|
GstElement *src;
|
|
|
|
GstElementFactory *mp3factory;
|
|
|
|
GstElement *mp3;
|
|
|
|
GstElementFactory *sinkfactory;
|
|
|
|
GstElement *sink;
|
|
|
|
|
|
|
|
_gst_plugin_spew = TRUE;
|
|
|
|
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
gst_plugin_load_all();
|
|
|
|
|
|
|
|
bin = gst_bin_new("bin");
|
|
|
|
|
|
|
|
srcfactory = gst_elementfactory_find("disksrc");
|
|
|
|
if (argc == 3)
|
|
|
|
mp3factory = gst_elementfactory_find(argv[2]);
|
|
|
|
else
|
|
|
|
mp3factory = gst_elementfactory_find("xa");
|
|
|
|
sinkfactory = gst_elementfactory_find("audiosink");
|
|
|
|
|
|
|
|
src = gst_elementfactory_create(srcfactory,"src");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(src != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
|
|
|
|
mp3 = gst_elementfactory_create(mp3factory,"mp3");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(mp3 != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
sink = gst_elementfactory_create(sinkfactory,"sink");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(sink != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
|
|
|
|
gst_bin_add(GST_BIN(bin),GST_ELEMENT(mp3));
|
|
|
|
gst_bin_add(GST_BIN(bin),GST_ELEMENT(sink));
|
|
|
|
|
|
|
|
gst_pad_connect(gst_element_get_pad(src,"src"),
|
|
|
|
gst_element_get_pad(mp3,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(mp3,"src"),
|
|
|
|
gst_element_get_pad(sink,"sink"));
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(src),"eof",
|
|
|
|
GTK_SIGNAL_FUNC(eof),NULL);
|
|
|
|
|
2000-08-14 15:17:24 +00:00
|
|
|
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
|
2000-01-30 10:44:33 +00:00
|
|
|
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
while (playing)
|
2000-12-27 22:39:45 +00:00
|
|
|
gst_bin_iterate(GST_BIN(bin));
|
2000-08-14 15:17:24 +00:00
|
|
|
|
|
|
|
return 0;
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|