Commit e7fb740d by pidan

1、fixed 直播间卡死的问题

2、fixed 上传到AppStore报bitcode相关报错的问题
parent 7b6a86ca
...@@ -32,10 +32,10 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer; ...@@ -32,10 +32,10 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer;
@property (nonatomic, strong) NSMutableDictionary <NSString *, FUSStreamPlayer> *previewDictionary; @property (nonatomic, strong) NSMutableDictionary <NSString *, FUSStreamPlayer> *previewDictionary;
// 是否应该重载视频的数据字典 // 是否应该重载视频的数据字典
@property (nonatomic, strong) NSMutableDictionary <NSString *, NSNumber *>*reloadStateDict; //@property (nonatomic, strong) NSMutableDictionary <NSString *, NSNumber *>*reloadStateDict;
// 重载次数 // 重载次数
@property (nonatomic, strong) NSMutableDictionary <NSString *, NSNumber *>*reloadTimesDict; //@property (nonatomic, strong) NSMutableDictionary <NSString *, NSNumber *>*reloadTimesDict;
// 循环检测码率 Timer // 循环检测码率 Timer
//@property (nonatomic, strong) NSTimer *loopCheckBitrateTimer; //@property (nonatomic, strong) NSTimer *loopCheckBitrateTimer;
...@@ -60,7 +60,7 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer; ...@@ -60,7 +60,7 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer;
if (self) { if (self) {
_previewDictionary = [NSMutableDictionary dictionary]; _previewDictionary = [NSMutableDictionary dictionary];
_reloadTimesDict = [NSMutableDictionary dictionary]; // _reloadTimesDict = [NSMutableDictionary dictionary];
_videoFrameCallBackIdSet = [NSMutableSet set]; _videoFrameCallBackIdSet = [NSMutableSet set];
[self registerNotification]; [self registerNotification];
...@@ -462,8 +462,8 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer; ...@@ -462,8 +462,8 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer;
[player fus_destroyPlayer]; [player fus_destroyPlayer];
player.delegate = nil; player.delegate = nil;
[_previewDictionary removeObjectForKey:uid]; [_previewDictionary removeObjectForKey:uid];
[_reloadStateDict removeObjectForKey:uid]; // [_reloadStateDict removeObjectForKey:uid];
[_reloadTimesDict removeObjectForKey:uid]; // [_reloadTimesDict removeObjectForKey:uid];
} }
- (void)fus_destroyAllPlayer - (void)fus_destroyAllPlayer
...@@ -477,8 +477,8 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer; ...@@ -477,8 +477,8 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer;
} }
[_previewDictionary removeAllObjects]; [_previewDictionary removeAllObjects];
[_reloadStateDict removeAllObjects]; // [_reloadStateDict removeAllObjects];
[_reloadTimesDict removeAllObjects]; // [_reloadTimesDict removeAllObjects];
[self fus_updatePlayersFrame]; [self fus_updatePlayersFrame];
[_videoFrameCallBackIdSet removeAllObjects]; [_videoFrameCallBackIdSet removeAllObjects];
} }
...@@ -742,9 +742,9 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer; ...@@ -742,9 +742,9 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer;
case FUSVideoPlayerPlayStatePlaying: { case FUSVideoPlayerPlayStatePlaying: {
FUSLogInfo(@"uid:%@ FUSStreamPlayView 状态变化:正在播放状态。",player.videoId); FUSLogInfo(@"uid:%@ FUSStreamPlayView 状态变化:正在播放状态。",player.videoId);
_reloadStateDict[player.videoId] = @(NO); // _reloadStateDict[player.videoId] = @(NO);
[self fus_playingStatusDidChangedHandler:YES player:player]; [self fus_playingStatusDidChangedHandler:YES player:player];
self.reloadTimesDict[player.videoId] = @(0); // self.reloadTimesDict[player.videoId] = @(0);
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (player.videoId) { if (player.videoId) {
...@@ -803,15 +803,15 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer; ...@@ -803,15 +803,15 @@ typedef id<FUSVideoPlayerProtocal> FUSStreamPlayer;
} }
#pragma mark - Setter and Getter #pragma mark - Setter and Getter
- (NSMutableDictionary<NSString *,NSNumber *> *)reloadStateDict //- (NSMutableDictionary<NSString *,NSNumber *> *)reloadStateDict
{ //{
if (!_reloadStateDict) { // if (!_reloadStateDict) {
//
_reloadStateDict = [NSMutableDictionary dictionary]; // _reloadStateDict = [NSMutableDictionary dictionary];
//
} // }
return _reloadStateDict; // return _reloadStateDict;
} //}
#pragma mark - Other #pragma mark - Other
......
...@@ -150,11 +150,11 @@ ...@@ -150,11 +150,11 @@
} }
- (void)fus_stopPlayer { - (void)fus_stopPlayer {
[self fus_destroyPlayerAsync:NO]; [self fus_destroyPlayerAsync:YES];
} }
- (void)fus_destroyPlayer { - (void)fus_destroyPlayer {
[self fus_destroyPlayerAsync:NO]; [self fus_destroyPlayerAsync:YES];
} }
- (void)fus_destroyPlayerAsync:(BOOL)async { - (void)fus_destroyPlayerAsync:(BOOL)async {
...@@ -168,13 +168,15 @@ ...@@ -168,13 +168,15 @@
[self.liveManager setMuted:YES]; [self.liveManager setMuted:YES];
} }
[self.liveManager.playerView removeFromSuperview]; [self.liveManager.playerView removeFromSuperview];
[self.liveManager stop];
if (async) { if (async) {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self.liveManager stop];
});
[self.liveManager closeAsync]; [self.liveManager closeAsync];
} else { } else {
[self.liveManager stop];
[self.liveManager close]; [self.liveManager close];
} }
[self fus_removeKVOIfNeeded];
} @catch (NSException *exception) { } @catch (NSException *exception) {
} @finally { } @finally {
} }
...@@ -224,7 +226,7 @@ ...@@ -224,7 +226,7 @@
TVLManager *liveManager = [[TVLManager alloc] initWithOwnPlayer:YES]; TVLManager *liveManager = [[TVLManager alloc] initWithOwnPlayer:YES];
[liveManager setDelegate:self]; // TVLProtocol代理设置 [liveManager setDelegate:self]; // TVLProtocol代理设置
[liveManager setProjectKey:@"Fusi"]; // 标识产品 [liveManager setProjectKey:@"Fusi"]; // 标识产品
liveManager.commonTag = @"test"; liveManager.commonTag = @"ios";
[liveManager setRetryTimeInternal:5]; // 重试间隔 [liveManager setRetryTimeInternal:5]; // 重试间隔
[liveManager setRetryCountLimit:INT_MAX]; // 重试最大次数 [liveManager setRetryCountLimit:INT_MAX]; // 重试最大次数
[liveManager setRetryTimeLimit:INT_MAX]; // 单次重试最大时长 [liveManager setRetryTimeLimit:INT_MAX]; // 单次重试最大时长
......
...@@ -107,23 +107,42 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -107,23 +107,42 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
- (void)handleRouteChangeNotification:(NSNotification *)notification { - (void)handleRouteChangeNotification:(NSNotification *)notification {
NSNumber* reasonNumber =
notification.userInfo[AVAudioSessionRouteChangeReasonKey]; dispatch_async(dispatch_get_global_queue(0, 0), ^{
AVAudioSessionRouteChangeReason reason =
(AVAudioSessionRouteChangeReason)reasonNumber.unsignedIntegerValue; NSNumber* reasonNumber =
if (reason == AVAudioSessionRouteChangeReasonCategoryChange) { notification.userInfo[AVAudioSessionRouteChangeReasonKey];
AVAudioSessionCategoryOptions currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions; AVAudioSessionRouteChangeReason reason =
AVAudioSessionCategory currentCategory = [AVAudioSession sharedInstance].category; (AVAudioSessionRouteChangeReason)reasonNumber.unsignedIntegerValue;
// //在需要进行对audioSession进行修正的场景下(RTC直播),修改category时options未包含mixWithOther,则给options追加mixWithOther if (reason == AVAudioSessionRouteChangeReasonCategoryChange) {
AVAudioSessionCategoryOptions categoryOptions = AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetoothA2DP; AVAudioSessionCategoryOptions currentCategoryOptions = [AVAudioSession sharedInstance].categoryOptions;
if (currentCategoryOptions != categoryOptions) { AVAudioSessionCategory currentCategory = [AVAudioSession sharedInstance].category;
[[AVAudioSession sharedInstance] setCategory:currentCategory withOptions:categoryOptions error:nil]; // //在需要进行对audioSession进行修正的场景下(RTC直播),修改category时options未包含mixWithOther,则给options追加mixWithOther
} AVAudioSessionCategoryOptions categoryOptions = AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetoothA2DP;
//
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]; if (currentCategoryOptions != categoryOptions) {
[[AVAudioSession sharedInstance] setActive:YES error:nil]; [[AVAudioSession sharedInstance] setCategory:currentCategory withOptions:categoryOptions error:nil];
} }
}
[[AVAudioSession sharedInstance] setActive:YES error:nil];
} else if (reason == AVAudioSessionRouteChangeReasonRouteConfigurationChange) {
AVAudioSessionRouteDescription *currentRoute = [AVAudioSession sharedInstance].currentRoute;
BOOL needForceToSpeaker = NO;
for (AVAudioSessionPortDescription *port in currentRoute.outputs) {
/// 连麦不通过听筒播放
if (port.portType == AVAudioSessionPortBuiltInReceiver) {
needForceToSpeaker = YES;
}
}
if (needForceToSpeaker) {
[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil];
}
}
});}
- (void)fus_switchRole:(AgoraClientRole)role{ - (void)fus_switchRole:(AgoraClientRole)role{
...@@ -166,6 +185,11 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -166,6 +185,11 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
success:(void(^)(void))success success:(void(^)(void))success
failure:(void(^)(void))failure failure:(void(^)(void))failure
{ {
if (FUSLiveHelper.shareInstance.roomInfoModel.channelId.integerValue != channelId.integerValue) {
FUSLogVerbose(@"pp===中断加入频道 %@", channelId);
FUSLogVerbose(@"pp===当前channelid %@", FUSLiveHelper.shareInstance.roomInfoModel.channelId);
return;
}
[self delayUpdateToSpeakerPlay]; [self delayUpdateToSpeakerPlay];
_joinChannelSuccessBlock = success; _joinChannelSuccessBlock = success;
FUSLogVerbose(@"连麦:开始加入频道"); FUSLogVerbose(@"连麦:开始加入频道");
...@@ -235,6 +259,11 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -235,6 +259,11 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
success:(void(^)(void))success success:(void(^)(void))success
failure:(void(^)(void))failure{ failure:(void(^)(void))failure{
if (FUSLiveHelper.shareInstance.roomInfoModel.channelId.integerValue != channelId.integerValue) {
FUSLogVerbose(@"pp===中断加入频道 %@", channelId);
FUSLogVerbose(@"pp===当前channelid %@", FUSLiveHelper.shareInstance.roomInfoModel.channelId);
return;
}
_myselfIsOnMic = YES; _myselfIsOnMic = YES;
[self delayUpdateToSpeakerPlay]; [self delayUpdateToSpeakerPlay];
...@@ -367,6 +396,7 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -367,6 +396,7 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
[self fus_stopRTCStreamingWithCompletion:^{ [self fus_stopRTCStreamingWithCompletion:^{
[AgoraRtcEngineKit destroy]; [AgoraRtcEngineKit destroy];
self.agoraEngine = nil; self.agoraEngine = nil;
self->_role = AgoraClientRoleAudience;
}]; }];
} }
...@@ -426,7 +456,7 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange"; ...@@ -426,7 +456,7 @@ NSString * const kLiveLinkMicRoleDidChanged = @"linkMicRoleChange";
open = NO; open = NO;
} }
// [_agoraEngine muteLocalAudioStream:!open]; [_agoraEngine muteLocalAudioStream:!open];
//TODO: ludy:对应bugYBCH-28179 連麥的時候,開麥閉麥會断一下。 7580版本因为测试时间有限,先不改,下版本直接打开下面的注释,把上面的代码注释,修改测试 //TODO: ludy:对应bugYBCH-28179 連麥的時候,開麥閉麥會断一下。 7580版本因为测试时间有限,先不改,下版本直接打开下面的注释,把上面的代码注释,修改测试
// [_agoraEngine enableLocalAudio:open]; // [_agoraEngine enableLocalAudio:open];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment