/// GENERATED BY terra, DO NOT MODIFY BY HAND.

// ignore_for_file: public_member_api_docs, unused_local_variable, unused_import, annotate_overrides

import 'package:agora_rtc_engine/src/binding_forward_export.dart';
import 'package:agora_rtc_engine/src/binding/impl_forward_export.dart';
import 'package:iris_method_channel/iris_method_channel.dart';

class MediaEngineImpl implements MediaEngine {
  MediaEngineImpl(this.irisMethodChannel);

  @protected
  final IrisMethodChannel irisMethodChannel;

  @protected
  Map<String, dynamic> createParams(Map<String, dynamic> param) {
    return param;
  }

  @protected
  bool get isOverrideClassName => false;

  @protected
  String get className => 'MediaEngine';

  @override
  void registerAudioFrameObserver(AudioFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_registerAudioFrameObserver_d873a64';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for registerAudioFrameObserver');
  }

  @override
  void registerVideoFrameObserver(VideoFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_registerVideoFrameObserver_2cc0ef1';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for registerVideoFrameObserver');
  }

  @override
  void registerVideoEncodedFrameObserver(VideoEncodedFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_registerVideoEncodedFrameObserver_d45d579';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError(
        'Unimplement for registerVideoEncodedFrameObserver');
  }

  @override
  void registerFaceInfoObserver(FaceInfoObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_registerFaceInfoObserver_0303ed6';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for registerFaceInfoObserver');
  }

  @override
  Future<void> pushAudioFrame(
      {required AudioFrame frame, int trackId = 0}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_pushAudioFrame_c71f4ab';
    final param = createParams({'frame': frame.toJson(), 'trackId': trackId});
    final List<Uint8List> buffers = [];
    buffers.addAll(frame.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> pullAudioFrame(AudioFrame frame) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_pullAudioFrame_2c74a9c';
    final param = createParams({'frame': frame.toJson()});
    final List<Uint8List> buffers = [];
    buffers.addAll(frame.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setExternalVideoSource(
      {required bool enabled,
      required bool useTexture,
      ExternalVideoSourceType sourceType = ExternalVideoSourceType.videoFrame,
      SenderOptions encodedVideoOption = const SenderOptions()}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_setExternalVideoSource_fff99b6';
    final param = createParams({
      'enabled': enabled,
      'useTexture': useTexture,
      'sourceType': sourceType.value(),
      'encodedVideoOption': encodedVideoOption.toJson()
    });
    final List<Uint8List> buffers = [];
    buffers.addAll(encodedVideoOption.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setExternalRemoteEglContext(int eglContext) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_setExternalRemoteEglContext_f337cbf';
    final param = createParams({'eglContext': eglContext});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setExternalAudioSource(
      {required bool enabled,
      required int sampleRate,
      required int channels,
      bool localPlayback = false,
      bool publish = true}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_setExternalAudioSource_e6538be';
    final param = createParams({
      'enabled': enabled,
      'sampleRate': sampleRate,
      'channels': channels,
      'localPlayback': localPlayback,
      'publish': publish
    });
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<int> createCustomAudioTrack(
      {required AudioTrackType trackType,
      required AudioTrackConfig config}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_createCustomAudioTrack_5a0bf1a';
    final param = createParams(
        {'trackType': trackType.value(), 'config': config.toJson()});
    final List<Uint8List> buffers = [];
    buffers.addAll(config.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    return result as int;
  }

  @override
  Future<void> destroyCustomAudioTrack(int trackId) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_destroyCustomAudioTrack_6178b5d';
    final param = createParams({'trackId': trackId});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> setExternalAudioSink(
      {required bool enabled,
      required int sampleRate,
      required int channels}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_setExternalAudioSink_d275ce0';
    final param = createParams(
        {'enabled': enabled, 'sampleRate': sampleRate, 'channels': channels});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> enableCustomAudioLocalPlayback(
      {required int trackId, required bool enabled}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_enableCustomAudioLocalPlayback_5f38e8a';
    final param = createParams({'trackId': trackId, 'enabled': enabled});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> pushVideoFrame(
      {required ExternalVideoFrame frame, int videoTrackId = 0}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_pushVideoFrame_4e544e2';
    final param =
        createParams({'frame': frame.toJson(), 'videoTrackId': videoTrackId});
    final List<Uint8List> buffers = [];
    buffers.addAll(frame.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> pushEncodedVideoImage(
      {required Uint8List imageBuffer,
      required int length,
      required EncodedVideoFrameInfo videoEncodedFrameInfo,
      int videoTrackId = 0}) async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_pushEncodedVideoImage_e71452b';
    final param = createParams({
      'length': length,
      'videoEncodedFrameInfo': videoEncodedFrameInfo.toJson(),
      'videoTrackId': videoTrackId
    });
    final List<Uint8List> buffers = [];
    buffers.add(imageBuffer);
    buffers.addAll(videoEncodedFrameInfo.collectBufferList());
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: buffers));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  Future<void> release() async {
    final apiType =
        '${isOverrideClassName ? className : 'MediaEngine'}_release';
    final param = createParams({});
    final callApiResult = await irisMethodChannel.invokeMethod(
        IrisMethodCall(apiType, jsonEncode(param), buffers: null));
    if (callApiResult.irisReturnCode < 0) {
      throw AgoraRtcException(code: callApiResult.irisReturnCode);
    }
    final rm = callApiResult.data;
    final result = rm['result'];
    if (result < 0) {
      throw AgoraRtcException(code: result);
    }
  }

  @override
  void unregisterAudioFrameObserver(AudioFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_unregisterAudioFrameObserver';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for unregisterAudioFrameObserver');
  }

  @override
  void unregisterVideoFrameObserver(VideoFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_unregisterVideoFrameObserver';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for unregisterVideoFrameObserver');
  }

  @override
  void unregisterVideoEncodedFrameObserver(VideoEncodedFrameObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_unregisterVideoEncodedFrameObserver';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError(
        'Unimplement for unregisterVideoEncodedFrameObserver');
  }

  @override
  void unregisterFaceInfoObserver(FaceInfoObserver observer) {
    // Implementation template
// final apiType = '${isOverrideClassName ? className : 'MediaEngine'}_unregisterFaceInfoObserver';
// final param = createParams({
//   'observer': observer
// });
// final callApiResult = await irisMethodChannel.invokeMethod(IrisMethodCall(apiType, jsonEncode(param), buffers:null));
// if (callApiResult.irisReturnCode < 0) {
//   throw AgoraRtcException(code: callApiResult.irisReturnCode);
// }
// final rm = callApiResult.data;
// final result = rm['result'];
// if (result < 0) { throw AgoraRtcException(code: result); }
    throw UnimplementedError('Unimplement for unregisterFaceInfoObserver');
  }
}
