import 'package:fis_lib_media_rt/base/member.dart';
import 'package:fis_lib_media_rt/implementations/nt_rtmp/models.dart';

import 'channel/base.dart';
import 'channel/channel.dart';

class NTRemoteMember extends RemoteMember {
  /// 成员信息
  final RtmpMemberInfo memberInfo;

  /// 是否设备成员
  bool get isDevice =>
      memberInfo.deviceInfoList != null &&
      memberInfo.deviceInfoList!.isNotEmpty;

  NTRemoteMember({super.userId, required this.memberInfo});

  void handleVideoAvailableChange(bool available) {
    final channel = getDefaultChannel();
    channel.setVideoMute(!available);
  }

  void handleAudioAvailableChange(bool available) {
    final channel = getDefaultChannel();
    channel.setAudioMute(!available);
  }

  NTBasePlayChannel getDefaultChannel() {
    if (channels.isEmpty) {
      final channel = NTPlayChannel(member: this);
      addChannel(channel);
      return channel;
    } else {
      return channels.first as NTPlayChannel;
    }
  }
}

class NTLocalMember extends LocalMember {
  final RtmpMemberInfo memberInfo;

  NTLocalMember({required super.params, required this.memberInfo});
}
