MillicastSDK 2.0.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
12
13namespace millicast {
14
15// Forward declarations ///////////////////////////////////////////////////////
16
17class VideoTrack;
18class AudioTrack;
19class Track;
20
21// Scalability mode ///////////////////////////////////////////////////////////
22
23enum class ScalabilityMode {
24 L1_T2,
25 L1_T2_H,
26 L1_T3,
27 L1_T3_H,
28 L2_T1,
29 L2_T1_H,
31 L2_T2,
32 L2_T3,
33 L2_T2_H,
36 L2_T3_H,
37 L3_T1,
38 L3_T2,
39 L3_T3,
41 S2_T1,
42 S2_T2,
43 S2_T3,
44 S3_T1,
45 S3_T2,
46 S3_T3,
47 S2_T1_H,
48 S2_T2_H,
49 S2_T3_H,
50 S3_T1_H,
51 S3_T2_H,
53};
54
55// Publisher //////////////////////////////////////////////////////////////////
56
63 bool is_valid;
66 std::string stream_name;
67 std::string
69 std::string
71};
72
73
78 /* multisource options */
79 struct {
80 std::optional<std::string> source_id;
83
84 struct {
85 std::optional<std::string>
87 std::optional<std::string>
90
94 bool simulcast{false};
95
96 std::optional<ScalabilityMode> svc_mode;
101 bool record_stream{false};
103 std::optional<int> priority;
104};
105
110class MILLICAST_API Publisher : public virtual Client {
111 public:
114
116 std::string description;
117 };
118
120 std::string description;
121 };
122
133 std::optional<PublisherOption>&& options = std::nullopt) = 0;
134
141
147 [[nodiscard]] virtual Promise<bool> is_publishing() const = 0;
148
155
161 const = 0;
162
163 // to be deprecated
164 virtual Promise<void> add_track(std::weak_ptr<Track> track) = 0;
165
166 // to be deprecated
167 virtual Promise<void> add_track(std::weak_ptr<VideoTrack> track) = 0;
168
169 // to be deprecated
170 virtual Promise<void> add_track(std::weak_ptr<AudioTrack> track) = 0;
171
172 // to be deprecated
174
185 EncodedVideoFrameCallback&& callback) = 0;
186
191 static std::unique_ptr<Publisher> create();
192
197 virtual Promise<void> record() = 0;
198
203 virtual Promise<void> unrecord() = 0;
204
211 EventHandler<FirstViewerActive>&& handler) = 0;
212
220
228 EventHandler<StatsEvent>&& handler) = 0;
229
237 EventHandler<ViewerCount>&& handler) = 0;
238
245 EventHandler<SignalingError>&& handler) = 0;
246
254
261 EventHandler<WebsocketState>&& handler) = 0;
262
271};
272
273} // namespace millicast
274
275#endif /* MILLICAST_API_PUBLISHER_H */
The Client base class.
Definition client.h:142
Definition promise.h:45
The Publisher class. Its purpose is to publish media to a Millicast stream.
Definition publisher.h:110
virtual Promise< void > record()=0
Starts recording of the published stream.
virtual Promise< void > add_track(std::weak_ptr< Track > track)=0
virtual EventConnectionPtr add_event_handler(EventHandler< PeerConnectionState > &&handler)=0
Attach the event handler for the PeerConnectionState change event.
virtual Promise< void > unrecord()=0
Stops recording of the published stream.
virtual Promise< PublisherCredentials > get_credentials() const =0
Get the current publisher credentials.
static std::unique_ptr< Publisher > create()
Create a publisher object.
virtual Promise< void > add_track(std::weak_ptr< VideoTrack > track)=0
virtual EventConnectionPtr add_event_handler(EventHandler< FirstViewerActive > &&handler)=0
Attach the event handler for when first viewer is active in stream.
virtual EventConnectionPtr add_event_handler(EventHandler< StatsEvent > &&handler)=0
Attach the event handler for the StatsEvent containing the StatsReport..
virtual EventConnectionPtr add_event_handler(EventHandler< WebsocketState > &&handler)=0
Attach the event handler for the WebsocketState change event.
virtual Promise< bool > is_publishing() const =0
Tell if the publisher is publishing.
virtual Promise< void > publish(std::optional< PublisherOption > &&options=std::nullopt)=0
Publish a stream to Millicast You must be connected first in order to publish a stream.
virtual Promise< void > unpublish()=0
Stop sending media to Millicast. The SDK will automatically disconnect after unpublish.
virtual Promise< void > set_frame_metadata_handler(EncodedVideoFrameCallback &&callback)=0
Set a callback to receive encoded video frames that you can embed metadata into.
virtual EventConnectionPtr add_event_handler(EventHandler< LastViewerInactive > &&handler)=0
Attach the event handler for when last viewer has left stream.
virtual EventConnectionPtr add_event_handler(EventHandler< SignalingError > &&handler)=0
Attach the event handler for the SignalingError event.
virtual Promise< void > add_track(std::weak_ptr< AudioTrack > track)=0
virtual EventConnectionPtr add_event_handler(EventHandler< ViewerCount > &&handler)=0
Attach the event handler for the ViewerCount event emitted when the viewer count has changed.
virtual Promise< void > set_credentials(PublisherCredentials &&creds)=0
Set the publisher credentials.
virtual Promise< void > clear_tracks()=0
virtual EventConnectionPtr add_event_handler(EventHandler< HttpConnectionError > &&handler)=0
Attach the event handler for the HttpConnectionError event.
#define MILLICAST_API
Definition exports.h:51
Definition capabilities.h:15
ScalabilityMode
Definition publisher.h:23
std::function< void(const EventTypes &...)> EventHandler
Definition event_handling.h:10
std::unique_ptr< EventConnection > EventConnectionPtr
Definition event_handling.h:31
std::function< void(EncodedVideoFrame &)> EncodedVideoFrameCallback
Definition encoded_frames.h:116
Allows setting the desired minimum and/or maximum bitrates when publishing a stream....
Definition client.h:53
The ClientOption struct allows to setup the millicast connection.
Definition client.h:84
Definition publisher.h:115
std::string description
Definition publisher.h:116
std::string description
Definition publisher.h:120
The Credentials struct represent the credentials need to be able to connect and publish to a Millicas...
Definition publisher.h:62
std::string api_url
Definition publisher.h:70
bool is_valid
Definition publisher.h:63
std::string token
Definition publisher.h:68
std::string stream_name
Definition publisher.h:66
Option specific to the publisher.
Definition publisher.h:77
std::optional< ScalabilityMode > svc_mode
Definition publisher.h:96
std::optional< std::string > video
Definition publisher.h:86
bool record_stream
Definition publisher.h:101
BitrateSettings bitrate_settings
Definition publisher.h:99
std::optional< int > priority
Definition publisher.h:103
std::optional< std::string > audio
Definition publisher.h:88
struct millicast::PublisherOption::@0 multisource
std::optional< std::string > source_id
Definition publisher.h:80
bool simulcast
Enable simulcast (for VP8 and H264 only)
Definition publisher.h:94
struct millicast::PublisherOption::@1 codecs