OpenTok.MMAudioDevice
public class MMAudioDevice : OpenTok.IAudioDevice, IDisposable
To use this custom audio device:
- Create an instance of this class.
- Use AudioDevice.SetCustomAudioDevice before creating the first session to inform webrtc that it will be using this class as the audio device.
Use the following MMAudioDevice methods instead of the static equivalents in AudioDevice:
- EnumerateInputAudioDevices(), EnumerateOutputAudioDevices()
- GetDefaultInputAudioDevice(), GetDefaultOutputAudioDevice()
- SetInputAudioDevice(), SetOutputAudioDevice()
Subscribe to the following MMAudioDevice events instead of default AudioDevice.Notifications events:
- InputDeviceAdded, OutputDeviceAdded
- InputDeviceRemoved, OutputDeviceRemoved
- DefaultInputDeviceChanged, DefaultOutputDeviceChanged
Methods
| Name | Description |
|---|---|
MMAudioDevice(dispatcher) |
Creates a MMAudioDevice with enabled notifications that will be raised throw the provided IDispatcher. |
DestroyAudio() |
Called when the IAudioDevice instance is destroyed. |
DestroyAudioCapturer() |
Called when th audio capturer for the IAudioDevice instance is destroyed. |
DestroyAudioRenderer() |
Called when th audio renderer for the IAudioDevice instance is destroyed. |
Dispose() |
|
Dispose(disposing) |
|
EnumerateInputAudioDevices() → {IList<AudioDevice.InputAudioDevice>} |
|
EnumerateOutputAudioDevices() → {IList<AudioDevice.OutputAudioDevice>} |
|
GetAudioCapturerSettings() → {AudioDeviceSettings} |
Called when the IAudioDevice instance requires settings. |
GetAudioRendererSettings() → {AudioDeviceSettings} |
Gets settings for the audio renderer for the IAudioDevice instance. |
GetDefaultInputAudioDevice() → {AudioDevice.InputAudioDevice} |
|
GetDefaultOutputAudioDevice() → {AudioDevice.OutputAudioDevice} |
|
GetEstimatedAudioCaptureDelay() → {int} |
Gets the estimated audio capture delay. |
GetEstimatedAudioRenderDelay() → {int} |
Gets the estimated audio render delay. |
InitAudio(audioBus) |
|
InitAudioCapturer() |
Called when the audio capturer for the IAudioDevice instance is initialized. |
InitAudioRenderer() |
Called when the audio renderer for the IAudioDevice instance is initialized. |
IsAudioCapturerInitialized() → {bool} |
Checks if the audio capturer for the IAudioDevice instance is initialized. |
IsAudioCapturerStarted() → {bool} |
Checks if the audio capturer for the IAudioDevice instance is started. |
IsAudioRendererInitialized() → {bool} |
Checks if the audio renderer for the IAudioDevice instance is initialized. |
IsAudioRendererStarted() → {bool} |
Checks if the audio renderer for the IAudioDevice instance is started. |
SetInputAudioDevice(deviceId) |
|
SetOutputAudioDevice(deviceId) |
|
StartAudioCapturer() |
Called when the audio capturer starts. |
StartAudioRenderer() |
Called when the audio renderer starts. |
StopAudioCapturer() |
Called when the audio capturer stops. |
StopAudioRenderer() |
Called when the audio renderer stops. |
MMAudioDevice(dispatcher)
Creates a MMAudioDevice with enabled notifications that will be raised throw the provided IDispatcher. Subscribe to InputDeviceAdded, InputDeviceRemoved, DefaultInputDeviceChanged, OutputDeviceAdded, OutputDeviceRemoved, DefaultOutputDeviceChanged to take advantage of these notifications.
Parameters:
| Name | Type | Description |
|---|---|---|
dispatcher |
IDispatcher |
DestroyAudio()
Called when the IAudioDevice instance is destroyed.
DestroyAudioCapturer()
Called when th audio capturer for the IAudioDevice instance is destroyed.
DestroyAudioRenderer()
Called when th audio renderer for the IAudioDevice instance is destroyed.
Dispose()
Dispose(disposing)
Parameters:
| Name | Type | Description |
|---|---|---|
disposing |
bool |
EnumerateInputAudioDevices() → {IList<AudioDevice.InputAudioDevice>}
Returns:
A list of InputAudioDevice objects, representing available audio input devices on the system.
EnumerateOutputAudioDevices() → {IList<AudioDevice.OutputAudioDevice>}
Returns:
A list of InputAudioDevice objects, representing available audio input devices on the system.
GetAudioCapturerSettings() → {AudioDeviceSettings}
Called when the IAudioDevice instance requires settings. In your implementation of this method, return an AudioDeviceSettings object.
Returns:
AudioDeviceSettings
GetAudioRendererSettings() → {AudioDeviceSettings}
Gets settings for the audio renderer for the IAudioDevice instance.
Returns:
AudioDeviceSettings
GetDefaultInputAudioDevice() → {AudioDevice.InputAudioDevice}
Returns:
The system default audio input device.
GetDefaultOutputAudioDevice() → {AudioDevice.OutputAudioDevice}
Returns:
The system default audio output device.
GetEstimatedAudioCaptureDelay() → {int}
Gets the estimated audio capture delay.
Returns:
int
GetEstimatedAudioRenderDelay() → {int}
Gets the estimated audio render delay.
Returns:
int
InitAudio(audioBus)
Parameters:
| Name | Type | Description |
|---|---|---|
audioBus |
AudioDevice.AudioBus | The instance of the AudioBus to use for all publishers and subscribers. |
InitAudioCapturer()
Called when the audio capturer for the IAudioDevice instance is initialized.
InitAudioRenderer()
Called when the audio renderer for the IAudioDevice instance is initialized.
IsAudioCapturerInitialized() → {bool}
Checks if the audio capturer for the IAudioDevice instance is initialized.
Returns:
bool
IsAudioCapturerStarted() → {bool}
Checks if the audio capturer for the IAudioDevice instance is started.
Returns:
bool
IsAudioRendererInitialized() → {bool}
Checks if the audio renderer for the IAudioDevice instance is initialized.
Returns:
bool
IsAudioRendererStarted() → {bool}
Checks if the audio renderer for the IAudioDevice instance is started.
Returns:
bool
SetInputAudioDevice(deviceId)
Parameters:
| Name | Type | Description |
|---|---|---|
deviceId |
string | Id of the device |
SetOutputAudioDevice(deviceId)
Parameters:
| Name | Type | Description |
|---|---|---|
deviceId |
string | Id of the device |
StartAudioCapturer()
Called when the audio capturer starts. You should begin providing audio samples to the AudioBus.WriteCaptureData(IntPtr buffer, int numberOfSamples) method.
StartAudioRenderer()
Called when the audio renderer starts. You should begin receiving audio samples from the AudioBus.ReadRenderData(IntPtr buffer, int numberOfSamples) method.
StopAudioCapturer()
Called when the audio capturer stops.
StopAudioRenderer()
Called when the audio renderer stops.
Events
InputDeviceAdded
event EventHandler<AudioDevice.Notifications.InputAudioDeviceEventArgs> InputDeviceAdded
Sent when a new audio input device is detected by the system.
OutputDeviceAdded
event EventHandler<AudioDevice.Notifications.OutputAudioDeviceEventArgs> OutputDeviceAdded
Sent when a new audio output device is detected by the system.
InputDeviceRemoved
event EventHandler<AudioDevice.Notifications.InputAudioDeviceEventArgs> InputDeviceRemoved
Sent when an audio input device is removed from the system.
OutputDeviceRemoved
event EventHandler<AudioDevice.Notifications.OutputAudioDeviceEventArgs> OutputDeviceRemoved
Sent when an audio output device is removed from the system.
DefaultInputDeviceChanged
event EventHandler<AudioDevice.Notifications.InputAudioDeviceEventArgs> DefaultInputDeviceChanged
Sent when the default audio input device changes at the system level.
DefaultOutputDeviceChanged
event EventHandler<AudioDevice.Notifications.OutputAudioDeviceEventArgs> DefaultOutputDeviceChanged
Sent when the default audio output device changes at the system level.