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 deepstream_rt_src_add_del.py,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?

Thanks!

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
                stop_release_source(source_id)
                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.")
                exit(1)
            # Add source bin to our list and to pipeline
            g_source_bin_list[source_id] = source_bin
            g_source_bin_list[source_id].set_state(Gst.State.PAUSED)
            pipeline.add(source_bin)
            print('Add source %d' % source_id)
    pipeline.set_state(Gst.State.PLAYING)
    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?
Thanks!

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:
        sys.stdout.write("End-of-stream\n")
        pipeline.set_state(Gst.State.NULL)

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.