简体   繁体   English

Gstreamer:为什么我不能在localhost上通过UDP发送数据?

[英]Gstreamer: why can't I send data over UDP on localhost?

I'm trying to test udp streaming on localhost but it's not showing anything: 我正在尝试在localhost上测试udp流,但未显示任何内容:

videotestsrc (or audiotestsrc) -> udpsink (port: 5078, host: 127.0.0.1) videotestsrc(或audiotestsrc)-> udpsink(端口:5078,主机:127.0.0.1)

Here is the code: 这是代码:

console_out_inf("TESTING", "Starting work with test elements");
gint port = 5078;
// TEST PIPELINE OUT
gst_bin_add_many(GST_BIN(GSD->pipetest_out), GSD->testsrc, GSD->udpsink, NULL);
gchar* host = "127.0.0.1";
g_object_set(GSD->udpsink, "port", port, NULL);
g_object_set(GSD->udpsink, "host", host, NULL);
if (!gst_element_link(GSD->testsrc, GSD->udpsink))
    console_out_bad("STREAMING", "Error linking test udp elements -- SEND");
else
    console_out_yes("STREAMING", "Correctly linked test udp elements -- SEND");

// TEST PIPELINE IN
gst_bin_add_many(GST_BIN(GSD->pipetest_in), GSD->udpsrc, GSD->autovideosink, NULL);

gst_element_set_state(GSD->udpsrc, GST_STATE_NULL);
g_object_set(GSD->udpsrc, "port", port, NULL);

if (!gst_element_link(GSD->udpsrc, GSD->autovideosink))
    console_out_bad("STREAMING", "Error linking test udp elements -- RECEIVE");
else
    console_out_yes("STREAMING", "Correctly linked test udp elements -- RECEIVE");
// PLAY TEST PIPELINE OUT
GstStateChangeReturn ret1;
ret1 = gst_element_set_state(GSD->pipetest_out, GST_STATE_PLAYING);
if (ret1 == GST_STATE_CHANGE_FAILURE)
    console_out_bad("TESTING", "Failed playing pipetest out");
else
    console_out_yes("TESTING", "Correctly played pipetest out");

// PLAY TEST PIPELINE IN
GstStateChangeReturn ret2;
ret2 = gst_element_set_state(GSD->pipetest_in, GST_STATE_PLAYING);
if (ret2 == GST_STATE_CHANGE_FAILURE)
    console_out_bad("TESTING", "Failed playing pipetest in");
else
    console_out_yes("TESTING", "Correctly played pipetest in");

// PRINT PIPELINES
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(GSD->pipetest_out), GST_DEBUG_GRAPH_SHOW_ALL, "pipetest_out");
GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(GSD->pipetest_in), GST_DEBUG_GRAPH_SHOW_ALL, "pipetest_in");

This is "my own console output": 这是“我自己的控制台输出”:

EDIT : not relevant anymore! 编辑 :不再相关! Everything is instanciated fine, the pipeline was built correctly, yet with 一切都很好,管道建立正确,但是

PIPELINE OUT : videotestsrc --> udpsink (host:127.0.0.1, port: 5078) PIPELINE OUT :videotestsrc-> udpsink(主机:127.0.0.1,端口:5078)

PIPELINE IN : udpsrc (port: 5078) --> autovideosink 管道输入 :udpsrc(端口:5078)-> autovideosink

The autovideosink does not display anything! autovideosink不显示任何内容! By checking netstat -a, no connection on such port is showed. 通过检查netstat -a,不会显示该端口上的连接。

Additional INFO: 附加信息:

  1. The graph generated with "gstreamer debugging" contains of course only the video/audio testsrc element connected to udpsink. 当然,通过“ gstreamer调试”生成的图形仅包含连接到udpsink的视频/音频testsrc元素。
  2. The first time I run that code, the "Windows Firewall Window" appeared, so I guess something is being sent/received. 我第一次运行该代码时,出现了“ Windows防火墙窗口”,因此我猜正在发送/接收某些信息。
  3. This is inside a Visual Studio 2013/Qt5 Add-In Project, but that should not be an issue 这在Visual Studio 2013 / Qt5外接程序项目中,但这不应该成为问题

Does anyone know what am I doing wrong? 有人知道我在做什么错吗?

This code seems fine but it doesn't relate to the console output you posted. 这段代码看起来不错,但与您发布的控制台输出无关。

Try testing your pipeline piece by piece with the command line gst-launch: 尝试使用命令行gst-launch逐段测试管道:

gst-launch-1.0 -e -v videotestsrc ! udpsink host="127.0.01"

connected to a fakesink first and then swapping in the udp sink, once you have it working in the command line mirror the command in code. 一旦您在命令行中工作了该镜像,便会先连接到一个假接收器,然后在udp接收器中进行交换。

try it with host="localhost" or host="192.168.0.1" i can't remember but i think udpsink might have trouble sending to the loopback 用host =“ localhost”或host =“ 192.168.0.1”尝试一下,我不记得了,但是我认为udpsink可能无法发送到回送

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM