有任何方法来检查rtp流来自源超过udp?



我已经实现了通过UDP从摄像机源获取视频流的代码。我需要检查发送数据的源(摄像机)是否还活着。是否有任何方法来检查使用Gstreamer或其他方式,这是相关的套接字编程?

在Gstreamer中,有几个有用的侦听器用于检查管道状态。其中之一是流结束通知,但它不能检查udp源管道状态。

从医生:

流结束通知:当流有结束了。管道的状态不会改变,但进一步媒体处理将会停滞。应用程序可以使用它跳到下一个歌曲在他们的播放列表中。在流结束后,也可以在小溪中寻找。然后播放将自动继续。此消息没有特定参数

Pipeline pipeline = new Pipeline("monitoring-pipe");
pipeline.getBus().connect((Bus.ERROR) this);
pipeline.getBus().connect((Bus.WARNING) this);
pipeline.getBus().connect((Bus.STATE_CHANGED) this);
pipeline.getBus().connect((Bus.EOS) this);
Element udpsrc = ElementFactory.make("udpsrc", "udpsrc");
udpsrc.set("port", monitoringPort);
vc.getElement().set("sync", false);
udpsrc.setCaps(Caps
.fromString("application/x-rtp, media=(string)video, encoding-name=(string)H264, payload=(int)101"));
Bin bin = Gst.parseBinFromDescription(
"rtph264depay ! video/x-h264, stream-format=byte-stream, profile=high ! h264parse ! queue ! avdec_h264 ! queue2 ! videoconvert",
true);
pipeline.addMany(udpsrc, bin, vc.getElement());
Element.linkMany(udpsrc, bin, vc.getElement());
pipeline.play();
pipeline.setState(State.PLAYING);

提前感谢。

看门狗元素监视流经a的缓冲区和事件管道。如果在一段可配置的时间内没有看到缓冲区,则向总线发送错误消息。

要使用此元素,请将其插入到管道中身份的元素。一旦激活,缓冲区流中的任何暂停通过元素会导致元素错误。允许的最大值暂停由timeout属性决定。

该元素目前用于转码管道可能在其他上下文中有用。

watchdog元素可以用来检测流上的错误。Bus.MESSAGE监听器捕获如果服务器端流死亡或关闭。不幸的是,它只在流关闭时触发。当流再次启动时,它不会被触发,但仍然可以使用它进行一些更改(在其中触发另一个侦听器)

这里是代码有一些变化:

Bin bin = Gst.parseBinFromDescription(
"watchdog ! rtph264depay ! video/x-h264, stream-format=byte-stream, 
profile=high ! h264parse ! queue ! avdec_h264 ! queue2 ! videoconvert",
true);

pipeline.getBus().connect((Bus.MESSAGE) this);

@Override
public void busMessage(Bus bus, Message message) {
if (message.getType().equals(MessageType.ERROR)) {
//here you can get when stream has stopped 
//and trigger another listener like 
//state change listener to check or establish connection
pipeline.setState(State.PAUSED);
pipeline.setState(State.PLAYING);
}
}

最新更新