-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (54 loc) · 1.53 KB
/
Copy pathmain.cpp
File metadata and controls
70 lines (54 loc) · 1.53 KB
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
#include <signal.h>
#include <cstring>
#include "app.h"
#include "log.h"
App app{};
void sigintHandler(int)
{
exit(app.stop() ? 0 : -1);
}
int main(int argc, char *argv[])
{
bool printHelp = false;
std::string address = "127.0.0.1";
int port = 8080;
for (int i = 1; i < argc; i++)
{
char *arg = argv[i];
if (strcmp(arg, "-h") == 0)
{
printHelp = true;
break;
}
if (strcmp(arg, "-b") == 0 && i + 1 < argc)
{
address = std::string(argv[i + 1]);
i++;
continue;
}
if (strcmp(arg, "-p") == 0 && i + 1 < argc)
{
port = std::stoi(argv[i + 1]);
i++;
continue;
}
}
if (printHelp)
{
PRINT_LOG_SIMPLE("Usage: videoProcessor [options...]" << std::endl
<< "-h\t Print help" << std::endl
<< "-b\t Bind IP address. Default 127.0.0.1" << std::endl
<< "-p\t Listen port. Default 8080" << std::endl << std::endl
<< "example: curl -v -d \"gain=3&"
"filename=/path/to/file.mp4\" -X POST \"127.0.0.1:8080\"");
return 0;
}
PRINT_LOG_SIMPLE("example: curl -v -d \"gain=3&"
"filename=/path/to/file.mp4\" -X POST \"127.0.0.1:8080\""
<< std::endl);
signal(SIGINT, &sigintHandler);
if (!app.start(address, port))
return -1;
app.stop();
return 0;
}