2000-01-30 10:44:33 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
|
2000-12-30 01:53:05 +00:00
|
|
|
void eof(GstElement *src) {
|
2000-02-05 01:20:11 +00:00
|
|
|
g_print("have eof, quitting\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
int main(int argc,char *argv[]) {
|
|
|
|
GstElementFactory *srcfactory, *parsefactory, *decodefactory, *playfactory;
|
2000-12-30 01:53:05 +00:00
|
|
|
GstElement *pipeline, *src, *parse, *decode, *play;
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
g_print("have %d args\n",argc);
|
|
|
|
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new("pipeline");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(pipeline != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
srcfactory = gst_elementfactory_find("disksrc");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(srcfactory != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
parsefactory = gst_elementfactory_find("mp3parse");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(parsefactory != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
decodefactory = gst_elementfactory_find("mpg123");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(decodefactory != NULL, -1);
|
2001-03-24 17:22:03 +00:00
|
|
|
playfactory = gst_elementfactory_find("osssink");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(playfactory != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
src = gst_elementfactory_create(srcfactory,"src");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(src != NULL, -1);
|
2001-07-08 21:02:10 +00:00
|
|
|
g_object_set(G_OBJECT(src),"location",argv[1], NULL);
|
2000-01-30 10:44:33 +00:00
|
|
|
g_print("should be using file '%s'\n",argv[1]);
|
|
|
|
parse = gst_elementfactory_create(parsefactory,"parse");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(parse != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
decode = gst_elementfactory_create(decodefactory,"decode");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(decode != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
play = gst_elementfactory_create(playfactory,"play");
|
2001-06-01 18:09:26 +00:00
|
|
|
g_return_val_if_fail(play != NULL, -1);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
g_signal_connectc(G_OBJECT(src),"eos",
|
|
|
|
G_CALLBACK(eof),NULL, FALSE);
|
2000-02-05 01:20:11 +00:00
|
|
|
|
2000-01-30 10:44:33 +00:00
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(decode));
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(play));
|
|
|
|
|
|
|
|
gst_pad_connect(gst_element_get_pad(src,"src"),
|
|
|
|
gst_element_get_pad(parse,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
|
|
|
gst_element_get_pad(decode,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(decode,"src"),
|
|
|
|
gst_element_get_pad(play,"sink"));
|
|
|
|
|
2000-08-14 15:17:24 +00:00
|
|
|
g_print("setting to READY state\n");
|
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
|
2000-12-27 22:39:45 +00:00
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
2000-01-30 10:44:33 +00:00
|
|
|
|
|
|
|
g_print("about to enter loop\n");
|
2000-02-16 23:27:45 +00:00
|
|
|
while (1) {
|
2000-12-27 22:39:45 +00:00
|
|
|
gst_bin_iterate(GST_BIN(pipeline));
|
|
|
|
}
|
2000-01-30 10:44:33 +00:00
|
|
|
}
|