 MediaMtx: C++ replacement for the MediaMTX parts la_mojo uses
New project Projects/MediaMtx, in MediaMTX's module layout (internal/core, conf,
stream, staticsources/rtsp, servers/webrtc, recorder, api, ...):
- RTSP pull of the cameras with live555 (H264, TCP/UDP), reconnect after errors or
when no data arrives for --readTimeout
- WebRTC WHEP on :8889 with libdatachannel, the MediaMTX URLs
(POST /stream_N/whep, PATCH/DELETE /stream_N/whep/<id>), so the dashboard works as is
- recording as fragmented MP4 segments (no transcoding), playable in browsers,
MediaMTX file names; a fragment is flushed every --recordPartDuration
- no mediamtx.yml: command line options + a paths file (SIGHUP reload) + the
v3 paths API (add / patch / replace / delete, written back to the file)
- log lines in the MediaMTX format that kernelHelperMediaMTX parses
Tested with a GStreamer RTSP camera and Chromium (WHEP, recordings), camera
loss / reconnect, API, SIGHUP; ASan + UBSan clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
22 hours ago  MediaMtx: C++ replacement for the MediaMTX parts la_mojo uses
New project Projects/MediaMtx, in MediaMTX's module layout (internal/core, conf,
stream, staticsources/rtsp, servers/webrtc, recorder, api, ...):
- RTSP pull of the cameras with live555 (H264, TCP/UDP), reconnect after errors or
when no data arrives for --readTimeout
- WebRTC WHEP on :8889 with libdatachannel, the MediaMTX URLs
(POST /stream_N/whep, PATCH/DELETE /stream_N/whep/<id>), so the dashboard works as is
- recording as fragmented MP4 segments (no transcoding), playable in browsers,
MediaMTX file names; a fragment is flushed every --recordPartDuration
- no mediamtx.yml: command line options + a paths file (SIGHUP reload) + the
v3 paths API (add / patch / replace / delete, written back to the file)
- log lines in the MediaMTX format that kernelHelperMediaMTX parses
Tested with a GStreamer RTSP camera and Chromium (WHEP, recordings), camera
loss / reconnect, API, SIGHUP; ASan + UBSan clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
22 hours ago |
|
/*
MediaMtx (C++) - control API (MediaMTX: internal/api, the same v3 URLs for the parts that exist here)
GET /v3/paths/list paths with their state GET /v3/paths/get/{name} GET /v3/config/paths/list path configurations GET /v3/config/paths/get/{name} POST /v3/config/paths/add/{name} {"source":"rtsp://...","record":true,"rtspTransport":"tcp"} PATCH /v3/config/paths/patch/{name} the same fields, only those given are changed POST /v3/config/paths/replace/{name} DELETE /v3/config/paths/delete/{name}
A change is applied at once (only the changed path restarts) and saved to the paths file.*/#pragma once
#include <functional>
#include <string>
#include <vector>
#include "../conf/conf.h"
#include "../core/pathManager.h"
#include <protocols/httpp/httpServer.h>
namespace mtx {
class Api : public LogParent{ public: // applyConfs: replaces the path list (validated), returns false + err on failure
typedef std::function<bool(const std::vector<PathConf> &, std::string &)> ApplyFn;
Api(const Conf & global, PathManager * paths, ApplyFn apply); ~Api();
bool start(std::string & err); void stop();
private: void handle(const HttpRequest & req, HttpResponse & res);
Conf m_global; PathManager * m_pPaths; ApplyFn m_apply; HttpServer m_http;};
} // namespace mtx
|