-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
78 lines (62 loc) · 1.77 KB
/
common.h
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
76
77
78
//
// Created by Keaton Burleson on 11/2/23.
//
#include <sys/time.h>
#include <string>
#include <cstdlib>
#include <iostream>
#include <filesystem>
#include "nlohmann/json.hpp"
#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <fstream>
#include <csignal>
#include <cstdio>
#include <unistd.h>
#include <curl/curl.h>
#include <regex>
extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/timestamp.h>
}
#ifndef NEVER_CLI_COMMON_H
#define NEVER_CLI_COMMON_H
using string = std::string;
using nvr_logger = std::shared_ptr<spdlog::logger>;
// TODO: cleanup this file
namespace nvr {
enum StreamType {
h265,
h264
};
enum FileType {
video,
image,
log
};
struct CameraConfig {
string stream_url;
string sub_stream_url;
string snapshot_url;
string output_path;
string stream_name;
string ip_address;
string rtsp_username;
string rtsp_password;
StreamType type;
string stream_id;
string hardware_enc_priority;
const long clip_runtime;
const long snapshot_interval;
const int port;
};
string buildStreamURL(const string&url, const string&ip_address, int port, const string&password,
const string&username);
string sanitizeStreamURL(const string&stream_url, const string&password);
CameraConfig getConfig(const char* config_file);
string generateOutputFilename(const string&camera_id, const string&output_path, FileType file_type, bool temporary = false);
int countClips(const string&output_path, const string&camera_name);
nvr_logger buildLogger(const CameraConfig&config);
} // nvr
#endif