MillicastSDK 1.8.4
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
84 virtual void on_publishing() = 0;
85
90 virtual void on_publishing_error(const std::string& reason) = 0;
91
92 /* Broadcast events */
93
98 virtual void on_active() = 0;
99
103 virtual void on_inactive() = 0;
104
113 virtual void on_transformable_frame(uint32_t ssrc,
114 uint32_t timestamp,
115 std::vector<uint8_t>& data) {}
116};
117
119 RecordingListener() = default;
120
121 virtual void own_recording_stopped() = 0;
122
123 virtual void failed_to_stop_recording() = 0;
124
125 virtual void own_recording_started() = 0;
126
127 virtual void failed_to_start_recording() = 0;
128
129 virtual ~RecordingListener() = default;
130};
131
136 /* multisource options */
137 struct {
138 std::optional<std::string> source_id;
141
142 struct {
143 std::optional<std::string>
145 std::optional<std::string>
148
152 bool simulcast{false};
153
154 std::optional<ScalabilityMode> svc_mode;
159 bool record_stream{false};
161 std::optional<int> priority;
162};
163
164inline namespace compat {
165
170class MILLICAST_API Publisher : public virtual Client {
171 public:
175
185 virtual bool publish(
186 const std::optional<Publisher::Option>& options = std::nullopt) = 0;
187
194 virtual bool unpublish() = 0;
195
201 [[nodiscard]] virtual bool is_publishing() const = 0;
202
203 virtual void record() = 0;
204 virtual void unrecord() = 0;
205
213 virtual bool set_credentials(const Credentials& creds) = 0;
214 virtual bool set_credentials(Credentials&& creds) = 0;
215
221 [[nodiscard]] virtual Credentials get_credentials() const = 0;
222
228 virtual void add_track(std::weak_ptr<Track> track) = 0;
229 virtual void add_track(std::weak_ptr<VideoTrack> track) = 0;
230 virtual void add_track(std::weak_ptr<AudioTrack> track) = 0;
231
236 virtual void clear_tracks() = 0;
237
243 virtual void set_listener(Publisher::Listener* listener) = 0;
244 virtual void set_recording_listener(RecordingListener* rlistener) = 0;
245
251 static std::unique_ptr<Publisher> create();
252};
253} // namespace compat
254
255namespace promises {
260class MILLICAST_API Publisher : public virtual Client {
261 public:
272 std::optional<PublisherOption>&& options = std::nullopt) = 0;
273
280
286 [[nodiscard]] virtual Promise<bool> is_publishing() const = 0;
287
294
300 const = 0;
301
302 // to be deprecated
303 virtual Promise<void> add_track(std::weak_ptr<Track> track) = 0;
304
305 // to be deprecated
306 virtual Promise<void> add_track(std::weak_ptr<VideoTrack> track) = 0;
307
308 // to be deprecated
309 virtual Promise<void> add_track(std::weak_ptr<AudioTrack> track) = 0;
310
311 // to be deprecated
313
320
327
332 static std::unique_ptr<Publisher> create();
333
334 virtual Promise<void> record() = 0;
335 virtual Promise<void> unrecord() = 0;
336};
337} // namespace promises
338
339} // namespace millicast
340
341#endif /* MILLICAST_API_PUBLISHER_H */
ClientOption Option
Definition client.h:162
Definition promise.h:45
The Client base class.
Definition client.h:194
The Publisher class. Its purpose is to publish media to a Millicast stream.
Definition publisher.h:170
virtual void set_listener(Publisher::Listener *listener)=0
set_listener : set the viewer listener to receive event from the viewer.
virtual bool is_publishing() const =0
Tell if the publisher is publishing.
virtual void clear_tracks()=0
clear_tracks will clear all track added to the publisher.
virtual void add_track(std::weak_ptr< Track > track)=0
Add a track that will be used to publish media (audio or video).
static std::unique_ptr< Publisher > create()
Create a publisher object.
virtual void set_recording_listener(RecordingListener *rlistener)=0
virtual bool publish(const std::optional< Publisher::Option > &options=std::nullopt)=0
Publish a stream to Millicast You must be connected first in order to publish a stream.
virtual void add_track(std::weak_ptr< VideoTrack > track)=0
virtual bool unpublish()=0
Stop sending media to Millicast. The SDK will automatically disconnect after unpublish.
virtual void add_track(std::weak_ptr< AudioTrack > track)=0
virtual bool set_credentials(Credentials &&creds)=0
virtual Credentials get_credentials() const =0
Get the current publisher credentials.
virtual bool set_credentials(const Credentials &creds)=0
Set the publisher credentials.
The Client base class.
Definition client.h:265
The Publisher class. Its purpose is to publish media to a Millicast stream.
Definition publisher.h:260
virtual Promise< bool > is_publishing() const =0
Tell if the publisher is publishing.
virtual Promise< void > set_listener(PublisherListener *listener)=0
set_listener : set the publisher listener to receive event from the publisher.
virtual Promise< void > unrecord()=0
virtual Promise< void > add_track(std::weak_ptr< VideoTrack > track)=0
virtual Promise< void > add_track(std::weak_ptr< Track > track)=0
virtual Promise< void > record()=0
static std::unique_ptr< Publisher > create()
Create a publisher object.
virtual Promise< PublisherCredentials > get_credentials() const =0
Get the current publisher credentials.
virtual Promise< void > clear_tracks()=0
virtual Promise< void > add_track(std::weak_ptr< AudioTrack > track)=0
virtual Promise< void > unpublish()=0
Stop sending media to Millicast. The SDK will automatically disconnect after unpublish.
virtual Promise< void > set_credentials(PublisherCredentials &&creds)=0
Set the publisher credentials.
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 compat::Publisher & get_old_api()=0
Gets the synchronous API for this publisher. Note that it will be deprecated in the future.
#define MILLICAST_API
Definition exports.h:51
Definition capabilities.h:15
ScalabilityMode
Definition publisher.h:23
Allows setting the desired minimum and/or maximum bitrates when publishing a stream....
Definition client.h:51
The Client Listener struct which contains methods that will be called on specific events from a Clien...
Definition client.h:70
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
The PublisherListener struct for the Publisher class. It adds the publishing event on top of the Clie...
Definition publisher.h:79
virtual void on_transformable_frame(uint32_t ssrc, uint32_t timestamp, std::vector< uint8_t > &data)
Called after a frame has been encoded if you need to add data to this frame before the frame is being...
Definition publisher.h:113
virtual void on_publishing_error(const std::string &reason)=0
Called when the was an error while establishing the peerconnection.
virtual void on_active()=0
This event is called when the first viewer starts viewing the stream.
virtual void on_inactive()=0
This event is called when the last viewer stops viewing the stream.
virtual void on_publishing()=0
on_publishing is called when a peerconnection has been established with Millicast and the media excha...
Option specific to the publisher.
Definition publisher.h:135
std::optional< ScalabilityMode > svc_mode
Definition publisher.h:154
std::optional< std::string > video
Definition publisher.h:144
bool record_stream
Definition publisher.h:159
BitrateSettings bitrate_settings
Definition publisher.h:157
std::optional< int > priority
Definition publisher.h:161
std::optional< std::string > audio
Definition publisher.h:146
struct millicast::PublisherOption::@0 multisource
std::optional< std::string > source_id
Definition publisher.h:138
bool simulcast
Enable simulcast (for VP8 and H264 only)
Definition publisher.h:152
struct millicast::PublisherOption::@1 codecs
Definition publisher.h:118
virtual void failed_to_stop_recording()=0
virtual void own_recording_stopped()=0
virtual void failed_to_start_recording()=0
virtual ~RecordingListener()=default
virtual void own_recording_started()=0