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

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. MediaMtx (C++) - configuration
  3. No mediamtx.yml: the global settings come from the command line, the paths (streams) from a small
  4. paths file (one line per path, reloaded on SIGHUP) and from the control API.
  5. Paths file:
  6. # name source options
  7. stream_3 rtsp://user:pass@10.0.0.5:554/stream1 record=yes transport=tcp
  8. stream_4 rtsp://10.0.0.6/live record=no
  9. The option names follow MediaMTX (webrtcAddress, recordPath, ...).
  10. */
  11. #pragma once
  12. #include <cstdint>
  13. #include <string>
  14. #include <vector>
  15. #include <conf/serverConf.h>
  16. #include <logger/logger.h>
  17. namespace mtx {
  18. enum class RtspTransport { Tcp, Udp };
  19. struct PathConf
  20. {
  21. std::string name;
  22. std::string source; // rtsp://...
  23. bool record = false;
  24. RtspTransport transport = RtspTransport::Tcp;
  25. bool operator==(const PathConf & o) const { return name == o.name && source == o.source && record == o.record && transport == o.transport; }
  26. bool operator!=(const PathConf & o) const { return ! (*this == o); }
  27. };
  28. struct Conf : public ServerConf
  29. {
  30. // general
  31. LogLevel logLevel = LogLevel::Info;
  32. bool logStdout = true;
  33. std::string logFile; // empty: no file
  34. int64_t readTimeoutMs = 10000; // source: no data for this long -> reconnect
  35. int64_t sourceRetryPauseMs = 5000; // pause before a reconnect
  36. // control API (empty address: disabled)
  37. std::string apiAddress = "127.0.0.1:9997";
  38. // paths
  39. std::string pathsFile;
  40. std::vector<PathConf> paths; // paths file + command line
  41. std::vector<PathConf> cmdPaths; // --path options only
  42. void mergeCmdPaths(std::vector<PathConf> & out) const;
  43. // Parses the command line (and loads the paths file). False + err on a bad option.
  44. bool load(int argc, char ** argv, std::string & err);
  45. static void printUsage(const char * prog);
  46. };
  47. bool loadPathsFile(const std::string & file, std::vector<PathConf> & out, std::string & err);
  48. bool savePathsFile(const std::string & file, const std::vector<PathConf> & paths, std::string & err);
  49. bool validPathName(const std::string & name);
  50. } // namespace mtx