v4l2src set to PLAYING failure
Frank Du
duyingfang at neusoft.com
Mon Mar 5 19:56:23 PST 2012
Hello,
I have a problem with v4l2src plugin.
It works perfectly: “gst-launch-0.10 �v v4l2src ! ffmpegcolorspace !
xvimagesink”
But the following codes failed to work:
gst_init(NULL, NULL);
pipeline = gst_pipeline_new("dpipeline");
source = gst_element_factory_make("v4l2src", "dsrc");
csp = gst_element_factory_make("ffmpegcolorspace", "dcsp");
sink = gst_element_factory_make("appsink", "dsink");
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
g_object_set(G_OBJECT(source), "device", “/dev/video0”, NULL);
gst_bin_add_many(GST_BIN(pipeline), source, filter, csp, sink,
NULL);
gst_bus_add_watch(bus, G_CALLBACK(bus_callback), pipeline);
gst_object_unref(bus);
gst_element_link(source, csp);
caps = gst_caps_new_simple("video/x-raw-yuv",
"format", GST_TYPE_FOURCC,
GST_MAKE_FOURCC('U','Y','V','Y'),
"width", G_TYPE_INT, 720,
"height", G_TYPE_INT, 480,
NULL);
if (!gst_element_link_filtered(csp, sink, caps))
{
printf("UYVY Format Not Supported.\n");
return NULL;
}
else
{
printf("Image Format Setting Finished.\n");
}
gst_caps_unref(caps);
// state = gst_element_set_state(GST_ELEMENT(sink),
GST_STATE_PLAYING);
// state = gst_element_set_state(GST_ELEMENT(csp), GST_STATE_PLAYING);
// state = gst_element_set_state(GST_ELEMENT(source),
GST_STATE_PLAYING);
state = gst_element_set_state(GST_ELEMENT(pipeline),
GST_STATE_PLAYING);
switch(state)
{
case GST_STATE_CHANGE_SUCCESS:
printf("Init Capture Succeed.\n");
break;
case GST_STATE_CHANGE_FAILURE:
printf("Init Capture Failure.\n");
break;
case GST_STATE_CHANGE_ASYNC:
if(GST_STATE_CHANGE_ASYNC == state)
{
printf("Trying to Sync...\n");
state = gst_element_get_state(csp,
NULL, NULL, GST_CLOCK_TIME_NONE);
}
if (GST_STATE_CHANGE_SUCCESS == state)
{
printf("Sync Succeed.\n");
}
else
{
printf("Init Capture...Failure.\n");
return NULL;
}
break;
case GST_STATE_CHANGE_NO_PREROLL:
printf("Init File Capture Succeed(with no
data).\n");
break;
default:
printf("Init File Capture Error(unknown)\n");
}
In fact, when I enabled these codes respectively
state = gst_element_set_state(GST_ELEMENT(sink),
GST_STATE_PLAYING);
state = gst_element_set_state(GST_ELEMENT(csp),
GST_STATE_PLAYING);
state = gst_element_set_state(GST_ELEMENT(source),
GST_STATE_PLAYING);
// state = gst_element_set_state(GST_ELEMENT(pipeline),
GST_STATE_PLAYING);
I found that the source(v4l2src) could not be set to GST_STATE_PLAYING
(GST_STATE_PAUSED neither) state.
Maybe I should do some additional initialization?
I’ve also used filesrc and it worked well.
Please help me.
Thanks & Best Regards
_____
Frank Du
---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s)
is intended only for the use of the intended recipient and may be confidential and/or privileged of
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is
not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying
is strictly prohibited, and may be unlawful.If you have received this communication in error,please
immediately notify the sender by return e-mail, and delete the original message and all copies from
your system. Thank you.
---------------------------------------------------------------------------------------------------
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/v4l2src-set-to-PLAYING-failure-tp4448692p4448692.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120305/7d857b00/attachment.html>
More information about the gstreamer-devel
mailing list