MillicastSDK 2.5.0
Loading...
Searching...
No Matches
client.h
Go to the documentation of this file.
1#ifndef MILLICAST_API_CLIENT_H
2#define MILLICAST_API_CLIENT_H
3
11#ifdef __cplusplus
12
13#include <functional>
14#include <list>
15#include <memory>
16#include <optional>
17#include <string>
18#include <vector>
19
20#include "encoded_frames.h"
21#include "event_handling.h"
22#include "exports.h"
23#include "mc_logging.h"
24#include "promise.h"
25#include "stats.h"
26
27namespace millicast {
33enum class DegradationPreferences {
34 DISABLED,
35 MAINTAIN_RESOLUTION,
37 MAINTAIN_FRAMERATE,
39 BALANCED
41};
42
55struct BitrateSettings {
56 bool disable_bwe{true};
57 std::optional<int> min_bitrate_kbps;
58 std::optional<int> max_bitrate_kbps;
59};
60
65struct TrackInfo {
66 std::string media;
67 std::string track_id;
68};
69
73struct MILLICAST_API ClientConnectionOptions {
80 bool auto_reconnect{true};
81};
82
86struct MILLICAST_API ClientOption {
87 std::optional<bool> stereo;
88 std::optional<bool>
89 dtx;
91 int stats_delay_ms{3000};
94 std::optional<DegradationPreferences>
95 degradation;
98 std::string rtc_event_log_output_path;
99};
100
105struct ClientJsonData {
106 std::string ws_url;
107 std::string jwt;
108};
109
110class MILLICAST_API ClientBase {
111 public:
112 using ConnectionOptions = ClientConnectionOptions;
113 using Option = ClientOption;
114 using JsonData = ClientJsonData;
115
116 virtual ~ClientBase() = default;
117
123 static std::list<std::string> get_supported_video_codecs();
124
130 static std::list<std::string> get_supported_audio_codecs();
131
136 static void cleanup();
137};
138
144class MILLICAST_API Client : public ClientBase {
145 public:
151 struct StatsEvent {
155 std::shared_ptr<StatsReport> report{};
156 };
157
162 struct ViewerCount {
166 int viewer_count{0};
167 };
168
173 struct SignalingError {
177 std::string description;
178 };
179
184 struct HttpConnectionError {
188 int status_code;
192 std::string description;
193 };
194
201 enum class ConnectionState {
202 IDLE,
203 CONNECTING,
204 CONNECTED,
205 RECONNECTING,
206 DISCONNECTING,
207 FAILED
208 };
209
213 struct WebsocketState {
217 ConnectionState state;
218 };
219
223 struct PeerConnectionState {
227 ConnectionState state;
228 };
229
238 virtual Promise<void> connect(
239 std::optional<ConnectionOptions>&& connection_options) = 0;
240
250 virtual Promise<void> connect(
251 JsonData&& data,
252 std::optional<ConnectionOptions>&& connection_options) = 0;
253
259 [[nodiscard]] virtual Promise<bool> is_connected() const = 0;
260
269 virtual Promise<void> disconnect() = 0;
270
277 virtual Promise<void> enable_stats(bool enable) = 0;
278};
279
280} // namespace millicast
281#endif /* MILLICAST_API_CLIENT_H */
282#endif // __cplusplus
#define MILLICAST_API
Definition exports.h:51