MillicastSDK 2.5.0
Loading...
Searching...
No Matches
publisher.h
Go to the documentation of this file.
1#ifndef MILLICAST_API_PUBLISHER_H
2#define MILLICAST_API_PUBLISHER_H
3
4#ifdef __cplusplus
5
13#include "client.h"
14
15namespace millicast {
16
17// Forward declarations ///////////////////////////////////////////////////////
18
19class VideoTrack;
20class AudioTrack;
21class Track;
22
23// Scalability mode ///////////////////////////////////////////////////////////
24
25enum class ScalabilityMode {
26 L1_T2,
27 L1_T2_H,
28 L1_T3,
29 L1_T3_H,
30 L2_T1,
31 L2_T1_H,
32 L2_T1_KEY,
33 L2_T2,
34 L2_T3,
35 L2_T2_H,
36 L2_T2_KEY,
37 L2_T2_KEY_SHIFT,
38 L2_T3_H,
39 L3_T1,
40 L3_T2,
41 L3_T3,
42 L3_T3_KEY,
43 S2_T1,
44 S2_T2,
45 S2_T3,
46 S3_T1,
47 S3_T2,
48 S3_T3,
49 S2_T1_H,
50 S2_T2_H,
51 S2_T3_H,
52 S3_T1_H,
53 S3_T2_H,
54 S3_T3_H
55};
56
57// Publisher //////////////////////////////////////////////////////////////////
58
64struct PublisherCredentials {
65 bool is_valid;
68 std::string stream_name;
69 std::string
70 token;
71 std::string
72 api_url;
73};
74
75
79struct PublisherOption : public Client::Option {
80 /* multisource options */
81 struct {
82 std::optional<std::string> source_id;
84 } multisource;
85
86 struct {
87 std::optional<std::string>
88 video;
89 std::optional<std::string>
90 audio;
91 } codecs;
92
96 bool simulcast{false};
97
98 std::optional<ScalabilityMode> svc_mode;
100 BitrateSettings
101 bitrate_settings;
103 bool record_stream{false};
105 std::optional<int> priority;
106};
107
112class MILLICAST_API Publisher : public virtual Client {
113 public:
114 using Credentials = PublisherCredentials;
115 using Option = PublisherOption;
116
117 struct FirstViewerActive {
118 std::string description;
119 };
120
121 struct LastViewerInactive {
122 std::string description;
123 };
124
134 virtual Promise<void> publish(
135 std::optional<PublisherOption>&& options = std::nullopt) = 0;
136
142 virtual Promise<void> unpublish() = 0;
143
149 [[nodiscard]] virtual Promise<bool> is_publishing() const = 0;
150
156 virtual Promise<void> set_credentials(PublisherCredentials&& creds) = 0;
157
162 [[nodiscard]] virtual Promise<PublisherCredentials> get_credentials()
163 const = 0;
164
165 // to be deprecated
166 virtual Promise<void> add_track(std::weak_ptr<Track> track) = 0;
167
168 // to be deprecated
169 virtual Promise<void> add_track(std::weak_ptr<VideoTrack> track) = 0;
170
171 // to be deprecated
172 virtual Promise<void> add_track(std::weak_ptr<AudioTrack> track) = 0;
173
174 // to be deprecated
175 virtual Promise<void> clear_tracks() = 0;
176
186 virtual Promise<void> set_frame_metadata_handler(
187 EncodedVideoFrameCallback&& callback) = 0;
188
193 static std::unique_ptr<Publisher> create();
194
199 virtual Promise<void> record() = 0;
200
205 virtual Promise<void> unrecord() = 0;
206
212 virtual EventConnectionPtr add_event_handler(
213 EventHandler<FirstViewerActive>&& handler) = 0;
214
220 virtual EventConnectionPtr add_event_handler(
221 EventHandler<LastViewerInactive>&& handler) = 0;
222
229 virtual EventConnectionPtr add_event_handler(
230 EventHandler<StatsEvent>&& handler) = 0;
231
238 virtual EventConnectionPtr add_event_handler(
239 EventHandler<ViewerCount>&& handler) = 0;
240
246 virtual EventConnectionPtr add_event_handler(
247 EventHandler<SignalingError>&& handler) = 0;
248
254 virtual EventConnectionPtr add_event_handler(
255 EventHandler<HttpConnectionError>&& handler) = 0;
256
262 virtual EventConnectionPtr add_event_handler(
263 EventHandler<WebsocketState>&& handler) = 0;
264
271 virtual EventConnectionPtr add_event_handler(
272 EventHandler<PeerConnectionState>&& handler) = 0;
273};
274
275} // namespace millicast
276
277#endif // __cplusplus
278#endif /* MILLICAST_API_PUBLISHER_H */
#define MILLICAST_API
Definition exports.h:51