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

时间:2016-08-08 15:56:07

标签: c++ udp gstreamer

我试图在localhost上测试udp流,但它没有显示任何内容:

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

以下是代码:

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");

这是我自己的控制台输出":

编辑:不再相关了!一切都很好,管道正确构建,但

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

PIPELINE IN :udpsrc(port:5078) - > autovideosink

autovideosink不显示任何内容! 通过检查netstat -a,没有显示此端口上的连接。

其他信息:

  1. 使用" gstreamer调试生成的图表"当然只包含连接到udpsink的视频/音频testsrc元素。
  2. 我第一次运行该代码," Windows防火墙窗口"出现了,所以我想有些东西正在发送/收到。
  3. 这是在Visual Studio 2013 / Qt5加载项项目中,但这应该不是问题
  4. 有谁知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

此代码似乎很好,但它与您发布的控制台输出无关。

尝试使用命令行gst-launch:

逐个测试您的管道
 animations: [
    trigger('flyInOut', [
        state('in', style({transform: 'translateX(0)'})),
        transition('void => in', [
            style({transform: 'translateX(-100%)'}),
            animate(1000)
        ]),
        transition('in => void', [
            animate(1000, style({transform: 'translateX(100%)'}))
        ])
    ])
]

首先连接到fakesink然后在udp接收器中交换,一旦你在命令行中工作就镜像命令中的命令。

尝试使用host =" localhost"或者主持人=" 192.168.0.1"我无法记住,但我认为udpsink可能无法发送到环回