Photon C++ Client API  5.0.7.3
Public Types | Public Member Functions | List of all members
VoiceClient Class Reference

Voice client interacts with other clients on network via IVoiceTransport. More...

Public Types

typedef void() RemoteVoiceInfoCallback(void *opaque, int channelId, int playerId, nByte voiceId, const VoiceInfo &voiceInfo, RemoteVoiceOptions &options)
 

Public Member Functions

 VoiceClient (IVoiceTransport *transport)
 Creates VoiceClient instance More...
 
void setOnRemoteVoiceInfoAction (void *opaque, RemoteVoiceInfoCallback *callback)
 Register a method to be called when remote voice info arrived (after join or new new remote voice creation). Metod parameters: (int channelId, int playerId, byte voiceId, VoiceInfo voiceInfo, ref RemoteVoiceOptions options); More...
 
void service (void)
 This method dispatches all available incoming commands and then sends this client's outgoing commands. Call this method regularly (2..20 times a second). More...
 
IVoiceTransportgetTransport (void) const
 
void forEachLocalVoice (void *opaque, void(*op)(void *, const LocalVoice &)) const
 
void forEachLocalVoiceInChannel (int channelId, void *opaque, void(*op)(void *, const LocalVoice &)) const
 Returns copies of all local voices for given channel. More...
 
Common::JVector< RemoteVoiceInfogetRemoteVoiceInfos (void) const
 Iterates through all remote voices infos. More...
 
int getFramesLost (void) const
 Lost frames counter. More...
 
int getFramesReceived (void) const
 Received frames counter. More...
 
int getFramesSent (void) const
 Sent frames counter. More...
 
int getFramesSentBytes (void) const
 Sent frames bytes counter. More...
 
int getRoundTripTime (void) const
 Average time required voice packet to return to sender. More...
 
int getRoundTripTimeVariance (void) const
 Average round trip time variation. More...
 
bool getSuppressInfoDuplicateWarning (void) const
 Do not log warning when duplicate info received. More...
 
void setSuppressInfoDuplicateWarning (bool yes)
 
int getDebugLostPercent (void) const
 Lost frames simulation ratio. More...
 
void setDebugLostPercent (int debugLostPercent)
 
LocalVoicecreateLocalVoice (const VoiceInfo &voiceInfo, int channelId=0, Common::Helpers::SharedPointer< IEncoder > encoder=static_cast< IEncoder * >(NULL))
 Creates basic outgoing stream w/o data processing support. Provided encoder should generate output data stream. More...
 
template<typename T >
LocalVoiceFramed< T > * createLocalVoiceFramed (const VoiceInfo &voiceInfo, int frameSize, int channelId=0, Common::Helpers::SharedPointer< IEncoder > encoder=static_cast< IEncoder * >(NULL))
 Creates outgoing stream consuming sequence of values passed in array buffers of arbitrary length which repacked in frames of constant length for further processing and encoding. More...
 
template<typename T >
LocalVoiceAudio< T > * createLocalVoiceAudio (const VoiceInfo &voiceInfo, const IAudioDesc &audioSourceDesc, int channelId=0, Common::Helpers::SharedPointer< IEncoder > encoder=static_cast< IEncoder * >(NULL))
 Creates outgoing audio stream. Adds audio specific features (e.g. resampling, level meter) to processing pipeline and to returning stream handler. More...
 
template<typename T >
LocalVoiceAudio< T > * createLocalVoiceAudioFromSource (const VoiceInfo &voiceInfo, IAudioPusher< T > *source, int channelId=0, Common::Helpers::SharedPointer< IEncoder > encoder=static_cast< IEncoder * >(NULL))
 Creates outgoing audio stream. Adds audio specific features (e.g. resampling, level meter) to processing pipeline and to returning stream handler. More...
 
void removeLocalVoice (LocalVoice &voice)
 Removes local voice (outgoing data stream).

Parameters
voiceHandler of outgoing stream to be removed.
More...
 
Common::JString channelStr (int channelId)
 
Common::JString playerStr (int playerId)
 
void onJoinChannel (int channel)
 
void onLeaveChannel (int channel)
 
void onLeaveAllChannels ()
 
void onPlayerJoin (int channelId, int playerId)
 
void onPlayerLeave (int channelId, int playerId)
 
void onVoiceInfo (int channelId, int playerId, nByte voiceId, nByte eventNumber, const VoiceInfo &info)
 
void onVoiceRemove (int channelId, int playerId, const Common::JVector< nByte > &voiceIds)
 
nByte getGlobalInterestGroup (void) const
 
void setGlobalInterestGroup (nByte group)
 
void onFrame (int channelId, int playerId, nByte voiceId, nByte evNumber, Buffer< nByte > receivedBytes, bool isLocalPlayer)
 

Detailed Description

Voice client interacts with other clients on network via IVoiceTransport.

Constructor & Destructor Documentation

◆ VoiceClient()

VoiceClient ( IVoiceTransport transport)

Creates VoiceClient instance

Member Function Documentation

◆ setOnRemoteVoiceInfoAction()

void setOnRemoteVoiceInfoAction ( void *  opaque,
VoiceClient::RemoteVoiceInfoCallback *  callback 
)

Register a method to be called when remote voice info arrived (after join or new new remote voice creation). Metod parameters: (int channelId, int playerId, byte voiceId, VoiceInfo voiceInfo, ref RemoteVoiceOptions options);

◆ service()

void service ( void  )

This method dispatches all available incoming commands and then sends this client's outgoing commands. Call this method regularly (2..20 times a second).

◆ forEachLocalVoiceInChannel()

void forEachLocalVoiceInChannel ( int  channelId,
void *  opaque,
void(*)(void *, const LocalVoice &)  op 
) const

Returns copies of all local voices for given channel.

◆ getRemoteVoiceInfos()

JVector< RemoteVoiceInfo > getRemoteVoiceInfos ( void  ) const

Iterates through all remote voices infos.

◆ getFramesLost()

int getFramesLost ( void  ) const

Lost frames counter.

◆ getFramesReceived()

int getFramesReceived ( void  ) const

Received frames counter.

◆ getFramesSent()

int getFramesSent ( void  ) const

Sent frames counter.

◆ getFramesSentBytes()

int getFramesSentBytes ( void  ) const

Sent frames bytes counter.

◆ getRoundTripTime()

int getRoundTripTime ( void  ) const

Average time required voice packet to return to sender.

◆ getRoundTripTimeVariance()

int getRoundTripTimeVariance ( void  ) const

Average round trip time variation.

◆ getSuppressInfoDuplicateWarning()

bool getSuppressInfoDuplicateWarning ( void  ) const

Do not log warning when duplicate info received.

◆ getDebugLostPercent()

int getDebugLostPercent ( void  ) const

Lost frames simulation ratio.

◆ createLocalVoice()

LocalVoice * createLocalVoice ( const VoiceInfo voiceInfo,
int  channelId = 0,
Common::Helpers::SharedPointer< IEncoder encoder = static_cast<IEncoder*>(NULL) 
)

Creates basic outgoing stream w/o data processing support. Provided encoder should generate output data stream.

Parameters
voiceInfoOutgoing stream parameters. Set applicable fields to read them by encoder and by receiving client when voice created.
channelIdTransport channel specific to transport.
encoderEncoder producing the stream.
Returns
Outgoing stream handler.

◆ createLocalVoiceFramed()

LocalVoiceFramed< T > * createLocalVoiceFramed ( const VoiceInfo voiceInfo,
int  frameSize,
int  channelId = 0,
Common::Helpers::SharedPointer< IEncoder encoder = static_cast<IEncoder*>(NULL) 
)

Creates outgoing stream consuming sequence of values passed in array buffers of arbitrary length which repacked in frames of constant length for further processing and encoding.

Template Parameters
TType of data consumed by outgoing stream (element type of array buffers).
Parameters
voiceInfoOutgoing stream parameters. Set applicable fields to read them by encoder and by receiving client when voice created.
frameSizeSize of buffer LocalVoiceFramed repacks input data stream to.
channelIdTransport channel specific to transport.
encoderEncoder compressing data stream in pipeline.
Returns
Outgoing stream handler.

◆ createLocalVoiceAudio()

LocalVoiceAudio< T > * createLocalVoiceAudio ( const VoiceInfo voiceInfo,
const IAudioDesc audioSourceDesc,
int  channelId = 0,
Common::Helpers::SharedPointer< IEncoder encoder = static_cast<IEncoder*>(NULL) 
)

Creates outgoing audio stream. Adds audio specific features (e.g. resampling, level meter) to processing pipeline and to returning stream handler.

Template Parameters
TElement type of audio array buffers.
Parameters
voiceInfoOutgoing audio stream parameters. Set applicable fields to read them by encoder and by receiving client when voice created.
audioSourceDescStreaming audio source description.
channelIdTransport channel specific to transport.
encoderAudio encoder. Set to null to use default Opus encoder.
Returns
Outgoing stream handler.

Sampling rates of audioSourceDesc voiceInfo may do not match. Automatic resampling will occur in this case.

◆ createLocalVoiceAudioFromSource()

LocalVoiceAudio< T > * createLocalVoiceAudioFromSource ( const VoiceInfo voiceInfo,
IAudioPusher< T > *  source,
int  channelId = 0,
Common::Helpers::SharedPointer< IEncoder encoder = static_cast<IEncoder*>(NULL) 
)

Creates outgoing audio stream. Adds audio specific features (e.g. resampling, level meter) to processing pipeline and to returning stream handler.

Parameters
voiceInfoOutgoing audio stream parameters. Set applicable fields to read them by encoder and by receiving client when voice created.
sourceStreaming audio source.
channelIdTransport channel specific to transport.
encoderAudio encoder. Set to null to use default Opus encoder.
Returns
Outgoing stream handler.

Sampling rates of audioSourceDesc voiceInfo may do not match. Automatic resampling will occur in this case.

◆ removeLocalVoice()

void removeLocalVoice ( LocalVoice voice)

Removes local voice (outgoing data stream).

Parameters
voiceHandler of outgoing stream to be removed.