From f0d8a7b18b54aa785bb79f002035d597b8d4ff18 Mon Sep 17 00:00:00 2001 From: Barzan Hayati Date: Tue, 1 Jul 2025 17:18:28 +0000 Subject: [PATCH] Fix rtsp sink bug --- data/configuration.json | 2 +- src/sink_manager.cpp | 9 +++++---- src/sink_manager.hpp | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/data/configuration.json b/data/configuration.json index 8d40e62..d8a23fb 100644 --- a/data/configuration.json +++ b/data/configuration.json @@ -2,7 +2,7 @@ "MUXER_OUTPUT_HEIGHT": 1080, "MUXER_OUTPUT_WIDTH": 1920, "output_video_path": "test.mkv", - "display_output": 2, + "display_output": 3, "codec_rtsp_out": "H264", "mount_address": "/rtsp-output", "udp_buffer_size": 524288, diff --git a/src/sink_manager.cpp b/src/sink_manager.cpp index 1a081e7..fb834c1 100644 --- a/src/sink_manager.cpp +++ b/src/sink_manager.cpp @@ -12,6 +12,7 @@ SinkManager::SinkManager() { i >> j; j.at("output_video_path").get_to(output_video_path); j.at("display_output").get_to(display_output); + j.at("codec_rtsp_out").get_to(codec_rtsp_out); } bool SinkManager::create_sink(cudaDeviceProp prop) { @@ -54,10 +55,10 @@ bool SinkManager::create_sink(cudaDeviceProp prop) { } // Make the encoder - if (!strcmp(codec.c_str(), "H264")) { + if (!strcmp(codec_rtsp_out.c_str(), "H264")) { encoder = gst_element_factory_make("nvv4l2h264enc", "encoder"); g_printerr("Creating H264 Encoder.\n"); - } else if (!strcmp(codec.c_str(), "H265")) { + } else if (!strcmp(codec_rtsp_out.c_str(), "H265")) { encoder = gst_element_factory_make("nvv4l2h265enc", "encoder"); g_printerr("Creating H265 Encoder.\n"); } else { @@ -73,10 +74,10 @@ bool SinkManager::create_sink(cudaDeviceProp prop) { } // Make the payload-encode video into RTP packets - if (!strcmp(codec.c_str(), "H264")) { + if (!strcmp(codec_rtsp_out.c_str(), "H264")) { rtppay = gst_element_factory_make("rtph264pay", "rtppay"); g_printerr("Creating H264 rtppay.\n"); - } else if (!strcmp(codec.c_str(), "H265")) { + } else if (!strcmp(codec_rtsp_out.c_str(), "H265")) { rtppay = gst_element_factory_make("rtph265pay", "rtppay"); g_printerr("Creating H265 rtppay.\n"); } diff --git a/src/sink_manager.hpp b/src/sink_manager.hpp index 3c5d581..c8981d7 100644 --- a/src/sink_manager.hpp +++ b/src/sink_manager.hpp @@ -9,10 +9,12 @@ class SinkManager { private: + std::string codec_rtsp_out; + public: GstElement *sink = NULL, *nvvidconv_postosd = NULL, *caps = NULL, *encoder = NULL, *rtppay = NULL; - std::string codec, host, output_sink, output_video_path; + std::string host, output_sink, output_video_path; int display_output = 1, bitrate; guint updsink_port_num; SinkManager();