I want to suggest you something. Instead of creating elements at the time of taking screenshot , why don't you create them already, add into bin and then link them later when you want to take screen shot. And obviously by this approach you save some time in taking screenshot. <div>
<br></div><div> And try to use bin for set of elements, for example screenshot_bin having related elements and so on. This makes your code easy to read and debug.</div><div><br></div><div><br><div><br><br><div class="gmail_quote">
On Mon, Jan 3, 2011 at 9:57 AM, lithium <span dir="ltr"><<a href="mailto:cmaster2@hotmail.com">cmaster2@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I've been writing a tv capture program. Basically by the end of it i'm hoping<br>
to have the gstreamer stuff setup somewhat like this:<br>
<br>
/*<br>
/----queue----xvimagesink //screenoutput<br>
v4l2src---------tee-----<br>
\----queue----filesink //screenshot<br>
\----queue----\<br>
----multiplexer ---filesink //recording<br>
/----queue----/<br>
alsasrc----------tee-----<br>
\----queue----alsasink //playback from capture if needed<br>
*/<br>
<br>
At the moment i've implemented the top video branch and am now working on<br>
the screenshot one.<br>
I've been using a combination of gtk and gstreamer to write the program.<br>
<br>
When the program starts I call the 'openVideoPipeline' function (see below)<br>
and on clicking the screenshot button in my gtk window it runs the<br>
'take_screenshot' function. The problem I am having is that when I press the<br>
screenshot button it causes the screen output to freeze. The file is not<br>
created by the filesink. I have found that when i click my button that<br>
causes the tv card options menu to be created and drawn it causes the screen<br>
output to resume playing and the file to be written. The only functions used<br>
from gstreamer in the tv card menu are 'gst_tuner_list_channels',<br>
'gst_tuner_list_norms', and 'gst_tuner_get_norm'. It is very likely I am<br>
going about taking screenshots the wrong way, if someone has a better idea<br>
please suggest it. Otherwise it would be good if someone has any idea whats<br>
causing the video to freeze.<br>
<br>
I have tried setting the pipeline to playing again after unlinking the<br>
screenshot pads but it didn't change anything.<br>
<br>
int openVideoPipeline(videoIOStruct *videoIO)<br>
{<br>
//create elements<br>
videoIO->pipeline = gst_pipeline_new("tvVideo");<br>
videoIO->vidSrc = gst_element_factory_make("v4l2src", "source");<br>
GstElement *vidSink = gst_element_factory_make("xvimagesink", "sink");<br>
videoIO->tee = gst_element_factory_make("tee", "splitter");<br>
GstElement *vidQueue = gst_element_factory_make("queue", NULL);<br>
<br>
if (!videoIO->pipeline || !videoIO->vidSrc || !vidSink || !videoIO->tee ||<br>
!vidQueue)<br>
return 0;<br>
<br>
//set arguments<br>
g_object_set(videoIO->vidSrc, "device", videoIO->devName, NULL);<br>
<br>
gst_bin_add_many(GST_BIN(videoIO->pipeline), videoIO->vidSrc, videoIO->tee,<br>
vidQueue, vidSink, NULL);<br>
<br>
videoIO->videoScreenPad = gst_element_get_request_pad(videoIO->tee,<br>
"src%d");<br>
GstPad *staticOutputPad = gst_element_get_static_pad(vidQueue, "sink");<br>
<br>
//link stuff<br>
gst_pad_link(videoIO->videoScreenPad, staticOutputPad);<br>
<br>
gst_object_unref(GST_OBJECT(videoIO->videoScreenPad));<br>
<br>
gst_element_link(videoIO->vidSrc, videoIO->tee);<br>
<br>
gst_element_link(vidQueue, vidSink);<br>
<br>
if (!videoIO->pipeline)<br>
return 0;<br>
<br>
return 1;<br>
}<br>
<br>
void close_screenshot(GstElement *jpegEncode, videoIOStruct *videoIO)<br>
{<br>
GstPad *pad1 = GST_PAD(g_object_get_data(G_OBJECT(jpegEncode),<br>
"videoScreenshotPad"));<br>
GstPad *pad2 = GST_PAD(g_object_get_data(G_OBJECT(jpegEncode),<br>
"staticOutputPad"));<br>
gst_pad_unlink(pad1, pad2);<br>
}<br>
<br>
void take_screenshot(GtkWidget *widget, videoIOStruct *videoIO)<br>
{<br>
GstElement *jpegOutput = gst_element_factory_make("filesink",<br>
"jpegoutput");<br>
GstElement *jpegQueue = gst_element_factory_make("queue", "jpgqueue");<br>
GstElement *jpegEncode = gst_element_factory_make("jpegenc",<br>
"jpegencoder");<br>
<br>
if (!jpegOutput || !jpegQueue || !jpegEncode || !videoIO->jpegPipeline)<br>
return;<br>
<br>
//set arguments<br>
g_object_set(jpegOutput, "location", "test.jpg", NULL);<br>
<br>
//link stuff<br>
gst_bin_add_many(GST_BIN(videoIO->pipeline), jpegEncode, jpegQueue,<br>
jpegOutput, NULL);<br>
<br>
gst_element_link_many(jpegQueue, jpegEncode, jpegOutput, NULL);<br>
<br>
//gst_element_set_state(videoIO->jpegPipeline, GST_STATE_PLAYING);<br>
<br>
g_signal_connect(jpegEncode, "frame-encoded", G_CALLBACK(close_screenshot),<br>
videoIO);<br>
<br>
GstPad *videoScreenshotPad = gst_element_get_request_pad(videoIO->tee,<br>
"src%d");<br>
GstPad *staticOutputPad = gst_element_get_static_pad(jpegQueue, "sink");<br>
g_object_set_data(G_OBJECT(jpegEncode), "videoScreenshotPad",<br>
videoScreenshotPad);<br>
g_object_set_data(G_OBJECT(jpegEncode), "staticOutputPad",<br>
staticOutputPad);<br>
<br>
gst_pad_link(videoScreenshotPad, staticOutputPad);<br>
}<br>
<br>
--<br>
View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/Video-freeze-tp3171570p3171570.html" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/Video-freeze-tp3171570p3171570.html</a><br>
Sent from the GStreamer-devel mailing list archive at Nabble.com.<br>
<br>
------------------------------------------------------------------------------<br>
Learn how Oracle Real Application Clusters (RAC) One Node allows customers<br>
to consolidate database storage, standardize their database environment, and,<br>
should the need arise, upgrade to a full multi-node Oracle RAC database<br>
without downtime or disruption<br>
<a href="http://p.sf.net/sfu/oracle-sfdevnl" target="_blank">http://p.sf.net/sfu/oracle-sfdevnl</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Regards,<br><br>Sudarshan Bisht<br>
</div></div>