OpenTera WebRTC API (C++) 1.2.5
Public Member Functions | Protected Member Functions | List of all members
opentera::StreamClient Class Reference

A signaling client to join a WebRTC room and stream a video source. More...

#include <StreamClient.h>

Inheritance diagram for opentera::StreamClient:
opentera::WebrtcClient

Public Member Functions

 StreamClient (SignalingServerConfiguration signalingServerConfiguration, WebrtcConfiguration webrtcConfiguration, VideoStreamConfiguration videoStreamConfiguration)
 Creates a stream client. More...
 
 StreamClient (SignalingServerConfiguration signalingServerConfiguration, WebrtcConfiguration webrtcConfiguration, VideoStreamConfiguration videoStreamConfiguration, std::shared_ptr< VideoSource > videoSource)
 Creates a stream client. More...
 
 StreamClient (SignalingServerConfiguration signalingServerConfiguration, WebrtcConfiguration webrtcConfiguration, VideoStreamConfiguration videoStreamConfiguration, std::shared_ptr< AudioSource > audioSource)
 Creates a stream client. More...
 
 StreamClient (SignalingServerConfiguration signalingServerConfiguration, WebrtcConfiguration webrtcConfiguration, VideoStreamConfiguration videoStreamConfiguration, std::shared_ptr< VideoSource > videoSource, std::shared_ptr< AudioSource > audioSource)
 Creates a stream client. More...
 
 DECLARE_NOT_COPYABLE (StreamClient)
 
 DECLARE_NOT_MOVABLE (StreamClient)
 
bool isLocalAudioMuted ()
 Indicates if the local audio is muted. More...
 
void muteLocalAudio ()
 Mutes the local audio.
 
void unmuteLocalAudio ()
 Unmutes the local audio.
 
void setLocalAudioMuted (bool muted)
 Mutes or unmutes the local audio. More...
 
bool isRemoteAudioMuted ()
 Indicates if the remote audio is muted. More...
 
void muteRemoteAudio ()
 Mutes the remote audio.
 
void unmuteRemoteAudio ()
 Unmutes the remote audio.
 
void setRemoteAudioMuted (bool muted)
 Mutes or unmutes the remote audio. More...
 
bool isLocalVideoMuted ()
 Indicates if the local video is muted. More...
 
void muteLocalVideo ()
 Mutes the local video.
 
void unmuteLocalVideo ()
 Unmutes the local video.
 
void setLocalVideoMuted (bool muted)
 Mutes or unmutes the local video. More...
 
void setOnAddRemoteStream (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a stream is added. More...
 
void setOnRemoveRemoteStream (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a stream is removed. More...
 
void setOnVideoFrameReceived (const VideoFrameReceivedCallback &callback)
 Sets the callback that is called when a video stream frame is received. More...
 
void setOnEncodedVideoFrameReceived (const EncodedVideoFrameReceivedCallback &callback)
 Sets the callback that is called when an encoded video stream frame is received. More...
 
void setOnAudioFrameReceived (const AudioFrameReceivedCallback &callback)
 Sets the callback that is called when an audio stream frame is received. More...
 
void setOnMixedAudioFrameReceived (const AudioSinkCallback &callback)
 Sets the callback that is called when a mixed audio stream frame is received. More...
 
- Public Member Functions inherited from opentera::WebrtcClient
 WebrtcClient (SignalingServerConfiguration &&signalingServerConfiguration, WebrtcConfiguration &&webrtcConfiguration, VideoStreamConfiguration &&videoStreamConfiguration)
 
 DECLARE_NOT_COPYABLE (WebrtcClient)
 
 DECLARE_NOT_MOVABLE (WebrtcClient)
 
void setTlsVerificationEnabled (bool isEnabled)
 
void connect ()
 Connects the client the signaling server.
 
void close ()
 Closes all client connections (asynchronous).
 
void closeSync ()
 Closes all client connections (synchronous).
 
void callAll ()
 Calls all room clients.
 
void callIds (const std::vector< std::string > &ids)
 Calls the specified clients. More...
 
void hangUpAll ()
 Hangs up all clients.
 
void closeAllRoomPeerConnections ()
 Closes all room peer connections.
 
bool isConnected ()
 Indicates if the client is connected to the signaling server. More...
 
bool isRtcConnected ()
 Indicates if the client is connected to at least one client (RTCPeerConnection). More...
 
std::string id ()
 Returns the client id. More...
 
std::vector< std::string > getConnectedRoomClientIds ()
 Returns the connected room client ids. More...
 
RoomClient getRoomClient (const std::string &id)
 Returns the room client that matches with the specified id. If no room client matches with the id, a default room client is returned. More...
 
std::vector< RoomClientgetRoomClients ()
 Returns the room clients. More...
 
void setOnSignalingConnectionOpened (const std::function< void()> &callback)
 Sets the callback that is called when the signaling connection opens. More...
 
void setOnSignalingConnectionClosed (const std::function< void()> &callback)
 Sets the callback that is called when the signaling connection closes. More...
 
void setOnSignalingConnectionError (const std::function< void(const std::string &)> &callback)
 Sets the callback that is called when a signaling connection error occurs. More...
 
void setOnRoomClientsChanged (const std::function< void(const std::vector< RoomClient > &)> &callback)
 Sets the callback that is called when the room client changes. More...
 
void setCallAcceptor (const std::function< bool(const Client &)> &callback)
 Sets the callback that is used to accept or reject a call. More...
 
void setOnCallRejected (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a call is rejected. More...
 
void setOnClientConnected (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a client peer connection opens. More...
 
void setOnClientDisconnected (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a client peer connection closes. More...
 
void setOnClientConnectionFailed (const std::function< void(const Client &)> &callback)
 Sets the callback that is called when a client peer connection fails. More...
 
void setOnError (const std::function< void(const std::string &error)> &callback)
 Sets the callback that is called when an error occurs. More...
 
void setLogger (const std::function< void(const std::string &message)> &callback)
 Sets the callback that is used to log information. More...
 

Protected Member Functions

std::unique_ptr< PeerConnectionHandlercreatePeerConnectionHandler (const std::string &id, const Client &peerClient, bool isCaller) override
 Creates the peer connection handler for this client. More...
 
- Protected Member Functions inherited from opentera::WebrtcClient
template<class T , class... Types>
void invokeIfCallable (const std::function< T > &f, Types... args)
 
void log (const std::string &message)
 
std::function< void(const std::string &)> getOnErrorFunction ()
 
std::function< void(const Client &)> getOnClientConnectedFunction ()
 
std::function< void(const Client &)> getOnClientDisconnectedFunction ()
 
std::function< void(const Client &)> getOnClientConnectionFailedFunction ()
 
rtc::Thread * getInternalClientThread ()
 

Additional Inherited Members

- Protected Attributes inherited from opentera::WebrtcClient
std::unique_ptr< SignalingClientm_signalingClient
 
rtc::scoped_refptr< webrtc::PeerConnectionFactoryInterface > m_peerConnectionFactory
 
std::map< std::string, std::unique_ptr< PeerConnectionHandler > > m_peerConnectionHandlersById
 
rtc::scoped_refptr< OpenteraAudioDeviceModulem_audioDeviceModule
 
rtc::scoped_refptr< webrtc::AudioProcessing > m_audioProcessing
 

Detailed Description

A signaling client to join a WebRTC room and stream a video source.

Constructor & Destructor Documentation

◆ StreamClient() [1/4]

StreamClient::StreamClient ( SignalingServerConfiguration  signalingServerConfiguration,
WebrtcConfiguration  webrtcConfiguration,
VideoStreamConfiguration  videoStreamConfiguration 
)

Creates a stream client.

Parameters
signalingServerConfigurationThe configuration to connect to the signaling server
webrtcConfigurationThe WebRTC configuration
videoStreamConfigurationThe video stream configuration

◆ StreamClient() [2/4]

StreamClient::StreamClient ( SignalingServerConfiguration  signalingServerConfiguration,
WebrtcConfiguration  webrtcConfiguration,
VideoStreamConfiguration  videoStreamConfiguration,
std::shared_ptr< VideoSource videoSource 
)

Creates a stream client.

Parameters
signalingServerConfigurationThe configuration to connect to the signaling server
webrtcConfigurationThe WebRTC configuration
videoStreamConfigurationThe video stream configuration
videoSourceThe video source that this client will add to the call

◆ StreamClient() [3/4]

StreamClient::StreamClient ( SignalingServerConfiguration  signalingServerConfiguration,
WebrtcConfiguration  webrtcConfiguration,
VideoStreamConfiguration  videoStreamConfiguration,
std::shared_ptr< AudioSource audioSource 
)

Creates a stream client.

Parameters
signalingServerConfigurationThe configuration to connect to the signaling server
webrtcConfigurationThe WebRTC configuration
videoStreamConfigurationThe video stream configuration
audioSourceThe audio source that this client will add to the call

◆ StreamClient() [4/4]

StreamClient::StreamClient ( SignalingServerConfiguration  signalingServerConfiguration,
WebrtcConfiguration  webrtcConfiguration,
VideoStreamConfiguration  videoStreamConfiguration,
std::shared_ptr< VideoSource videoSource,
std::shared_ptr< AudioSource audioSource 
)

Creates a stream client.

Parameters
signalingServerConfigurationThe configuration to connect to the signaling server
webrtcConfigurationThe WebRTC configuration
videoStreamConfigurationThe video stream configuration
videoSourceThe video source that this client will add to the call
audioSourceThe audio source that this client will add to the call

Member Function Documentation

◆ createPeerConnectionHandler()

unique_ptr< PeerConnectionHandler > StreamClient::createPeerConnectionHandler ( const std::string &  id,
const Client peerClient,
bool  isCaller 
)
overrideprotectedvirtual

Creates the peer connection handler for this client.

Parameters
idthis peer id
peerClientthis peer client object
isCallerindicates if this peer initiated the call
Returns
the peer connection handler

Implements opentera::WebrtcClient.

◆ isLocalAudioMuted()

bool opentera::StreamClient::isLocalAudioMuted ( )
inline

Indicates if the local audio is muted.

Returns
true if the local audio is muted.

◆ isLocalVideoMuted()

bool opentera::StreamClient::isLocalVideoMuted ( )
inline

Indicates if the local video is muted.

Returns
true if the local audio is muted.

◆ isRemoteAudioMuted()

bool opentera::StreamClient::isRemoteAudioMuted ( )
inline

Indicates if the remote audio is muted.

Returns
true if the remote audio is muted.

◆ setLocalAudioMuted()

void StreamClient::setLocalAudioMuted ( bool  muted)

Mutes or unmutes the local audio.

Parameters
mutedindicates if the local audio is muted or not

◆ setLocalVideoMuted()

void StreamClient::setLocalVideoMuted ( bool  muted)

Mutes or unmutes the local video.

Parameters
mutedindicates if the local video is muted or not

◆ setOnAddRemoteStream()

void opentera::StreamClient::setOnAddRemoteStream ( const std::function< void(const Client &)> &  callback)
inline

Sets the callback that is called when a stream is added.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the stream
Parameters
callbackThe callback

◆ setOnAudioFrameReceived()

void opentera::StreamClient::setOnAudioFrameReceived ( const AudioFrameReceivedCallback &  callback)
inline

Sets the callback that is called when an audio stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • client: The client of the stream frame
  • audioData: The audio data
  • bitsPerSample: The audio stream sample size (8, 16 or 32 bits)
  • sampleRate: The audio stream sample rate
  • numberOfChannels: The audio stream channel count
  • numberOfFrames: The number of frames
Parameters
callbackThe callback

◆ setOnEncodedVideoFrameReceived()

void opentera::StreamClient::setOnEncodedVideoFrameReceived ( const EncodedVideoFrameReceivedCallback &  callback)
inline

Sets the callback that is called when an encoded video stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • client: The client of the stream frame
  • data: The binary data
  • dataSize: The data size
  • codecType: The codec type
  • isKeyFrame: Indicates if it is a key frame
  • width: The frame width if it is a key frame
  • height: The frame height if it is a key frame
  • timestampUs The timestamp in microseconds
Parameters
callbackThe callback

◆ setOnMixedAudioFrameReceived()

void opentera::StreamClient::setOnMixedAudioFrameReceived ( const AudioSinkCallback &  callback)
inline

Sets the callback that is called when a mixed audio stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • audioData: The audio data
  • bitsPerSample: The audio stream sample size (8, 16 or 32 bits)
  • sampleRate: The audio stream sample rate
  • numberOfChannels: The audio stream channel count
  • numberOfFrames: The number of frames
Parameters
callbackThe callback

◆ setOnRemoveRemoteStream()

void opentera::StreamClient::setOnRemoveRemoteStream ( const std::function< void(const Client &)> &  callback)
inline

Sets the callback that is called when a stream is removed.

The callback is called from the internal client thread. The callback should not block.

Callback parameters:
  • client: The client of the stream
Parameters
callbackThe callback

◆ setOnVideoFrameReceived()

void opentera::StreamClient::setOnVideoFrameReceived ( const VideoFrameReceivedCallback &  callback)
inline

Sets the callback that is called when a video stream frame is received.

The callback is called from a WebRTC processing thread. The callback should not block.

Callback parameters:
  • client: The client of the stream frame
  • bgrImg: The BGR frame image
  • timestampUs The timestamp in microseconds
Parameters
callbackThe callback

◆ setRemoteAudioMuted()

void StreamClient::setRemoteAudioMuted ( bool  muted)

Mutes or unmutes the remote audio.

Parameters
mutedindicates if the remote audio is muted or not

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