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

StackOverflow https://stackoverflow.com/questions/22743772

  •  24-06-2023
  •  | 
  •  

Question

I currently have a simple pipeline consisting of a tcpserversrc that relays its input a tcpserversink. But this pipeline repeats the following 4 error messages every g_main_loop iteration.

(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

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

The errors suggest something about caps, but the documentation does not suggest it is required for the tcpserver sinks and or sources. 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.

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. 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.

Was it helpful?

Solution

In this case the tcpServerSink did not know what it was sending and this triggered the assertions. So in my case as I was streaming MP3 audio over this pipeline I had to add a mpegaudioparse element to my pipeline.

This ensured that the tcpserversink knew what it was about to send (it set the caps) so that it no longer spawns those assertions.

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.

this is a summary and a slight variation to the stackoverflow question found here: gst-launch with tcpserversink not working

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top