 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
1 day 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
1 day 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
1 day ago |
|
/*
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
|