[gst-devel] filesrc rewind
august
august at alien.mur.at
Fri Mar 7 05:27:16 CET 2003
below is the test code I am using. Now I have it looping an mp3 file.
funny thing though that I can't call the seek on the decoder or something
other than osssink. in fact, it only works when I check to see if the
decoder state is not playing and then send a seek event to osssink. It
_doesnot_ work when I check to see if the filesrc is not playing and then
send the seek event to osssink.
but this is just a simple pipline:
filesrc->decoder->osssink
what to do when it gets more complex, such as ???:
filesrc->decoder->queue
\
- adder->osssink
/
filesrc->decoder->queue
how to rewind or set a
file on this one ?? : http://gstreamer.net/images/gst-editor-gstreamix.png
I have this pipeline structure working and playing two mp3 files, but
can't seek anywhere.
-august.
----------------------------------------
#include <stdlib.h>
#include <gst/gst.h>
int main (int argc, char *argv[])
{
GstElement *bin, *filesrc, *decoder, *osssink;
GValue value = { 0, };
gchar *str = 0;
gst_init (&argc, &argv);
if (argc != 2) {
g_print ("usage: %s <mp3 file>\n", argv[0]);
exit (-1);
}
/* create a new bin to hold the elements */
bin = gst_pipeline_new ("pipeline");
g_assert (bin);
/* create a disk reader */
filesrc = gst_element_factory_make ("filesrc", "disk_source");
g_assert (filesrc);
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
/* now it's time to get the decoder */
decoder = gst_element_factory_make ("mad", "decoderrr");
if (!decoder) {
g_print ("could not find plugin \"mad\"");
return -1;
}
g_value_init (&value, G_TYPE_STRING);
g_object_get_property (G_OBJECT (decoder), "name", &value);
//g_object_set (G_OBJECT (decoder), "name", "mydecoder", NULL);
str = g_strdup_value_contents (&value);
g_print("%s name is %s", GST_OBJECT_NAME (decoder), str);
g_free(str);
/* and an audio sink */
osssink = gst_element_factory_make ("osssink", "play_audio");
g_assert (osssink);
/* add objects to the main pipeline */
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, osssink, NULL);
/* link the elements */
gst_element_link_many (filesrc, decoder, osssink, NULL);
/* start playing */
gst_element_set_state (bin, GST_STATE_PLAYING);
g_print("\n\nstarting \n");
while (1) {
if ( ( gst_element_get_state( decoder ) ) == GST_STATE_PAUSED ) {
GstEvent *s_event;
gboolean audio_seek_worked = FALSE;
gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PAUSED);
g_print("end of stream \n");
s_event = gst_event_new_seek (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, 0);
audio_seek_worked = gst_element_send_event ( GST_ELEMENT(osssink), s_event);
if (audio_seek_worked) g_print("seeking worked!!!\n");
//gst_element_set_state(GST_ELEMENT(filesrc), GST_STATE_PLAYING);
gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
}
gst_bin_iterate (GST_BIN (bin));
}
g_print("ending \n");
/* stop the bin */
gst_element_set_state (bin, GST_STATE_NULL);
exit (0);
}
More information about the gstreamer-devel
mailing list