Gstreamer:为什么我不能在本地主机上通过UDP发送数据?
Gstreamer: why can't I send data over UDP on localhost?
我试图在本地主机上测试udp流,但它没有显示任何内容:
videotestsrc (or audiotestsrc) -> udpsink (port: 5078, host: 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");
这是"我自己的控制台输出":
EDIT:不相关了!一切都很好地实例化了,管道构建正确,但是
PIPELINE OUT: videotestsrc -> udpsink (host:127.0.0.1, port: 5078)
PIPELINE IN: udpsrc (port: 5078) -> autovideosink
autovideosink不显示任何内容!通过检查netstat -a,该端口上没有显示任何连接。
附加信息:
- 使用"gstreamer debugging"生成的图形当然只包含连接到udpsink的视频/音频testsrc元素。
- 我第一次运行代码,"Windows防火墙窗口"出现了,所以我猜有东西正在发送/接收。
- 这是在Visual Studio 2013/Qt5 Add-In项目中,但这不应该是一个问题
有人知道我做错了什么吗?
这段代码看起来很好,但它与您发布的控制台输出无关。
尝试使用命令行gst-launch:
逐个测试管道gst-launch-1.0 -e -v videotestsrc ! udpsink host="127.0.01"
首先连接到一个伪链接,然后在udp接收器中交换,一旦你让它在命令行中工作,在代码中镜像命令。
尝试host="localhost"或host="192.168.0.1"我不记得了,但我认为udpsink可能在发送到环回时遇到麻烦
相关文章:
- 发送固定大小的 UDP 数据包
- 使用C++将UDP数据包存储在Structure中
- 读取访问冲突. _Mycont 在 C++ 中将 udp 数据放入向量时出现 nullptr 错误
- 如何使用 ZeroMQ 在特定端口上监听和解析 UDP 数据?
- 在高数据包速率下最大限度地减少丢弃的 UDP 数据包 (Windows 10)
- Qt 在可预测的秒数后跳过 UDP 数据包
- 高频接收UDP数据包:丢包?
- 为 posix recv 设置超时会导致 udp 数据包丢失吗?
- 了解 UDP 数据包大小限制的 TCP 数据包大小限制以及它在 boost::asio 编程级别的含义
- 获取进入UDP数据包的目标端口
- 操纵Windows Explorer窗口时,UDP数据包会掉落
- C++ 使用 recvmmsg 丢弃 UDP 数据包
- 如何在QT中接收适当的UDP数据包
- 使用ASIO捕获大量UDP数据包
- 如何正确接收多播UDP数据包
- 套接字:在没有memcpy的情况下,使用recvfrom将UDP数据获取到字对齐的缓冲区
- 服务器未收到UDP数据包,花费数小时试图找出问题所在
- 当接收缓冲区几乎满时,阻止UDP数据包被部分截断
- 如何检查UDP数据包是否在发送器上发送
- 使用 QNX 实时操作系统实时接收 UDP 数据包