-
Notifications
You must be signed in to change notification settings - Fork 8
/
nico-live.hpp
104 lines (91 loc) · 2.54 KB
/
nico-live.hpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include <chrono>
#include <ctime>
#include <memory>
#include <string>
class NicoLiveWatcher;
class NicoLiveApi;
class NicoLive
{
friend class NicoLiveWatcher;
enum class LiveState {
BEFORE_START,
ENABLE_LIVE,
AFTER_END,
};
public:
private:
std::string mail;
std::string password;
std::string session;
std::string ticket;
struct {
std::string id;
std::string url;
std::string stream;
std::string ticket;
std::chrono::system_clock::time_point server_time;
std::chrono::system_clock::time_point base_time;
std::chrono::system_clock::time_point open_time;
std::chrono::system_clock::time_point start_time;
std::chrono::system_clock::time_point end_time;
long long bitrate = 0;
bool exclude = false;
} live_info;
std::string live_url;
std::string live_key;
std::string onair_live_id;
struct {
bool session_valid = false;
bool onair = false;
bool load_viqo = false;
bool adjust_bitrate = false;
bool silent_once = false;
} flags;
std::unique_ptr<NicoLiveWatcher> watcher;
std::unique_ptr<NicoLiveApi> webApi;
public:
NicoLive();
~NicoLive();
void setSession(const char *session);
void setSession(const std::string &session);
void setAccount(const char *mail, const char *password);
void setAccount(const std::string &mail, const std::string &password);
void setEnabledAdjustBitrate(bool enabled);
const std::string &getMail() const;
const std::string &getPassword() const;
const std::string &getSession() const;
const std::string &getLiveId() const;
const std::string &getLiveUrl() const;
const std::string &getLiveKey() const;
long long getLiveBitrate() const;
const std::string &getOnairLiveId() const;
bool enabledLive() const;
LiveState getLiveState() const;
std::chrono::system_clock::time_point getLiveStartTime() const;
std::chrono::system_clock::time_point getLiveEndTime() const;
std::chrono::system_clock::duration getRemainingStartTime() const;
std::chrono::system_clock::duration getRemainingEndTime() const;
std::chrono::system_clock::duration getRemainingLive() const;
bool enabledStopBeforeEndTime() const;
bool enabledStartBeforeStartTime() const;
bool enabledAdjustBitrate() const;
bool enabledSession() const;
bool isOnair() const;
void startStreaming();
void stopStreaming();
void startWatching();
void stopWatching();
bool checkSession();
bool checkLive();
bool loadViqoSettings();
void nextSilentOnce();
bool silentOnce();
private:
// Access Niconico Site
bool siteLogin();
bool siteLoginNLE();
bool sitePubStat();
bool siteLiveProf();
void clearLiveInfo();
};