-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
67 lines (49 loc) · 1.13 KB
/
main.cpp
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
#include "file_rtmp_server.h"
#include "rtmp_server_base/librtmp/rtmp_sys.h"
#ifdef WIN32
#include <Winsock2.h>
#define InitSockets() {\
WORD version; \
WSADATA wsaData; \
\
version = MAKEWORD(1,1); \
WSAStartup(version, &wsaData); }
#define CleanupSockets() WSACleanup()
#else
#include<signal.h>
#define InitSockets()
#define CleanupSockets()
void handle_pipe(int sigid)
{
}
#endif
int main(int argc, char** argv)
{
FileRtmpServer* file_rtmpserver = new FileRtmpServer();
#ifndef WIN32
struct sigaction action;
action.sa_handler = handle_pipe;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
sigaction(SIGPIPE, &action, NULL);
#endif
InitSockets();
printf("---------------------\nrtmp_file_server 1.1\n---------------------\n");
if (argc == 2)
file_rtmpserver->RtmpServer_Start( argv[1], 1935);
else
file_rtmpserver->RtmpServer_Start( "0.0.0.0", 1935);
for (;;)
{
char cmd[50];
scanf("%s", cmd);
if (strcmp(cmd, "exit") == 0)
{
break;
}
}
file_rtmpserver->RtmpServer_Stop();
delete file_rtmpserver;
CleanupSockets();
return 0;
}