initRtcEngine method

Future<int> initRtcEngine({
  1. required NERtcChannelEventCallback rtcChannelEventCallback,
  2. bool attendeeRecordOn = false,
  3. required MediaType mediaType,
  4. required String nrtcAppKey,
})

Implementation

Future<int> initRtcEngine({
  required NERtcChannelEventCallback rtcChannelEventCallback,
  bool attendeeRecordOn = false,
  required MediaType mediaType,
  required String nrtcAppKey,
}) async {
  if (_isInit) {
    if (_currentMediaType == mediaType) {
      return NERtcErrorCode.ok;
    } else {
      if (_currentMediaType == MediaType.inRoom) return NERtcErrorCode.ok;
      await engine.release();
      _isInit = !_isInit;
    }
  }

  var options = getOption(attendeeRecordOn);
  var result = await engine.create(
    appKey:nrtcAppKey,
    channelEventCallback: rtcChannelEventCallback,
    options: options,
  );
  _isInit = result == NERtcErrorCode.ok;
  _currentMediaType = mediaType;
  return result;
}