From 8b7b65406a79a45cadd195adc10e96b2e27c6367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ant=C3=B4nio=20Cardoso?= Date: Tue, 1 Oct 2024 16:18:14 -0300 Subject: [PATCH] src: lib: stream: sink: rtsp_sink: Better deal with socket file --- src/lib/stream/sink/rtsp_sink.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/stream/sink/rtsp_sink.rs b/src/lib/stream/sink/rtsp_sink.rs index 91843b92..84cac019 100644 --- a/src/lib/stream/sink/rtsp_sink.rs +++ b/src/lib/stream/sink/rtsp_sink.rs @@ -248,7 +248,15 @@ impl RtspSink { "Failed to find RTSP compatible address. Example: \"rtsp://0.0.0.0:8554/test\"", )?; - let socket_path = format!("/tmp/{id}"); + let socket_path = { + let path = std::env::temp_dir().join(format!("{id}.sock")); + + if path.try_exists()? { + std::fs::remove_file(path.clone())?; + } + path.to_string_lossy().to_string() + }; + let sink = gst::ElementFactory::make("shmsink") .property_from_str("socket-path", &socket_path) .property("sync", false)