Class AudioSocket
Provides Send and Receive I/O access to an audio stream.
Inherited Members
Namespace: Microsoft.Skype.Bots.Media
Assembly: Microsoft.Skype.Bots.Media.dll
Syntax
public sealed class AudioSocket : IAudioSocket, IDisposable, IInternalAudioSocket, IInternalSocket
Constructors
AudioSocket(AudioSocketSettings)
Initializes a new AudioSocket object.
Declaration
public AudioSocket(AudioSocketSettings settings)
Parameters
Type | Name | Description |
---|---|---|
AudioSocketSettings | settings | Configuration settings for the AudioSocket |
Methods
Dispose()
Disposes the object
Declaration
public void Dispose()
GetQualityOfExperienceData()
Get the Quality of Experience (QoE) data for the audio socket.
Declaration
public AudioQualityOfExperienceData GetQualityOfExperienceData()
Returns
Type | Description |
---|---|
AudioQualityOfExperienceData |
Remarks
The bot should fetch the QoE data no more than once every 30 seconds. To get accurate metrics, the bot should let media flow for at least 30 seconds before fetching the QoE data.
Send(AudioMediaBuffer)
Sends a frame of audio media, where a frame contains 20 milliseconds of audio content (PCM samples).
Declaration
public void Send(AudioMediaBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
AudioMediaBuffer | buffer | AudioMediaBuffer containing the frame of audio media to send. |
Remarks
The application must create a concrete class which derives from the AudioMediaBuffer abstract class. The buffer object passed to the Send method is still potentially in-use after the method returns to the caller. The application must not free the buffer's frame data until the the buffer object's Dispose() method is invoked by the Media Platform.
The application should be sending 50 frames of audio media per second with each frame containing 20 milliseconds of audio content.
The AudioSocket must be enabled to send media via the AudioSocketSettings.StreamDirections
property.
SendDtmfTone(ToneId)
Sends a DTMF tone.
Declaration
public void SendDtmfTone(ToneId tone)
Parameters
Type | Name | Description |
---|---|---|
ToneId | tone | The DTMF digit. Ranges from 0-16. |
Remarks
Sending DTMF tone is only allowed if the AudioSocket is configured for sending media.
SendDtmfTones(IEnumerable<ToneId>, Int32)
Sends a sequence of DTMF tones with an optional delay between each tone.
Declaration
public void SendDtmfTones(IEnumerable<ToneId> tones, int delayBetweenTonesInMilliseconds = -1)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ToneId> | tones | The list of DTMF digits to be sent. Ranges from 0-16. |
Int32 | delayBetweenTonesInMilliseconds | Delay (in milliseconds) between each DTMF digit sent. |
Remarks
By default, the delay is set to -1 which picks a random time between 0 to 500 milliseconds.
Events
AudioMediaReceived
If the application has configured the AudioSocket to receive media, this event is raised each time a frame of audio media is received, where a frame contains 20 milliseconds of audio content (PCM samples). Once the application has consumed the buffer, it must call the buffer's Dispose() method.
Declaration
public event EventHandler<AudioMediaReceivedEventArgs> AudioMediaReceived
Event Type
Type | Description |
---|---|
EventHandler<AudioMediaReceivedEventArgs> |
Remarks
The application must be able to handle at least 50 incoming audio buffers per second. Events are serialized, so only one event at a time is raised to the app. The event handler should return as quickly as possible; any time-consuming per-frame processing should be performed asynchronously from the event handler.
AudioSendStatusChanged
If the application has configured the AudioSocket to send media, this event is raised to inform the application when it may begin sending media and when it should stop. The application cannot send media before receiving a MediaSendStatusChanged event indicating the SendStatus is Active, such media will be discarded.
Declaration
public event EventHandler<AudioSendStatusChangedEventArgs> AudioSendStatusChanged
Event Type
Type | Description |
---|---|
EventHandler<AudioSendStatusChangedEventArgs> |
DominantSpeakerChanged
This event is raised when there is a change in the dominant speaker in the conference. If there is no dominant speaker in the conference the CurrentDominantSpeaker argument in the event will have the value None (0xFFFFFFFF).
Declaration
public event EventHandler<DominantSpeakerChangedEventArgs> DominantSpeakerChanged
Event Type
Type | Description |
---|---|
EventHandler<DominantSpeakerChangedEventArgs> |
MediaStreamFailure
This event is raised if there is a network connection failure with the peer. To recover, the bot will need to start a new call or rejoin the meeting.
Declaration
public event EventHandler<MediaStreamFailureEventArgs> MediaStreamFailure
Event Type
Type | Description |
---|---|
EventHandler<MediaStreamFailureEventArgs> |
ToneReceived
This event is raised when the DTMF tone is received. ToneId enum indicates the tone value.
Declaration
public event EventHandler<ToneReceivedEventArgs> ToneReceived
Event Type
Type | Description |
---|---|
EventHandler<ToneReceivedEventArgs> |