getSupportedAudioCodecs method
Gets the list of supported audio codecs available on the client
Returns a List<AudioCodec> containing commonly supported audio codecs for WebRTC calls. This method returns a predefined list of standard codecs that are widely supported across WebRTC implementations.
Note: This is a temporary implementation until flutter_webrtc adds support for RTCRtpSender.getCapabilities(). The returned codecs are standard WebRTC audio codecs that should work on most platforms.
You can still pass the desired codec/s via the newInvite method when creating a call. The codecs passed are in order of preference. If the codec/s passed are not supported it will default to a supported codec.
See: https://github.com/flutter-webrtc/flutter-webrtc/issues/930
Implementation
List<AudioCodec> getSupportedAudioCodecs() {
// Return a list of audio codecs supported by the Telnyx backend
// These codecs are confirmed to be supported by the Telnyx platform
return [
// Opus - Primary codec for WebRTC, excellent quality and compression
AudioCodec(
mimeType: 'audio/opus',
clockRate: 48000,
channels: 2,
sdpFmtpLine: 'minptime=10;useinbandfec=1',
),
// G722 - Wideband codec for better quality than G.711
AudioCodec(
mimeType: 'audio/G722',
clockRate: 8000,
channels: 1,
),
// PCMU (G.711 μ-law) - Standard codec
AudioCodec(
mimeType: 'audio/PCMU',
clockRate: 8000,
channels: 1,
),
// PCMA (G.711 A-law) - Standard codec
AudioCodec(
mimeType: 'audio/PCMA',
clockRate: 8000,
channels: 1,
),
// G729 - Low bitrate codec
AudioCodec(
mimeType: 'audio/G729',
clockRate: 8000,
channels: 1,
),
// AMR-WB - Adaptive Multi-Rate Wideband codec
AudioCodec(
mimeType: 'audio/AMR-WB',
clockRate: 16000,
channels: 1,
),
// Telephone-event - For DTMF support
AudioCodec(
mimeType: 'audio/telephone-event',
clockRate: 8000,
channels: 1,
),
];
}