After much trial and error I managed to restart pipeline.
My solution is to set pipeline to NULL and then create a new one. That way I can continue to use Gst-nvurisrcbin element.
def main():
create_pipeline()
loop = GLib.MainLoop()
loop.run()
def restart_pipeline(pipeline):
pipeline.set_state(Gst.State.NULL)
time.sleep(2)
logger.error("Recreate pipeline")
create_pipeline()
def create_pipeline():
'''
add all elements here
and set pipeline to PLAYING state
'''