Deepstream5.0 + Jetson NX + add source

I want to reconnect the camera after it is disconnected.
When all video sources are disconnected, the bus will receive Gst.MessageType.EOS message.
According to reference code in,I modify add_source function, delete the video source then adding it.
When executing, the bus receives Gst.MessageType.QOS message. At the same time, the pipeline is in a waiting state.
I think buffer resources are released during EOS.
What should I do?


What do you mean by this change? Can you post the whole code?

def add_sources():
    eos_loc = [i for i, d in enumerate(g_eos_list) if d is True]
    for source_id in range(number_sources):
        if g_eos_list[source_id]:
            if g_source_enabled[source_id]:
                # Delete
                g_source_enabled[source_id] = False
                print('Delete source %d' % source_id)
            # Add
            uri_name = video_sources[source_id]
            source_bin = create_uridecode_bin(source_id, uri_name)
            if not source_bin:
                sys.stderr.write("Failed to create source bin. Exiting.")
            # Add source bin to our list and to pipeline
            g_source_bin_list[source_id] = source_bin
            print('Add source %d' % source_id)
    return True

when all sources are disconnected, bus get Gst.MessageType.EOS.
Re add the source, can not get frame. Because bus get Gst.MessageType.QOS.

One all sources are disconnected, the whole pipeline state should be changed to NULL, and restart from the beginning. You can not add source back before the pipeline restart.

How to restart pipeline without interrupting the program?

When all resources are removed, the pipeline state should be set to NULL. And you need to restart the pipeline from beginning.

def bus_call(bus, message):
    t = message.type
    if t == Gst.MessageType.EOS:

I add pipeline.set_state(Gst.State.NULL) in EOS. Sometimes it can be executed normally, and sometimes it will report an Segment error.

Thank you!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.