2000-01-30 10:44:33 +00:00
|
|
|
#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) {
|
2001-01-01 07:44:32 +00:00
|
|
|
GST_DEBUG(0,"have EOF\n");
|
2000-01-30 10:44:33 +00:00
|
|
|
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");
|
2001-03-24 17:22:03 +00:00
|
|
|
sinkfactory = gst_elementfactory_find("osssink");
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|