Addressing Delay Issues in GStreamer Multi-Host Restreaming with multiudpsink

I’m currently utilizing the C++ library of GStreamer version 1.18.4 for a project where I need to restream data to multiple hosts. To achieve this, I’ve constructed a GStreamer pipeline incorporating multiudpsink to consolidate the data and distribute it to various hosts on designated ports. My approach involves adding hosts dynamically using the “add” function provided by multiudpsink.

However, I’ve noticed significant delays in the stream, particularly when one of the hosts in the network becomes unreachable. It seems that GStreamer attempts to reach the unreachable hosts, causing delays in transmitting data to other reachable hosts. To monitor the situation, I’ve been checking stats using the get-stats option every second, and I’ve observed that no new data is sent to my host for, say, 3 seconds during these periods of delay.

Interestingly, when all IPs (hosts) are reachable or when the IP is outside of the network, everything functions as expected with smooth data transmission.

Is there a way to prevent GStreamer from excessively attempting to reach unreachable hosts and prioritize smooth data transmission to other reachable hosts? Any insights or alternative approaches to mitigate this issue would be greatly appreciated.

Here is the overview of my gstreamer pipeline:

    GstreamerData m_data;
    GstElement* m_source;    
    GstElement* m_decoder;    
    GstElement* m_queue;    
    GstElement* m_sink;      
    unsigned short srcPort = 1234

    gst_init(nullptr,nullptr);
    m_data.pipeline = gst_pipeline_new("pipeline");
    m_source = gst_element_factory_make("udpsrc", nullptr);
    g_object_set(m_source, "port", srcPort,
                           "timeout", 5'000'000'000,
                           nullptr);
    std::string capsStr = std::string("application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2TS");
    GstCaps* caps = gst_caps_from_string(capsStr.data());
    g_object_set(m_source, "caps", caps, nullptr);
    if (type == VideoType::MPEG2TS) { m_decoder = gst_element_factory_make("rtpmp2tdepay", nullptr); }
    m_queue = gst_element_factory_make("queue", nullptr);

    m_sink = gst_element_factory_make("multiudpsink", nullptr);

    g_signal_emit_by_name(m_sink, "add", host1, port);
    g_signal_emit_by_name(m_sink, "add", host2, port);
    g_signal_emit_by_name(m_sink, "add", host3, port);
    g_signal_emit_by_name(m_sink, "add", host4, port);

    gst_bin_add_many(GST_BIN (m_data.pipeline), m_source, m_decoder, m_queue, m_sink, nullptr);
    if (!gst_element_link_many(m_source, m_decoder, m_queue, m_sink, nullptr)) {
         gst_object_unref (m_data.pipeline);
    }

    m_data.loop = g_main_loop_new (nullptr, FALSE);

    m_data.bus = gst_element_get_bus(m_data.pipeline);

void run() {
// Change pipeline state to PLAYING and run the main_loop
}