<div class="gmail_quote">On Thu, Jun 18, 2009 at 8:46 AM, Arnout Vandecappelle <span dir="ltr"><<a href="mailto:arnout@mind.be">arnout@mind.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wednesday 17 June 2009 10:29:43 Viraj Karandikar wrote:<br>
> And after every hour you will have to: pause the pipeline, create new<br>
> filesink, disconnect old filesink, connect new filesink and close old<br>
> filesink.<br>
<br>
</div> Actually, no. Pausing the pipeline will not (immediately) stop the threads<br>
in the source and queues. In addition, once it's paused any new data coming<br>
in on the live source will be dropped until it plays again, which probably is<br>
not the intention.<br>
<br>
Instead, you have to use blocking. Below there's a piece of code that I use.<br>
See also docs/design/part-block.txt. There should be high-level API for<br>
that, but nobody has bothered up to now to write it.<br>
<br>
You need to replace the decoder and muxer as well, so the proper headers are<br>
created in the new file. To simplify all that I put it in a bin (which can<br>
be unreffed as a whole).<br>
<div class="im"><br>
> You can do above things in another independent thread which will<br>
> just wait till 1 hour is complete.<br>
<br>
</div> Or you can use g_timeout_add_seconds (3600, ...) in your main loop.<br>
<br>
Regards,<br>
Arnout<br>
<br>
--<br>
<br>
static gboolean destroy_bin_cb (gpointer user_data)<br>
{<br>
GstElement *oldbin = user_data;<br>
<br>
log_message("Destroying old bin.\n");<br>
if (pipeline)<br>
{<br>
gst_element_set_state (oldbin, GST_STATE_NULL);<br>
gst_bin_remove (GST_BIN(pipeline), oldbin);<br>
}<br>
return FALSE;<br>
}<br>
<br>
<br>
static void replace_filesink_blocked_cb (GstPad *pad, gboolean blocked,<br>
gpointer user_data)<br>
{<br>
if (blocked)<br>
{<br>
GstElement *oldbin;<br>
GstPad *sinkpad;<br>
<br>
log_message("Blocked filesink queue.\n");<br>
g_static_rec_mutex_lock(&mutex);<br>
log_message("Locked.\n");<br>
oldbin = filesinkbin;<br>
sinkpad = gst_element_get_static_pad(oldbin, "sink");<br>
if (!sinkpad)<br>
{<br>
log_message("replace_filesink_blocked_cb: oldbin doesn't have sink<br>
pad.\n");<br>
goto fail;<br>
}<br>
gst_pad_unlink(queuesrcpad, sinkpad);<br>
log_message("Unlinked.\n");<br>
<br>
/* Finalize the old tail. */<br>
/* Sending EOS should be done from here (we're in the queue thread).<br>
*/<br>
gst_pad_send_event(sinkpad, gst_event_new_eos());<br>
log_message("Sent event.\n");<br>
<br>
log_message("Checked sinks.\n");<br>
/* Setting state should be done from the main thread. Do it before the<br>
pipeline has been set to PLAYING - implicitly, because that is also<br>
done in an idle callback, but one that is started after this one.<br>
*/<br>
g_idle_add(destroy_bin_cb, oldbin);<br>
<br>
create_filesink_tail();<br>
log_message("Created filesink.\n");<br>
g_static_rec_mutex_unlock(&mutex);<br>
log_message("Unlocked mutex.\n");<br>
<br>
/* And unblock again. */<br>
gst_pad_set_blocked_async(queuesrcpad, FALSE,<br>
replace_filesink_blocked_cb, NULL);<br>
<br>
log_message("Done replacing filesink.\n");<br>
}<br>
else<br>
{<br>
log_message("Unblocked filesink queue.\n");<br>
}<br>
return;<br>
<br>
fail:<br>
pipeline_terminate_async();<br>
g_static_rec_mutex_unlock(&mutex);<br>
}<br>
<br>
static void replace_filesink()<br>
{<br>
if (queuesrcpad == NULL)<br>
log_message("replace_filesink while no queuesrcpad yet, waiting for it<br>
to appear.\n");<br>
else<br>
gst_pad_set_blocked_async(queuesrcpad, TRUE,<br>
replace_filesink_blocked_cb, NULL);<br>
}<br>
<font color="#888888"><br>
</font></blockquote></div><br>Hi, <br>
<br>
thank you a lot for your help. I did it in Python and it seams it
works. Source code is on pastebin: <a href="http://pastebin.com/f3a80ed09(pipelineholder.py">http://pastebin.com/f3a80ed09
(pipelineholder.py</a>) and <a href="http://pastebin.com/f4ee27d6d">http://pastebin.com/f4ee27d6d</a>
(pipelinemanager). Any comments are appreciated.<br>
<br>
Best regards,<br>
Jura<br>