Skip to content

Commit c93d898

Browse files
committed
修复产品体验问题
Change-Id: I70ad8241f40d4dddc08b2bfc1bcbe0b4a4323fc7
1 parent f1583d9 commit c93d898

File tree

9 files changed

+160
-25
lines changed

9 files changed

+160
-25
lines changed

Source/LinkApp/Classes/Module/EquipmentPanel/Controller/TIoTPanelVC.m

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,22 @@ - (void)getDeviceData:(NSDictionary *)uiInfo andBaseInfo:(NSDictionary *)baseInf
452452

453453
//下发数据
454454
- (void)reportDeviceData:(NSDictionary *)deviceReport{
455+
456+
NSMutableDictionary *trtcReport = [deviceReport mutableCopy];
457+
NSString *userId = [TIoTCoreUserManage shared].userId;
458+
if (userId) {
459+
[trtcReport setValue:userId forKey:@"userid"];
460+
}
461+
NSString *username = [TIoTCoreUserManage shared].nickName;
462+
if (username) {
463+
[trtcReport setValue:username forKey:@"username"];
464+
}
465+
455466
NSDictionary *tmpDic = @{
456467
@"ProductId":self.productId,
457468
@"DeviceName":self.deviceName,
458-
@"Data":[NSString objectToJson:deviceReport],
469+
// @"Data":[NSString objectToJson:deviceReport],
470+
@"Data":[NSString objectToJson:trtcReport]
459471
};
460472

461473
[[TIoTRequestObject shared] post:AppControlDeviceData Param:tmpDic success:^(id responseObject) {
@@ -670,6 +682,13 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
670682
}
671683
else if ([dic[@"define"][@"type"] isEqualToString:@"enum"]){
672684

685+
//trtc特殊判断逻辑
686+
NSString *key = dic[@"id"];
687+
if ([key isEqualToString:TIoTTRTCaudio_call_status] || [key isEqualToString:TIoTTRTCvideo_call_status]) {
688+
[self reportDeviceData:@{key: @1}];
689+
return;
690+
}
691+
673692
TIoTChoseValueView *choseView = [[TIoTChoseValueView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
674693
choseView.dic = dic;
675694
choseView.updateData = ^(NSDictionary * _Nonnull dataDic) {

Source/LinkApp/Classes/Module/EquipmentPanel/View/TIoTLongCell.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ - (void)setInfo:(NSDictionary *)info
8080
// NSString *key = [NSString stringWithFormat:@"%@",info[@"status"][@"Value"]];
8181
NSString *key = [NSString stringWithFormat:@"%@",info[@"Value"]]?:@"";
8282
self.content.text = define[@"mapping"][key];
83+
84+
//trtc特殊判断逻辑
85+
NSString *infoid = info[@"id"];
86+
if ([infoid isEqualToString:TIoTTRTCaudio_call_status] || [infoid isEqualToString:TIoTTRTCvideo_call_status]) {
87+
self.content.hidden = YES;
88+
self.rightImg.hidden = YES;
89+
self.swich.hidden = YES;
90+
return;
91+
}
92+
8393
}
8494
else if ([define[@"type"] isEqualToString:@"int"] || [define[@"type"] isEqualToString:@"float"]) {
8595
[self.imgV setImage:[[UIImage imageNamed:@"c_light"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];

Source/LinkApp/Classes/Universal/WebSocket/TIoTTRTCUIManage.m

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ @interface TIoTTRTCUIManage ()<TRTCCallingViewDelegate> {
1616

1717
//socket payload
1818
TIOTtrtcPayloadParamModel *_deviceParam;
19+
20+
BOOL _isActiveCall;
1921
}
2022
@end
2123

@@ -66,7 +68,11 @@ - (void)didAcceptJoinRoom {
6668

6769
//---------------------TRTC设备轮训状态与注册物模型----------------------------
6870
- (void)repeatDeviceData:(NSArray *)devices {
69-
71+
//1.是trtc设备,注册socket通知
72+
NSArray *devIds = [devices valueForKey:@"DeviceId"];
73+
[HXYNotice postHeartBeat:devIds];
74+
[HXYNotice addActivePushPost:devIds];
75+
7076
NSArray *productIDs = [devices valueForKey:@"ProductId"];
7177
NSSet *productIDSet = [NSSet setWithArray:productIDs];//去chong
7278
[[TIoTRequestObject shared] post:AppGetProductsConfig Param:@{@"ProductIds":productIDSet.allObjects} success:^(id responseObject) {
@@ -98,9 +104,9 @@ - (void)getTRTCDeviceData:(NSString *)productID devices:(NSArray *)devices {
98104
if ([device.ProductId isEqualToString:productID]) {
99105
//通过产品ID筛选出设备Device,开始拉取Device的TRTC状态
100106

101-
//1.是trtc设备,注册socket通知
102-
[HXYNotice postHeartBeat:@[device.DeviceId]];
103-
[HXYNotice addActivePushPost:@[device.DeviceId]];
107+
//1.是trtc设备,注册socket通知,提前了注册时机了,要不然接口太多失败了就不知道啥原因
108+
// [HXYNotice postHeartBeat:@[device.DeviceId]];
109+
// [HXYNotice addActivePushPost:@[device.DeviceId]];
104110

105111
if (device.Online.intValue != 1) {
106112
continue;
@@ -121,6 +127,7 @@ - (void)getTRTCDeviceData:(NSString *)productID devices:(NSArray *)devices {
121127
}
122128
payloadParam._sys_video_call_status = product._sys_video_call_status.Value;
123129
payloadParam._sys_audio_call_status = product._sys_audio_call_status.Value;
130+
payloadParam.deviceName = device.DeviceName;
124131

125132
[self preEnterRoom:payloadParam failure:^(NSString * _Nullable reason, NSError * _Nullable error, NSDictionary * _Nullable dic) {
126133
NSLog(@"error--%@",error);
@@ -142,6 +149,8 @@ - (void)getTRTCDeviceData:(NSString *)productID devices:(NSArray *)devices {
142149

143150

144151
- (void)callDeviceFromPanel: (TIoTTRTCSessionCallType)audioORvideo {
152+
_isActiveCall = YES; //表示主动呼叫
153+
145154
UIViewController *topVC = [TIoTCoreUtil topViewController];
146155
if (_callAudioVC == topVC || _callVideoVC == topVC) {
147156
//正在主动呼叫中,或呼叫UI已启动
@@ -168,22 +177,27 @@ - (BOOL)isActiveCalling:(NSString *)deviceUserID {
168177
UIViewController *topVC = [TIoTCoreUtil topViewController];
169178
if (_callAudioVC == topVC || _callVideoVC == topVC) {
170179
//正在主动呼叫中,或呼叫UI已启动,直接进房间
171-
[self didAcceptJoinRoom];
180+
181+
if (_isActiveCall) { //如果是被动呼叫的话,不能自动进入房间
182+
[self didAcceptJoinRoom];
183+
}
172184
return YES;
173185
}
174186

175-
187+
_isActiveCall = NO;//表示被呼叫
176188
//被呼叫了,点击接听后才进房间吧
177189
if (_deviceParam._sys_audio_call_status.intValue == 1) { //audio
178190

179191
_callAudioVC = [[TRTCCallingAuidoViewController alloc] initWithOcUserID:_deviceParam._sys_userid];
192+
_callAudioVC.deviceName = _deviceParam.deviceName;
180193
_callAudioVC.actionDelegate = self;
181194
_callAudioVC.modalPresentationStyle = UIModalPresentationFullScreen;
182195
[[TIoTCoreUtil topViewController] presentViewController:_callAudioVC animated:NO completion:nil];
183196

184197
}else if (_deviceParam._sys_video_call_status.intValue == 1) { //video
185198

186199
_callVideoVC = [[TRTCCallingVideoViewController alloc] initWithOcUserID:_deviceParam._sys_userid];
200+
_callVideoVC.deviceName = _deviceParam.deviceName;
187201
_callVideoVC.actionDelegate = self;
188202
_callVideoVC.modalPresentationStyle = UIModalPresentationFullScreen;
189203
[[TIoTCoreUtil topViewController] presentViewController:_callVideoVC animated:NO completion:^{

Source/LinkApp/Classes/Universal/WebSocket/TIoTWebSocketManage.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ - (void)deviceInfo:(NSDictionary *)deviceInfo{
174174
NSDictionary *payloadDic = [NSString base64Decode:deviceInfo[@"Payload"]];
175175

176176
TIOTtrtcPayloadModel *model = [TIOTtrtcPayloadModel yy_modelWithJSON:payloadDic];
177+
model.params.deviceName = deviceInfo[@"DeviceId"];
177178
if (model.params._sys_userid.length < 1) {
178179
model.params._sys_userid = deviceInfo[@"DeviceId"];
179180
}

Source/LinkSDK/QCAPISets/Public/TIoTCoreDeviceSet.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ - (void)zipData:(NSDictionary *)uiInfo baseInfo:(NSDictionary *)baseInfo deviceD
105105
[propertiesForUI removeObject:self.bigProp];
106106
}
107107

108+
[self.properties addObjectsFromArray:propertiesForUI];
109+
}else {
110+
111+
//默认面板
112+
113+
NSMutableArray *propertiesForUI = [NSMutableArray array];
114+
NSArray *propertiesForInfo = baseInfo[@"properties"];
115+
116+
for (NSDictionary* protovalue in propertiesForInfo) {
117+
118+
NSMutableDictionary *proper = [NSMutableDictionary dictionary];
119+
120+
NSString *protoid = protovalue[@"id"];
121+
[proper setValue:deviceInfo[protoid] forKey:@"status"];
122+
123+
[proper setValue:protovalue[@"name"] forKey:@"name"];
124+
[proper setValue:protovalue[@"desc"] forKey:@"desc"];
125+
[proper setValue:protovalue[@"define"] forKey:@"define"];
126+
127+
[propertiesForUI addObject:proper];
128+
}
129+
130+
131+
[self.allProperties addObjectsFromArray:propertiesForUI];
108132
[self.properties addObjectsFromArray:propertiesForUI];
109133
}
110134
}

Source/LinkSDK/TRTC/TIOTTRTCModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
2121
@property (nonatomic, strong) NSString *_sys_video_call_status;
2222
@property (nonatomic, strong) NSString *_sys_audio_call_status;
2323
@property (nonatomic, strong) NSString *_sys_userid;
24+
@property (nonatomic, strong) NSString *deviceName;//UI展示的名字
2425
@end
2526

2627
@interface TIOTtrtcPayloadModel : NSObject

Source/LinkSDK/TRTC/ui/AudioCall/TRTCAudioCallViewController.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ class TRTCCallingAuidoViewController: UIViewController, CallingViewControllerRes
3636
var codeTimer = DispatchSource.makeTimerSource(queue: DispatchQueue.global(qos: .userInteractive))
3737
let callTimeLabel = UILabel()
3838

39+
@objc var deviceName: String = "Device"
40+
41+
lazy var tipLabel: UILabel = {
42+
let label = UILabel(frame: CGRect(origin: CGPoint.zero, size: UIScreen.main.bounds.size ))
43+
label.numberOfLines = 2
44+
label.font = UIFont.boldSystemFont(ofSize: 25)
45+
label.textColor = .white
46+
label.textAlignment = .center
47+
self.view.addSubview(label)
48+
return label
49+
}()
50+
3951
@objc weak var actionDelegate: TRTCCallingViewDelegate?
4052

4153
var curState: AudioiCallingState {
@@ -339,6 +351,8 @@ extension TRTCCallingAuidoViewController {
339351
make.width.equalTo(80)
340352
make.height.equalTo(80)
341353
}
354+
355+
tipLabel.text = "等待接听中…"
342356
break
343357
case .onInvitee:
344358
hangup.snp.remakeConstraints { (make) in
@@ -354,6 +368,8 @@ extension TRTCCallingAuidoViewController {
354368
make.width.equalTo(80)
355369
make.height.equalTo(80)
356370
}
371+
372+
tipLabel.text = "\(deviceName)\n邀请您语音通话"
357373
break
358374
case .calling:
359375
hangup.snp.remakeConstraints { (make) in
@@ -363,6 +379,8 @@ extension TRTCCallingAuidoViewController {
363379
make.height.equalTo(60)
364380
}
365381
startGCDTimer()
382+
383+
tipLabel.text = "正在通话中…"
366384
break
367385
}
368386

Source/LinkSDK/TRTC/ui/VideoCall/TRTCVideoCallViewController.swift

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ class TRTCCallingVideoViewController: UIViewController, CallingViewControllerRes
129129
let localPreView = VideoCallingRenderView.init()
130130
static var renderViews:VideoCallingRenderView? = VideoCallingRenderView.init()
131131

132+
@objc var deviceName: String = "Device"
133+
132134
var curState: VideoCallingState {
133135
didSet {
134136
if oldValue != curState {
@@ -166,7 +168,7 @@ class TRTCCallingVideoViewController: UIViewController, CallingViewControllerRes
166168

167169
@objc init(ocUserID: String? = nil) {
168170
curSponsor = CallingUserModel(avatarUrl: "https://imgcache.qq.com/qcloud/public/static//avatar1_100.20191230.png",
169-
name: "Device",
171+
name: self.deviceName,
170172
userId: ocUserID ?? "0",
171173
isEnter: false,
172174
isVideoAvaliable: false,
@@ -367,6 +369,10 @@ extension TRTCCallingVideoViewController: UICollectionViewDelegate, UICollection
367369
if let renderView = TRTCCallingVideoViewController.renderViews {
368370
renderView.userModel = user
369371
TRTCCalling.shareInstance().startRemoteView(userId: user.userId, view: renderView)
372+
373+
374+
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(tap:)))
375+
renderView.addGestureRecognizer(tap)
370376
}
371377

372378
curState = .calling
@@ -523,7 +529,9 @@ extension TRTCCallingVideoViewController {
523529
view.addSubview(localPreView)
524530
localPreView.backgroundColor = .appBackGround
525531
localPreView.frame = UIScreen.main.bounds
526-
localPreView.isUserInteractionEnabled = false
532+
localPreView.isUserInteractionEnabled = true
533+
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(tap:)))
534+
localPreView.addGestureRecognizer(tap)
527535

528536
userCollectionView.isHidden = true
529537

@@ -548,19 +556,20 @@ extension TRTCCallingVideoViewController {
548556
let userImage = UIImageView()
549557
sponsorPanel.addSubview(userImage)
550558
userImage.snp.makeConstraints { (make) in
551-
make.trailing.equalTo(sponsorPanel).offset(-18)
559+
// make.trailing.equalTo(sponsorPanel).offset(-18)
560+
make.trailing.equalTo(sponsorPanel).offset(30)
552561
make.top.equalTo(sponsorPanel)
553562
make.width.equalTo(60)
554563
make.height.equalTo(60)
555564
}
556-
userImage.sd_setImage(with: URL(string: sponsor.avatarUrl), completed: nil)
565+
// userImage.sd_setImage(with: URL(string: sponsor.avatarUrl), completed: nil)
557566

558567
//发起者名字
559568
let userName = UILabel()
560569
userName.textAlignment = .right
561-
userName.font = UIFont.boldSystemFont(ofSize: 30)
570+
userName.font = UIFont.boldSystemFont(ofSize: 20)
562571
userName.textColor = .white
563-
userName.text = sponsor.name
572+
userName.text = self.deviceName//sponsor.name
564573
sponsorPanel.addSubview(userName)
565574
userName.snp.makeConstraints { (make) in
566575
make.trailing.equalTo(userImage.snp.leading).offset(-6)
@@ -764,4 +773,43 @@ extension TRTCCallingVideoViewController {
764773
// 启动时间源
765774
codeTimer.resume()
766775
}
776+
777+
778+
779+
@objc func handleTapGesture(tap: UIPanGestureRecognizer) {
780+
781+
if tap.view == localPreView {
782+
if localPreView.frame.size.width == kSmallVideoViewWidth {
783+
784+
if let firstRender = TRTCCallingVideoViewController.renderViews {
785+
UIView.animate(withDuration: 0.3, animations: { [weak firstRender, weak self] in
786+
guard let `self` = self else { return }
787+
self.localPreView.frame = self.view.frame
788+
firstRender?.frame = CGRect(x: self.view.frame.size.width - kSmallVideoViewWidth - 18,
789+
y: 20, width: kSmallVideoViewWidth, height: kSmallVideoViewWidth / 9.0 * 16.0)
790+
}) { [weak self] (result) in
791+
guard let `self` = self else { return }
792+
firstRender.removeFromSuperview()
793+
self.view.insertSubview(firstRender, aboveSubview: self.localPreView)
794+
}
795+
}
796+
}
797+
} else {
798+
if let smallView = tap.view {
799+
if smallView.frame.size.width == kSmallVideoViewWidth {
800+
UIView.animate(withDuration: 0.3, animations: { [weak smallView ,weak self] in
801+
guard let self = self else {return}
802+
smallView?.frame = self.view.frame
803+
self.localPreView.frame = CGRect(x: self.view.frame.size.width - kSmallVideoViewWidth - 18,
804+
y: 20, width: kSmallVideoViewWidth, height: kSmallVideoViewWidth / 9.0 * 16.0)
805+
806+
}) { [weak self] (result) in
807+
guard let `self` = self else { return }
808+
smallView.removeFromSuperview()
809+
self.view.insertSubview(smallView, belowSubview: self.localPreView)
810+
}
811+
}
812+
}
813+
}
814+
}
767815
}

Source/LinkSDK/TRTC/ui/Views/TRTCCallingCell.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,18 @@ class AudioCallUserCell: UICollectionViewCell {
167167
}
168168

169169
func configModel(model: CallingUserModel) {
170-
cellImgView.sd_setImage(with: URL(string: model.avatarUrl), completed: nil)
171-
cellUserLabel.text = userModel.name
172-
let noModel = model.userId.count == 0
173-
dimBk.isHidden = userModel.isEnter || noModel
174-
loading.isHidden = userModel.isEnter || noModel
175-
if userModel.isEnter || noModel {
176-
loading.stopAnimating()
177-
} else {
178-
loading.startAnimating()
179-
}
180-
cellUserLabel.isHidden = noModel
181-
cellVoiceImageView.isHidden = model.volume < 0.05
170+
// cellImgView.sd_setImage(with: URL(string: model.avatarUrl), completed: nil)
171+
// cellUserLabel.text = userModel.name
172+
// let noModel = model.userId.count == 0
173+
// dimBk.isHidden = userModel.isEnter || noModel
174+
// loading.isHidden = userModel.isEnter || noModel
175+
// if userModel.isEnter || noModel {
176+
// loading.stopAnimating()
177+
// } else {
178+
// loading.startAnimating()
179+
// }
180+
// cellUserLabel.isHidden = noModel
181+
// cellVoiceImageView.isHidden = model.volume < 0.05
182182
}
183183
}
184184

0 commit comments

Comments
 (0)