// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v26.3.4), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "./include/video_player_avfoundation_objc/VideoPlayerInstanceMessages.g.h"

#if TARGET_OS_OSX
@import FlutterMacOS;
#else
@import Flutter;
#endif

static BOOL __attribute__((unused)) FLTPigeonDeepEquals(id _Nullable a, id _Nullable b) {
  if (a == b) {
    return YES;
  }
  if (a == nil) {
    return b == [NSNull null];
  }
  if (b == nil) {
    return a == [NSNull null];
  }
  if ([a isKindOfClass:[NSNumber class]] && [b isKindOfClass:[NSNumber class]]) {
    return
        [a isEqual:b] || (isnan([(NSNumber *)a doubleValue]) && isnan([(NSNumber *)b doubleValue]));
  }
  if ([a isKindOfClass:[NSArray class]] && [b isKindOfClass:[NSArray class]]) {
    NSArray *arrayA = (NSArray *)a;
    NSArray *arrayB = (NSArray *)b;
    if (arrayA.count != arrayB.count) {
      return NO;
    }
    for (NSUInteger i = 0; i < arrayA.count; i++) {
      if (!FLTPigeonDeepEquals(arrayA[i], arrayB[i])) {
        return NO;
      }
    }
    return YES;
  }
  if ([a isKindOfClass:[NSDictionary class]] && [b isKindOfClass:[NSDictionary class]]) {
    NSDictionary *dictA = (NSDictionary *)a;
    NSDictionary *dictB = (NSDictionary *)b;
    if (dictA.count != dictB.count) {
      return NO;
    }
    for (id keyA in dictA) {
      id valueA = dictA[keyA];
      BOOL found = NO;
      for (id keyB in dictB) {
        if (FLTPigeonDeepEquals(keyA, keyB)) {
          id valueB = dictB[keyB];
          if (FLTPigeonDeepEquals(valueA, valueB)) {
            found = YES;
            break;
          } else {
            return NO;
          }
        }
      }
      if (!found) {
        return NO;
      }
    }
    return YES;
  }
  return [a isEqual:b];
}

static NSUInteger __attribute__((unused)) FLTPigeonDeepHash(id _Nullable value) {
  if (value == nil || value == (id)[NSNull null]) {
    return 0;
  }
  if ([value isKindOfClass:[NSNumber class]]) {
    NSNumber *n = (NSNumber *)value;
    double d = n.doubleValue;
    if (isnan(d)) {
      // Normalize NaN to a consistent hash.
      return (NSUInteger)0x7FF8000000000000;
    }
    if (d == 0.0) {
      // Normalize -0.0 to 0.0 so they have the same hash code.
      d = 0.0;
    }
    return @(d).hash;
  }
  if ([value isKindOfClass:[NSArray class]]) {
    NSUInteger result = 1;
    for (id item in (NSArray *)value) {
      result = result * 31 + FLTPigeonDeepHash(item);
    }
    return result;
  }
  if ([value isKindOfClass:[NSDictionary class]]) {
    NSUInteger result = 0;
    NSDictionary *dict = (NSDictionary *)value;
    for (id key in dict) {
      result += ((FLTPigeonDeepHash(key) * 31) ^ FLTPigeonDeepHash(dict[key]));
    }
    return result;
  }
  return [value hash];
}

static NSArray<id> *wrapResult(id result, FlutterError *error) {
  if (error) {
    return @[
      error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null]
    ];
  }
  return @[ result ?: [NSNull null] ];
}

static id GetNullableObjectAtIndex(NSArray<id> *array, NSInteger key) {
  id result = array[key];
  return (result == [NSNull null]) ? nil : result;
}

@interface FVPMediaSelectionAudioTrackData ()
+ (FVPMediaSelectionAudioTrackData *)fromList:(NSArray<id> *)list;
+ (nullable FVPMediaSelectionAudioTrackData *)nullableFromList:(NSArray<id> *)list;
- (NSArray<id> *)toList;
@end

@interface FVPMediaSelectionVideoTrackData ()
+ (FVPMediaSelectionVideoTrackData *)fromList:(NSArray<id> *)list;
+ (nullable FVPMediaSelectionVideoTrackData *)nullableFromList:(NSArray<id> *)list;
- (NSArray<id> *)toList;
@end

@interface FVPAssetVideoTrackData ()
+ (FVPAssetVideoTrackData *)fromList:(NSArray<id> *)list;
+ (nullable FVPAssetVideoTrackData *)nullableFromList:(NSArray<id> *)list;
- (NSArray<id> *)toList;
@end

@interface FVPNativeVideoTrackData ()
+ (FVPNativeVideoTrackData *)fromList:(NSArray<id> *)list;
+ (nullable FVPNativeVideoTrackData *)nullableFromList:(NSArray<id> *)list;
- (NSArray<id> *)toList;
@end

@implementation FVPMediaSelectionAudioTrackData
+ (instancetype)makeWithIndex:(NSInteger)index
                  displayName:(nullable NSString *)displayName
                 languageCode:(nullable NSString *)languageCode
                   isSelected:(BOOL)isSelected
          commonMetadataTitle:(nullable NSString *)commonMetadataTitle {
  FVPMediaSelectionAudioTrackData *pigeonResult = [[FVPMediaSelectionAudioTrackData alloc] init];
  pigeonResult.index = index;
  pigeonResult.displayName = displayName;
  pigeonResult.languageCode = languageCode;
  pigeonResult.isSelected = isSelected;
  pigeonResult.commonMetadataTitle = commonMetadataTitle;
  return pigeonResult;
}
+ (FVPMediaSelectionAudioTrackData *)fromList:(NSArray<id> *)list {
  FVPMediaSelectionAudioTrackData *pigeonResult = [[FVPMediaSelectionAudioTrackData alloc] init];
  pigeonResult.index = [GetNullableObjectAtIndex(list, 0) integerValue];
  pigeonResult.displayName = GetNullableObjectAtIndex(list, 1);
  pigeonResult.languageCode = GetNullableObjectAtIndex(list, 2);
  pigeonResult.isSelected = [GetNullableObjectAtIndex(list, 3) boolValue];
  pigeonResult.commonMetadataTitle = GetNullableObjectAtIndex(list, 4);
  return pigeonResult;
}
+ (nullable FVPMediaSelectionAudioTrackData *)nullableFromList:(NSArray<id> *)list {
  return (list) ? [FVPMediaSelectionAudioTrackData fromList:list] : nil;
}
- (NSArray<id> *)toList {
  return @[
    @(self.index),
    self.displayName ?: [NSNull null],
    self.languageCode ?: [NSNull null],
    @(self.isSelected),
    self.commonMetadataTitle ?: [NSNull null],
  ];
}
- (BOOL)isEqual:(id)object {
  if (self == object) {
    return YES;
  }
  if (![object isKindOfClass:[self class]]) {
    return NO;
  }
  FVPMediaSelectionAudioTrackData *other = (FVPMediaSelectionAudioTrackData *)object;
  return self.index == other.index && FLTPigeonDeepEquals(self.displayName, other.displayName) &&
         FLTPigeonDeepEquals(self.languageCode, other.languageCode) &&
         self.isSelected == other.isSelected &&
         FLTPigeonDeepEquals(self.commonMetadataTitle, other.commonMetadataTitle);
}

- (NSUInteger)hash {
  NSUInteger result = [self class].hash;
  result = result * 31 + @(self.index).hash;
  result = result * 31 + FLTPigeonDeepHash(self.displayName);
  result = result * 31 + FLTPigeonDeepHash(self.languageCode);
  result = result * 31 + @(self.isSelected).hash;
  result = result * 31 + FLTPigeonDeepHash(self.commonMetadataTitle);
  return result;
}
@end

@implementation FVPMediaSelectionVideoTrackData
+ (instancetype)makeWithVariantIndex:(NSInteger)variantIndex
                               label:(nullable NSString *)label
                             bitrate:(nullable NSNumber *)bitrate
                               width:(nullable NSNumber *)width
                              height:(nullable NSNumber *)height
                           frameRate:(nullable NSNumber *)frameRate
                               codec:(nullable NSString *)codec
                          isSelected:(BOOL)isSelected {
  FVPMediaSelectionVideoTrackData *pigeonResult = [[FVPMediaSelectionVideoTrackData alloc] init];
  pigeonResult.variantIndex = variantIndex;
  pigeonResult.label = label;
  pigeonResult.bitrate = bitrate;
  pigeonResult.width = width;
  pigeonResult.height = height;
  pigeonResult.frameRate = frameRate;
  pigeonResult.codec = codec;
  pigeonResult.isSelected = isSelected;
  return pigeonResult;
}
+ (FVPMediaSelectionVideoTrackData *)fromList:(NSArray<id> *)list {
  FVPMediaSelectionVideoTrackData *pigeonResult = [[FVPMediaSelectionVideoTrackData alloc] init];
  pigeonResult.variantIndex = [GetNullableObjectAtIndex(list, 0) integerValue];
  pigeonResult.label = GetNullableObjectAtIndex(list, 1);
  pigeonResult.bitrate = GetNullableObjectAtIndex(list, 2);
  pigeonResult.width = GetNullableObjectAtIndex(list, 3);
  pigeonResult.height = GetNullableObjectAtIndex(list, 4);
  pigeonResult.frameRate = GetNullableObjectAtIndex(list, 5);
  pigeonResult.codec = GetNullableObjectAtIndex(list, 6);
  pigeonResult.isSelected = [GetNullableObjectAtIndex(list, 7) boolValue];
  return pigeonResult;
}
+ (nullable FVPMediaSelectionVideoTrackData *)nullableFromList:(NSArray<id> *)list {
  return (list) ? [FVPMediaSelectionVideoTrackData fromList:list] : nil;
}
- (NSArray<id> *)toList {
  return @[
    @(self.variantIndex),
    self.label ?: [NSNull null],
    self.bitrate ?: [NSNull null],
    self.width ?: [NSNull null],
    self.height ?: [NSNull null],
    self.frameRate ?: [NSNull null],
    self.codec ?: [NSNull null],
    @(self.isSelected),
  ];
}
- (BOOL)isEqual:(id)object {
  if (self == object) {
    return YES;
  }
  if (![object isKindOfClass:[self class]]) {
    return NO;
  }
  FVPMediaSelectionVideoTrackData *other = (FVPMediaSelectionVideoTrackData *)object;
  return self.variantIndex == other.variantIndex && FLTPigeonDeepEquals(self.label, other.label) &&
         FLTPigeonDeepEquals(self.bitrate, other.bitrate) &&
         FLTPigeonDeepEquals(self.width, other.width) &&
         FLTPigeonDeepEquals(self.height, other.height) &&
         FLTPigeonDeepEquals(self.frameRate, other.frameRate) &&
         FLTPigeonDeepEquals(self.codec, other.codec) && self.isSelected == other.isSelected;
}

- (NSUInteger)hash {
  NSUInteger result = [self class].hash;
  result = result * 31 + @(self.variantIndex).hash;
  result = result * 31 + FLTPigeonDeepHash(self.label);
  result = result * 31 + FLTPigeonDeepHash(self.bitrate);
  result = result * 31 + FLTPigeonDeepHash(self.width);
  result = result * 31 + FLTPigeonDeepHash(self.height);
  result = result * 31 + FLTPigeonDeepHash(self.frameRate);
  result = result * 31 + FLTPigeonDeepHash(self.codec);
  result = result * 31 + @(self.isSelected).hash;
  return result;
}
@end

@implementation FVPAssetVideoTrackData
+ (instancetype)makeWithTrackId:(NSInteger)trackId
                          label:(nullable NSString *)label
                          width:(nullable NSNumber *)width
                         height:(nullable NSNumber *)height
                      frameRate:(nullable NSNumber *)frameRate
                          codec:(nullable NSString *)codec
                     isSelected:(BOOL)isSelected {
  FVPAssetVideoTrackData *pigeonResult = [[FVPAssetVideoTrackData alloc] init];
  pigeonResult.trackId = trackId;
  pigeonResult.label = label;
  pigeonResult.width = width;
  pigeonResult.height = height;
  pigeonResult.frameRate = frameRate;
  pigeonResult.codec = codec;
  pigeonResult.isSelected = isSelected;
  return pigeonResult;
}
+ (FVPAssetVideoTrackData *)fromList:(NSArray<id> *)list {
  FVPAssetVideoTrackData *pigeonResult = [[FVPAssetVideoTrackData alloc] init];
  pigeonResult.trackId = [GetNullableObjectAtIndex(list, 0) integerValue];
  pigeonResult.label = GetNullableObjectAtIndex(list, 1);
  pigeonResult.width = GetNullableObjectAtIndex(list, 2);
  pigeonResult.height = GetNullableObjectAtIndex(list, 3);
  pigeonResult.frameRate = GetNullableObjectAtIndex(list, 4);
  pigeonResult.codec = GetNullableObjectAtIndex(list, 5);
  pigeonResult.isSelected = [GetNullableObjectAtIndex(list, 6) boolValue];
  return pigeonResult;
}
+ (nullable FVPAssetVideoTrackData *)nullableFromList:(NSArray<id> *)list {
  return (list) ? [FVPAssetVideoTrackData fromList:list] : nil;
}
- (NSArray<id> *)toList {
  return @[
    @(self.trackId),
    self.label ?: [NSNull null],
    self.width ?: [NSNull null],
    self.height ?: [NSNull null],
    self.frameRate ?: [NSNull null],
    self.codec ?: [NSNull null],
    @(self.isSelected),
  ];
}
- (BOOL)isEqual:(id)object {
  if (self == object) {
    return YES;
  }
  if (![object isKindOfClass:[self class]]) {
    return NO;
  }
  FVPAssetVideoTrackData *other = (FVPAssetVideoTrackData *)object;
  return self.trackId == other.trackId && FLTPigeonDeepEquals(self.label, other.label) &&
         FLTPigeonDeepEquals(self.width, other.width) &&
         FLTPigeonDeepEquals(self.height, other.height) &&
         FLTPigeonDeepEquals(self.frameRate, other.frameRate) &&
         FLTPigeonDeepEquals(self.codec, other.codec) && self.isSelected == other.isSelected;
}

- (NSUInteger)hash {
  NSUInteger result = [self class].hash;
  result = result * 31 + @(self.trackId).hash;
  result = result * 31 + FLTPigeonDeepHash(self.label);
  result = result * 31 + FLTPigeonDeepHash(self.width);
  result = result * 31 + FLTPigeonDeepHash(self.height);
  result = result * 31 + FLTPigeonDeepHash(self.frameRate);
  result = result * 31 + FLTPigeonDeepHash(self.codec);
  result = result * 31 + @(self.isSelected).hash;
  return result;
}
@end

@implementation FVPNativeVideoTrackData
+ (instancetype)makeWithAssetTracks:(nullable NSArray<FVPAssetVideoTrackData *> *)assetTracks
               mediaSelectionTracks:
                   (nullable NSArray<FVPMediaSelectionVideoTrackData *> *)mediaSelectionTracks {
  FVPNativeVideoTrackData *pigeonResult = [[FVPNativeVideoTrackData alloc] init];
  pigeonResult.assetTracks = assetTracks;
  pigeonResult.mediaSelectionTracks = mediaSelectionTracks;
  return pigeonResult;
}
+ (FVPNativeVideoTrackData *)fromList:(NSArray<id> *)list {
  FVPNativeVideoTrackData *pigeonResult = [[FVPNativeVideoTrackData alloc] init];
  pigeonResult.assetTracks = GetNullableObjectAtIndex(list, 0);
  pigeonResult.mediaSelectionTracks = GetNullableObjectAtIndex(list, 1);
  return pigeonResult;
}
+ (nullable FVPNativeVideoTrackData *)nullableFromList:(NSArray<id> *)list {
  return (list) ? [FVPNativeVideoTrackData fromList:list] : nil;
}
- (NSArray<id> *)toList {
  return @[
    self.assetTracks ?: [NSNull null],
    self.mediaSelectionTracks ?: [NSNull null],
  ];
}
- (BOOL)isEqual:(id)object {
  if (self == object) {
    return YES;
  }
  if (![object isKindOfClass:[self class]]) {
    return NO;
  }
  FVPNativeVideoTrackData *other = (FVPNativeVideoTrackData *)object;
  return FLTPigeonDeepEquals(self.assetTracks, other.assetTracks) &&
         FLTPigeonDeepEquals(self.mediaSelectionTracks, other.mediaSelectionTracks);
}

- (NSUInteger)hash {
  NSUInteger result = [self class].hash;
  result = result * 31 + FLTPigeonDeepHash(self.assetTracks);
  result = result * 31 + FLTPigeonDeepHash(self.mediaSelectionTracks);
  return result;
}
@end

@interface FVPVideoPlayerInstanceMessagesPigeonCodecReader : FlutterStandardReader
@end
@implementation FVPVideoPlayerInstanceMessagesPigeonCodecReader
- (nullable id)readValueOfType:(UInt8)type {
  switch (type) {
    case 129:
      return [FVPMediaSelectionAudioTrackData fromList:[self readValue]];
    case 130:
      return [FVPMediaSelectionVideoTrackData fromList:[self readValue]];
    case 131:
      return [FVPAssetVideoTrackData fromList:[self readValue]];
    case 132:
      return [FVPNativeVideoTrackData fromList:[self readValue]];
    default:
      return [super readValueOfType:type];
  }
}
@end

@interface FVPVideoPlayerInstanceMessagesPigeonCodecWriter : FlutterStandardWriter
@end
@implementation FVPVideoPlayerInstanceMessagesPigeonCodecWriter
- (void)writeValue:(id)value {
  if ([value isKindOfClass:[FVPMediaSelectionAudioTrackData class]]) {
    [self writeByte:129];
    [self writeValue:[value toList]];
  } else if ([value isKindOfClass:[FVPMediaSelectionVideoTrackData class]]) {
    [self writeByte:130];
    [self writeValue:[value toList]];
  } else if ([value isKindOfClass:[FVPAssetVideoTrackData class]]) {
    [self writeByte:131];
    [self writeValue:[value toList]];
  } else if ([value isKindOfClass:[FVPNativeVideoTrackData class]]) {
    [self writeByte:132];
    [self writeValue:[value toList]];
  } else {
    [super writeValue:value];
  }
}
@end

@interface FVPVideoPlayerInstanceMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter
@end
@implementation FVPVideoPlayerInstanceMessagesPigeonCodecReaderWriter
- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data {
  return [[FVPVideoPlayerInstanceMessagesPigeonCodecWriter alloc] initWithData:data];
}
- (FlutterStandardReader *)readerWithData:(NSData *)data {
  return [[FVPVideoPlayerInstanceMessagesPigeonCodecReader alloc] initWithData:data];
}
@end

NSObject<FlutterMessageCodec> *FVPGetVideoPlayerInstanceMessagesCodec(void) {
  static FlutterStandardMessageCodec *sSharedObject = nil;
  static dispatch_once_t sPred = 0;
  dispatch_once(&sPred, ^{
    FVPVideoPlayerInstanceMessagesPigeonCodecReaderWriter *readerWriter =
        [[FVPVideoPlayerInstanceMessagesPigeonCodecReaderWriter alloc] init];
    sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter];
  });
  return sSharedObject;
}
void SetUpFVPVideoPlayerInstanceApi(id<FlutterBinaryMessenger> binaryMessenger,
                                    NSObject<FVPVideoPlayerInstanceApi> *api) {
  SetUpFVPVideoPlayerInstanceApiWithSuffix(binaryMessenger, api, @"");
}

void SetUpFVPVideoPlayerInstanceApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger,
                                              NSObject<FVPVideoPlayerInstanceApi> *api,
                                              NSString *messageChannelSuffix) {
  messageChannelSuffix = messageChannelSuffix.length > 0
                             ? [NSString stringWithFormat:@".%@", messageChannelSuffix]
                             : @"";
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.setLooping",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert(
          [api respondsToSelector:@selector(setLooping:error:)],
          @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(setLooping:error:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        BOOL arg_looping = [GetNullableObjectAtIndex(args, 0) boolValue];
        FlutterError *error;
        [api setLooping:arg_looping error:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.setVolume",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert(
          [api respondsToSelector:@selector(setVolume:error:)],
          @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(setVolume:error:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        double arg_volume = [GetNullableObjectAtIndex(args, 0) doubleValue];
        FlutterError *error;
        [api setVolume:arg_volume error:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.setPlaybackSpeed",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(setPlaybackSpeed:error:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to "
                @"@selector(setPlaybackSpeed:error:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        double arg_speed = [GetNullableObjectAtIndex(args, 0) doubleValue];
        FlutterError *error;
        [api setPlaybackSpeed:arg_speed error:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.play",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(playWithError:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(playWithError:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        FlutterError *error;
        [api playWithError:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.getPosition",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(position:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(position:)", api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        FlutterError *error;
        NSNumber *output = [api position:&error];
        callback(wrapResult(output, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.seekTo",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert(
          [api respondsToSelector:@selector(seekTo:completion:)],
          @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(seekTo:completion:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSInteger arg_position = [GetNullableObjectAtIndex(args, 0) integerValue];
        [api seekTo:arg_position
            completion:^(FlutterError *_Nullable error) {
              callback(wrapResult(nil, error));
            }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.pause",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(pauseWithError:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(pauseWithError:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        FlutterError *error;
        [api pauseWithError:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.dispose",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert(
          [api respondsToSelector:@selector(disposeWithError:)],
          @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(disposeWithError:)",
          api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        FlutterError *error;
        [api disposeWithError:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.getAudioTracks",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(getAudioTracks:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(getAudioTracks:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        FlutterError *error;
        NSArray<FVPMediaSelectionAudioTrackData *> *output = [api getAudioTracks:&error];
        callback(wrapResult(output, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.selectAudioTrack",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(selectAudioTrackAtIndex:error:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to "
                @"@selector(selectAudioTrackAtIndex:error:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSInteger arg_trackIndex = [GetNullableObjectAtIndex(args, 0) integerValue];
        FlutterError *error;
        [api selectAudioTrackAtIndex:arg_trackIndex error:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  /// Gets the available video tracks for the video.
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.getVideoTracks",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(getVideoTracks:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to @selector(getVideoTracks:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        [api getVideoTracks:^(FVPNativeVideoTrackData *_Nullable output,
                              FlutterError *_Nullable error) {
          callback(wrapResult(output, error));
        }];
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  /// Selects a video track by setting preferredPeakBitRate.
  /// Pass 0 to enable auto quality selection.
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi.selectVideoTrack",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(selectVideoTrackWithBitrate:error:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to "
                @"@selector(selectVideoTrackWithBitrate:error:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        NSInteger arg_bitrate = [GetNullableObjectAtIndex(args, 0) integerValue];
        FlutterError *error;
        [api selectVideoTrackWithBitrate:arg_bitrate error:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
  {
    FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]
           initWithName:[NSString stringWithFormat:@"%@%@",
                                                   @"dev.flutter.pigeon.video_player_avfoundation."
                                                   @"VideoPlayerInstanceApi."
                                                   @"setPreventsDisplaySleepDuringVideoPlayback",
                                                   messageChannelSuffix]
        binaryMessenger:binaryMessenger
                  codec:FVPGetVideoPlayerInstanceMessagesCodec()];
    if (api) {
      NSCAssert([api respondsToSelector:@selector(setPreventsDisplaySleepDuringVideoPlayback:
                                                                                       error:)],
                @"FVPVideoPlayerInstanceApi api (%@) doesn't respond to "
                @"@selector(setPreventsDisplaySleepDuringVideoPlayback:error:)",
                api);
      [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
        NSArray<id> *args = message;
        BOOL arg_preventsDisplaySleepDuringVideoPlayback =
            [GetNullableObjectAtIndex(args, 0) boolValue];
        FlutterError *error;
        [api setPreventsDisplaySleepDuringVideoPlayback:arg_preventsDisplaySleepDuringVideoPlayback
                                                  error:&error];
        callback(wrapResult(nil, error));
      }];
    } else {
      [channel setMessageHandler:nil];
    }
  }
}
