<DIV>Hi all,<BR> I want to make my simple palyer with gstreamer plugin,<BR>the test script is :<BR>gst-launch-0.10 filesrc location=testmediafile ! *demux name=demux d.! queue !*decoded ! audioconvert!.... d. !queue !*decodec ! ffmpegcolorsapce....<BR>(the way above can work properly)</DIV>
<DIV> I tried to find some example on the subject,but the document on the gstreamer.com do little help with me for this case,<BR>I have tried to do that as the following:</DIV>
<DIV>main piple :<BR> |--a_queue ---*decodec--videooutbin <BR> filesrc--*demuxer-|<BR> |--v_queue ---*decodec--audiooutbin<BR>audio out process :<BR> construct a bin,which contains:<BR> audioconvert--...--audiosink<BR> constrcut a ghost pad for audio out bin<BR>video out process :<BR> construct a bin,which contains:<BR> ffmepgcolorsapce--...--videosink<BR> constrcut a ghost pad for video out bin</DIV>
<DIV>link each element<BR> .........</DIV>
<DIV>and my piple is :</DIV>
<DIV>int build_pipeline(gchar *location)<BR>{<BR> GstElement *filesrc;<BR> GstElement *a_dec,*a_conv,*audiosink,*a_resample,*a_queue;<BR> GstStateChangeReturn ret;<BR> GstPad *audiopad,*queuesinkpad,*queuesrcpad;<BR> <BR> g_print("vesion 20070907\n");<BR> sleep(2);</DIV>
<DIV> // create a new pipeline to hold the elements <BR> pipeline = gst_pipeline_new ("pipe");</DIV>
<DIV> // create file source element<BR> filesrc = gst_element_factory_make ("filesrc", "source");<BR> if (!filesrc )<BR> {<BR> g_print ("source element could not be created\n");<BR> return -1;<BR> }<BR> g_object_set (G_OBJECT (filesrc), "location", location, NULL);<BR> gst_bin_add (GST_BIN (pipeline), filesrc);</DIV>
<DIV> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<BR> gst_bus_add_watch (bus, bus_call, loop);<BR> gst_object_unref (bus);</DIV>
<DIV>// create ts demux element<BR> ts_demux = gst_element_factory_make ("flutsdemux", "ts_demux");<BR> if (!ts_demux )<BR> {<BR> g_print ("ts_demux element could not be created\n");<BR> return -1;<BR> } <BR> gst_bin_add (GST_BIN (pipeline), ts_demux);</DIV>
<DIV> gst_element_link (filesrc, ts_demux);<BR> <BR>//audio process....<BR>//create a queue bettwen demuxer and decoder, link ts_demux with queue<BR> a_queue = gst_element_factory_make ("queue", "a_queue");<BR> if (!a_queue )<BR> {<BR> g_print ("a_queue element could not be created\n");<BR> return -1;<BR> }</DIV>
<DIV> gst_bin_add (GST_BIN (pipeline), a_queue);<BR> gst_element_set_state (a_queue, GST_STATE_READY);<BR> queuesinkpad = gst_element_get_pad (a_queue, "sink");<BR> queuesrcpad = gst_element_get_pad (a_queue, "src");</DIV>
<DIV> gst_pad_link (gst_element_get_pad (ts_demux, "audio_%02d"), queuesinkpad);</DIV>
<DIV> </DIV>
<DIV>//create audio decoder and link queue with a_dec<BR> a_dec = gst_element_factory_make ("flump3dec", "a_dec");<BR> gst_bin_add (GST_BIN (pipeline), a_dec);<BR> gst_pad_link (queuesrcpad,gst_element_get_pad (a_dec, "sink") );</DIV>
<DIV> </DIV>
<DIV>//create audio out bin<BR> audio=gst_bin_new ("audio");<BR> a_conv = gst_element_factory_make ("audioconvert", "a_conv");<BR> a_resample=gst_element_factory_make ("audioresample", "a_resample");<BR> audiosink = gst_element_factory_make ("alsasink", "audiosink");<BR> if ( !a_conv || !a_resample || !audiosink) {<BR> g_print ("One element could not be created\n");<BR> return -1;<BR> }<BR> <BR> gst_bin_add_many (GST_BIN (audio), a_conv,a_resample,audiosink,NULL);<BR> gst_element_link_many (a_conv,a_resample,audiosink,NULL);<BR> <BR> //create ghost pad <BR> audiopad = gst_element_get_pad (a_conv, "sink");<BR> gst_element_add_pad (audio,gst_ghost_pad_new ("sink", audiopad));<BR> gst_bin_add (GST_BIN (pipeline), audio);</DIV>
<DIV><BR> //link a_dec with audio out bin<BR> gst_pad_link (gst_element_get_pad (a_dec, "src"),audiopad );<BR> gst_object_unref (audiopad);<BR> <BR> ret = gst_element_set_state (audio, GST_STATE_PLAYING);<BR> if (ret != GST_STATE_CHANGE_SUCCESS)<BR> g_printf("\nset audio out state : change state Expection!\n");</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>//video process.......<BR>//....<BR> ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);<BR> if (ret != GST_STATE_CHANGE_SUCCESS)<BR> g_printf("\nset pipeline bin state : change state Expection!\n");<BR> <BR> return 0;<BR>}</DIV>
<DIV> </DIV>
<DIV>but when excuting gst_element_set_state to GST_STATE_PLAYING,the final state is GST_STATE_CHANGE_ASYNC....</DIV>
<DIV>I don't know how to process it?</DIV>
<DIV>maybe there is some problem with the mianframe of my program ? </DIV>
<DIV>can anybody help me or give me some related example? </DIV>
<DIV>Thank you!</DIV>
<DIV><BR>Volter<BR></DIV>
<DIV> </DIV><br><!-- footer --><br>
<hr>
<font style="font-size:12px;line-height:15px;">独有“账号保险柜”保护密码,</font><a style="font-size:12px;line-height:15px; color:blue; text-decoration:underline;" href="http://adclient.163.com/event.ng/Type=click&FlightID=94603&AdID=96090&TargetID=1200&Values=31,43,51,60,72,85,91,100,110,312,332,499,587,701,702,733,734&Redirect=http://www.rising.com.cn/2008/trial/index.htm">“瑞星08版”开始免费</a>