2001-04-26 00:25:19 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2001-04-26 23:34:02 +00:00
|
|
|
GstElement *audiothread;
|
|
|
|
GstElement *audioqueue;
|
|
|
|
GstElement *audiodecode;
|
|
|
|
GstElement *audiosink;
|
|
|
|
|
2001-04-26 00:25:19 +00:00
|
|
|
void new_pad(GstElement *parse,GstPad *pad,GstElement *pipeline) {
|
|
|
|
|
|
|
|
if (!strncmp(gst_pad_get_name(pad), "audio_", 6)) {
|
|
|
|
fprintf(stderr,"have audio pad\n");
|
|
|
|
|
2001-04-26 22:32:52 +00:00
|
|
|
fprintf(stderr,"creating thread\n");
|
|
|
|
audiothread = gst_elementfactory_make("thread","audiothread");
|
|
|
|
gst_bin_add(GST_BIN(pipeline),audiothread);
|
|
|
|
|
|
|
|
fprintf(stderr,"creating queue\n");
|
|
|
|
audioqueue = gst_elementfactory_make("queue","audioqueue");
|
|
|
|
gst_bin_add(GST_BIN(audiothread),audioqueue);
|
|
|
|
gst_pad_connect(pad,gst_element_get_pad(audioqueue,"sink"));
|
|
|
|
|
|
|
|
fprintf(stderr,"creating decoder\n");
|
2001-04-26 00:25:19 +00:00
|
|
|
audiodecode = gst_elementfactory_make("mad","audiodecode");
|
2001-04-26 22:32:52 +00:00
|
|
|
gst_bin_add(GST_BIN(audiothread),audiodecode);
|
|
|
|
gst_element_connect(audioqueue,"src",audiodecode,"sink");
|
2001-04-26 00:25:19 +00:00
|
|
|
|
2001-04-26 22:32:52 +00:00
|
|
|
fprintf(stderr,"creating esdsink\n");
|
2001-04-27 19:35:54 +00:00
|
|
|
audiosink = gst_elementfactory_make("osssink","audiosink");
|
2001-04-26 22:32:52 +00:00
|
|
|
gst_bin_add(GST_BIN(audiothread),audiosink);
|
2001-04-26 00:25:19 +00:00
|
|
|
gst_element_connect(audiodecode,"src",audiosink,"sink");
|
|
|
|
|
2001-04-26 22:32:52 +00:00
|
|
|
fprintf(stderr,"setting state to PLAYING\n");
|
|
|
|
gst_element_set_state(audiothread,GST_STATE_PLAYING);
|
2001-04-26 00:25:19 +00:00
|
|
|
|
|
|
|
fprintf(stderr,"done dealing with new audio pad\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc,char *argv[]) {
|
2001-04-26 23:34:02 +00:00
|
|
|
GstElement *pipeline, *sourcethread, *src, *parse;
|
2001-04-26 00:25:19 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new("pipeline");
|
2001-04-26 23:34:02 +00:00
|
|
|
sourcethread = gst_elementfactory_make("thread","sourcethread");
|
2001-04-26 00:25:19 +00:00
|
|
|
src = gst_elementfactory_make("disksrc","src");
|
2001-05-01 21:41:40 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(src),"location","/home/omega/media/AlienSong.mpg",NULL);
|
2001-04-26 00:25:19 +00:00
|
|
|
parse = gst_elementfactory_make("mpeg1parse","parse");
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",
|
|
|
|
GTK_SIGNAL_FUNC(new_pad),pipeline);
|
|
|
|
|
2001-04-26 23:34:02 +00:00
|
|
|
gst_bin_add(GST_BIN(sourcethread),src);
|
|
|
|
gst_bin_add(GST_BIN(sourcethread),parse);
|
2001-04-26 00:25:19 +00:00
|
|
|
|
|
|
|
gst_element_connect(src,"src",parse,"sink");
|
|
|
|
|
2001-04-26 23:34:02 +00:00
|
|
|
gst_bin_add(GST_BIN(pipeline),sourcethread);
|
|
|
|
|
2001-04-26 00:25:19 +00:00
|
|
|
gst_schedule_show(GST_ELEMENT_SCHED(pipeline));
|
|
|
|
|
2001-04-26 23:34:02 +00:00
|
|
|
gst_element_set_state(pipeline,GST_STATE_PLAYING);
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
// sleep(1);
|
2001-05-01 21:41:40 +00:00
|
|
|
fprintf(stderr,"setting to PAUSED\n");
|
2001-04-26 23:34:02 +00:00
|
|
|
gst_element_set_state(pipeline,GST_STATE_PAUSED);fprintf(stderr,"paused... ");
|
|
|
|
// sleep(1);
|
2001-05-01 21:41:40 +00:00
|
|
|
fprintf(stderr,"setting to PLAYING\n");
|
2001-04-26 23:34:02 +00:00
|
|
|
gst_element_set_state(pipeline,GST_STATE_PLAYING);fprintf(stderr,"playing.\n");
|
|
|
|
}
|
|
|
|
|
2001-04-26 00:25:19 +00:00
|
|
|
// for (i=0;i<10;i++)
|
2001-04-26 23:34:02 +00:00
|
|
|
// while (1)
|
|
|
|
// gst_bin_iterate(GST_BIN(pipeline));
|
2001-04-26 00:25:19 +00:00
|
|
|
}
|