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.
 
 
 
 
 
 

75 lines
1.7 KiB

/*
MediaMtx (C++) - path (MediaMTX: internal/core/path.go)
A path has a static source (RTSP camera), a stream while the source is ready, an optional recorder and
the readers (WebRTC sessions).
*/
#pragma once
#include <memory>
#include <mutex>
#include <set>
#include <string>
#include "../conf/conf.h"
#include "../logger/logger.h"
#include "../staticsources/rtsp/rtspSource.h"
#include "../stream/stream.h"
namespace mtx {
class Recorder;
class PathReader : public StreamReader
{
public:
// The source of the path is gone: the reader must close (called with the path locked: do not block,
// do not call back into the path)
virtual void pathNotReady() = 0;
};
struct PathInfo
{
std::string name;
std::string source;
bool record = false;
bool ready = false;
int64_t readySinceUs = 0;
StreamDesc desc;
size_t readers = 0;
uint64_t bytesReceived = 0;
};
class Path : public SourceParent, public LogParent
{
public:
Path(const PathConf & conf, const Conf & global);
~Path() override;
void start();
void stop();
const PathConf & conf() const { return m_conf; }
PathInfo info() const;
// false + err when the path has no stream
bool addReader(PathReader * r, StreamDesc & desc, std::string & err);
void removeReader(PathReader * r);
// SourceParent
void sourceSetReady(const StreamDesc & desc) override;
void sourceSetNotReady() override;
void sourceWriteUnit(const UnitPtr & unit) override;
private:
PathConf m_conf;
Conf m_global;
std::unique_ptr<RtspSource> m_pSource;
mutable std::mutex m_mutex;
std::shared_ptr<Stream> m_pStream;
std::unique_ptr<Recorder> m_pRecorder;
std::set<PathReader *> m_readers;
int64_t m_tReadySinceUs = 0;
};
} // namespace mtx