setPreferredCodec method

String setPreferredCodec({
  1. WebRTCCodec codec = WebRTCCodec.h264,
})

Implementation

String setPreferredCodec({WebRTCCodec codec = WebRTCCodec.h264}) {
  final capSel = CodecCapabilitySelector(this);

  final vcaps = capSel.getCapabilities('video');
  if (vcaps != null) {
    final List codecsFiltered = vcaps.codecs
        .where((e) => (e['codec'] as String).toLowerCase() == codec.codec)
        .toList();

    if (codecsFiltered.isEmpty) return this; // Prefered codec not supported

    vcaps.codecs = codecsFiltered;
    vcaps.setCodecPreferences('video', vcaps.codecs);
    capSel.setCapabilities(vcaps);
  }

  if (codec == WebRTCCodec.h264) return capSel.sdp().useH264HighLevel();

  return capSel.sdp();
}