Hermes 0.7.0
Linux game streaming host
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
18namespace 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 {
57 };
58
75
76 std::string_view termination_reason_str(termination_reason_e reason);
77 termination_reason_e last_termination_reason();
78
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
Declarations for audio capture and encoding.
Declarations for cryptography functions.
PERM
The permissions of a client.
Definition crypto.h:45
@ STARTING
The session is starting.
Definition stream.h:55
@ STOPPED
The session is stopped.
Definition stream.h:53
@ RUNNING
The session is running.
Definition stream.h:56
@ STOPPING
The session is stopping.
Definition stream.h:54
termination_reason_e
Why a streaming session ended.
Definition stream.h:66
@ HANDSHAKE_FAILED
Video/audio handshake never completed.
Definition stream.h:70
@ PROTOCOL_ERROR
Malformed/failed control-stream exchange.
Definition stream.h:71
@ SERVER_STOPPED
Host stopped the session (API stop, shutdown).
Definition stream.h:72
@ CLIENT_QUIT
Client closed the stream (ENet disconnect).
Definition stream.h:68
@ UNKNOWN
No reason recorded yet.
Definition stream.h:67
@ PERMISSION_REVOKED
View permission was revoked mid-session.
Definition stream.h:73
@ CLIENT_LOST
Client stopped responding (ping timeout / network loss).
Definition stream.h:69
std::string mic_source
The session mic the client's microphone plays into; empty for none.
Definition stream.h:48
Aggregate reconnection/termination stats for diagnostics.
Definition stream.h:86
uint64_t ms_since_last_end
Steady-clock ms since the last session ended; 0 if none has ended yet.
Definition stream.h:89
uint64_t client_lost_count
Of those, ended by client loss (drops).
Definition stream.h:91
uint64_t total_ended
Sessions that have ended this run.
Definition stream.h:90
Declarations for video.