onNegotiationNeeded method
Future<void>
onNegotiationNeeded(
)
Implementation
Future<void> onNegotiationNeeded() async {
Logs().i('Negotiation is needed!');
makingOffer = true;
try {
// The first addTrack(audio track) on iOS will trigger
// onNegotiationNeeded, which causes creatOffer to only include
// audio m-line, add delay and wait for video track to be added,
// then createOffer can get audio/video m-line correctly.
await Future.delayed(Duration(milliseconds: Timeouts.delayBeforeOfferMs));
final offer = await pc!.createOffer({});
await _gotLocalOffer(offer);
} catch (e) {
await _getLocalOfferFailed(e);
return;
} finally {
makingOffer = false;
}
}