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.

53 lines
1.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. MediaMtx (C++) - settings of the reusable parts (WebRTC server, recorder)
  3. Shared by the stand-alone server (Projects/MediaMtx, which adds the command line, the paths file, the
  4. RTSP sources and the API) and la_mojo (kernelModuleEmbedVideo, which feeds the streams itself).
  5. The names follow MediaMTX (webrtcAddress, recordPath, ...).
  6. */
  7. #pragma once
  8. #include <cstdint>
  9. #include <functional>
  10. #include <string>
  11. #include <vector>
  12. namespace mtx {
  13. // A finished recording segment (the file is closed and complete)
  14. struct SegmentInfo
  15. {
  16. std::string path; // path name (e.g. stream_12)
  17. std::string file; // full file name
  18. int64_t startUs = 0; // local wall clock when its first sample was written (us since the epoch)
  19. int64_t durationUs = 0; // from the timestamps of the samples
  20. int width = 0;
  21. int height = 0;
  22. };
  23. struct ServerConf
  24. {
  25. // WebRTC (WHEP)
  26. std::string webrtcAddress = ":8889";
  27. std::string webrtcAllowOrigin = "*";
  28. std::vector<std::string> webrtcICEServers; // e.g. stun:stun.l.google.com:19302
  29. std::string webrtcBindAddress; // ICE: bind to this local address (default: all)
  30. uint16_t webrtcUDPPortMin = 8189;
  31. uint16_t webrtcUDPPortMax = 8289;
  32. // recording
  33. std::string recordPath = "./recordings/%path/%Y-%m-%d_%H-%M-%S-%f";
  34. int64_t recordSegmentDurationMs = 60000;
  35. int64_t recordPartDurationMs = 1000;
  36. // Called (from the recorder thread) for every closed segment; must not block. Optional.
  37. std::function<void(const SegmentInfo &)> onSegmentDone;
  38. };
  39. // "60s", "1m", "500ms", "1h", "1.5s"; plain number = seconds
  40. bool parseDurationMs(const std::string & s, int64_t & ms);
  41. // "host:port" / ":port" -> host ("" = any) and port
  42. bool splitHostPort(const std::string & addr, std::string & host, uint16_t & port);
  43. // rtsp://user:pass@host/... -> rtsp://host/... (for logs)
  44. std::string hideCredentials(const std::string & url);
  45. } // namespace mtx