开发者

Realtime changing the ip source into a gstreamer pipeline

I have two ip addresses linked to two cameras. I can stream one ip address. I need to switch from one camera to the other so my source in the pipeline should change from o开发者_StackOverflow中文版ne ip address to another. Is there a way to accomplish that using a gstreamer plugin? Or by command line? Is there an application that can do this? Should I create a custom application?


You should create a custom application.

It's not clear what you do with the stream coming from either camera; let's assume for now you're just displaying it.

Create a bin with a source element for the camera, and a decodebin element for decoding.

When you want to switch, pause the pipeline, renmove source and decodebin, and add two new ones (with the new ip) and set them to paused.

Then set the whole pipeline to playing.

If the camera's are of the same type, you may get away with reusing the one source element (going to NULL or READY first), but it's more than likely you should throw away and recreate the decoder.


Here is the function I list assuming you use gstreamer-java. You may need to modify this for your requirements. In your case you need src_bin_new, src_bin_old instead of dest_bin_new, dest_bin_old. The following function will change but this gives you an idea.

private static void dynamic_bin_replacement(Pipeline pipe, Element src_bin, Element dst_bin_new, Element dst_bin_old) {
    pipe.pause();
    src_bin.unlink(dst_bin_old);                     
    pipe.remove(dst_bin_old);
    pipe.add(dst_bin_new);
    dst_bin_new.syncStateWithParent();
    src_bin.link(dst_bin_new);
    pipe.ready();                    
    pipe.play();
}

Also look at the following post http://gstreamer-devel.966125.n4.nabble.com/Adding-new-tee-src-d-to-a-running-pipeline-td2304488.html (see the last post on that page)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜