mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-10-28 01:08:27 -04:00
Rough in code for the RTSP Server thread
This commit is contained in:
1 parent
47b3f319e7
commit
054e1b583d
2 files changed
+74
No files matched your search
@@ -0,0 +1,33 @@
|
||||
#include "zm_rtsp_server_thread.h"
|
||||
#if HAVE_RTSP_SERVER
|
||||
#define ZM_RTSP_SERVER_BASE 10000
|
||||
|
||||
RTSPServerThread::RTSPServerThread(Monitor *p_monitor) :
|
||||
monitor(p_monitor),
|
||||
terminate(false) {
|
||||
|
||||
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
|
||||
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
|
||||
UserAuthenticationDatabase* authDB = NULL;
|
||||
authDB = new UserAuthenticationDatabase;
|
||||
authDB->addUserRecord("username1", "password1"); // replace these with real strings
|
||||
|
||||
portNumBits rtspServerPortNum = ZM_RTSP_SERVER_BASE + monitor->Id();
|
||||
RTSPServer* rtspServer = RTSPServer::createNew(*env, rtspServerPortNum, authDB);
|
||||
if ( rtspServer == NULL) {
|
||||
Error("Failed to create rtspServer at port %d", rtspServerPortNum);
|
||||
}
|
||||
Debug(1, "RTSP prefix is %s", rtspServer->rtspURLPrefix());
|
||||
}
|
||||
|
||||
RTSPServerThread::~RTSPServerThread() {
|
||||
Debug(2, "THREAD: deleting");
|
||||
}
|
||||
|
||||
int RTSPServerThread::run() {
|
||||
|
||||
if ( rtspServer )
|
||||
env->taskScheduler().doEventLoop(); // does not return
|
||||
return 0;
|
||||
} // end in RTSPServerThread::run()
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "zm.h"
|
||||
#if HAVE_RTSP_SERVER
|
||||
|
||||
#ifndef ZM_RTSP_SERVER_THREAD_H
|
||||
#define ZM_RTSP_SERVER_THREAD_H
|
||||
|
||||
#include "zm_thread.h"
|
||||
#include <signal.h>
|
||||
|
||||
#include "zm_monitor.h"
|
||||
|
||||
#include <BasicUsageEnvironment.hh>
|
||||
#include <RTSPServer.hh>
|
||||
|
||||
class RTSPServerThread : public Thread {
|
||||
private:
|
||||
Monitor *monitor;
|
||||
bool terminate;
|
||||
|
||||
TaskScheduler* scheduler;
|
||||
UsageEnvironment* env;
|
||||
UserAuthenticationDatabase* authDB;
|
||||
|
||||
RTSPServer* rtspServer;
|
||||
|
||||
|
||||
public:
|
||||
explicit RTSPServerThread(Monitor *);
|
||||
~RTSPServerThread();
|
||||
int run();
|
||||
|
||||
void stop() {
|
||||
terminate = true;
|
||||
}
|
||||
bool stopped() const {
|
||||
return terminate;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user