<meta http-equiv=Content-Type content="text/html; charset=gb2312"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Hello,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>I have a problem with v4l2src plugin.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>It works perfectly: “gst-launch-0.10 �v v4l2src ! ffmpegcolorspace ! xvimagesink”<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>But the following codes failed to work:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:36.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>gst_init(NULL, NULL);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> pipeline = gst_pipeline_new("dpipeline");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> source = gst_element_factory_make("v4l2src", "dsrc");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> csp = gst_element_factory_make("ffmpegcolorspace", "dcsp");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> sink = gst_element_factory_make("appsink", "dsink");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> g_object_set(G_OBJECT(source), "device", “/dev/video0”, NULL);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> gst_bin_add_many(GST_BIN(pipeline), source, filter, csp, sink, NULL);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> gst_bus_add_watch(bus, G_CALLBACK(bus_callback), pipeline);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> gst_object_unref(bus);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> gst_element_link(source, csp);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='text-indent:36.0pt;text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>caps = gst_caps_new_simple("video/x-raw-yuv",<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC('U','Y','V','Y'),<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> "width", G_TYPE_INT, 720,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> "height", G_TYPE_INT, 480,<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> NULL);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> if (!gst_element_link_filtered(csp, sink, caps))<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("UYVY Format Not Supported.\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> return NULL;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> else<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Image Format Setting Finished.\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> gst_caps_unref(caps);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>// state = gst_element_set_state(GST_ELEMENT(sink), GST_STATE_PLAYING);</span> <span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>// state = gst_element_set_state(GST_ELEMENT(csp), GST_STATE_PLAYING);</span> <span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>// state = gst_element_set_state(GST_ELEMENT(source), GST_STATE_PLAYING);</span> <span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> state = gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> switch(state)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> case GST_STATE_CHANGE_SUCCESS:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Init Capture Succeed.\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> break;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> case GST_STATE_CHANGE_FAILURE:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Init Capture Failure.\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> break;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> case GST_STATE_CHANGE_ASYNC:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> if(GST_STATE_CHANGE_ASYNC == state) <o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Trying to Sync...\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> state = gst_element_get_state(csp, NULL, NULL, GST_CLOCK_TIME_NONE);<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> if (GST_STATE_CHANGE_SUCCESS == state)<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Sync Succeed.\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> else<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> {<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Init Capture...Failure.\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> return NULL;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> }<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> break;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> case GST_STATE_CHANGE_NO_PREROLL:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Init File Capture Succeed(with no data).\n");<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> break;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> default:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> printf("Init File Capture Error(unknown)\n");<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> }<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>In fact, when I enabled these codes respectively<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> state = gst_element_set_state(GST_ELEMENT(sink), GST_STATE_PLAYING); <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> state = gst_element_set_state(GST_ELEMENT(csp), GST_STATE_PLAYING); <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'> state = gst_element_set_state(GST_ELEMENT(source), GST_STATE_PLAYING); <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>// state = gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>I found that the source(v4l2src) could not be set to GST_STATE_PLAYING (GST_STATE_PAUSED neither) state.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Maybe I should do some additional initialization?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>I’ve also used filesrc and it worked well.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>Please help me.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Comic Sans MS"'>Thanks & </span><span style='font-size:9.0pt;font-family:"Comic Sans MS"'>Best Regards </span><span style='font-size:9.0pt;font-family:"Verdana","sans-serif"'><o:p></o:p></span></p><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div class=MsoNormal><span style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:black'></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div><p class=MsoNormal><span style='font-size:9.0pt;font-family:"Verdana","sans-serif";color:black'>Frank Du</span><span style='font-family:"Verdana","sans-serif";color:#BFBFBF'><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div><br />---------------------------------------------------------------------------------------------------
<br/>Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s)
<br/>is intended only for the use of the intended recipient and may be confidential and/or privileged of
<br/>Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is
<br/>not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying
<br/>is strictly prohibited, and may be unlawful.If you have received this communication in error,please
<br/>immediately notify the sender by return e-mail, and delete the original message and all copies from
<br/>your system. Thank you.
<br/>---------------------------------------------------------------------------------------------------
<br/>
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/v4l2src-set-to-PLAYING-failure-tp4448692p4448692.html">v4l2src set to PLAYING failure</a><br/>
Sent from the <a href="http://gstreamer-devel.966125.n4.nabble.com/">GStreamer-devel mailing list archive</a> at Nabble.com.<br/>