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)