addSimulcastTrack method
Future<RTCRtpSender>
addSimulcastTrack(
- MediaStreamTrack track, {
- required RTCVideoCodec vCodec,
- required MediaStream stream,
- RtcTrackKind kind = RtcTrackKind.video,
- required bool isSingleTrack,
Implementation
Future<RTCRtpSender> addSimulcastTrack(
MediaStreamTrack track, {
required RTCVideoCodec vCodec,
required MediaStream stream,
RtcTrackKind kind = RtcTrackKind.video,
required bool isSingleTrack,
}) async {
final List<RTCRtpEncoding> encodings = [];
if (kind == RtcTrackKind.video) {
if (vCodec == RTCVideoCodec.vp9) {
encodings.addAll(RTCConfigurations.svcEncodings);
} else {
encodings.addAll(RTCConfigurations.simulcastEncodings);
}
}
final transceiver = await addTransceiver(
track: track,
kind: kind == RtcTrackKind.video
? RTCRtpMediaType.RTCRtpMediaTypeVideo
: RTCRtpMediaType.RTCRtpMediaTypeAudio,
init: RTCRtpTransceiverInit(
direction: TransceiverDirection.SendOnly,
streams: [stream],
sendEncodings: encodings,
),
);
final sender = transceiver.sender;
if (kind != RtcTrackKind.video) return sender;
await _setPreferredCodec(
transceiver: transceiver,
vCodec: vCodec.codec,
kind: kind,
);
return sender;
}