@@ -76,6 +76,9 @@ @interface TIoTDemoPreviewDeviceVC ()<UITableViewDelegate,UITableViewDataSource,
7676
7777@property (nonatomic , strong ) NSString *saveFilePath; // 视频保存路径
7878@property (nonatomic , strong ) NSString *deviceName; // 设备名称 NVR 和 IPC model有区别
79+ @property (nonatomic , strong ) NSString *productId;
80+
81+ @property (nonatomic , strong ) NSString *combinedId;
7982
8083@property (nonatomic , assign ) CFTimeInterval startPlayer;
8184@property (nonatomic , assign ) CFTimeInterval endPlayer;
@@ -104,6 +107,8 @@ - (void)viewDidLoad {
104107 self.is_reconnect_break = NO ;
105108
106109 _is_ijkPlayer_stream = YES ;
110+
111+ self.productId = [TIoTCoreAppEnvironment shareEnvironment ].cloudProductId ;
107112 // 关闭日志
108113 [TIoTCoreXP2PBridge sharedInstance ].logEnable = YES ;
109114 self.navigationController .navigationBar .tintColor = [UIColor blackColor ];
@@ -118,6 +123,8 @@ - (void)viewDidLoad {
118123 self.deviceName = self.deviceNameNVR ?:@" " ;
119124 }
120125
126+ self.combinedId = [NSString stringWithFormat: @" %@ /%@ " , self .productId, self .deviceName];
127+
121128 [self installMovieNotificationObservers ];
122129
123130 [self initializedVideo ];
@@ -231,7 +238,7 @@ - (void)dealloc{
231238 [[UIDevice currentDevice ]endGeneratingDeviceOrientationNotifications];
232239 [[NSNotificationCenter defaultCenter ]removeObserver:self ];
233240 if (self.isNVR == NO ) {
234- [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .deviceName?: @" " ];
241+ [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .combinedId ];
235242
236243 [[TIoTSessionManager sharedInstance ] resetToCachedAudioSession ];
237244 }
@@ -257,7 +264,7 @@ - (void)getDeviceStatusWithType:(NSString *)singleType qualityType:(NSString *)q
257264 }
258265
259266 __weak typeof (self) weakSelf = self;
260- [[TIoTCoreXP2PBridge sharedInstance ] getCommandRequestWithAsync: self .deviceName?: @" " cmd: actionString?:@" " timeout: 2 *1000 *1000 completion: ^(NSString * _Nonnull jsonList) {
267+ [[TIoTCoreXP2PBridge sharedInstance ] getCommandRequestWithAsync: self .combinedId cmd: actionString?:@" " timeout: 2 *1000 *1000 completion: ^(NSString * _Nonnull jsonList) {
261268 NSArray *responseArray = [NSArray yy_modelArrayWithClass: [TIoTDemoDeviceStatusModel class ] json: jsonList];
262269 TIoTDemoDeviceStatusModel *responseModel = responseArray.firstObject ;
263270 if ([responseModel.status isEqualToString: @" 0" ]) {
@@ -274,7 +281,7 @@ - (void)getDeviceStatusWithType:(NSString *)singleType qualityType:(NSString *)q
274281 channel = [NSString stringWithFormat: @" channel=%d " ,channelNum.intValue];
275282 }
276283
277- // [[TIoTCoreXP2PBridge sharedInstance] sendVoiceToServer:weakSelf.deviceName?:@"" channel:channel];
284+
278285 [[TIoTSessionManager sharedInstance ] resumeRTCAudioSession ];
279286
280287 static int tt_pitch = -6 ;
@@ -289,7 +296,7 @@ - (void)getDeviceStatusWithType:(NSString *)singleType qualityType:(NSString *)q
289296 video_config.localView = nil ;
290297 video_config.videoPosition = AVCaptureDevicePositionFront;
291298
292- [[TIoTCoreXP2PBridge sharedInstance ] sendVoiceToServer: weakSelf.deviceName?: @" " channel: channel audioConfig: audio_config videoConfig: video_config];
299+ [[TIoTCoreXP2PBridge sharedInstance ] sendVoiceToServer: weakSelf.combinedId channel: channel audioConfig: audio_config videoConfig: video_config];
293300
294301 if (tt_pitch == 6 ){
295302 tt_pitch = -6 ;
@@ -317,7 +324,7 @@ - (void)getDeviceStatusWithType:(NSString *)singleType qualityType:(NSString *)q
317324 }
318325
319326 __weak typeof (self) weakSelf = self;
320- [[TIoTCoreXP2PBridge sharedInstance ] getCommandRequestWithAsync: self .deviceName?: @" " cmd: actionString?:@" " timeout: 1.5 *1000 *1000 completion: ^(NSString * _Nonnull jsonList) {
327+ [[TIoTCoreXP2PBridge sharedInstance ] getCommandRequestWithAsync: self .combinedId cmd: actionString?:@" " timeout: 1.5 *1000 *1000 completion: ^(NSString * _Nonnull jsonList) {
321328 NSArray *responseArray = [NSArray yy_modelArrayWithClass: [TIoTDemoDeviceStatusModel class ] json: jsonList];
322329 TIoTDemoDeviceStatusModel *responseModel = responseArray.firstObject ;
323330 if ([responseModel.status isEqualToString: @" 0" ]) {
@@ -856,7 +863,7 @@ - (void)sendDeivecWithSignalling:(NSString *)singleText {
856863 singleString = [NSString stringWithFormat: @" %@ &channel=0" ,singleText];
857864 }
858865
859- [[TIoTCoreXP2PBridge sharedInstance ] getCommandRequestWithAsync: self .deviceName?: @" " cmd: singleText?:@" " timeout: 2 *1000 *1000 completion: ^(NSString * _Nonnull jsonList) {
866+ [[TIoTCoreXP2PBridge sharedInstance ] getCommandRequestWithAsync: self .combinedId cmd: singleText?:@" " timeout: 2 *1000 *1000 completion: ^(NSString * _Nonnull jsonList) {
860867 if (![NSString isNullOrNilWithObject: jsonList] || ![NSString isFullSpaceEmpty: jsonList]) {
861868 [MBProgressHUD showMessage: jsonList icon: @" " ];
862869 }
@@ -1108,7 +1115,7 @@ - (void)moviePlayBackStateDidChange:(NSNotification*)notification
11081115 [self presentViewController: alertC animated: YES completion: nil ];
11091116
11101117 // 获取当前发送链路的连接模式:0 无效;62 直连;63 转发
1111- int netmode = [TIoTCoreXP2PBridge getStreamLinkMode: self .deviceName ];
1118+ int netmode = [TIoTCoreXP2PBridge getStreamLinkMode: self .combinedId ];
11121119 NSLog (@" nnnnnn---netmode==%d " ,netmode);
11131120
11141121 break ;
@@ -1201,7 +1208,7 @@ - (void)responseP2PdisConnect:(NSNotification *)notify {
12011208 NSLog (@" 通道断开,正在重连" );
12021209 [MBProgressHUD showError: @" 通道断开,正在重连" ];
12031210
1204- [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .deviceName?: @" " ];
1211+ [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .combinedId ];
12051212 [self requestXp2pInfo ];// 重新获取info,启动p2p
12061213}
12071214
@@ -1218,7 +1225,7 @@ - (void)setVieoPlayerStartPlayWith:(NSString *)qualityString {
12181225 qualityID = [NSString stringWithFormat: @" %@ &channel=0" ,qualityString];
12191226 }
12201227
1221- NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance ] getUrlForHttpFlv: self .deviceName?: @" " ];
1228+ NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance ] getUrlForHttpFlv: self .combinedId ];
12221229
12231230 self.videoUrl = [NSString stringWithFormat: @" %@%@ " ,urlString,qualityID?:@" " ];
12241231
@@ -1261,7 +1268,7 @@ - (void)configVideo {
12611268 _fileHandle = [NSFileHandle fileHandleForWritingAtPath: h264File];
12621269
12631270 [TIoTCoreXP2PBridge sharedInstance ].writeFile = YES ;
1264- [TIoTCoreXP2PBridge recordstream: self .deviceName ]; // 保存到 document 目录 video.data 文件,需打开writeFile开关
1271+ [TIoTCoreXP2PBridge recordstream: self .combinedId ]; // 保存到 document 目录 video.data 文件,需打开writeFile开关
12651272
12661273 [self stopPlayMovie ];
12671274
@@ -1321,7 +1328,7 @@ - (void)configVideo {
13211328 fileTip.textColor = [UIColor whiteColor ];
13221329 [self .imageView addSubview: fileTip];
13231330 if (self.isNVR == NO ) {
1324- [[TIoTCoreXP2PBridge sharedInstance ] startAvRecvService: self .deviceName?: @" " cmd: @" action=live" ];
1331+ [[TIoTCoreXP2PBridge sharedInstance ] startAvRecvService: self .combinedId cmd: @" action=live" ];
13251332 }
13261333
13271334 }
@@ -1525,7 +1532,7 @@ - (void)resetVideoPlayerWithQuality:(NSString *)qualityString {
15251532 if (self.isNVR == NO ) {
15261533
15271534 if ([TIoTCoreXP2PBridge sharedInstance ].writeFile ) {
1528- [[TIoTCoreXP2PBridge sharedInstance ] stopAvRecvService: self .deviceName?: @" " ];
1535+ [[TIoTCoreXP2PBridge sharedInstance ] stopAvRecvService: self .combinedId ];
15291536 }
15301537 }
15311538
@@ -1539,7 +1546,7 @@ - (void)resetVideoPlayerWithQuality:(NSString *)qualityString {
15391546
15401547
15411548 dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
1542- NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance ] getUrlForHttpFlv: self .deviceName?: @" " ];
1549+ NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance ] getUrlForHttpFlv: self .combinedId ];
15431550 self.videoUrl = [NSString stringWithFormat: @" %@%@ " ,urlString,qualityID?:@" " ];
15441551 [self configVideo ];
15451552
@@ -1632,15 +1639,15 @@ - (void)appNetWorkBreak {
16321639 if (self.endPlayer == 0 ) { // 正在直播中,断开才响应
16331640 return ;
16341641 }
1635- [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .deviceName?: @" " ];
1642+ [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .combinedId ];
16361643}
16371644
16381645- (void )appNetWorkResume {
16391646 if (self.endPlayer == 0 ) { // 正在直播中,断开才响应
16401647 return ;
16411648 }
16421649 // 重连使用
1643- [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .deviceName?: @" " ];
1650+ [[TIoTCoreXP2PBridge sharedInstance ] stopService: self .combinedId ];
16441651 TIoTCoreAppEnvironment *env = [TIoTCoreAppEnvironment shareEnvironment ];
16451652 [self requestXp2pInfo ];// 重新获取info,启动p2p
16461653}
0 commit comments