This commit is contained in:
cxh 2026-01-22 13:37:25 +08:00
parent e05487deef
commit b3ff821ef4

View File

@ -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* 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"); GstElement* record_valve = gst_bin_get_by_name(GST_BIN(pipeline), "record_valve");
// ===== 对 sink 做“可选属性”配置 ===== // ===== 获取 rec_sink / live_sink =====
// 某些版本 rtmpsink 有 protocol有些没有 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(rec_sink, "protocol", 0);
try_set_property(live_sink, "protocol", 0); try_set_property(live_sink, "protocol", 0);
// ===== 清理引用 ===== // ===== 引用使用完就释放(不交给 ctx 管理)=====
if (rec_sink) gst_object_unref(rec_sink); if (rec_sink) gst_object_unref(rec_sink);
if (live_sink) gst_object_unref(live_sink); if (live_sink) gst_object_unref(live_sink);
if (!live_valve || !record_valve) if (!live_valve || !record_valve)