[gst-devel] Question about spiders and sinks.......
Bob Doan
bdoan at sicompos.com
Sat May 31 18:46:06 CEST 2003
Hi All,
I'm trying to make use of "spider" and "fakesink" in order to get the
total amount of seconds of songs. However if I use spider and fakesink
in my pipeline I can't get the total amount of time. If I subsitute
"spider" with "mad" for an MP3 it will give me the correct time.. or if
I keep spider and replace fakesink with "osssink" I also can get the
correct time... Am I doing something wrong or is it not supposed to
work??
TYIA!
- Bob
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline;
GstElement *filesrc, *decoder, *sink;
int res;
int total=0;
gint64 value;
gboolean query_worked = FALSE;
GstFormat format = GST_FORMAT_TIME;
gst_init(&argc, &argv);
if (argc != 2) {
g_print ("usage: %s\n", argv[0]);
exit (-1);
}
pipeline = gst_pipeline_new ("pipeline");
filesrc = gst_element_factory_make ("filesrc", "disk_source");
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
decoder = gst_element_factory_make ("spider", "decoder");
sink = gst_element_factory_make ("fakesink", "play_audio");
gst_bin_add_many (GST_BIN (pipeline), filesrc, decoder, sink, NULL);
res = gst_element_link_many (filesrc, decoder, sink, NULL);
res = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if(gst_bin_iterate (GST_BIN (pipeline))) {
query_worked = gst_element_query (sink, GST_QUERY_TOTAL, &format,
&value);
if(query_worked)
total = value / GST_SECOND;
}
printf("total=%d\n", total);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
exit (0);
}
--
More information about the gstreamer-devel
mailing list