dynamic plugging

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

dynamic plugging

Tonu Jaansoo
Hi!

I have been using this commandline so far  (basically raw audio+video are compressed into file and also into rtspclientsink with different bitrates): 

                "imxv4l2videosrc device=/dev/video0 imx-capture-mode=4 fps-n=30 ! tee name=rawVideo "
                "alsasrc ! audio/x-raw,format=S16LE,rate=48000,channels=1 ! audioconvert ! tee name=rawAudio "
//
                "rawVideo. ! queue ! imxvpuenc_h264 bitrate={streamVideoBitrate} ! video/x-h264,profile=baseline ! h264parse ! queue ! rtspsink. "
                "rawAudio. ! queue ! imxmp3audioenc bitrate={streamAudioBitrate} ! mpegaudioparse ! queue !  rtspsink. "
                "rtspclientsink location=rtsp://{streamIP}:{streamPort}/test profiles=4 name=rtspsink latency=3000 ";
//
                "rawVideo. ! queue ! imxvpuenc_h264 bitrate=5000 ! video/x-h264,profile=baseline ! h264parse ! queue ! mux. "
                "rawAudio. ! queue ! imxmp3audioenc bitrate=160 ! mpegaudioparse ! queue ! mux. "
                "mpegtsmux name=mux ! multifilesink location=/storage/video_{datetime}_%04d.ts next-file=4 max-file-size=10000000 "


Now this commandline has problem. When internet connection fails for a second, rtspclientsink tears down everything - also writing to files. I want that when internet fails, audio+video is still being captured into files. Currently I have different commandline without rtspclientsink branches that I use when there is no internet.

I am trying to rewrite this in C, but so that I intercept rtspclientsink having no connection and dynamically unpluging RTSP branches of the pipeline.

Something like this is correct way to do it?

* wait on bus for error message from rtspclientsink
* when error comes, set all elements from q1 and q3 to rtspclientsink to NULL
* also remove those elements from bin
* wait 10s to retry connection
* dynamically add all elements that were removed 
* set set their status to PLAYING

I have tried something like this. I get no errors, but no luck getting stream going. 
Also, I know there is an example for dynamically pluging things, but that did not help me so much to get my thing running.

Tonu

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

Re: dynamic plugging

Tim Müller
On Wed, 2017-08-23 at 14:08 +0300, Tonu Jaansoo wrote:

Hi Tonu,

> (snip pipeline)
>
> Now this commandline has problem. When internet connection fails for
> a second, rtspclientsink tears down everything - also writing to
> files. I want that when internet fails, audio+video is still being
> captured into files. Currently I have different commandline without
> rtspclientsink branches that I use when there is no internet.
>
> I am trying to rewrite this in C, but so that I intercept
> rtspclientsink having no connection and dynamically unpluging RTSP
> branches of the pipeline.
>
> Something like this is correct way to do it?
>
> * wait on bus for error message from rtspclientsink
> * when error comes, set all elements from q1 and q3 to rtspclientsink
> to NULL
> * also remove those elements from bin
> * wait 10s to retry connection
> * dynamically add all elements that were removed 
> * set set their status to PLAYING
>
> I have tried something like this. I get no errors, but no luck
> getting stream going.

There are two parts to this:

1) catching the error message on the bus in your application, and then
doing something smarter than just stopping the entire pipeline; and

2) making sure that a 'flow error' return from rtspclientsink doesn't
make the upstream elements stop streaming.

There is an 'errorignore' element that can do 2. You'll want one of
those in each branch before the rtspclientsink. When an error happens
you should be able to unlink the sink and stop it, and then restart it
and re-link. The errorignore element will make sure the error flow
return is not propagated to the rest of the pipeline.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com

Join us at the GStreamer Conference!
21-22 October 2017 in Prague, Czech Republic
http://gstreamer.freedesktop.org/conference/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: dynamic plugging

Tonu Jaansoo-3
Hm

By catching error on the bus you mean relinking the pipeline with fakesinks, or do I have to do anything else like acknowledge or drop this message?
Also can I remove all elements from bus callback and relink and set PLAYING states (same thread)?  Bus callback runs in main thread.

When I remove something from bin while playing and without any blocking probes, doesn't this create a situation where pipeline sometimes just crash?

I have attached very ugly hack that

* Creates pipeline where it writes to file and to rtspclientsink. Rtspclientsink connects to the server.
* After startup, i quicly shut down rtsp server
* When rtspclientsink generates error on bus, I replace audio and video branches with fakesinks.. (this works sometimes and rest of the pipeline still writing to file)
* After 30s timeout from startup, from callback I try to replace fakesinks with the pipeline that originally was in place. This has worked once … dont know what I was doing :-D

Tõnu






> On 28 Aug 2017, at 20:50, Tim Müller <[hidden email]> wrote:
>
> On Wed, 2017-08-23 at 14:08 +0300, Tonu Jaansoo wrote:
>
> Hi Tonu,
>
>> (snip pipeline)
>>
>> Now this commandline has problem. When internet connection fails for
>> a second, rtspclientsink tears down everything - also writing to
>> files. I want that when internet fails, audio+video is still being
>> captured into files. Currently I have different commandline without
>> rtspclientsink branches that I use when there is no internet.
>>
>> I am trying to rewrite this in C, but so that I intercept
>> rtspclientsink having no connection and dynamically unpluging RTSP
>> branches of the pipeline.
>>
>> Something like this is correct way to do it?
>>
>> * wait on bus for error message from rtspclientsink
>> * when error comes, set all elements from q1 and q3 to rtspclientsink
>> to NULL
>> * also remove those elements from bin
>> * wait 10s to retry connection
>> * dynamically add all elements that were removed
>> * set set their status to PLAYING
>>
>> I have tried something like this. I get no errors, but no luck
>> getting stream going.
>
> There are two parts to this:
>
> 1) catching the error message on the bus in your application, and then
> doing something smarter than just stopping the entire pipeline; and
>
> 2) making sure that a 'flow error' return from rtspclientsink doesn't
> make the upstream elements stop streaming.
>
> There is an 'errorignore' element that can do 2. You'll want one of
> those in each branch before the rtspclientsink. When an error happens
> you should be able to unlink the sink and stop it, and then restart it
> and re-link. The errorignore element will make sure the error flow
> return is not propagated to the rest of the pipeline.
>
> Cheers
> -Tim
>
> --
> Tim Müller, Centricular Ltd - http://www.centricular.com
>
> Join us at the GStreamer Conference!
> 21-22 October 2017 in Prague, Czech Republic
> http://gstreamer.freedesktop.org/conference/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

gst.cpp (9K) Download Attachment
gst.h (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: dynamic plugging

Tonu Jaansoo-3
I put the cut down example to the github. Please check and tell whats wrong. (No qt actually needed for compiling. just remove all Q-things and itll run). I just use Qt creator alot.
I think if I solve this issue, this should be put to the Application developers manual. As there is no example about “catching” error from element and then synchronizing what comes next.


Tõnu

On 30 Aug 2017, at 10:25, Tonu Jaansoo <[hidden email]> wrote:

Hm

By catching error on the bus you mean relinking the pipeline with fakesinks, or do I have to do anything else like acknowledge or drop this message?
Also can I remove all elements from bus callback and relink and set PLAYING states (same thread)?  Bus callback runs in main thread.

When I remove something from bin while playing and without any blocking probes, doesn't this create a situation where pipeline sometimes just crash?

I have attached very ugly hack that

* Creates pipeline where it writes to file and to rtspclientsink. Rtspclientsink connects to the server.
* After startup, i quicly shut down rtsp server
* When rtspclientsink generates error on bus, I replace audio and video branches with fakesinks.. (this works sometimes and rest of the pipeline still writing to file)
* After 30s timeout from startup, from callback I try to replace fakesinks with the pipeline that originally was in place. This has worked once … dont know what I was doing :-D

Tõnu


<gst.cpp><gst.h>


On 28 Aug 2017, at 20:50, Tim Müller <[hidden email]> wrote:

On Wed, 2017-08-23 at 14:08 +0300, Tonu Jaansoo wrote:

Hi Tonu,

(snip pipeline)

Now this commandline has problem. When internet connection fails for
a second, rtspclientsink tears down everything - also writing to
files. I want that when internet fails, audio+video is still being
captured into files. Currently I have different commandline without
rtspclientsink branches that I use when there is no internet.

I am trying to rewrite this in C, but so that I intercept
rtspclientsink having no connection and dynamically unpluging RTSP
branches of the pipeline.

Something like this is correct way to do it?

* wait on bus for error message from rtspclientsink
* when error comes, set all elements from q1 and q3 to rtspclientsink
to NULL
* also remove those elements from bin
* wait 10s to retry connection
* dynamically add all elements that were removed
* set set their status to PLAYING

I have tried something like this. I get no errors, but no luck
getting stream going.

There are two parts to this:

1) catching the error message on the bus in your application, and then
doing something smarter than just stopping the entire pipeline; and

2) making sure that a 'flow error' return from rtspclientsink doesn't
make the upstream elements stop streaming.

There is an 'errorignore' element that can do 2. You'll want one of
those in each branch before the rtspclientsink. When an error happens
you should be able to unlink the sink and stop it, and then restart it
and re-link. The errorignore element will make sure the error flow
return is not propagated to the rest of the pipeline.

Cheers
-Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com

Join us at the GStreamer Conference!
21-22 October 2017 in Prague, Czech Republic
http://gstreamer.freedesktop.org/conference/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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


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