RealtimeAudioFormats.fromJson constructor

RealtimeAudioFormats.fromJson(
  1. Map<String, dynamic> json
)

Creates from JSON.

Returns an UnknownRealtimeAudioFormats for unrecognised type values rather than throwing — the raw payload is preserved on round-trip.

Implementation

factory RealtimeAudioFormats.fromJson(Map<String, dynamic> json) {
  final type = json['type'];
  return switch (type) {
    'audio/pcm' => AudioPcm.fromJson(json),
    'audio/pcmu' => AudioPcmu.fromJson(json),
    'audio/pcma' => AudioPcma.fromJson(json),
    _ => UnknownRealtimeAudioFormats(Map<String, dynamic>.from(json)),
  };
}