onNegotiationNeeded method

Future<void> onNegotiationNeeded()

Implementation

Future<void> onNegotiationNeeded() async {
  Logs().d('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(CallTimeouts.delayBeforeOffer);
    final offer = await pc!.createOffer({});
    await _gotLocalOffer(offer);
  } catch (e) {
    await _getLocalOfferFailed(e);
    return;
  } finally {
    _makingOffer = false;
  }
}