I have implemented a ROS2 node where I am using a GStreamer pipeline that takes video data from the ROS2 node and writes it a file using filesink. I think in your case you can replace the filesink and use an rtspclientsink.
Please find the link to the implementation here: https://github.com/Modular-Autonomous-Robotics-Systems/neurorobotics-toolkit/blob/master/src/sensors/src/video/logger.cpp