2020-12-10 01:19:35 +08:00
|
|
|
#ifndef ZM_RTSP_SERVER_THREAD_H
|
|
|
|
#define ZM_RTSP_SERVER_THREAD_H
|
|
|
|
|
2021-02-04 11:47:28 +08:00
|
|
|
#include "zm_config.h"
|
|
|
|
#include "zm_ffmpeg.h"
|
2021-03-11 00:01:04 +08:00
|
|
|
#include "xop/RtspServer.h"
|
|
|
|
|
2021-02-28 01:26:19 +08:00
|
|
|
#include "zm_rtsp_server_fifo_source.h"
|
2021-03-03 08:11:39 +08:00
|
|
|
#include <atomic>
|
2021-02-04 11:47:28 +08:00
|
|
|
#include <list>
|
2021-02-08 02:12:39 +08:00
|
|
|
#include <memory>
|
2020-12-10 01:19:35 +08:00
|
|
|
|
2021-02-04 11:47:28 +08:00
|
|
|
#if HAVE_RTSP_SERVER
|
|
|
|
|
|
|
|
class Monitor;
|
2020-12-10 01:19:35 +08:00
|
|
|
|
2021-03-03 08:11:39 +08:00
|
|
|
class RTSPServerThread {
|
2020-12-10 01:19:35 +08:00
|
|
|
private:
|
2021-02-09 21:50:07 +08:00
|
|
|
std::shared_ptr<Monitor> monitor_;
|
2021-03-03 08:11:39 +08:00
|
|
|
|
|
|
|
std::thread thread_;
|
|
|
|
std::atomic<bool> terminate_;
|
|
|
|
std::mutex scheduler_watch_var_mutex_;
|
|
|
|
char scheduler_watch_var_;
|
2020-12-10 01:19:35 +08:00
|
|
|
|
2021-03-11 00:01:04 +08:00
|
|
|
std::shared_ptr<xop::EventLoop> eventLoop;
|
|
|
|
std::shared_ptr<xop::RtspServer> rtspServer;
|
2020-12-10 01:19:35 +08:00
|
|
|
|
2021-03-11 00:01:04 +08:00
|
|
|
std::list<ZoneMinderFifoSource *> sources;
|
|
|
|
int port;
|
2020-12-10 01:19:35 +08:00
|
|
|
|
|
|
|
public:
|
2021-03-02 03:02:12 +08:00
|
|
|
explicit RTSPServerThread(int port);
|
2020-12-10 01:19:35 +08:00
|
|
|
~RTSPServerThread();
|
2021-03-11 00:01:04 +08:00
|
|
|
xop::MediaSession *addSession(std::string &streamname);
|
|
|
|
void removeSession(xop::MediaSession *sms);
|
|
|
|
ZoneMinderFifoSource *addFifo(xop::MediaSession *sms, std::string fifo);
|
2021-03-03 08:11:39 +08:00
|
|
|
void Run();
|
|
|
|
void Stop();
|
2021-03-11 00:01:04 +08:00
|
|
|
int Start();
|
2021-03-03 08:11:39 +08:00
|
|
|
bool IsStopped() const { return terminate_; };
|
2020-12-10 01:19:35 +08:00
|
|
|
};
|
2021-02-04 11:59:03 +08:00
|
|
|
#endif // HAVE_RTSP_SERVER
|
2020-12-10 01:19:35 +08:00
|
|
|
|
2021-02-04 11:59:03 +08:00
|
|
|
#endif // ZM_RTSP_SERVER_THREAD_H
|