diff --git a/plugins/publish/publish_node.cpp b/plugins/publish/publish_node.cpp index d88a754..b5a39e2 100644 --- a/plugins/publish/publish_node.cpp +++ b/plugins/publish/publish_node.cpp @@ -37,6 +37,7 @@ inline int Align16(int v) { return (v + 15) & ~15; } struct OutputConfig { std::string proto = "rtsp"; // rtsp | hls + std::string host = "127.0.0.1"; // rtsp server host to publish to int port = 8554; std::string path = "/live/stream"; // rtsp: url path; hls: dir or m3u8 path int segment_sec = 2; @@ -252,9 +253,10 @@ private: std::string BuildUrl(const OutputConfig& cfg) const { if (proto_ == "hls") return cfg.path; + std::string host = cfg.host.empty() ? "127.0.0.1" : cfg.host; std::string path = cfg.path; if (path.empty() || path[0] != '/') path = "/" + path; - return "rtsp://0.0.0.0:" + std::to_string(cfg.port) + path; + return "rtsp://" + host + ":" + std::to_string(cfg.port) + path; } OutputConfig cfg_; @@ -602,6 +604,7 @@ public: if (!o.IsObject()) continue; OutputConfig cfg; cfg.proto = o.ValueOr("proto", cfg.proto); + cfg.host = o.ValueOr("host", cfg.host); cfg.port = o.ValueOr("port", cfg.port); cfg.path = o.ValueOr("path", cfg.path); cfg.segment_sec = o.ValueOr("segment_sec", cfg.segment_sec);