Changing filesrc location in a gst-rtsp-server media session pipeline

This question is about adaptation of gst-rtsp-server (we’re using 1.18.5).

As an overview, I am trying to adapt an Onvif NVT (Network Video Tranmitter aka an IP camera) with edge recording to provide recordings via Onvif Profile G services. In particular working with Milestone that has the ability to record a live stream from an NVT and then fill in missing gaps by searching for and then streaming from edge recordings on the NVT.

I am using the gst-rtsp-server, in particular I have a basic pipeline like the following for the edge recording retrieval:

( filesrc location=“/tmp/rtsp_recording0” name=filesrc0 ! qtdemux name=demux ! queue ! rtph264pay pt=96 name=pay0 demux. ! queue ! rtpmp4gpay pt=97 name=pay1 )

The idea is that the most recent recording is symlinked to /tmp/rtsp_recording0 (actually it does not matter whether it is most recent or older), this pipeline gets pre-rolled to service the RTSP DESCRIBE request, then when the PLAY request comes in with the all important parameter, e.g. Range: clock=20240216T075314.000Z-\r\n, I replace the filesrc0 location that was pre-rolled with the one that provides the requested start time, I also allow the rest of the PLAY command handling with some adjustment to set the play position within that file accordingly.

The bit I am stuck with is how to set the pipeline to NULL/READY to change the location on filesrc0, then change back to its current state. Doing this state change is also useful I would imagine to flush out old recording content from the pipeline. Firstly, I tried both suspend (with GST_RTSP_SUSPEND_MODE_RESET) then unsuspend, also unprepare followed by prepare, but in both cases I get the same error in the second pre-roll as reported by the message handler:

got error Internal data stream error. (…/git/gst/isomp4/qtdemux.c(6749): gst_qtdemux_loop (): /GstPipeline:media-pipeline/GstBin:bin0/GstQTDemux:demux: streaming stopped, reason not-linked (-1))

Any pointers to what is wrong would be most welcome.

I realise this is a bit of a hack and that using an interpipesrc (instead of the filesrc) and changing its listen-to parameter may be the best approach but I’d like to try my current method first.