MillicastSDK 1.8.4
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#include <functional>
12#include <list>
13#include <memory>
14#include <optional>
15#include <string>
16#include <vector>
17
21#include "millicast-sdk/stats.h"
22
23namespace millicast {
30 DISABLED,
37};
38
52 bool disable_bwe{true};
53 std::optional<int> min_bitrate_kbps;
54 std::optional<int> max_bitrate_kbps;
55};
56
61struct TrackInfo {
62 std::string media;
63 std::string track_id;
64};
65
75 virtual void on_connected() = 0;
76
83 virtual void on_disconnected() = 0;
84
91 virtual void on_connection_error(int status, const std::string& reason) = 0;
92
98 virtual void on_signaling_error(const std::string& message) = 0;
99
106 virtual void on_stats_report(std::unique_ptr<StatsReport>) {}
107
113 virtual void on_viewer_count(int count) = 0;
114
115 virtual ~ClientListener() = default;
116};
117
128 bool auto_reconnect{true};
129};
130
136 std::optional<bool> stereo;
137 std::optional<bool>
142 std::optional<DegradationPreferences>
147};
148
154 std::string ws_url;
155 std::string jwt;
156};
157
159 public:
164
165 virtual ~ClientBase() = default;
166
172 static std::list<std::string> get_supported_video_codecs();
173
179 static std::list<std::string> get_supported_audio_codecs();
180
185 static void cleanup();
186};
187
188inline namespace compat {
195 public:
203 virtual bool connect(const std::optional<ConnectionOptions>&
204 connection_options = std::nullopt) = 0;
205
214 virtual bool connect(const JsonData& data,
215 const std::optional<ConnectionOptions>&
216 connection_options = std::nullopt) = 0;
217
223 [[nodiscard]] virtual bool is_connected() const = 0;
224
233 virtual bool disconnect() = 0;
234
240 virtual void enable_stats(bool enable) = 0;
241
247 virtual std::optional<std::string> get_mid(const std::string& track_id) = 0;
248
255 virtual void enable_frame_transformer(bool enable) = 0;
256};
257} // namespace compat
258
259namespace promises {
266 public:
276 std::optional<ConnectionOptions>&& connection_options) = 0;
277
288 JsonData&& data,
289 std::optional<ConnectionOptions>&& connection_options) = 0;
290
296 [[nodiscard]] virtual Promise<bool> is_connected() const = 0;
297
307
314 virtual Promise<void> enable_stats(bool enable) = 0;
315
316 // to be deprecated
318 std::string&& track_id) = 0;
319
327 virtual Promise<void> enable_frame_transformer(bool enable) = 0;
328};
329} // namespace promises
330
331} // namespace millicast
332
333#endif /* MILLICAST_API_CLIENT_H */
Definition client.h:158
static std::list< std::string > get_supported_video_codecs()
get_supported_video_codecs returns the list of the supported video codecs.
virtual ~ClientBase()=default
static void cleanup()
Clean and free the memory of dynamic objects.
static std::list< std::string > get_supported_audio_codecs()
get_supported_audio_codecs returns the list of the supported audio codecs.
Definition promise.h:45
The Client base class.
Definition client.h:194
virtual bool is_connected() const =0
is_connected
virtual bool connect(const std::optional< ConnectionOptions > &connection_options=std::nullopt)=0
Connect and open a websocket connection with the Millicast platform.
virtual std::optional< std::string > get_mid(const std::string &track_id)=0
Get the transceiver mid associated to a track if any.
virtual bool disconnect()=0
Disconnect from Millicast. The websocket connection to Millicast will no longer be active after disco...
virtual void enable_stats(bool enable)=0
Enable the rtc stats collecting. The stats are collected once the client is either publishing or subs...
virtual void enable_frame_transformer(bool enable)=0
Add frame transformer so you can add metadata to frame When a new transformable frame is available,...
virtual bool connect(const JsonData &data, const std::optional< ConnectionOptions > &connection_options=std::nullopt)=0
Connect to the media server directly using the websocket url and the JWT.
The Client base class.
Definition client.h:265
virtual Promise< void > disconnect()=0
Disconnect from Millicast. The websocket connection to Millicast will no longer be active after disco...
virtual Promise< void > connect(std::optional< ConnectionOptions > &&connection_options)=0
Connect and open a websocket connection with the Millicast platform.
virtual Promise< bool > is_connected() const =0
is_connected
virtual Promise< void > connect(JsonData &&data, std::optional< ConnectionOptions > &&connection_options)=0
Connect to the media server directly using the websocket url and the JWT.
virtual Promise< void > enable_stats(bool enable)=0
Enable the rtc stats collecting. The stats are collected once the client is either publishing or subs...
virtual Promise< void > enable_frame_transformer(bool enable)=0
Add frame transformer so you can add metadata to frame When a new transformable frame is available,...
virtual Promise< std::optional< std::string > > get_mid(std::string &&track_id)=0
#define MILLICAST_API
Definition exports.h:51
Definition capabilities.h:15
DegradationPreferences
The DegradationPreferences enum.
Definition client.h:29
Allows setting the desired minimum and/or maximum bitrates when publishing a stream....
Definition client.h:51
std::optional< int > max_bitrate_kbps
Definition client.h:54
bool disable_bwe
Definition client.h:52
std::optional< int > min_bitrate_kbps
Definition client.h:53
Connection related options.
Definition client.h:121
Authentication data returned by the director api in order to open a websocket connection.
Definition client.h:153
std::string jwt
Definition client.h:155
std::string ws_url
Definition client.h:154
The Client Listener struct which contains methods that will be called on specific events from a Clien...
Definition client.h:70
virtual void on_signaling_error(const std::string &message)=0
Called when millicast sends back an error message in response to a websocket command.
virtual void on_connection_error(int status, const std::string &reason)=0
on_connection_error is called when the attempt to connect to Millicast failed.
virtual void on_connected()=0
on_connected is called when the WebSocket connection to Millicast is opened
virtual ~ClientListener()=default
virtual void on_disconnected()=0
on_disconnected is called when the WebSocket connection to Millicast is closed. If this was an uninte...
virtual void on_stats_report(std::unique_ptr< StatsReport >)
on_stats_report is called when a new rtc stats report has been collected.
Definition client.h:106
virtual void on_viewer_count(int count)=0
Called when a new viewer join the stream or when a viewer quit the stream.
The ClientOption struct allows to setup the millicast connection.
Definition client.h:134
int stats_delay_ms
Definition client.h:140
std::optional< bool > stereo
Definition client.h:136
std::optional< bool > dtx
Definition client.h:138
std::optional< DegradationPreferences > degradation
Definition client.h:143
std::string rtc_event_log_output_path
Definition client.h:146
Useful informations about the available tracks in the media server. These informations are received i...
Definition client.h:61
std::string track_id
Definition client.h:63
std::string media
Definition client.h:62