GStreamer-Java:RTSP-源到UDP-接收器 [英] GStreamer-Java: RTSP-Source to UDP-Sink

查看:448
本文介绍了GStreamer-Java:RTSP-源到UDP-接收器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在一个项目中,以将IP网络摄像头中的RTP流(在以后进行转码)转发给视频通话中的SIP用户.

I'm currently working on a project to forward (and later transcode) a RTP-Stream from a IP-Webcam to a SIP-User in a videocall.

我想出了以下gstreamer管道:

I came up with the following gstreamer pipeline:

  gst-launch -v rtspsrc location="rtsp://user:pw@ip:554/axis-media/media.amp?videocodec=h264" ! rtph264depay ! rtph264pay ! udpsink sync=false host=xxx.xxx.xx.xx port=xxxx

效果很好.现在,我想使用Java创建此管道.这是我创建管道的代码:

It works very fine. Now I want to create this pipeline using java. This is my code for creating the pipe:

    Pipeline pipe = new Pipeline("IPCamStream");

    // Source
    Element source = ElementFactory.make("rtspsrc", "source");
    source.set("location", ipcam);

    //Elements
    Element rtpdepay = ElementFactory.make("rtph264depay", "rtpdepay");
    Element rtppay = ElementFactory.make("rtph264pay", "rtppay");

    //Sink
    Element udpsink = ElementFactory.make("udpsink", "udpsink");
    udpsink.set("sync", "false");
    udpsink.set("host", sinkurl);
    udpsink.set("port", sinkport);


    //Connect
    pipe.addMany(source, rtpdepay, rtppay, udpsink);
    Element.linkMany(source, rtpdepay, rtppay, udpsink);


    return pipe;

当我启动/设置管道时,我可以使用Wireshark看到摄像机的输入,但是不幸的是,没有发送到UDP-Sink的消息.我已经检查了几次代码中的错误,甚至设置了一个从文件(filesrc)流到同一udpsink的流水线,它也可以正常工作.

When I start/set up the pipeline, I'm able to see the input of the camera using wireshark, but unfortunately there is no sending to the UDP-Sink. I have checked the code for mistakes a couple of times, I even set a pipeline for streaming from a file (filesrc) to the same udpsink, and it also works fine.

但是为什么IP-Cam转发"到UDP-Sink不能与此Java-Pipeline一起使用?

But why is the "forwarding" of the IP-Cam to the UDP-Sink not working with this Java-Pipeline?

推荐答案

我没有使用Java版本的GStreamer,但是在链接时需要注意的一点是,有时元素的源极板不会立即可用.

I haven't used the Java version of GStreamer, but something you need to be aware of when linking is that sometimes the source pad of an element is not immediately available.

如果您执行 gst-inspect rtspsrc ,并查看护垫,则会看到以下内容:

If you do gst-inspect rtspsrc, and look at the pads, you'll see this:

Pad Templates: 
  SRC template: 'stream_%u'
    Availability: Sometimes
    Capabilities:
      application/x-rtp
      application/x-rdt

可用性:有时"表示您的初始链接将失败.您想要的源板将仅在到达一定数量的RTP数据包之后出现.

That "Availability: Sometimes" means your initial link will fail. The source pad you want will only appear after some number of RTP packets have arrived.

在这种情况下,您需要等待 pad-事件来手动链接元素,或者我想在C语言中使用 gst_parse_bin_from_description 函数. Java中可能有类似的东西.它会自动为填充事件添加侦听器并链接管道.

For this case you need to either link the elements manually by waiting for the pad-added event, or what I like to do in C is use the gst_parse_bin_from_description function. There is probably something similar in Java. It automatically adds listeners for the pad-added events and links up the pipeline.

gst-launch使用这些相同的parse_bin函数.这就是为什么它总是可以很好地进行链接的原因.

gst-launch uses these same parse_bin functions, I believe. That's why it always links things up fine.

这篇关于GStreamer-Java:RTSP-源到UDP-接收器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆