Commit f48c2f6c by ludi

修复直播崩溃的bug,调整一些ui

parent 3159f1dc
Showing with 168 additions and 76 deletions
......@@ -7,6 +7,7 @@
#import "FUSStreamCatureHelper.h"
#import <TTSDK/VeLivePusher.h>
#import <QuartzCore/QuartzCore.h>
#import "FUSBeautyTTSDKEngine.h"
#import "FUSBeautyEngine.h"
#import "FUSStreamKitConfig.h"
......@@ -43,6 +44,10 @@
/// 手动记录是否停止采集
@property (nonatomic, assign) BOOL videoCaptureIsOn;
@property (nonatomic, assign) BOOL isRestartingPush;
@property (nonatomic, assign) CFTimeInterval lastRestartPushTime;
@property (nonatomic, assign) NSInteger lowVideoBitrateCount;
@end
@implementation FUSStreamCatureHelper
......@@ -373,10 +378,37 @@
*/
- (void)onStatistics:(VeLivePusherStatistics *)statistics
{
FUSLogInfo(@"suolong::statistics.transportVideoBitrate == %d", statistics.transportVideoBitrate);
if (statistics.transportVideoBitrate <= 0) {
[self fus_restartStreamPush];
int transportVideoBitrate = statistics.transportVideoBitrate;
if (FUSStreamKitConfig.sharedInstance.logType | FUSStreamKitLogTypePush) {
FUSLogInfo(@"suolong::statistics.transportVideoBitrate == %d", transportVideoBitrate);
}
dispatch_async_on_main_queue(^{
if (transportVideoBitrate > 0) {
self.lowVideoBitrateCount = 0;
return;
}
self.lowVideoBitrateCount += 1;
if (self.lowVideoBitrateCount < 2) {
return;
}
if (self.isRestartingPush) {
return;
}
CFTimeInterval now = CACurrentMediaTime();
if (now - self.lastRestartPushTime < 5.0) {
return;
}
self.lastRestartPushTime = now;
self.isRestartingPush = YES;
if (FUSStreamKitConfig.sharedInstance.logType | FUSStreamKitLogTypePush) {
FUSLogInfo(@"suolong::statistics restartPush, lowCount=%zd", self.lowVideoBitrateCount);
}
[self fus_restartStreamPush];
});
}
/**
......@@ -443,7 +475,9 @@
self.pushUrl = url;
self.completionHandler = completionHandler;
[self.livePusher startPush:self.pushUrl];
dispatch_async_on_main_queue(^{
[self.livePusher startPush:self.pushUrl];
});
}
/**
......@@ -454,9 +488,11 @@
if (FUSStreamKitConfig.sharedInstance.logType | FUSStreamKitLogTypePush) {
FUSLogInfo(@"pierce:stop %s",__func__);
}
if (self.livePusher.isPushing) {
[self.livePusher stopPush];
}
dispatch_async_on_main_queue(^{
if (self.livePusher.isPushing) {
[self.livePusher stopPush];
}
});
}
/**
......@@ -464,58 +500,79 @@
*/
- (void)fus_restartStreamPush
{
if (self.livePusher == nil) {
return;
}
if ([NSString isNullWithString:self.pushUrl]) {
return;
}
if (self.config.captureType == FUSStreamCaptureTypeVideoChat) {
return;
}
if (self.onlyCapture) {
return;
}
BOOL muted = self.mute;
// 在后台期间不做重载操作,容易导致闪退
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
return;
}
VeLivePushStatus state = self.livePusher;
if (self.liveSessionState == FUSStreamSessionStateReconnecting ||
self.liveSessionState == FUSStreamSessionStateStarted ||
self.liveSessionState == FUSStreamSessionStateStarting) {
[self.livePusher startPush:self.pushUrl];
self.mute = muted;
return;
}
if (self.liveSessionState == FUSStreamSessionStateError) {
// 重新推流。先把原本的推流对象释放掉。生成新的推流对象,否则会发送推不上流的情况
[self fus_stopStreamPush];
[_lock lock];
self.livePusher = nil;
[_lock unlock];
if (FUSStreamKitConfig.sharedInstance.logType | FUSStreamKitLogTypePush) {
FUSLogInfo(@"pierce:stop %s",__func__);
dispatch_async_on_main_queue(^{
if (self.livePusher == nil) {
self.isRestartingPush = NO;
return;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self initEngine];
[self fus_startStreamPushWithUrl:self.pushUrl pushMixUrl:self.pushMixUrl completionHandler:self.completionHandler];
self.mute = muted;
});
} else {
MJWeakSelf
dispatch_async_on_main_queue(^{
[weakSelf fus_setupLiveSessionConfigs];
[weakSelf fus_startStreamPushWithUrl:self.pushUrl pushMixUrl:self.pushMixUrl completionHandler:self.completionHandler];
});
}
if ([NSString isNullWithString:self.pushUrl]) {
self.isRestartingPush = NO;
return;
}
if (self.config.captureType == FUSStreamCaptureTypeVideoChat) {
self.isRestartingPush = NO;
return;
}
if (self.onlyCapture) {
self.isRestartingPush = NO;
return;
}
BOOL muted = self.mute;
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
self.isRestartingPush = NO;
return;
}
VeLivePushStatus state = self.livePusher;
if (self.liveSessionState == FUSStreamSessionStateReconnecting ||
self.liveSessionState == FUSStreamSessionStateStarted ||
self.liveSessionState == FUSStreamSessionStateStarting) {
[self fus_stopStreamPush];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.livePusher startPush:self.pushUrl];
self.mute = muted;
self.isRestartingPush = NO;
});
return;
}
if (self.liveSessionState == FUSStreamSessionStateError) {
[self fus_stopStreamPush];
VeLivePusher *oldPusher = self.livePusher;
[_lock lock];
self.livePusher = nil;
[_lock unlock];
[oldPusher destroy];
if (FUSStreamKitConfig.sharedInstance.logType | FUSStreamKitLogTypePush) {
FUSLogInfo(@"pierce:stop %s",__func__);
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self initEngine];
[self fus_startStreamPushWithUrl:self.pushUrl pushMixUrl:self.pushMixUrl completionHandler:self.completionHandler];
self.mute = muted;
self.lowVideoBitrateCount = 0;
self.isRestartingPush = NO;
});
return;
}
else {
[self fus_stopStreamPush];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self fus_setupLiveSessionConfigs];
[self fus_startStreamPushWithUrl:self.pushUrl pushMixUrl:self.pushMixUrl completionHandler:self.completionHandler];
self.mute = muted;
self.lowVideoBitrateCount = 0;
self.isRestartingPush = NO;
});
}
});
}
/**
......
......@@ -13,8 +13,8 @@ class FUSPKScoreProgressView: FUSBaseView {
public var clickLeftSideHandler:((Bool) -> Void)?
let circleViewHeight: CGFloat = 36.0 * UIView.fus_screenW() / 375.0
let circleBlackBackgroundHeight: CGFloat = 42.0 * UIView.fus_screenW() / 375.0
let circleViewHeight: CGFloat = 38.0 * UIView.fus_screenW() / 375.0
let circleBlackBackgroundHeight: CGFloat = 44.0 * UIView.fus_screenW() / 375.0
let leftBtn = UIButton(type: .custom)
let leftBlackColorView = UIView()
......@@ -69,6 +69,7 @@ class FUSPKScoreProgressView: FUSBaseView {
self.rightView.layer.masksToBounds = true
self.addSubview(self.rightView)
self.lightImageView.contentMode = .scaleAspectFit
self.addSubview(self.lightImageView)
// var animImages:[UIImage] = .init()
......@@ -156,7 +157,9 @@ class FUSPKScoreProgressView: FUSBaseView {
}
self.lightImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
// make.edges.equalToSuperview()
make.top.bottom.equalToSuperview()
make.left.right.equalToSuperview()
}
self.progressLightImageView.snp.makeConstraints { make in
......
......@@ -399,7 +399,7 @@ class FUSPKControlContributionHotDataCell: UITableViewCell {
firstBloodImageView.isHidden = true
self.contentView.addSubview(firstBloodImageView)
firstBloodImageView.snp.makeConstraints { make in
make.right.equalTo(hotImageView.snp.left)
make.right.equalTo(hotImageView.snp.left).offset(-2)
make.centerY.equalToSuperview()
}
}
......
......@@ -101,7 +101,7 @@ public class FUSPKControlContributionView: FUSPKControlSubBaseView {
// emptyView.isHidden = true
emptyView.backgroundColor = .clear
let emptyShowView = FUSEmptyView(frame: CGRectMake(0, 0, 200, 200))
let emptyShowView = FUSEmptyView(frame: CGRectMake(0, 0, 240, 240))
emptyShowView.fus_setEmptyViewIcon(.fus_emptyImg(), title: .fus_localString("暂无数据"), buttonTittle: "")
emptyView.addSubview(emptyShowView)
emptyShowView.snp.makeConstraints { make in
......
......@@ -49,18 +49,25 @@ class FUSPKControlPKModeView: FUSPKControlSubBaseView {
contentView.addSubview(modeTitleLabel)
modeTitleLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(self.naviView.snp.bottom).offset(20)
make.top.equalTo(self.naviView.snp.bottom).offset(12)
}
let modeDescLabelBgView = UIView()
contentView.addSubview(modeDescLabelBgView)
modeDescLabelBgView.snp.makeConstraints { make in
make.top.equalTo(modeTitleLabel.snp.bottom).offset(2)
make.left.right.equalToSuperview().inset(18)
make.height.equalTo(32)
}
modeDescLabel.font = .fus_themeFont(13)
modeDescLabel.textColor = .init(hex: "#808080")
modeDescLabel.textAlignment = .center
modeDescLabel.numberOfLines = 2
contentView.addSubview(modeDescLabel)
modeDescLabelBgView.addSubview(modeDescLabel)
modeDescLabel.snp.makeConstraints { make in
make.top.equalTo(modeTitleLabel.snp.bottom).offset(2)
make.left.right.equalToSuperview().inset(18)
make.height.equalTo(32)
make.left.right.equalToSuperview()
make.top.equalTo(4)
}
self.collectionView.backgroundColor = .clear
......@@ -85,7 +92,7 @@ class FUSPKControlPKModeView: FUSPKControlSubBaseView {
self.contentView.addSubview(self.collectionView)
self.collectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(modeDescLabel.snp.bottom).offset(10)
make.top.equalTo(modeDescLabelBgView.snp.bottom).offset(10)
// make.height.equalTo(210)
}
......
......@@ -43,7 +43,7 @@ class FUSPKControlSettingView: FUSPKControlSubBaseView {
}
sectionColorView.isHidden = true
sectionColorView.backgroundColor = .white.withAlphaComponent(0.05)
sectionColorView.backgroundColor = .init(hex: "#F0F0F0")
sectionColorView.layer.cornerRadius = 8
sectionColorView.layer.masksToBounds = true
contentView.addSubview(sectionColorView)
......@@ -211,9 +211,9 @@ class FUSPKControlSettingSwitchView: FUSBaseView {
override func makeUI() {
super.makeUI()
bgView.backgroundColor = .init(hex: "#F0F0F0")
bgView.layer.cornerRadius = 8
bgView.layer.masksToBounds = true
// bgView.backgroundColor = .init(hex: "#F0F0F0")
// bgView.layer.cornerRadius = 8
// bgView.layer.masksToBounds = true
self.addSubview(bgView)
bgView.snp.makeConstraints { make in
make.edges.equalToSuperview()
......
......@@ -258,7 +258,7 @@ extension FUSPKMessageAlertView{
}), for: .normal)
acceptAgainBtn.setAttributedTitle(.sj.makeText({ make in
make.append { make in
make.image = .fus_selectedIcon()
make.image = .fus_selectedIconFillStyle()
make.bounds = CGRectMake(0, 0, 13, 13)
make.alignment = .center
}
......
......@@ -164,9 +164,9 @@ extension FUSPKControlViewType {
/// 获取内容默认高度
public func fus_getContentViewHeight() -> CGFloat {
switch self {
case .base, .contribution, .setting, .pkRecord, .pkDescription, .contributionLogListInMatch:
case .base, .contribution, .pkRecord, .pkDescription, .contributionLogListInMatch:
return 620 + UIView.fus_SafeBottom()
case .pkMode, .pkGamePlay, .searchPlayer, .matching, .opponent:
case .pkMode, .searchPlayer, .matching, .opponent, .setting:
return 428 + UIView.fus_SafeBottom()
case .contributionListInMatch:
return 513 + UIView.fus_SafeBottom()
......@@ -176,6 +176,8 @@ extension FUSPKControlViewType {
return 495 + UIView.fus_SafeBottom()
case .punishActivate:
return 240 + UIView.fus_SafeBottom()
case .pkGamePlay:
return 528 + UIView.fus_SafeBottom()
default:
return 0
}
......
......@@ -67,6 +67,8 @@ NS_ASSUME_NONNULL_BEGIN
-(instancetype)initWithPunishId:(NSString *)punishId type:(NSInteger)type resourceId:(NSString *)resourceId queueLevel:(NSInteger)queueLevel expTime:(NSTimeInterval)expTime;
-(void)fus_printModel;
@end
NS_ASSUME_NONNULL_END
......@@ -9,6 +9,15 @@
@implementation FUSLiveRoomPunishListModel
- (instancetype)init
{
self = [super init];
if (self) {
_progress = [[FUSLiveRoomPunishListProgressModel alloc] init];
}
return self;
}
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
return @{@"progress": [FUSLiveRoomPunishListProgressModel class]};
}
......@@ -18,6 +27,13 @@
return model;
}
- (FUSLiveRoomPunishListProgressModel *)progress{
if (_progress == nil) {
_progress = [[FUSLiveRoomPunishListProgressModel alloc] init];
}
return _progress;
}
@end
@implementation FUSLiveRoomPunishListProgressModel
......@@ -35,8 +51,13 @@
self.resourceId = resourceId;
self.queueLevel = queueLevel;
self.expTime = expTime;
FUSLogInfo(@"FUSLiveRoomPunishListModel create punishId:%ld type:%ld resourceId:%@ queueLevel:%ld expTime:%lf",punishId,type,resourceId,queueLevel,expTime);
}
return self;
}
-(void)fus_printModel {
FUSLogInfo(@"FUSLiveRoomPunishListModel print punishId:%ld type:%ld resourceId:%@ queueLevel:%ld expTime:%lf",self.punishId,self.type,self.resourceId,self.queueLevel,self.expTime);
}
@end
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