优化音量评估参数,将最大评估时间从900毫秒更改为300毫秒;在处理公共房间消息时,新增对 NIM 通知对象的类型检查,确保在特定事件类型下不进行处理;扩展礼物和游戏相关的横幅清理逻辑,确保在特定条件下正确移除横幅;新增清理 CP 相关横幅的逻辑,确保在关闭礼物特效时不再展示;实现麦克风队列的深度复制,确保数据一致性;重置声波动画状态以避免视图复用问题。

This commit is contained in:
edwinQQQ
2025-09-19 23:17:56 +08:00
parent 33e42234ca
commit 024936570c
7 changed files with 303 additions and 23 deletions

View File

@@ -33,7 +33,7 @@
AudioVolumeParams.enableVadDetection = YES;
AudioVolumeParams.enablePitchCalculation = YES;
AudioVolumeParams.enableSpectrumCalculation = YES;
[self.engine enableAudioVolumeEvaluation:900 withParams:AudioVolumeParams];
[self.engine enableAudioVolumeEvaluation:300 withParams:AudioVolumeParams];
[TRTCCloud setConsoleEnabled:NO];
[_engine addDelegate:self];
}

View File

@@ -741,7 +741,11 @@ BannerSchedulerDelegate
}
} else if (obj.second == Custom_Message_Sub_Super_Gift_Banner ||
obj.second == Custom_Message_Sub_Gift_ChannelNotify ||
obj.second == Custom_Message_Sub_LuckyPackage) {
obj.second == Custom_Message_Sub_LuckyPackage ||
obj.second == Custom_Message_Sub_Super_Gift_Winning_Coins_ALL_Room ||
obj.second == Custom_Message_Sub_Room_Gift_LuckBag ||
obj.second == Custom_Message_Sub_Room_Gift_LuckBag_Server ||
obj.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree) {
// banner
BOOL allowGiftScreen = [[TurboModeStateManager sharedManager] isGlobalGiftScreenEnabledForRoom:roomIdForTurbo];
if (!allowGiftScreen) {
@@ -3900,7 +3904,8 @@ BannerSchedulerDelegate
for (UIView *subview in self.bannerContainer.subviews) {
if ([subview isKindOfClass:[BravoGiftBannerView class]] ||
[subview isKindOfClass:[LuckyGiftWinningBannerView class]] ||
[subview isKindOfClass:[RoomHighValueGiftBannerAnimation class]]) {
[subview isKindOfClass:[RoomHighValueGiftBannerAnimation class]] ||
[subview isKindOfClass:[LuckyPackageBannerView class]]) {
[viewsToRemove addObject:subview];
}
}
@@ -3909,6 +3914,22 @@ BannerSchedulerDelegate
[view removeFromSuperview];
}
// bannerbannerbanner
if (self.bannerScheduler) {
//
for (NSInteger i = self.bannerScheduler.queueCount - 1; i >= 0; i--) {
id queued = [self.bannerScheduler bannerAtIndex:i];
if ([queued isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *att = (AttachmentModel *)queued;
if (att.second == Custom_Message_Sub_Super_Gift_Banner ||
att.second == Custom_Message_Sub_Gift_ChannelNotify ||
att.second == Custom_Message_Sub_LuckyPackage) {
[self.bannerScheduler removeBannerAtIndex:i];
}
}
}
}
// banner
if (self.isRoomBannerV2Displaying) {
self.isRoomBannerV2Displaying = NO;
@@ -3934,6 +3955,20 @@ BannerSchedulerDelegate
[view removeFromSuperview];
}
// banner/
if (self.bannerScheduler) {
for (NSInteger i = self.bannerScheduler.queueCount - 1; i >= 0; i--) {
id queued = [self.bannerScheduler bannerAtIndex:i];
if ([queued isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *att = (AttachmentModel *)queued;
if (att.second == Custom_Message_Sub_General_Floating_Screen_One_Room ||
att.second == Custom_Message_Sub_General_Floating_Screen_All_Room) {
[self.bannerScheduler removeBannerAtIndex:i];
}
}
}
}
// banner
if (self.isRoomBannerV2Displaying) {
self.isRoomBannerV2Displaying = NO;
@@ -3977,14 +4012,38 @@ BannerSchedulerDelegate
#pragma mark - BannerSchedulerDelegate
- (void)bannerScheduler:(BannerScheduler *)scheduler shouldPlayBanner:(id)banner {
// Banner AttachmentModel
if ([banner isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)banner;
[self _playBannerWithAttachment:attachment];
} else {
// Banner AttachmentModel
if (![banner isKindOfClass:[AttachmentModel class]]) {
NSLog(@"⚠️ BannerSchedulerDelegate: Banner 不是 AttachmentModel 类型");
[self.bannerScheduler markBannerFinished];
return;
}
AttachmentModel *attachment = (AttachmentModel *)banner;
// TurboMode
NSString *roomIdForTurbo = self.currentRoomId ?: @([self.hostDelegate getRoomInfo].roomId).stringValue;
BOOL allowed = YES;
if (attachment.second == Custom_Message_Sub_General_Floating_Screen_One_Room ||
attachment.second == Custom_Message_Sub_General_Floating_Screen_All_Room) {
allowed = [[TurboModeStateManager sharedManager] isGlobalGameScreenEnabledForRoom:roomIdForTurbo];
} else if (attachment.second == Custom_Message_Sub_Super_Gift_Banner ||
attachment.second == Custom_Message_Sub_Gift_ChannelNotify ||
attachment.second == Custom_Message_Sub_LuckyPackage) {
allowed = [[TurboModeStateManager sharedManager] isGlobalGiftScreenEnabledForRoom:roomIdForTurbo];
} else if (attachment.second == Custom_Message_Sub_CP_Gift ||
attachment.second == Custom_Message_Sub_CP_Upgrade ||
attachment.second == Custom_Message_Sub_CP_Binding) {
allowed = [[TurboModeStateManager sharedManager] isGiftEffectsEnabledForRoom:roomIdForTurbo];
}
if (!allowed) {
NSLog(@"🎮 TurboMode 二次校验拒绝播放 banner(second=%ld) - 房间ID:%@", (long)attachment.second, roomIdForTurbo);
[self.bannerScheduler markBannerFinished];
return;
}
[self _playBannerWithAttachment:attachment];
}
- (void)bannerSchedulerDidFinishPlaying:(BannerScheduler *)scheduler {
@@ -4188,6 +4247,12 @@ BannerSchedulerDelegate
//
if (!enabled) {
[self cleanupGiftEffects];
// CP Banner CP
if (self.currentRoomId.length > 0) {
[self cleanupCpBanners];
} else {
[self cleanupCpBanners];
}
}
NSLog(@"🎮 RoomAnimationView 礼物特效状态变化: %@", enabled ? @"开启" : @"关闭");
@@ -4225,6 +4290,50 @@ BannerSchedulerDelegate
NSLog(@"🎮 RoomAnimationView CP麦位开关状态变化: %@", enabled ? @"开启" : @"关闭");
}
// 🔧 CP banner
- (void)cleanupCpBanners {
NSLog(@"🎮 清理 CP 相关banner");
// CP
NSMutableArray *viewsToRemove = [NSMutableArray array];
for (UIView *subview in self.bannerContainer.subviews) {
if ([subview isKindOfClass:[CPGiftBanner class]]) {
[viewsToRemove addObject:subview];
}
}
for (UIView *subview in self.topContainer.subviews) {
if ([subview isKindOfClass:[CPBindingAnimation class]] ||
[subview isKindOfClass:[CPLevelUpAnimation class]]) {
[viewsToRemove addObject:subview];
}
}
for (UIView *v in viewsToRemove) {
[v removeFromSuperview];
}
// CP bannerCP //
if (self.bannerScheduler) {
for (NSInteger i = self.bannerScheduler.queueCount - 1; i >= 0; i--) {
id queued = [self.bannerScheduler bannerAtIndex:i];
if ([queued isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *att = (AttachmentModel *)queued;
if (att.second == Custom_Message_Sub_CP_Gift ||
att.second == Custom_Message_Sub_CP_Upgrade ||
att.second == Custom_Message_Sub_CP_Binding) {
[self.bannerScheduler removeBannerAtIndex:i];
}
}
}
}
if (self.isRoomBannerV2Displaying) {
self.isRoomBannerV2Displaying = NO;
[self.bannerScheduler markBannerFinished];
}
NSLog(@"🎮 CP 相关banner清理完成");
}
// 🔧 ID
- (void)handleCurrentRoomIdSet:(NSNotification *)notification {
NSString *roomId = notification.userInfo[@"roomId"];

View File

@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
///开始展示声波动画
- (void)startWaveAnimationWithUrl:(NSString *)url;
- (void)startWaveAnimationWithVideoItem:(SVGAVideoEntity *)videoItem;
///结束声波动画
- (void)stopWaveAnimation;
@end

View File

@@ -584,6 +584,9 @@
self.microModel = model;
MicroStateModel * micStats = model.microState;
UserInfoModel * userInfo = model.userInfo;
// //
[self.animationView stopWaveAnimation];
[self.nobleWaveView stopWaveAnimation];
[self configMicroState:micStats];
[self configUser:userInfo];
}
@@ -638,6 +641,9 @@
- (void)configUser:(UserInfoModel *)userInfo {
self.userInfo = userInfo;
// userSpeaking
[self.animationView stopWaveAnimation];
[self.nobleWaveView stopWaveAnimation];
self.nickLabel.hidden = NO;
self.sexImageView.hidden = YES;

View File

@@ -42,9 +42,8 @@
return;
}
if (self.isAnimationing) {
[self.firstView.layer removeAllAnimations];
}
[self.firstView.layer removeAllAnimations];
self.isAnimationing = YES;
self.firstView.hidden = NO;
[self animationWithLayer:self.firstView];

View File

@@ -281,6 +281,7 @@
[RtcManager instance].localMuted = YES;
}
}
if (roomInfo.type == RoomType_Anchor && [[AccountInfoStorage instance].getUid isEqualToString:[NSString stringWithFormat:@"%ld", roomInfo.uid]]) {
selfNeedBroadcast = YES;///
}
@@ -290,8 +291,7 @@
[statisMicArray addObject:str];
}
}
if (statisMicArray.count) {
}
if (leaveMode) {
UserInfoModel *owner = [[UserInfoModel alloc] init];
owner.avatar = anchorModel.userInfo.avatar? anchorModel.userInfo.avatar : roomInfo.avatar;
@@ -428,7 +428,142 @@
}
- (NSMutableDictionary<NSString *,MicroQueueModel *> *)getMicroQueue {
return self.micQueue;
// micQueue
NSMutableDictionary<NSString *,MicroQueueModel *> *deepCopy = [NSMutableDictionary dictionary];
for (NSString *position in self.micQueue.allKeys) {
MicroQueueModel *originalModel = [self.micQueue objectForKey:position];
MicroQueueModel *copiedModel = [[MicroQueueModel alloc] init];
// microState
if (originalModel.microState) {
MicroStateModel *copiedMicroState = [[MicroStateModel alloc] init];
copiedMicroState.position = originalModel.microState.position;
copiedMicroState.posState = originalModel.microState.posState;
copiedMicroState.micState = originalModel.microState.micState;
copiedMicroState.datingMicType = originalModel.microState.datingMicType;
copiedMicroState.indexOffset = originalModel.microState.indexOffset;
copiedModel.microState = copiedMicroState;
}
// userInfo
if (originalModel.userInfo) {
UserInfoModel *copiedUserInfo = [[UserInfoModel alloc] init];
//
copiedUserInfo.bindType = originalModel.userInfo.bindType;
copiedUserInfo.createTime = originalModel.userInfo.createTime;
copiedUserInfo.parentMode = originalModel.userInfo.parentMode;
copiedUserInfo.isBindPhone = originalModel.userInfo.isBindPhone;
copiedUserInfo.erbanNo = originalModel.userInfo.erbanNo;
copiedUserInfo.registerDay = originalModel.userInfo.registerDay;
copiedUserInfo.isFirstCharge = originalModel.userInfo.isFirstCharge;
copiedUserInfo.hasPrettyErbanNo = originalModel.userInfo.hasPrettyErbanNo;
copiedUserInfo.isBindApple = originalModel.userInfo.isBindApple;
copiedUserInfo.fansNum = originalModel.userInfo.fansNum;
copiedUserInfo.isBindBankCard = originalModel.userInfo.isBindBankCard;
copiedUserInfo.hasRegPacket = originalModel.userInfo.hasRegPacket;
copiedUserInfo.gender = originalModel.userInfo.gender;
copiedUserInfo.platformRole = originalModel.userInfo.platformRole;
copiedUserInfo.uid = originalModel.userInfo.uid;
copiedUserInfo.defUser = originalModel.userInfo.defUser;
copiedUserInfo.remainDay = originalModel.userInfo.remainDay;
copiedUserInfo.isReview = originalModel.userInfo.isReview;
copiedUserInfo.newUser = originalModel.userInfo.newUser;
copiedUserInfo.followNum = originalModel.userInfo.followNum;
copiedUserInfo.isBindPaymentPwd = originalModel.userInfo.isBindPaymentPwd;
copiedUserInfo.isBindXCZAccount = originalModel.userInfo.isBindXCZAccount;
copiedUserInfo.isBindAlipay = originalModel.userInfo.isBindAlipay;
copiedUserInfo.isBindPasswd = originalModel.userInfo.isBindPasswd;
copiedUserInfo.visitNum = originalModel.userInfo.visitNum;
copiedUserInfo.inRoomNum = originalModel.userInfo.inRoomNum;
copiedUserInfo.showLimitCharge = originalModel.userInfo.showLimitCharge;
copiedUserInfo.limitChargeEndTime = originalModel.userInfo.limitChargeEndTime;
copiedUserInfo.isCertified = originalModel.userInfo.isCertified;
copiedUserInfo.isCustomWord = originalModel.userInfo.isCustomWord;
copiedUserInfo.otherViewType = originalModel.userInfo.otherViewType;
copiedUserInfo.headwearType = originalModel.userInfo.headwearType;
copiedUserInfo.headWearType = originalModel.userInfo.headWearType;
copiedUserInfo.vipMic = originalModel.userInfo.vipMic;
copiedUserInfo.hasSelectUser = originalModel.userInfo.hasSelectUser;
copiedUserInfo.selectMicPosition = originalModel.userInfo.selectMicPosition;
copiedUserInfo.gameStatus = originalModel.userInfo.gameStatus;
copiedUserInfo.groupType = originalModel.userInfo.groupType;
copiedUserInfo.preventKick = originalModel.userInfo.preventKick;
copiedUserInfo.fromSayHelloChannel = originalModel.userInfo.fromSayHelloChannel;
copiedUserInfo.banAccount = originalModel.userInfo.banAccount;
copiedUserInfo.isRechargeUser = originalModel.userInfo.isRechargeUser;
copiedUserInfo.isNoProhibitMic = originalModel.userInfo.isNoProhibitMic;
copiedUserInfo.hasSuperRole = originalModel.userInfo.hasSuperRole;
copiedUserInfo.uploadGifAvatarPrice = originalModel.userInfo.uploadGifAvatarPrice;
copiedUserInfo.birth = originalModel.userInfo.birth;
//
copiedUserInfo.phone = [originalModel.userInfo.phone copy];
copiedUserInfo.email = [originalModel.userInfo.email copy];
copiedUserInfo.nick = [originalModel.userInfo.nick copy];
copiedUserInfo.avatar = [originalModel.userInfo.avatar copy];
copiedUserInfo.reviewingAvatar = [originalModel.userInfo.reviewingAvatar copy];
copiedUserInfo.region = [originalModel.userInfo.region copy];
copiedUserInfo.userDesc = [originalModel.userInfo.userDesc copy];
copiedUserInfo.nameplatePic = [originalModel.userInfo.nameplatePic copy];
copiedUserInfo.nameplateWord = [originalModel.userInfo.nameplateWord copy];
copiedUserInfo.roomUid = [originalModel.userInfo.roomUid copy];
copiedUserInfo.roomTitle = [originalModel.userInfo.roomTitle copy];
copiedUserInfo.carEffect = [originalModel.userInfo.carEffect copy];
copiedUserInfo.viewUrl = [originalModel.userInfo.viewUrl copy];
copiedUserInfo.carName = [originalModel.userInfo.carName copy];
copiedUserInfo.headwearEffect = [originalModel.userInfo.headwearEffect copy];
copiedUserInfo.headwearPic = [originalModel.userInfo.headwearPic copy];
copiedUserInfo.headWearUrl = [originalModel.userInfo.headWearUrl copy];
copiedUserInfo.capUrl = [originalModel.userInfo.capUrl copy];
copiedUserInfo.userInfoCardPic = [originalModel.userInfo.userInfoCardPic copy];
copiedUserInfo.micCircle = [originalModel.userInfo.micCircle copy];
copiedUserInfo.micNickColor = [originalModel.userInfo.micNickColor copy];
copiedUserInfo.fromNick = [originalModel.userInfo.fromNick copy];
copiedUserInfo.fromUid = [originalModel.userInfo.fromUid copy];
copiedUserInfo.androidBubbleUrl = [originalModel.userInfo.androidBubbleUrl copy];
copiedUserInfo.iosBubbleUrl = [originalModel.userInfo.iosBubbleUrl copy];
copiedUserInfo.phoneAreaCode = [originalModel.userInfo.phoneAreaCode copy];
copiedUserInfo.partitionId = [originalModel.userInfo.partitionId copy];
copiedUserInfo.guildNameplateIcon = [originalModel.userInfo.guildNameplateIcon copy];
copiedUserInfo.regionIcon = [originalModel.userInfo.regionIcon copy];
copiedUserInfo.visitTimeDesc = [originalModel.userInfo.visitTimeDesc copy];
//
copiedUserInfo.labels = [originalModel.userInfo.labels copy];
copiedUserInfo.privatePhoto = [originalModel.userInfo.privatePhoto copy];
copiedUserInfo.absCardPics = [originalModel.userInfo.absCardPics copy];
copiedUserInfo.userGiftWall = [originalModel.userInfo.userGiftWall copy];
copiedUserInfo.userLuckyBagGiftWall = [originalModel.userInfo.userLuckyBagGiftWall copy];
copiedUserInfo.dynamicInfo = [originalModel.userInfo.dynamicInfo copy];
copiedUserInfo.userNameplateList = [originalModel.userInfo.userNameplateList copy];
copiedUserInfo.medalsPic = [originalModel.userInfo.medalsPic copy];
//
copiedUserInfo.userExpand = originalModel.userInfo.userExpand;
copiedUserInfo.userLevelVo = originalModel.userInfo.userLevelVo;
copiedUserInfo.userInfoSkillVo = originalModel.userInfo.userInfoSkillVo;
copiedUserInfo.userVipInfoVO = originalModel.userInfo.userVipInfoVO;
copiedUserInfo.audioCard = originalModel.userInfo.audioCard;
copiedUserInfo.medals = originalModel.userInfo.medals;
copiedUserInfo.relationUserVO = originalModel.userInfo.relationUserVO;
copiedUserInfo.guildInfo = originalModel.userInfo.guildInfo;
copiedUserInfo.usingPersonalBackground = originalModel.userInfo.usingPersonalBackground;
copiedUserInfo.infoCardVo = originalModel.userInfo.infoCardVo;
//
copiedUserInfo.levelAtt = [originalModel.userInfo.levelAtt copy];
copiedUserInfo.idAtt = [originalModel.userInfo.idAtt copy];
copiedModel.userInfo = copiedUserInfo;
} else {
copiedModel.userInfo = nil;
}
[deepCopy setObject:copiedModel forKey:position];
}
return deepCopy;
}
- (void)onRoomUpdate {
@@ -486,9 +621,7 @@
NSString* position = [data objectForKey:NIMChatroomEventInfoQueueChangeItemKey];
UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]];
NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue];
// if (userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
// ownerRTCChanged = YES;
// }
//
for (MicroQueueModel *sequence in self.micQueue.allValues) {
if (userInfo.uid == sequence.userInfo.uid) {
@@ -496,7 +629,19 @@
}
}
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
if (changeType == 2){
if (changeType == 2){ //
// position MicroQueueModel userInfo
MicroQueueModel *sequence = [self.micQueue objectForKey:position];
if (sequence) {
sequence.userInfo = nil;
// micQueue
UIView<MicroViewProtocol> *microView = [self findMicroViewByIndex:[self positionToIndex:position]];
if (microView) {
[microView configMicroView:sequence];
}
}
if (userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && roomInfo.roomModeType == RoomModeType_Open_Blind){
if (roomInfo.roomModeType != RoomModeType_Open_AcrossRoomPK_mode){
if ([RtcManager instance].isAnckorPk == NO){
@@ -510,6 +655,12 @@
}else if (changeType == 1) { //
MicroQueueModel *sequence = [self.micQueue objectForKey:position];
sequence.userInfo = userInfo;
// micQueue
UIView<MicroViewProtocol> *microView = [self findMicroViewByIndex:[self positionToIndex:position]];
if (microView) {
[microView configMicroView:sequence];
}
if (self.hostDelegate.getRoomInfo.showGiftValue && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo;
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
@@ -546,9 +697,7 @@
}
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[RtcManager instance].isMiniEnter = NO;
});
[RtcManager instance].isMiniEnter = NO;
}
}
if(userInfo.isNoProhibitMic == YES){
@@ -590,6 +739,10 @@
case NIMChatroomEventTypeExit:
case NIMChatroomEventTypeKicked:
{
if (message.session.sessionId == self.hostDelegate.getRoomInfo.roomId) {
}
for (NIMChatroomNotificationMember *member in content.targets) {
for (MicroQueueModel *sequence in self.micQueue.allValues) {
if (member.userId.integerValue == sequence.userInfo.uid) {
@@ -1379,6 +1532,7 @@
}
- (NSMutableDictionary<NSString *, MicroQueueModel *> *)micQueue {
// 使- stageview nineteenmicstageview queue
if (!_micQueue) {
_micQueue= [NSMutableDictionary dictionary];
for (int i = 0; i < self.countOfMicroView; i++) {

View File

@@ -3720,9 +3720,19 @@ XPCandyTreeInsufficientBalanceViewDelegate>
return;
}
if ([message.messageObject isKindOfClass:[NIMNotificationObject class]]) {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
if ([notiMsg respondsToSelector:@selector(content)]) {
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
if (content.eventType == NIMChatroomEventTypeExit || content.eventType == NIMChatroomEventTypeKicked) {
return;
}
}
}
switch (message.messageType) {
case NIMMessageTypeNotification:
[self handleNIMNotificationTypeMessage:message];
break;
case NIMMessageTypeCustom:
[self handleNimCustomTypeMessage:message];