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.
49 lines
1.3 KiB
49 lines
1.3 KiB
/*
|
|
MediaMtx (C++) - WebRTC server, WHEP (MediaMTX: internal/servers/webrtc)
|
|
|
|
POST /<path>/whep SDP offer -> 201 + SDP answer, Location /<path>/whep/<secret>
|
|
PATCH /<path>/whep/<secret> trickle ICE (application/trickle-ice-sdpfrag)
|
|
DELETE /<path>/whep/<secret> close the session
|
|
OPTIONS CORS preflight
|
|
GET /<path>/ a small player page
|
|
*/
|
|
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <thread>
|
|
|
|
#include "../../conf/serverConf.h"
|
|
#include "../../core/mediaPath.h"
|
|
#include "../../protocols/httpp/httpServer.h"
|
|
#include "session.h"
|
|
|
|
namespace mtx {
|
|
|
|
class WebrtcServer : public LogParent
|
|
{
|
|
public:
|
|
WebrtcServer(const ServerConf & global, PathProvider * paths);
|
|
~WebrtcServer();
|
|
|
|
bool start(std::string & err);
|
|
void stop();
|
|
size_t sessionCount() const;
|
|
|
|
private:
|
|
void handle(const HttpRequest & req, HttpResponse & res);
|
|
void janitor();
|
|
|
|
ServerConf m_global;
|
|
PathProvider * m_pPaths;
|
|
HttpServer m_http;
|
|
mutable std::mutex m_mutex;
|
|
std::map<std::string, std::shared_ptr<WebrtcSession>> m_sessions;
|
|
std::thread m_janitor;
|
|
std::mutex m_stopMutex;
|
|
std::condition_variable m_stopCond;
|
|
bool m_bRun = false;
|
|
};
|
|
|
|
} // namespace mtx
|