2001-01-01 00:42:10 +00:00
|
|
|
#include <stdlib.h>
|
2000-08-18 20:38:54 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
gboolean playing;
|
|
|
|
|
2000-09-09 16:36:10 +00:00
|
|
|
/* eos will be called when the src element has an end of stream */
|
2001-01-01 00:42:10 +00:00
|
|
|
void eos(GstElement *element)
|
2000-08-18 20:38:54 +00:00
|
|
|
{
|
|
|
|
g_print("have eos, quitting\n");
|
|
|
|
|
|
|
|
playing = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc,char *argv[])
|
|
|
|
{
|
2001-04-12 18:11:19 +00:00
|
|
|
GstElement *bin, *disksrc, *parse, *decoder, *downmix, *mulaw, *mulawdec, *osssink;
|
2000-08-18 20:38:54 +00:00
|
|
|
|
2001-01-03 19:12:21 +00:00
|
|
|
gst_init(&argc,&argv);
|
|
|
|
|
2000-08-18 20:38:54 +00:00
|
|
|
if (argc != 2) {
|
|
|
|
g_print("usage: %s <filename>\n", argv[0]);
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a new bin to hold the elements */
|
2001-06-02 16:38:58 +00:00
|
|
|
bin = gst_pipeline_new("pipeline");
|
2000-08-18 20:38:54 +00:00
|
|
|
|
|
|
|
/* create a disk reader */
|
|
|
|
disksrc = gst_elementfactory_make("disksrc", "disk_source");
|
|
|
|
gtk_object_set(GTK_OBJECT(disksrc),"location", argv[1],NULL);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(disksrc),"eos",
|
|
|
|
GTK_SIGNAL_FUNC(eos),NULL);
|
|
|
|
|
|
|
|
/* now it's time to get the parser */
|
|
|
|
parse = gst_elementfactory_make("mp3parse","parse");
|
|
|
|
decoder = gst_elementfactory_make("mpg123","decoder");
|
2001-03-30 23:56:07 +00:00
|
|
|
downmix = gst_elementfactory_make("stereo2mono","stereo2mono");
|
2001-04-02 19:56:34 +00:00
|
|
|
mulaw = gst_elementfactory_make("mulawencode","mulaw");
|
2001-04-12 18:11:19 +00:00
|
|
|
mulawdec = gst_elementfactory_make("mulawdecode","mulawdec");
|
2000-08-18 20:38:54 +00:00
|
|
|
/* and an audio sink */
|
2001-03-24 17:22:03 +00:00
|
|
|
osssink = gst_elementfactory_make("osssink", "play_audio");
|
2000-08-18 20:38:54 +00:00
|
|
|
|
|
|
|
/* add objects to the main pipeline */
|
|
|
|
gst_bin_add(GST_BIN(bin), disksrc);
|
2000-09-09 16:36:10 +00:00
|
|
|
gst_bin_add(GST_BIN(bin), parse);
|
2000-08-18 20:38:54 +00:00
|
|
|
gst_bin_add(GST_BIN(bin), decoder);
|
2001-03-30 23:56:07 +00:00
|
|
|
gst_bin_add(GST_BIN(bin), downmix);
|
2001-04-02 19:56:34 +00:00
|
|
|
gst_bin_add(GST_BIN(bin), mulaw);
|
2001-04-12 18:11:19 +00:00
|
|
|
gst_bin_add(GST_BIN(bin), mulawdec);
|
2001-03-24 17:22:03 +00:00
|
|
|
gst_bin_add(GST_BIN(bin), osssink);
|
2000-08-18 20:38:54 +00:00
|
|
|
|
|
|
|
/* connect src to sink */
|
|
|
|
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
|
|
|
gst_element_get_pad(parse,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
|
|
|
gst_element_get_pad(decoder,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(decoder,"src"),
|
2001-03-30 23:56:07 +00:00
|
|
|
gst_element_get_pad(downmix,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(downmix,"src"),
|
2001-04-02 19:56:34 +00:00
|
|
|
gst_element_get_pad(mulaw,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(mulaw,"src"),
|
2001-04-12 18:11:19 +00:00
|
|
|
gst_element_get_pad(mulawdec,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(mulawdec,"src"),
|
2001-03-24 17:22:03 +00:00
|
|
|
gst_element_get_pad(osssink,"sink"));
|
2000-08-18 20:38:54 +00:00
|
|
|
|
|
|
|
/* start playing */
|
|
|
|
gst_element_set_state(bin, GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
playing = TRUE;
|
|
|
|
|
|
|
|
while (playing) {
|
|
|
|
gst_bin_iterate(GST_BIN(bin));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stop the bin */
|
|
|
|
gst_element_set_state(bin, GST_STATE_NULL);
|
|
|
|
|
2001-03-24 17:22:03 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(osssink));
|
2000-09-09 16:36:10 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(parse));
|
2000-08-18 20:38:54 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(decoder));
|
2001-03-30 23:56:07 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(downmix));
|
2001-04-02 19:56:34 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(mulaw));
|
2001-04-12 18:11:19 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(mulawdec));
|
2000-08-18 20:38:54 +00:00
|
|
|
gst_object_destroy(GST_OBJECT(disksrc));
|
|
|
|
gst_object_destroy(GST_OBJECT(bin));
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|