2020-12-10 01:19:35 +08:00
|
|
|
#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() {
|
2020-12-16 05:01:34 +08:00
|
|
|
Debug(2, "RTSPServerThread::run()");
|
2020-12-10 01:19:35 +08:00
|
|
|
if ( rtspServer )
|
|
|
|
env->taskScheduler().doEventLoop(); // does not return
|
|
|
|
return 0;
|
|
|
|
} // end in RTSPServerThread::run()
|
|
|
|
#endif
|