Adding source to demux in runtime

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU NVIDIA RTX A4000
• DeepStream Version 6.3
• NVIDIA GPU Driver Version (valid for GPU only) 535.161.07
• Issue Type( questions, new requirements, bugs) questions
• How to reproduce the issue ? I have attached a test code to reproduce this issue
• Language Python3

This is an extension of How to add elements after demux during runtime?. After some experiments, I realised I have to change the state of demux to ‘NULL’ before requesting for a new pad during runtime.

It worked fine, but when I added many sources (30+ during runtime), the streams stopped flowing through streammux.

    def create_fakesource_bin(self, ID):
        # Create a source GstBin to abstract this bin's content from the rest of the
        bin_name = f"fakebin-{ID}"
        nbin = Gst.Bin.new(bin_name)
        print(f"creating fake source bin for {ID} bin name {bin_name}")

        bin = self.make_element("videotestsrc", f"fakesrc-{ID}")
        bin.set_property("is_live", True)
        bin.set_property("pattern", 0)
        Gst.Bin.add(nbin, bin)

        converter = self.make_element('nvvideoconvert', f'convert-{ID}')
        Gst.Bin.add(nbin, converter)

        bin.link(converter)

        converter_srcpad = converter.get_static_pad("src")
        if not converter_srcpad:
            print("Unable to create queue sink pad")
        #
        bin_pad = nbin.add_pad(Gst.GhostPad("src", converter_srcpad))
        if not bin_pad:
            print("sink bin Failed to add ghost pad in source bin ")
            return None
        return nbin

    def create_sink_bin(self, index):
        bin_name = f"sink-{index}"
        print(f"creating downstream elements  for {index} with  bin name {bin_name}")

        sinkbin = Gst.Bin.new(bin_name)

        sink = self.make_element("appsink", f"sink-{index}")
        sink.set_property("emit-signals", True)
        sink.set_property("max-buffers", 2)
        sink.set_property("drop", True)
        sink.set_property("sync", False)
        sink.connect("new-sample", self.outbound_func, index)
        Gst.Bin.add(sinkbin, sink)

        queue = self.make_element("queue", f"queue-{index}")
        queue.set_property("leaky", 2)
        queue.set_property("max-size-buffers", 1)
        queue.set_property("flush-on-eos", True)
        Gst.Bin.add(sinkbin, queue)

        nvvidconv = self.make_element("nvvideoconvert", f"convertor-{index}")
        nvvidconv.set_property("gpu_id", self.gpu_id)
        sinkbin.add(nvvidconv)
        #
        encoder = self.make_element("nvjpegenc", f"encoder-{index}")
        sinkbin.add(encoder)

        queue.link(nvvidconv)
        nvvidconv.link(encoder)
        encoder.link(sink)

        queuesinkpad = queue.get_static_pad("sink")
        if not queuesinkpad:
            sys.stderr.write("Unable to create queue sink pad \n")

        bin_pad = sinkbin.add_pad(Gst.GhostPad("sink", queuesinkpad))
        if not bin_pad:
            sys.stderr.write("sink bin Failed to add ghost pad in source bin \n")
            return None
        return sinkbin

attaching a test code to add 50 fake sources one at a time during runtime
deepstream_test_v2.0.txt (12.4 KB)

let me try to reproduce it.