簡體   English   中英

Gstreamer:為什么我不能在localhost上通過UDP發送數據?

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

我正在嘗試在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)

管道輸入 :udpsrc(端口:5078)-> autovideosink

autovideosink不顯示任何內容! 通過檢查netstat -a,不會顯示該端口上的連接。

附加信息:

  1. 當然,通過“ gstreamer調試”生成的圖形僅包含連接到udpsink的視頻/音頻testsrc元素。
  2. 我第一次運行該代碼時,出現了“ Windows防火牆窗口”,因此我猜正在發送/接收某些信息。
  3. 這在Visual Studio 2013 / Qt5外接程序項目中,但這不應該成為問題

有人知道我在做什么錯嗎?

這段代碼看起來不錯,但與您發布的控制台輸出無關。

嘗試使用命令行gst-launch逐段測試管道:

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

一旦您在命令行中工作了該鏡像,便會先連接到一個假接收器,然后在udp接收器中進行交換。

用host =“ localhost”或host =“ 192.168.0.1”嘗試一下,我不記得了,但是我認為udpsink可能無法發送到回送

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM