Hermes
0.7.0
Linux game streaming host
Toggle main menu visibility
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1
5
#pragma once
6
7
// standard includes
8
#include <utility>
9
10
// lib includes
11
#include <boost/asio.hpp>
12
13
// local includes
14
#include "
audio.h
"
15
#include "
crypto.h
"
16
#include "
video.h
"
17
18
namespace
stream {
19
constexpr
auto
VIDEO_STREAM_PORT = 9;
20
constexpr
auto
CONTROL_PORT = 10;
21
constexpr
auto
AUDIO_STREAM_PORT = 11;
22
constexpr
auto
MIC_STREAM_PORT = 12;
23
24
// Client microphone encryption, from Apollo's mic passthrough
25
// (logabell/moonlight-common-c-mic); upstream moonlight-common-c lacks it.
26
#ifndef SS_ENC_MICROPHONE
27
#define SS_ENC_MICROPHONE 0x08
28
#endif
29
30
struct
session_t
;
31
32
struct
config_t
{
33
audio::config_t
audio;
34
video::config_t
monitor;
35
36
int
packetsize;
37
int
minRequiredFecPackets;
38
int
mlFeatureFlags;
39
int
controlProtocolType;
40
int
audioQosType;
41
int
videoQosType;
42
43
uint32_t encryptionFlagsEnabled;
44
45
std::optional<int> gcmap;
46
48
std::string
mic_source
;
49
};
50
51
namespace
session {
52
enum class
state_e
:
int
{
53
STOPPED
,
54
STOPPING
,
55
STARTING
,
56
RUNNING
,
57
};
58
66
enum class
termination_reason_e
:
int
{
67
UNKNOWN,
68
CLIENT_QUIT
,
69
CLIENT_LOST
,
70
HANDSHAKE_FAILED
,
71
PROTOCOL_ERROR
,
72
SERVER_STOPPED
,
73
PERMISSION_REVOKED
,
74
};
75
76
std::string_view termination_reason_str(termination_reason_e reason);
77
termination_reason_e last_termination_reason();
78
86
struct
termination_stats_t
{
87
termination_reason_e
last_reason {
termination_reason_e::UNKNOWN
};
89
uint64_t
ms_since_last_end
{0};
90
uint64_t
total_ended
{0};
91
uint64_t
client_lost_count
{0};
92
};
93
95
termination_stats_t termination_stats();
96
97
std::shared_ptr<session_t> alloc(
config_t
&config,
rtsp_stream::launch_session_t
&launch_session);
98
std::string uuid(
const
session_t
& session);
99
bool
uuid_match(
const
session_t
& session,
const
std::string_view& uuid);
100
bool
isolated(
const
session_t
&session);
101
bool
update_device_info(
session_t
& session,
const
std::string& name,
const
crypto::PERM
& newPerm);
102
int
start(
session_t
&session,
const
std::string &addr_string);
103
void
stop(
session_t
&session, termination_reason_e reason = termination_reason_e::UNKNOWN);
104
void
graceful_stop(
session_t
& session);
105
void
join(
session_t
&session);
106
state_e state(
session_t
&session);
107
inline
bool
send(
session_t
& session,
const
std::string_view &payload);
108
}
// namespace session
109
}
// namespace stream
audio.h
Declarations for audio capture and encoding.
crypto.h
Declarations for cryptography functions.
crypto::PERM
PERM
The permissions of a client.
Definition
crypto.h:45
stream::session::state_e
state_e
Definition
stream.h:52
stream::session::state_e::STARTING
@ STARTING
The session is starting.
Definition
stream.h:55
stream::session::state_e::STOPPED
@ STOPPED
The session is stopped.
Definition
stream.h:53
stream::session::state_e::RUNNING
@ RUNNING
The session is running.
Definition
stream.h:56
stream::session::state_e::STOPPING
@ STOPPING
The session is stopping.
Definition
stream.h:54
stream::session::termination_reason_e
termination_reason_e
Why a streaming session ended.
Definition
stream.h:66
stream::session::termination_reason_e::HANDSHAKE_FAILED
@ HANDSHAKE_FAILED
Video/audio handshake never completed.
Definition
stream.h:70
stream::session::termination_reason_e::PROTOCOL_ERROR
@ PROTOCOL_ERROR
Malformed/failed control-stream exchange.
Definition
stream.h:71
stream::session::termination_reason_e::SERVER_STOPPED
@ SERVER_STOPPED
Host stopped the session (API stop, shutdown).
Definition
stream.h:72
stream::session::termination_reason_e::CLIENT_QUIT
@ CLIENT_QUIT
Client closed the stream (ENet disconnect).
Definition
stream.h:68
stream::session::termination_reason_e::UNKNOWN
@ UNKNOWN
No reason recorded yet.
Definition
stream.h:67
stream::session::termination_reason_e::PERMISSION_REVOKED
@ PERMISSION_REVOKED
View permission was revoked mid-session.
Definition
stream.h:73
stream::session::termination_reason_e::CLIENT_LOST
@ CLIENT_LOST
Client stopped responding (ping timeout / network loss).
Definition
stream.h:69
audio::config_t
Definition
audio.h:48
rtsp_stream::launch_session_t
Definition
rtsp.h:29
stream::config_t
Definition
stream.h:32
stream::config_t::mic_source
std::string mic_source
The session mic the client's microphone plays into; empty for none.
Definition
stream.h:48
stream::session::termination_stats_t
Aggregate reconnection/termination stats for diagnostics.
Definition
stream.h:86
stream::session::termination_stats_t::ms_since_last_end
uint64_t ms_since_last_end
Steady-clock ms since the last session ended; 0 if none has ended yet.
Definition
stream.h:89
stream::session::termination_stats_t::client_lost_count
uint64_t client_lost_count
Of those, ended by client loss (drops).
Definition
stream.h:91
stream::session::termination_stats_t::total_ended
uint64_t total_ended
Sessions that have ended this run.
Definition
stream.h:90
stream::session_t
Definition
stream.cpp:374
video::config_t
Definition
video.h:37
video.h
Declarations for video.
src
stream.h
Generated by
1.18.0