You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.1 KiB
66 lines
2.1 KiB
/*
|
|
MediaMtx (C++) - configuration
|
|
|
|
No mediamtx.yml: the global settings come from the command line, the paths (streams) from a small
|
|
paths file (one line per path, reloaded on SIGHUP) and from the control API.
|
|
|
|
Paths file:
|
|
# name source options
|
|
stream_3 rtsp://user:pass@10.0.0.5:554/stream1 record=yes transport=tcp
|
|
stream_4 rtsp://10.0.0.6/live record=no
|
|
|
|
The option names follow MediaMTX (webrtcAddress, recordPath, ...).
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <conf/serverConf.h>
|
|
#include <logger/logger.h>
|
|
|
|
namespace mtx {
|
|
|
|
enum class RtspTransport { Tcp, Udp };
|
|
|
|
struct PathConf
|
|
{
|
|
std::string name;
|
|
std::string source; // rtsp://...
|
|
bool record = false;
|
|
RtspTransport transport = RtspTransport::Tcp;
|
|
|
|
bool operator==(const PathConf & o) const { return name == o.name && source == o.source && record == o.record && transport == o.transport; }
|
|
bool operator!=(const PathConf & o) const { return ! (*this == o); }
|
|
};
|
|
|
|
struct Conf : public ServerConf
|
|
{
|
|
// general
|
|
LogLevel logLevel = LogLevel::Info;
|
|
bool logStdout = true;
|
|
std::string logFile; // empty: no file
|
|
int64_t readTimeoutMs = 10000; // source: no data for this long -> reconnect
|
|
int64_t sourceRetryPauseMs = 5000; // pause before a reconnect
|
|
|
|
// control API (empty address: disabled)
|
|
std::string apiAddress = "127.0.0.1:9997";
|
|
|
|
// paths
|
|
std::string pathsFile;
|
|
std::vector<PathConf> paths; // paths file + command line
|
|
std::vector<PathConf> cmdPaths; // --path options only
|
|
|
|
void mergeCmdPaths(std::vector<PathConf> & out) const;
|
|
|
|
// Parses the command line (and loads the paths file). False + err on a bad option.
|
|
bool load(int argc, char ** argv, std::string & err);
|
|
static void printUsage(const char * prog);
|
|
};
|
|
|
|
bool loadPathsFile(const std::string & file, std::vector<PathConf> & out, std::string & err);
|
|
bool savePathsFile(const std::string & file, const std::vector<PathConf> & paths, std::string & err);
|
|
bool validPathName(const std::string & name);
|
|
|
|
} // namespace mtx
|