MillicastSDK 2.0.0
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
millicast::Publisher Class Referenceabstract

The Publisher class. Its purpose is to publish media to a Millicast stream. More...

#include <publisher.h>

Inheritance diagram for millicast::Publisher:
Inheritance graph
[legend]
Collaboration diagram for millicast::Publisher:
Collaboration graph
[legend]

Classes

struct  FirstViewerActive
 
struct  LastViewerInactive
 

Public Types

using Credentials = PublisherCredentials
 
using Option = PublisherOption
 
- Public Types inherited from millicast::Client
enum class  ConnectionState {
  IDLE , CONNECTING , CONNECTED , RECONNECTING ,
  DISCONNECTING , FAILED
}
 The Connection State enum describes the possible states that a network connecting socket can be in. This enum will be used in the WebsocketState and PeerConnectionState events to describe the state of those network mediums. More...
 
- Public Types inherited from millicast::ClientBase
using ConnectionOptions = ClientConnectionOptions
 
using Option = ClientOption
 
using JsonData = ClientJsonData
 

Public Member Functions

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< bool > is_publishing () const =0
 Tell if the publisher is publishing.
 
virtual Promise< void > set_credentials (PublisherCredentials &&creds)=0
 Set the publisher credentials.
 
virtual Promise< PublisherCredentialsget_credentials () const =0
 Get the current publisher credentials.
 
virtual Promise< void > add_track (std::weak_ptr< Track > track)=0
 
virtual Promise< void > add_track (std::weak_ptr< VideoTrack > track)=0
 
virtual Promise< void > add_track (std::weak_ptr< AudioTrack > track)=0
 
virtual Promise< void > clear_tracks ()=0
 
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 Promise< void > record ()=0
 Starts recording of the published stream.
 
virtual Promise< void > unrecord ()=0
 Stops recording of the published stream.
 
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< LastViewerInactive > &&handler)=0
 Attach the event handler for when last viewer has left 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< ViewerCount > &&handler)=0
 Attach the event handler for the ViewerCount event emitted when the viewer count has changed.
 
virtual EventConnectionPtr add_event_handler (EventHandler< SignalingError > &&handler)=0
 Attach the event handler for the SignalingError event.
 
virtual EventConnectionPtr add_event_handler (EventHandler< HttpConnectionError > &&handler)=0
 Attach the event handler for the HttpConnectionError event.
 
virtual EventConnectionPtr add_event_handler (EventHandler< WebsocketState > &&handler)=0
 Attach the event handler for the WebsocketState change event.
 
virtual EventConnectionPtr add_event_handler (EventHandler< PeerConnectionState > &&handler)=0
 Attach the event handler for the PeerConnectionState change event.
 
- Public Member Functions inherited from millicast::Client
virtual Promise< void > connect (std::optional< ConnectionOptions > &&connection_options)=0
 Connect and open a websocket connection with the Millicast platform.
 
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< bool > is_connected () const =0
 is_connected
 
virtual Promise< void > disconnect ()=0
 Disconnect from Millicast. The websocket connection to Millicast will no longer be active after disconnect is complete. If the client is currently publishing/subscribing, the SDK will first stop the publishing/subscribing before disconnecting.
 
virtual Promise< void > enable_stats (bool enable)=0
 Enable the rtc stats collecting. The stats are collected once the client is either publishing or subscribed.
 
- Public Member Functions inherited from millicast::ClientBase
virtual ~ClientBase ()=default
 

Static Public Member Functions

static std::unique_ptr< Publishercreate ()
 Create a publisher object.
 
- Static Public Member Functions inherited from millicast::ClientBase
static std::list< std::string > get_supported_video_codecs ()
 get_supported_video_codecs returns the list of the supported video codecs.
 
static std::list< std::string > get_supported_audio_codecs ()
 get_supported_audio_codecs returns the list of the supported audio codecs.
 
static void cleanup ()
 Clean and free the memory of dynamic objects.
 

Detailed Description

The Publisher class. Its purpose is to publish media to a Millicast stream.

Member Typedef Documentation

◆ Credentials

◆ Option

Member Function Documentation

◆ add_event_handler() [1/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< FirstViewerActive > &&  handler)
pure virtual

Attach the event handler for when first viewer is active in stream.

Parameters
handlerthe callback to invoke when first viewer is active.
Returns
event connection

◆ add_event_handler() [2/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< HttpConnectionError > &&  handler)
pure virtual

Attach the event handler for the HttpConnectionError event.

Parameters
handlerthe callback to invoke when an http error has occured..
Returns
event connection

◆ add_event_handler() [3/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< LastViewerInactive > &&  handler)
pure virtual

Attach the event handler for when last viewer has left stream.

Parameters
handlerthe callback to invoke when last viewer has left.
Returns
event connection

◆ add_event_handler() [4/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< PeerConnectionState > &&  handler)
pure virtual

Attach the event handler for the PeerConnectionState change event.

Parameters
handlerThe callback to invoke when the peer connection state has changed.
Returns
event connection

◆ add_event_handler() [5/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< SignalingError > &&  handler)
pure virtual

Attach the event handler for the SignalingError event.

Parameters
handlerthe callback to invoke when signaling error has occured..
Returns
event connection

◆ add_event_handler() [6/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< StatsEvent > &&  handler)
pure virtual

Attach the event handler for the StatsEvent containing the StatsReport..

Parameters
handlerthe callback to invoke when a StatsEvent is ready.
Returns
event connection

◆ add_event_handler() [7/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< ViewerCount > &&  handler)
pure virtual

Attach the event handler for the ViewerCount event emitted when the viewer count has changed.

Parameters
handlerthe callback to invoke publisher has stopped stream.
Returns
event connection

◆ add_event_handler() [8/8]

virtual EventConnectionPtr millicast::Publisher::add_event_handler ( EventHandler< WebsocketState > &&  handler)
pure virtual

Attach the event handler for the WebsocketState change event.

Parameters
handlerThe callback to invoke when the websocket state has changed.
Returns
event connection

◆ add_track() [1/3]

virtual Promise< void > millicast::Publisher::add_track ( std::weak_ptr< AudioTrack track)
pure virtual

◆ add_track() [2/3]

virtual Promise< void > millicast::Publisher::add_track ( std::weak_ptr< Track track)
pure virtual

◆ add_track() [3/3]

virtual Promise< void > millicast::Publisher::add_track ( std::weak_ptr< VideoTrack track)
pure virtual

◆ clear_tracks()

virtual Promise< void > millicast::Publisher::clear_tracks ( )
pure virtual

◆ create()

static std::unique_ptr< Publisher > millicast::Publisher::create ( )
static

Create a publisher object.

Returns
A publisher object.

◆ get_credentials()

virtual Promise< PublisherCredentials > millicast::Publisher::get_credentials ( ) const
pure virtual

Get the current publisher credentials.

Returns
Promise object providing asynchronous status.

◆ is_publishing()

virtual Promise< bool > millicast::Publisher::is_publishing ( ) const
pure virtual

Tell if the publisher is publishing.

Returns
Promise object providing asynchronous status. The completion callback will be invoked with true if publishing, and with false if not.

◆ publish()

virtual Promise< void > millicast::Publisher::publish ( std::optional< PublisherOption > &&  options = std::nullopt)
pure virtual

Publish a stream to Millicast You must be connected first in order to publish a stream.

Parameters
optionspublishing options (optional)
Returns
Promise object providing asynchronous status.
Remarks
when the success callback on the returned promise is invoked, the Publisher is publishing. There's no need to implement listener's on_publishing method.

◆ record()

virtual Promise< void > millicast::Publisher::record ( )
pure virtual

Starts recording of the published stream.

Returns
a Promise that resolves to the operation's state.

◆ set_credentials()

virtual Promise< void > millicast::Publisher::set_credentials ( PublisherCredentials &&  creds)
pure virtual

Set the publisher credentials.

Parameters
credsThe credentials
Returns
Promise object providing asynchronous status.

◆ set_frame_metadata_handler()

virtual Promise< void > millicast::Publisher::set_frame_metadata_handler ( EncodedVideoFrameCallback &&  callback)
pure virtual

Set a callback to receive encoded video frames that you can embed metadata into.

Remarks
This API only works when using H264 as a codec. This callback will not be invoked for other codecs.
Parameters
callbacka function callback that accepts EncodedVideoFrame
Returns
a Promise that resolves to the operation's state.

◆ unpublish()

virtual Promise< void > millicast::Publisher::unpublish ( )
pure virtual

Stop sending media to Millicast. The SDK will automatically disconnect after unpublish.

Returns
Promise object providing asynchronous status.

◆ unrecord()

virtual Promise< void > millicast::Publisher::unrecord ( )
pure virtual

Stops recording of the published stream.

Returns
a Promise that resolves to the operation's state.

The documentation for this class was generated from the following file: