setPreferredCodec method

String setPreferredCodec({
  1. RTCVideoCodec codec = RTCVideoCodec.h264,
  2. bool isP2P = false,
})

Implementation

String setPreferredCodec({
  RTCVideoCodec codec = RTCVideoCodec.h264,
  bool isP2P = false,
}) {
  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 == RTCVideoCodec.h264) {
    return capSel.sdp().updateH264Profile();
  }

  return capSel.sdp();
}