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.

48 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. MediaMtx (C++) - control API (MediaMTX: internal/api, the same v3 URLs for the parts that exist here)
  3. GET /v3/paths/list paths with their state
  4. GET /v3/paths/get/{name}
  5. GET /v3/config/paths/list path configurations
  6. GET /v3/config/paths/get/{name}
  7. POST /v3/config/paths/add/{name} {"source":"rtsp://...","record":true,"rtspTransport":"tcp"}
  8. PATCH /v3/config/paths/patch/{name} the same fields, only those given are changed
  9. POST /v3/config/paths/replace/{name}
  10. DELETE /v3/config/paths/delete/{name}
  11. A change is applied at once (only the changed path restarts) and saved to the paths file.
  12. */
  13. #pragma once
  14. #include <functional>
  15. #include <string>
  16. #include <vector>
  17. #include "../conf/conf.h"
  18. #include "../core/pathManager.h"
  19. #include <protocols/httpp/httpServer.h>
  20. namespace mtx {
  21. class Api : public LogParent
  22. {
  23. public:
  24. // applyConfs: replaces the path list (validated), returns false + err on failure
  25. typedef std::function<bool(const std::vector<PathConf> &, std::string &)> ApplyFn;
  26. Api(const Conf & global, PathManager * paths, ApplyFn apply);
  27. ~Api();
  28. bool start(std::string & err);
  29. void stop();
  30. private:
  31. void handle(const HttpRequest & req, HttpResponse & res);
  32. Conf m_global;
  33. PathManager * m_pPaths;
  34. ApplyFn m_apply;
  35. HttpServer m_http;
  36. };
  37. } // namespace mtx