简体   繁体   English

如何在简单的TcpServerSrc到TcpServerSink管道中解决失败的gstreamer断言

[英]How to solve failing gstreamer assertions in a simple TcpServerSrc to TcpServerSink pipeline

I currently have a simple pipeline consisting of a tcpserversrc that relays its input a tcpserversink. 我目前有一个简单的管道,该管道由tcpserversrc组成,该管道将其输入中继到tcpserversink。 But this pipeline repeats the following 4 error messages every g_main_loop iteration. 但是,此管道在每次g_main_loop迭代时都会重复以下4条错误消息。

(dmp-server:9726): GStreamer-CRITICAL **: gst_mini_object_ref: assertion 'mini_object != NULL' failed

(dmp-server:9726): GStreamer-CRITICAL **: gst_caps_get_structure: assertion 'GST_IS_CAPS (caps)' failed

(dmp-server:9726): GStreamer-CRITICAL **: gst_structure_has_field: assertion 'structure != NULL' failed

(dmp-server:9726): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed

in the constructor of my object I intialise the Gstreamer elements as follows 在对象的构造函数中,我如下初始化Gstreamer元素

GMainLoop* loop = g_main_loop_new(nullptr, false);
GstElement* pipeline = gst_pipeline_new("tcp_bridge");
GstElement* source = gst_element_factory_make("tcpserversrc", "recv");
GstElement* sink = gst_element_factory_make("tcpserversink", "send");
GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline))
uint16_t recv_port = 2000
uint16_t send_port = 2001

if (!pipeline || !source || !sink)
{
    throw std::runtime_error("Could not create the pipeline components for this radio.");
}

g_object_set(G_OBJECT(source), "port", gint(recv_port), nullptr);
g_object_set(G_OBJECT(sink), "port", gint(send_port), nullptr);

bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, this);

gst_bin_add_many (GST_BIN(pipeline), source, sink, nullptr);
gst_element_link_many(source, sink, nullptr);

In a separate function I call the g_main_loop_run() function 在一个单独的函数中,我调用g_main_loop_run()函数

The errors suggest something about caps, but the documentation does not suggest it is required for the tcpserver sinks and or sources. 该错误提示有关上限的某些内容,但文档并不建议tcpserver接收器和/或源需要它。 2 other pipelines that decode to and encode from mp3 as well as send to and receive from this pipeline both have no caps attached to them and no assertions fail in those pipelines. 从mp3解码和从mp3编码以及从该管道发送和从该管道接收的其他2个管道都没有附加上限,并且在这些管道中没有断言失败。

I also should say that the pipeline operates normally, which does not mean my code isn't erroneous, but I find the CRITICAL assertions a bit awkward if the pipeline still works as intended. 我还应该说管道正常运行,这并不意味着我的代码不是错误的,但是如果管道仍按预期运行,我发现CRITICAL断言有些尴尬。 The main reason I want to get rid of the messages is a possible bug that might come back to bite me and the massive output that clogs up my application log. 我想摆脱这些消息的主要原因是一个可能的错误,可能会再次咬住我,并且大量的输出阻塞了我的应用程序日志。

In this case the tcpServerSink did not know what it was sending and this triggered the assertions. 在这种情况下,tcpServerSink不知道发送的内容,这触发了断言。 So in my case as I was streaming MP3 audio over this pipeline I had to add a mpegaudioparse element to my pipeline. 因此,以我为例,当我通过该管道传输MP3音频时,我必须在管道中添加mpegaudioparse元素。

This ensured that the tcpserversink knew what it was about to send (it set the caps) so that it no longer spawns those assertions. 这样可以确保tcpserversink知道要发送的内容(设置了上限),从而不再产生这些断言。

Some tips when facing the same issues, use the G_DEBUG=fatal_warnings environment variable in conjunction with a debugger to get a stacktrace to identify the component that has failing (critical) assertions. 面对相同问题时的一些技巧,请结合使用G_DEBUG = fatal_warnings环境变量和调试器来获取堆栈跟踪信息,以标识具有失败(关键)断言的组件。

this is a summary and a slight variation to the stackoverflow question found here: gst-launch with tcpserversink not working 这是对此处找到的stackoverflow问题的摘要和细微变化: 使用tcpserversink的gst-launch无法正常工作

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

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