This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
rtsp.cxx
75 lines (56 loc) · 2.25 KB
/
rtsp.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <fcntl.h>
#include "config.h"
#include "common.h"
#ifdef ENABLE_RTSP
#include "liveMedia.hh"
#include "BasicUsageEnvironment.hh"
UsageEnvironment* env;
Boolean reuseFirstSource = True;
Boolean iFramesOnly = False;
static void announceStream(RTSPServer* rtspServer, ServerMediaSession* sms,
char const* streamName, char const* inputFileName); // fwd
extern "C" void* min(void *) {
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
env = BasicUsageEnvironment::createNew(*scheduler);
UserAuthenticationDatabase* authDB = NULL;
#ifdef ACCESS_CONTROL
authDB = new UserAuthenticationDatabase;
authDB->addUserRecord("username1", "password1");
#endif
RTSPServer* rtspServer = RTSPServer::createNew(*env, MODE_RTSP, authDB);
if (rtspServer == NULL) {
*env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
exit(1);
}
char const* descriptionString
= "Session streamed by " PACKAGE " (" PACKAGE_URL ")";
{
char const* streamName = "";
int fd = open(MODE_RTSP_FIFO_FILE, O_RDONLY); // open inmediatelly to avoid hanging write process
close(fd);
char const* inputFileName = MODE_RTSP_FIFO_FILE;
OutPacketBuffer::maxSize = 100000;
ServerMediaSession* sms
= ServerMediaSession::createNew(*env, streamName, streamName,
descriptionString);
sms->addSubsession(H264VideoFileServerMediaSubsession
::createNew(*env, inputFileName, reuseFirstSource));
rtspServer->addServerMediaSession(sms);
announceStream(rtspServer, sms, streamName, inputFileName);
}
if (rtspServer->setUpTunnelingOverHTTP(80) || rtspServer->setUpTunnelingOverHTTP(8000) || rtspServer->setUpTunnelingOverHTTP(8080)) {
*env << "(Using port " << rtspServer->httpServerPortNum() << " for optional RTSP-over-HTTP tunneling.)\n";
} else {
*env << "(RTSP-over-HTTP tunneling is not available.)\n";
}
*env << "\n";
env->taskScheduler().doEventLoop();
}
static void announceStream(RTSPServer* rtspServer, ServerMediaSession* sms,
char const* streamName, char const* inputFileName) {
char* url = rtspServer->rtspURL(sms);
UsageEnvironment& env = rtspServer->envir();
env << "Starting RTSP server on \"" << url << "\"\n";
delete[] url;
}
#endif