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

// ignore_for_file: public_member_api_docs, unused_local_variable, unused_import

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 H265TranscoderObserverWrapper implements EventLoopEventHandler {
  const H265TranscoderObserverWrapper(this.h265TranscoderObserver);

  final H265TranscoderObserver h265TranscoderObserver;

  @override
  bool operator ==(Object other) {
    if (other.runtimeType != runtimeType) {
      return false;
    }
    return other is H265TranscoderObserverWrapper &&
        other.h265TranscoderObserver == h265TranscoderObserver;
  }

  @override
  int get hashCode => h265TranscoderObserver.hashCode;

  @override
  bool handleEventInternal(
      String eventName, String eventData, List<Uint8List> buffers) {
    switch (eventName) {
      case 'onEnableTranscode_6ba6646':
        if (h265TranscoderObserver.onEnableTranscode == null) {
          return true;
        }
        final jsonMap = jsonDecode(eventData);
        H265TranscoderObserverOnEnableTranscodeJson paramJson =
            H265TranscoderObserverOnEnableTranscodeJson.fromJson(jsonMap);
        paramJson = paramJson.fillBuffers(buffers);
        H265TranscodeResult? result = paramJson.result;
        if (result == null) {
          return true;
        }

        h265TranscoderObserver.onEnableTranscode!(result);
        return true;

      case 'onQueryChannel_31ba3df':
        if (h265TranscoderObserver.onQueryChannel == null) {
          return true;
        }
        final jsonMap = jsonDecode(eventData);
        H265TranscoderObserverOnQueryChannelJson paramJson =
            H265TranscoderObserverOnQueryChannelJson.fromJson(jsonMap);
        paramJson = paramJson.fillBuffers(buffers);
        H265TranscodeResult? result = paramJson.result;
        String? originChannel = paramJson.originChannel;
        String? transcodeChannel = paramJson.transcodeChannel;
        if (result == null ||
            originChannel == null ||
            transcodeChannel == null) {
          return true;
        }

        h265TranscoderObserver.onQueryChannel!(
            result, originChannel, transcodeChannel);
        return true;

      case 'onTriggerTranscode_6ba6646':
        if (h265TranscoderObserver.onTriggerTranscode == null) {
          return true;
        }
        final jsonMap = jsonDecode(eventData);
        H265TranscoderObserverOnTriggerTranscodeJson paramJson =
            H265TranscoderObserverOnTriggerTranscodeJson.fromJson(jsonMap);
        paramJson = paramJson.fillBuffers(buffers);
        H265TranscodeResult? result = paramJson.result;
        if (result == null) {
          return true;
        }

        h265TranscoderObserver.onTriggerTranscode!(result);
        return true;
    }
    return false;
  }

  @override
  bool handleEvent(
      String eventName, String eventData, List<Uint8List> buffers) {
    if (!eventName.startsWith('H265TranscoderObserver')) return false;
    final newEvent = eventName.replaceFirst('H265TranscoderObserver_', '');
    if (handleEventInternal(newEvent, eventData, buffers)) {
      return true;
    }
    return false;
  }
}
