From b3ff821ef421b972ad11a835af2fcc2434e01167 Mon Sep 17 00:00:00 2001 From: cxh Date: Thu, 22 Jan 2026 13:37:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rtmp_manager.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rtmp_manager.cpp b/src/rtmp_manager.cpp index 5758015..6a8fc02 100644 --- a/src/rtmp_manager.cpp +++ b/src/rtmp_manager.cpp @@ -193,14 +193,16 @@ void RTMPManager::stream_loop(Camera cam, StreamContext* ctx) GstElement* live_valve = gst_bin_get_by_name(GST_BIN(pipeline), "live_valve"); GstElement* record_valve = gst_bin_get_by_name(GST_BIN(pipeline), "record_valve"); - // ===== 对 sink 做“可选属性”配置 ===== - // 某些版本 rtmpsink 有 protocol,有些没有 + // ===== 获取 rec_sink / live_sink ===== + GstElement* rec_sink = gst_bin_get_by_name(GST_BIN(pipeline), "rec_sink"); + GstElement* live_sink = gst_bin_get_by_name(GST_BIN(pipeline), "live_sink"); + + // ===== 尝试设置 protocol=0(兼容:有就设,无就跳过)===== try_set_property(rec_sink, "protocol", 0); try_set_property(live_sink, "protocol", 0); - // ===== 清理引用 ===== + // ===== 引用使用完就释放(不交给 ctx 管理)===== if (rec_sink) gst_object_unref(rec_sink); - if (live_sink) gst_object_unref(live_sink); if (!live_valve || !record_valve)