[gst-devel] please correct for me about the construction of a simple player...
Volter Yen
volter619 at 163.com
Wed Sep 12 05:20:40 CEST 2007
Hi all,
I want to make my simple palyer with gstreamer plugin,
the test script is :
gst-launch-0.10 filesrc location=testmediafile ! *demux name=demux d.! queue !*decoded ! audioconvert!.... d. !queue !*decodec ! ffmpegcolorsapce....
(the way above can work properly) I tried to find some example on the subject,but the document on the gstreamer.com do little help with me for this case,
I have tried to do that as the following:main piple :
|--a_queue ---*decodec--videooutbin
filesrc--*demuxer-|
|--v_queue ---*decodec--audiooutbin
audio out process :
construct a bin,which contains:
audioconvert--...--audiosink
constrcut a ghost pad for audio out bin
video out process :
construct a bin,which contains:
ffmepgcolorsapce--...--videosink
constrcut a ghost pad for video out binlink each element
.........and my piple is :int build_pipeline(gchar *location)
{
GstElement *filesrc;
GstElement *a_dec,*a_conv,*audiosink,*a_resample,*a_queue;
GstStateChangeReturn ret;
GstPad *audiopad,*queuesinkpad,*queuesrcpad;
g_print("vesion 20070907\n");
sleep(2); // create a new pipeline to hold the elements
pipeline = gst_pipeline_new ("pipe"); // create file source element
filesrc = gst_element_factory_make ("filesrc", "source");
if (!filesrc )
{
g_print ("source element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (filesrc), "location", location, NULL);
gst_bin_add (GST_BIN (pipeline), filesrc); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);// create ts demux element
ts_demux = gst_element_factory_make ("flutsdemux", "ts_demux");
if (!ts_demux )
{
g_print ("ts_demux element could not be created\n");
return -1;
}
gst_bin_add (GST_BIN (pipeline), ts_demux); gst_element_link (filesrc, ts_demux);
//audio process....
//create a queue bettwen demuxer and decoder, link ts_demux with queue
a_queue = gst_element_factory_make ("queue", "a_queue");
if (!a_queue )
{
g_print ("a_queue element could not be created\n");
return -1;
} gst_bin_add (GST_BIN (pipeline), a_queue);
gst_element_set_state (a_queue, GST_STATE_READY);
queuesinkpad = gst_element_get_pad (a_queue, "sink");
queuesrcpad = gst_element_get_pad (a_queue, "src"); gst_pad_link (gst_element_get_pad (ts_demux, "audio_%02d"), queuesinkpad); //create audio decoder and link queue with a_dec
a_dec = gst_element_factory_make ("flump3dec", "a_dec");
gst_bin_add (GST_BIN (pipeline), a_dec);
gst_pad_link (queuesrcpad,gst_element_get_pad (a_dec, "sink") ); //create audio out bin
audio=gst_bin_new ("audio");
a_conv = gst_element_factory_make ("audioconvert", "a_conv");
a_resample=gst_element_factory_make ("audioresample", "a_resample");
audiosink = gst_element_factory_make ("alsasink", "audiosink");
if ( !a_conv || !a_resample || !audiosink) {
g_print ("One element could not be created\n");
return -1;
}
gst_bin_add_many (GST_BIN (audio), a_conv,a_resample,audiosink,NULL);
gst_element_link_many (a_conv,a_resample,audiosink,NULL);
//create ghost pad
audiopad = gst_element_get_pad (a_conv, "sink");
gst_element_add_pad (audio,gst_ghost_pad_new ("sink", audiopad));
gst_bin_add (GST_BIN (pipeline), audio);
//link a_dec with audio out bin
gst_pad_link (gst_element_get_pad (a_dec, "src"),audiopad );
gst_object_unref (audiopad);
ret = gst_element_set_state (audio, GST_STATE_PLAYING);
if (ret != GST_STATE_CHANGE_SUCCESS)
g_printf("\nset audio out state : change state Expection!\n"); //video process.......
//....
ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
if (ret != GST_STATE_CHANGE_SUCCESS)
g_printf("\nset pipeline bin state : change state Expection!\n");
return 0;
} but when excuting gst_element_set_state to GST_STATE_PLAYING,the final state is GST_STATE_CHANGE_ASYNC....I don't know how to process it?maybe there is some problem with the mianframe of my program ?can anybody help me or give me some related example?Thank you!
Volter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20070912/e3b6ad7c/attachment.htm>
More information about the gstreamer-devel
mailing list