update plugins/publish/publish_node.cpp
This commit is contained in:
parent
7f540617c9
commit
b78eb7fbb5
@ -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<std::string>("proto", cfg.proto);
|
||||
cfg.host = o.ValueOr<std::string>("host", cfg.host);
|
||||
cfg.port = o.ValueOr<int>("port", cfg.port);
|
||||
cfg.path = o.ValueOr<std::string>("path", cfg.path);
|
||||
cfg.segment_sec = o.ValueOr<int>("segment_sec", cfg.segment_sec);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user