How to wait for the pipeline destruction

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

How to wait for the pipeline destruction

elio.francesconi
Hi all,
this is my code to close a pipeline:
        if(pPipeline!=NULL)
        {
            gst_element_set_state(pPipeline, GST_STATE_NULL);
            gst_object_unref(pPipeline);
            pPipeline = NULL;
        }

I noticed the pipeline is closed correctly but I need to wait for the pipeline destruction. Which is the best way to do that?
Thanks
Elio

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

Sebastian Dröge-3
On Fr, 2014-01-03 at 17:35 +0100, Elio Francesconi wrote:

> Hi all,
> this is my code to close a pipeline:
>         if(pPipeline!=NULL)
>         {
>             gst_element_set_state(pPipeline, GST_STATE_NULL);
>             gst_object_unref(pPipeline);
>             pPipeline = NULL;
>         }
>
> I noticed the pipeline is closed correctly but I need to wait for the pipeline destruction. Which is the best way to do that?
Send an EOS event to the pipeline with gst_element_send_event(), wait
for the EOS message to arrive on the bus.

--
Sebastian Dröge, Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (985 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

Andrey Utkin
In reply to this post by elio.francesconi
2014/1/3 Elio Francesconi <[hidden email]>:
> I noticed the pipeline is closed correctly but I need to wait for the
> pipeline destruction. Which is the best way to do that?

Why are you disturbed with it? You get valgrind warnings?

--
Andrey Utkin
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

elio.francesconi
No valgrind warning,
I’m using GStreamer to send/recv audio video rtp streams and sometimes I need to close a pipeline and create a new one.
Before create the new one I need to be sure the previous is closed.

I tried sending the EOS message with this code, but the app hangs because I don’t receive any GST_MESSAGE_EOS messages 
if(pPipeline!=NULL)
        {
            GstMessage *msg;
            GstBus *bus = gst_element_get_bus (pPipeline);

            

            /* shut down pipeline (should send EOS message) ... */
            gst_element_send_event (pPipeline, gst_event_new_eos ());
            /* ... and wait for the EOS message from the sink */
            msg = gst_bus_poll (bus, GST_MESSAGE_EOS| GST_MESSAGE_ERROR, -1);

          

            gst_element_set_state(pPipeline, GST_STATE_NULL);
            gst_object_unref(pPipeline);
            pPipeline = NULL;
        }


On 03 Jan 2014, at 17:51, Andrey Utkin <[hidden email]> wrote:

2014/1/3 Elio Francesconi <[hidden email]>:
I noticed the pipeline is closed correctly but I need to wait for the
pipeline destruction. Which is the best way to do that?

Why are you disturbed with it? You get valgrind warnings?

--
Andrey Utkin
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

Andrey Utkin
2014/1/3 Elio Francesconi <[hidden email]>:
> No valgrind warning,
> I’m using GStreamer to send/recv audio video rtp streams and sometimes I
> need to close a pipeline and create a new one.
> Before create the new one I need to be sure the previous is closed.

So i guess the reason why you want this is because you cannot bind to
port which is still in use?

--
Andrey Utkin
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

elio.francesconi
No, in few words: 
I’ve created a Voip application and I’m using SIP as signalling protocol, the scenario I need to handle is with a Re-INVITE request where the streams are negotiated again, and if I don’t sync the pipelines with my signalling protocol I could receive the new SSRC stream on the previous pipeline. In that case an exception is thrown by GStreamer because the link is already ON.
That’s why I need to be sure the rtp pipelines must be closed.
I tried sending the EOS message with this code, but the app hangs because I don’t receive any GST_MESSAGE_EOS messages 
if(pPipeline!=NULL)
        {
            GstMessage *msg;
            GstBus *bus = gst_element_get_bus (pPipeline);
            
            /* shut down pipeline (should send EOS message) ... */
            gst_element_send_event (pPipelinegst_event_new_eos ());
            /* ... and wait for the EOS message from the sink */
            msg = gst_bus_poll (bus, GST_MESSAGE_EOS| GST_MESSAGE_ERROR, -1);
          
            gst_element_set_state(pPipelineGST_STATE_NULL);
            gst_object_unref(pPipeline);
            pPipeline = NULL;
        }


On 03 Jan 2014, at 18:43, Andrey Utkin <[hidden email]> wrote:

2014/1/3 Elio Francesconi <[hidden email]>:
No valgrind warning,
I’m using GStreamer to send/recv audio video rtp streams and sometimes I
need to close a pipeline and create a new one.
Before create the new one I need to be sure the previous is closed.

So i guess the reason why you want this is because you cannot bind to
port which is still in use?

--
Andrey Utkin
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

Andrey Utkin
2014/1/3 Elio Francesconi <[hidden email]>:

> No, in few words:
> I’ve created a Voip application and I’m using SIP as signalling protocol,
> the scenario I need to handle is with a Re-INVITE request where the streams
> are negotiated again, and if I don’t sync the pipelines with my signalling
> protocol I could receive the new SSRC stream on the previous pipeline. In
> that case an exception is thrown by GStreamer because the link is already
> ON.
> That’s why I need to be sure the rtp pipelines must be closed.
> I tried sending the EOS message with this code, but the app hangs because I
> don’t receive any GST_MESSAGE_EOS messages

Quite complex. In my non-qualified opinion, EOS message requires quite
a bit of efforts, and does not guarantee RTP sockets closing, which
still can happen asynchronously (at last i don't know without looking
in RTP element code).
I'd suggest you to check manually that the ports you need got free, by
trying to bind on them manually.

--
Andrey Utkin
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

Andrey Utkin
In reply to this post by elio.francesconi
I think in your case there's either a GStreamer bug or your misconception.
In GST_STATE_NULL, all elements must have all resources (including
sockets) released.
gst_element_set_state() is guaranteed to NOT finish asynchronously, in
case of setting to GST_STATE_NULL.

To locate the situation, you could make up a test app which sets your
pipeline to NULL state, then immediately trying to bind to the port
you have just used. If you fail to bind to it, it means the port is
still not released, which is a violation of GStreamer API guarantee.


--
Andrey Utkin
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

SoureCode
In reply to this post by elio.francesconi
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

elio.francesconi
Thanks guys.
I did more tests and added more logs and the pipeline is closed correctly.

Ciao
Elio
On 04 Jan 2014, at 07:19, RajuB <[hidden email]> wrote:

> Could you send the pipeline you are using for this??
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-wait-for-the-pipeline-destruction-tp4664440p4664461.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

Sven Heyll
On 04.01.2014 14:46, Elio Francesconi wrote:

> Thanks guys.
> I did more tests and added more logs and the pipeline is closed correctly.
>
> Ciao
> Elio
> On 04 Jan 2014, at 07:19, RajuB <[hidden email]> wrote:
>
>> Could you send the pipeline you are using for this??
>>
>>
>>
>> --
>> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-wait-for-the-pipeline-destruction-tp4664440p4664461.html
>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email]
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Sorry, but this is not nice. You ask for help, people try to help you,
then find a solution by yourself but don't tell us the solution.

Please I am interested in this, what was the problem, how did you fix it?

wbr Sven

--
Sven Heyll, Karlsruhe, Germany

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to wait for the pipeline destruction

elio.francesconi
As Andrey said, my scenario is quite complex and it’s hard for me send you my pipeline but I tried to explain it better than I could.
I solved my  issue after Andrey’s reply when he pointed me in the right way :-)
I noticed the opening of a new socket was made in the right way so my problem was not due to the closure of the pipeline but in the new one pipeline.
So after the RE-INVITE message I open a new pipeline to handle the new stream but in some cases I still continue receiving the previous SSRC stream (due to the far endpoint), that causes a failure in the pipeline due to multiple SSRC received.
To solve my issue I negotiated a different rtp port so that no old SSRC stream is received by my pipeline, that’s all.
Thanks for your help and thanks for your clarification about how close  pipeline in a gracefully way.
Ciao
Elio
 
On 05 Jan 2014, at 01:18, Sven Heyll <[hidden email]> wrote:

> On 04.01.2014 14:46, Elio Francesconi wrote:
>> Thanks guys.
>> I did more tests and added more logs and the pipeline is closed correctly.
>>
>> Ciao
>> Elio
>> On 04 Jan 2014, at 07:19, RajuB <[hidden email]> wrote:
>>
>>> Could you send the pipeline you are using for this??
>>>
>>>
>>>
>>> --
>>> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-wait-for-the-pipeline-destruction-tp4664440p4664461.html
>>> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>>> _______________________________________________
>>> gstreamer-devel mailing list
>>> [hidden email]
>>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>> _______________________________________________
>> gstreamer-devel mailing list
>> [hidden email]
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> Sorry, but this is not nice. You ask for help, people try to help you,
> then find a solution by yourself but don't tell us the solution.
>
> Please I am interested in this, what was the problem, how did you fix it?
>
> wbr Sven
>
> --
> Sven Heyll, Karlsruhe, Germany
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel