Discord Social SDK
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
discordpp::Call Class Reference

Detailed Description

Class that manages an active voice session in a Lobby.

Public Member Functions

 Call (Call &&other) noexcept
 Move constructor for Call.
 
Calloperator= (Call &&other) noexcept
 Move assignment operator for Call.
 
 operator bool () const
 Returns true if the instance contains a valid object.
 
 Call (const Call &other)
 Copy constructor for Call.
 
Calloperator= (const Call &other)
 Copy assignment operator for Call.
 
discordpp::AudioModeType GetAudioMode ()
 Returns whether the call is configured to use voice auto detection or push to talk for the current user.
 
uint64_t GetChannelId () const
 Returns the ID of the lobby with which this call is associated.
 
uint64_t GetGuildId () const
 Returns the ID of the lobby with which this call is associated.
 
bool GetLocalMute (uint64_t userId)
 Returns whether the current user has locally muted the given userId for themselves.
 
std::vector< uint64_t > GetParticipants () const
 Returns a list of all of the user IDs of the participants in the call.
 
float GetParticipantVolume (uint64_t userId)
 Returns the locally set playout volume of the given userId.
 
bool GetPTTActive ()
 Returns whether push to talk is currently active, meaning the user is currently pressing their configured push to talk key.
 
uint32_t GetPTTReleaseDelay ()
 Returns the time that PTT is active after the user releases the PTT key and SetPTTActive(false) is called.
 
bool GetSelfDeaf ()
 Returns whether the current user is deafened.
 
bool GetSelfMute ()
 Returns whether the current user's microphone is muted.
 
discordpp::Call::Status GetStatus () const
 Returns the current call status.
 
discordpp::VADThresholdSettings GetVADThreshold () const
 Returns the current configuration for void auto detection thresholds. See the description of the VADThreshold struct for specifics.
 
std::optional< discordpp::VoiceStateHandleGetVoiceStateHandle (uint64_t userId) const
 Returns a reference to the VoiceStateHandle for the user ID of the given call participant.
 
void SetAudioMode (discordpp::AudioModeType audioMode)
 Sets whether to use voice auto detection or push to talk for the current user on this call.
 
void SetLocalMute (uint64_t userId, bool mute)
 Locally mutes the given userId, so that the current user cannot hear them anymore.
 
void SetOnVoiceStateChangedCallback (discordpp::Call::OnVoiceStateChanged cb)
 Sets a callback function to generally be invoked whenever a field on a VoiceStateHandle object for a user would have changed.
 
void SetParticipantChangedCallback (discordpp::Call::OnParticipantChanged cb)
 Sets a callback function to be invoked whenever some joins or leaves a voice call.
 
void SetParticipantVolume (uint64_t userId, float volume)
 Locally changes the playout volume of the given userId.
 
void SetPTTActive (bool active)
 When push to talk is enabled, this should be called whenever the user pushes or releases their configured push to talk key. This key must be configured in the game, the SDK does not handle keybinds itself.
 
void SetPTTReleaseDelay (uint32_t releaseDelayMs)
 If set, extends the time that PTT is active after the user releases the PTT key and SetPTTActive(false) is called.
 
void SetSelfDeaf (bool deaf)
 Mutes all audio from the currently active call for the current user. They will not be able to hear any other participants, and no other participants will be able to hear the current user either.
 
void SetSelfMute (bool mute)
 Mutes the current user's microphone so that no other participant in their active calls can hear them.
 
void SetSpeakingStatusChangedCallback (discordpp::Call::OnSpeakingStatusChanged cb)
 Sets a callback function to be invoked whenever a user starts or stops speaking and is passed in the userId and whether they are currently speaking.
 
void SetStatusChangedCallback (discordpp::Call::OnStatusChanged cb)
 Sets a callback function to be invoked when the call status changes, such as when it fully connects or starts reconnecting.
 
void SetVADThreshold (bool automatic, float threshold)
 Customizes the void auto detection thresholds for picking up activity from a user's mic.
 

Public Types

enum class  Error {
  None = 0 , SignalingConnectionFailed = 1 , SignalingUnexpectedClose = 2 , VoiceConnectionFailed = 3 ,
  JoinTimeout = 4 , Forbidden = 5
}
 Enum that represents any network errors with the Call. More...
 
enum class  Status {
  Disconnected = 0 , Joining = 1 , Connecting = 2 , SignalingConnected = 3 ,
  Connected = 4 , Reconnecting = 5 , Disconnecting = 6
}
 Enum that respresents the state of the Call's network connection. More...
 
using OnVoiceStateChanged = std::function<void(uint64_t userId)>
 Callback function for Call::SetOnVoiceStateChangedCallback.
 
using OnParticipantChanged = std::function<void(uint64_t userId, bool added)>
 Callback function for Call::SetParticipantChangedCallback.
 
using OnSpeakingStatusChanged = std::function<void(uint64_t userId, bool isPlayingSound)>
 Callback function for Call::SetSpeakingStatusChangedCallback.
 
using OnStatusChanged
 Callback function for Call::SetStatusChangedCallback.
 

Static Public Member Functions

static std::string ErrorToString (discordpp::Call::Error type)
 Converts the Error enum to a string.
 
static std::string StatusToString (discordpp::Call::Status type)
 Converts the Status enum to a string.
 

Static Public Attributes

static const Call nullobj
 Uninitialized instance of Call.
 

Member Typedef Documentation

◆ OnParticipantChanged

using discordpp::Call::OnParticipantChanged = std::function<void(uint64_t userId, bool added)>

Callback function for Call::SetParticipantChangedCallback.

◆ OnSpeakingStatusChanged

using discordpp::Call::OnSpeakingStatusChanged = std::function<void(uint64_t userId, bool isPlayingSound)>

◆ OnStatusChanged

Initial value:
std::function<
void(discordpp::Call::Status status, discordpp::Call::Error error, int32_t errorDetail)>
Error
Enum that represents any network errors with the Call.
Definition discordpp.h:1725
Status
Enum that respresents the state of the Call's network connection.
Definition discordpp.h:1747

Callback function for Call::SetStatusChangedCallback.

◆ OnVoiceStateChanged

using discordpp::Call::OnVoiceStateChanged = std::function<void(uint64_t userId)>

Callback function for Call::SetOnVoiceStateChangedCallback.

Member Enumeration Documentation

◆ Error

enum class discordpp::Call::Error
strong

Enum that represents any network errors with the Call.

Enumerator
None 

None.

SignalingConnectionFailed 

SignalingConnectionFailed.

SignalingUnexpectedClose 

SignalingUnexpectedClose.

VoiceConnectionFailed 

VoiceConnectionFailed.

JoinTimeout 

JoinTimeout.

Forbidden 

Forbidden.

◆ Status

enum class discordpp::Call::Status
strong

Enum that respresents the state of the Call's network connection.

Enumerator
Disconnected 

Disconnected.

Joining 

Joining.

Connecting 

Connecting.

SignalingConnected 

SignalingConnected.

Connected 

Connected.

Reconnecting 

Reconnecting.

Disconnecting 

Disconnecting.

Constructor & Destructor Documentation

◆ Call() [1/2]

discordpp::Call::Call ( Call && other)
noexcept

Move constructor for Call.

◆ Call() [2/2]

discordpp::Call::Call ( const Call & other)

Copy constructor for Call.

Member Function Documentation

◆ ErrorToString()

static std::string discordpp::Call::ErrorToString ( discordpp::Call::Error type)
static

Converts the Error enum to a string.

◆ GetAudioMode()

discordpp::AudioModeType discordpp::Call::GetAudioMode ( )

Returns whether the call is configured to use voice auto detection or push to talk for the current user.

◆ GetChannelId()

uint64_t discordpp::Call::GetChannelId ( ) const

Returns the ID of the lobby with which this call is associated.

◆ GetGuildId()

uint64_t discordpp::Call::GetGuildId ( ) const

Returns the ID of the lobby with which this call is associated.

◆ GetLocalMute()

bool discordpp::Call::GetLocalMute ( uint64_t userId)

Returns whether the current user has locally muted the given userId for themselves.

◆ GetParticipants()

std::vector< uint64_t > discordpp::Call::GetParticipants ( ) const

Returns a list of all of the user IDs of the participants in the call.

◆ GetParticipantVolume()

float discordpp::Call::GetParticipantVolume ( uint64_t userId)

Returns the locally set playout volume of the given userId.

Does not affect the volume of this user for any other connected clients. The range of volume is [0, 200], where 100 indicate default audio volume of the playback device.

◆ GetPTTActive()

bool discordpp::Call::GetPTTActive ( )

Returns whether push to talk is currently active, meaning the user is currently pressing their configured push to talk key.

◆ GetPTTReleaseDelay()

uint32_t discordpp::Call::GetPTTReleaseDelay ( )

Returns the time that PTT is active after the user releases the PTT key and SetPTTActive(false) is called.

◆ GetSelfDeaf()

bool discordpp::Call::GetSelfDeaf ( )

Returns whether the current user is deafened.

◆ GetSelfMute()

bool discordpp::Call::GetSelfMute ( )

Returns whether the current user's microphone is muted.

◆ GetStatus()

discordpp::Call::Status discordpp::Call::GetStatus ( ) const

Returns the current call status.

A call is not ready to be used until the status changes to "Connected".

◆ GetVADThreshold()

discordpp::VADThresholdSettings discordpp::Call::GetVADThreshold ( ) const

Returns the current configuration for void auto detection thresholds. See the description of the VADThreshold struct for specifics.

◆ GetVoiceStateHandle()

std::optional< discordpp::VoiceStateHandle > discordpp::Call::GetVoiceStateHandle ( uint64_t userId) const

Returns a reference to the VoiceStateHandle for the user ID of the given call participant.

The VoiceStateHandle allows other users to know if the target user has muted or deafened themselves.

◆ operator bool()

discordpp::Call::operator bool ( ) const
inline

Returns true if the instance contains a valid object.

◆ operator=() [1/2]

Call & discordpp::Call::operator= ( Call && other)
noexcept

Move assignment operator for Call.

◆ operator=() [2/2]

Call & discordpp::Call::operator= ( const Call & other)

Copy assignment operator for Call.

◆ SetAudioMode()

void discordpp::Call::SetAudioMode ( discordpp::AudioModeType audioMode)

Sets whether to use voice auto detection or push to talk for the current user on this call.

If using push to talk you should call SetPTTActive() whenever the user presses their confused push to talk key.

◆ SetLocalMute()

void discordpp::Call::SetLocalMute ( uint64_t userId,
bool mute )

Locally mutes the given userId, so that the current user cannot hear them anymore.

Does not affect whether the given user is muted for any other connected clients.

◆ SetOnVoiceStateChangedCallback()

void discordpp::Call::SetOnVoiceStateChangedCallback ( discordpp::Call::OnVoiceStateChanged cb)

Sets a callback function to generally be invoked whenever a field on a VoiceStateHandle object for a user would have changed.

For example when a user mutes themselves, all other connected clients will invoke the VoiceStateChanged callback, because the "self mute" field will be true now. The callback is generally not invoked when users join or leave channels.

◆ SetParticipantChangedCallback()

void discordpp::Call::SetParticipantChangedCallback ( discordpp::Call::OnParticipantChanged cb)

Sets a callback function to be invoked whenever some joins or leaves a voice call.

◆ SetParticipantVolume()

void discordpp::Call::SetParticipantVolume ( uint64_t userId,
float volume )

Locally changes the playout volume of the given userId.

Does not affect the volume of this user for any other connected clients. The range of volume is [0, 200], where 100 indicate default audio volume of the playback device.

◆ SetPTTActive()

void discordpp::Call::SetPTTActive ( bool active)

When push to talk is enabled, this should be called whenever the user pushes or releases their configured push to talk key. This key must be configured in the game, the SDK does not handle keybinds itself.

◆ SetPTTReleaseDelay()

void discordpp::Call::SetPTTReleaseDelay ( uint32_t releaseDelayMs)

If set, extends the time that PTT is active after the user releases the PTT key and SetPTTActive(false) is called.

Defaults to no release delay, but we recommend setting to 20ms, which is what Discord uses.

◆ SetSelfDeaf()

void discordpp::Call::SetSelfDeaf ( bool deaf)

Mutes all audio from the currently active call for the current user. They will not be able to hear any other participants, and no other participants will be able to hear the current user either.

◆ SetSelfMute()

void discordpp::Call::SetSelfMute ( bool mute)

Mutes the current user's microphone so that no other participant in their active calls can hear them.

◆ SetSpeakingStatusChangedCallback()

void discordpp::Call::SetSpeakingStatusChangedCallback ( discordpp::Call::OnSpeakingStatusChanged cb)

Sets a callback function to be invoked whenever a user starts or stops speaking and is passed in the userId and whether they are currently speaking.

It can be invoked in other cases as well, such as if the priority speaker changes or if the user plays a soundboard sound.

◆ SetStatusChangedCallback()

void discordpp::Call::SetStatusChangedCallback ( discordpp::Call::OnStatusChanged cb)

Sets a callback function to be invoked when the call status changes, such as when it fully connects or starts reconnecting.

◆ SetVADThreshold()

void discordpp::Call::SetVADThreshold ( bool automatic,
float threshold )

Customizes the void auto detection thresholds for picking up activity from a user's mic.

  • When automatic is set to True, Discord will automatically detect the appropriate threshold to use.
  • When automatic is set to False, the given threshold value will be used. Threshold has a range of -100, 0, and defaults to -60.

◆ StatusToString()

static std::string discordpp::Call::StatusToString ( discordpp::Call::Status type)
static

Converts the Status enum to a string.

Member Data Documentation

◆ nullobj

const Call discordpp::Call::nullobj
static

Uninitialized instance of Call.