Skip to content

Commit dea2538

Browse files
committed
p2p双目
Change-Id: I884948b5e138992a06c33118206eda457dcbd13b
1 parent e23d2f9 commit dea2538

File tree

5 files changed

+218
-91
lines changed

5 files changed

+218
-91
lines changed

Podfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
platform :ios, '9.0'
22
#inhibit_all_warnings!
33
use_frameworks!
4-
#source 'https://cdn.cocoapods.org/'
5-
source 'https://github.com/CocoaPods/Specs.git'
4+
source 'https://cdn.cocoapods.org/'
5+
#source 'https://github.com/CocoaPods/Specs.git'
66
def common_all_pods
77
pod 'Masonry', '1.1.0'
88
pod 'MBProgressHUD', '1.1.0'

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ DEPENDENCIES:
7171
- YYModel (= 1.0.4)
7272

7373
SPEC REPOS:
74-
https://github.com/CocoaPods/Specs.git:
74+
trunk:
7575
- Bugly
7676
- CocoaAsyncSocket
7777
- CocoaLumberjack
@@ -133,6 +133,6 @@ SPEC CHECKSUMS:
133133
TZImagePickerController: bf4c57b98d8707fce41ea6be872414a71c7a8c9d
134134
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
135135

136-
PODFILE CHECKSUM: 99bb22499b8f349bc1f98066cb6405b721967b20
136+
PODFILE CHECKSUM: 95ffca92ec8b202bbdbc55483f99d1e36de5f78a
137137

138138
COCOAPODS: 1.9.3

Source/LinkSDKDemo/Video/DeviceHomeList/Controller/TIoTDemoHomeViewController.m

Lines changed: 160 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,30 @@
3232
static NSString *const kVIdeoDeviceListHeaderID = @"kVIdeoDeviceListHeaderID";
3333
static NSInteger const kLimit = 100;
3434

35-
@interface TIoTDemoHomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
35+
36+
@interface MutiUITableViewCell : UITableViewCell
37+
@end
38+
@implementation MutiUITableViewCell
39+
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
40+
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
41+
self.multipleSelectionBackgroundView = [UIView new];
42+
self.tintColor = [UIColor redColor];
43+
}
44+
return self;
45+
}
46+
@end
47+
48+
@interface TIoTDemoHomeViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout, UITableViewDataSource, UITableViewDelegate>
3649
@property (nonatomic, strong) UICollectionView *collectionView;
3750
@property (nonatomic, strong) NSMutableArray *dataArray;
3851
@property (nonatomic, assign) BOOL isShowSameScreenChoiceIcon;
3952
@property (nonatomic, strong) NSMutableArray *selectedArray;
4053
@property (nonatomic, assign) BOOL isNVR;
54+
55+
@property (strong, nonatomic) UIView *contxtTableView;
56+
@property (strong, nonatomic) UITableView *tableView;
57+
@property (strong, nonatomic) NSMutableArray *listData;
58+
@property (strong, nonatomic) NSString *currentDeviceName;
4159
@end
4260

4361
@implementation TIoTDemoHomeViewController
@@ -232,7 +250,7 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
232250

233251
TIoTDemoCustomSheetView *customActionSheet = [[TIoTDemoCustomSheetView alloc]init];
234252
cell.moreActionBlock = ^{
235-
NSArray *actionTitleArray = @[@"预览", @"IPC双向通话", @"IPC双向通话-只推流", @"回放",@"图片流(mjpeg)",@"取消"];
253+
NSArray *actionTitleArray = @[@"预览", @"IPC双向通话", @"IPC双向通话-只推流", @"回放",@"图片流(mjpeg)", @"多通道选择", @"取消"];
236254

237255
ChooseFunctionBlock previewVideoBlock = ^(TIoTDemoCustomSheetView *view){
238256
DDLogVerbose(@"预览");
@@ -299,11 +317,30 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
299317
[customActionSheet removeFromSuperview];
300318
};
301319

320+
ChooseFunctionBlock channelVideoBlock = ^(TIoTDemoCustomSheetView *view){
321+
DDLogVerbose(@"多通道");
322+
// TIoTDemoSameScreenVC *sameScreenVC = [[TIoTDemoSameScreenVC alloc]init];
323+
// sameScreenVC.isNVRType = YES;
324+
// sameScreenVC.NVRDeviceName = model.DeviceName;
325+
// [sameScreenVC setupSameScreenArray:self.selectedArray];
326+
// [weakSelf.navigationController pushViewController:sameScreenVC animated:YES];
327+
// [weakSelf resetDeviceListStatus];
328+
329+
weakSelf.currentDeviceName = model.DeviceName;
330+
[weakSelf.view addSubview:weakSelf.contxtTableView];
331+
[UIView animateWithDuration:0.3 animations:^{
332+
[weakSelf.contxtTableView setFrame:CGRectMake(0, 0, kScreenWidth, weakSelf.view.bounds.size.height)];
333+
// [weakSelf.view layoutIfNeeded];
334+
}];
335+
336+
[customActionSheet removeFromSuperview];
337+
};
338+
302339
ChooseFunctionBlock cancelBlock = ^(TIoTDemoCustomSheetView *view) {
303340
DDLogVerbose(@"取消");
304341
[view removeFromSuperview];
305342
};
306-
NSArray *actionBlockArray = @[previewVideoBlock, videoCallBlock, videoPushBlock, playbackVideoBlock,mjpegVideoBlock,cancelBlock];
343+
NSArray *actionBlockArray = @[previewVideoBlock, videoCallBlock, videoPushBlock, playbackVideoBlock,mjpegVideoBlock, channelVideoBlock, cancelBlock];
307344

308345

309346
[customActionSheet sheetViewTopTitleArray:actionTitleArray withMatchBlocks:actionBlockArray];
@@ -440,14 +477,127 @@ - (NSMutableArray *)selectedArray {
440477
return _selectedArray;
441478
}
442479

443-
/*
444-
#pragma mark - Navigation
480+
#pragma mark - 多选
481+
- (void)dismissCancle {
482+
[UIView animateWithDuration:0.3 animations:^{
483+
[self.contxtTableView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, kScreenHeight)];
484+
}];
485+
}
486+
487+
- (UIView *)contxtTableView {
488+
if (!_contxtTableView) {
489+
_contxtTableView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, kScreenHeight)];
490+
[_contxtTableView setBackgroundColor:UIColor.clearColor];
491+
[_contxtTableView addSubview:self.tableView];
492+
493+
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
494+
make.left.right.bottom.equalTo(_contxtTableView);
495+
make.height.mas_equalTo(370);
496+
}];
497+
[self.tableView setEditing:YES animated:NO];
498+
}
499+
return _contxtTableView;
500+
}
501+
502+
- (UITableView *)tableView{
503+
if (!_tableView) {
504+
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 370)];
505+
_tableView.dataSource = self;
506+
_tableView.delegate = self;
507+
_tableView.backgroundColor = [UIColor whiteColor];
508+
_tableView.tableFooterView = [[UIView alloc] init];
509+
[_tableView registerClass:[MutiUITableViewCell class] forCellReuseIdentifier:@"Cell"];
510+
}
511+
return _tableView;
512+
}
513+
514+
#pragma mark -- UITabelViewDelegate And DataSource
515+
- (void)sectionHeaderSureClick {
516+
[self sectionHeaderCancelClick];
517+
518+
NSMutableArray *models = [[NSMutableArray alloc]init];
519+
[[self.tableView indexPathsForSelectedRows] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
520+
521+
TIoTExploreOrVideoDeviceModel *modell = [TIoTExploreOrVideoDeviceModel new];
522+
modell.DeviceName = self.currentDeviceName;
523+
modell.Channel = [NSString stringWithFormat:@"%d",(int)obj.row];
524+
[models addObject:modell];
525+
}];
526+
527+
if (models.count < 1) {
528+
return;
529+
}
530+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
531+
TIoTDemoSameScreenVC *sameScreenVC = [[TIoTDemoSameScreenVC alloc]init];
532+
sameScreenVC.isNVRType = NO;
533+
sameScreenVC.NVRDeviceName = self.currentDeviceName;
534+
[sameScreenVC setupSameScreenArray:models];
535+
[self.navigationController pushViewController:sameScreenVC animated:YES];
536+
});
537+
}
538+
539+
- (void)sectionHeaderCancelClick {
540+
[UIView animateWithDuration:0.3 animations:^{
541+
[self.contxtTableView setFrame:CGRectMake(0, kScreenHeight, kScreenWidth, self.view.bounds.size.height)];
542+
} completion:^(BOOL finished) {
543+
[self.contxtTableView removeFromSuperview];
544+
}];
545+
}
546+
547+
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
548+
return 50.0; // 返回你的 header view 的高度
549+
}
550+
551+
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
552+
553+
static NSString *headerReuseIdentifier = @"TableSectionHeaderViewIdentifier";
554+
UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerReuseIdentifier];
555+
if (!headerView) {
556+
headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:headerReuseIdentifier];
557+
}
558+
headerView.textLabel.text = @"通道选择";
559+
560+
UIButton *bt1 = [UIButton buttonWithType:UIButtonTypeCustom];
561+
bt1.backgroundColor = UIColor.yellowColor;
562+
bt1.frame = CGRectMake(kScreenWidth-90, 0, 80, 50);
563+
[bt1 setTitle:@"确定" forState:UIControlStateNormal];
564+
[bt1 addTarget:self action:@selector(sectionHeaderSureClick) forControlEvents:UIControlEventTouchUpInside];
565+
566+
UIButton *bt2 = [UIButton buttonWithType:UIButtonTypeCustom];
567+
bt2.backgroundColor = UIColor.orangeColor;
568+
bt2.frame = CGRectMake(kScreenWidth-90-90, 0, 80, 50);
569+
[bt2 setTitle:@"取消" forState:UIControlStateNormal];
570+
[bt2 addTarget:self action:@selector(sectionHeaderCancelClick) forControlEvents:UIControlEventTouchUpInside];
571+
572+
[headerView.contentView addSubview:bt1];
573+
[headerView.contentView addSubview:bt2];
574+
return headerView;
575+
}
576+
577+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
578+
return 4;
579+
}
580+
581+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
582+
583+
MutiUITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
584+
cell.textLabel.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row+1];
585+
return cell;
586+
}
587+
588+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
589+
return 80;
590+
}
591+
592+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
593+
if (tableView.isEditing) {
594+
return;
595+
}
596+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
597+
}
445598

446-
// In a storyboard-based application, you will often want to do a little preparation before navigation
447-
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
448-
// Get the new view controller using [segue destinationViewController].
449-
// Pass the selected object to the new view controller.
599+
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
600+
return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
450601
}
451-
*/
452602

453603
@end

Source/LinkSDKDemo/Video/P2P/Controller/TIoTDemoSameScreenVC.m

Lines changed: 46 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,16 @@ - (void)resetScreenSubviewsWithLandscape:(BOOL)rotation viewArray:(NSArray *)vie
542542
- (void)initVideoPlayer {
543543

544544
if (self.videoArray.count != 0) {
545-
[self.videoArray enumerateObjectsUsingBlock:^(TIoTExploreOrVideoDeviceModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
546-
TIoTExploreOrVideoDeviceModel *model = obj;
547-
if (self.isNVRType == NO) {
548-
549-
[self requestXp2pInfoWithDeviceName:model.DeviceName?:@"" isReconnection:NO];
550-
}
551-
}];
545+
// [self.videoArray enumerateObjectsUsingBlock:^(TIoTExploreOrVideoDeviceModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
546+
// TIoTExploreOrVideoDeviceModel *model = obj;
547+
// if (self.isNVRType == NO) {
548+
549+
550+
// [self requestXp2pInfoWithDeviceName:model.DeviceName?:@"" isReconnection:NO];
551+
[self requestXp2pInfoWithDeviceName:self.NVRDeviceName isReconnection:NO];
552+
553+
// }
554+
// }];
552555

553556
switch (self.videoArray.count) {
554557
case TIoTDemoSameScreenOne: {
@@ -605,38 +608,38 @@ - (void)initVideoPlayer {
605608
///MARK: 获取ipc/nvr设备状态,是否可以推流(type 参数区分直播和对讲)
606609
- (void)getDeviceStatusWithIndex:(NSInteger)index model:(TIoTExploreOrVideoDeviceModel *)model {
607610

608-
NSString *qualityTypeString = @"quality=high";
609-
NSString *actionString = @"";
610-
611-
if (self.isNVRType == YES) {
612-
actionString = [NSString stringWithFormat:@"action=inner_define&channel=%@&cmd=get_device_st&type=live&%@",model.Channel?:@"",qualityTypeString];
613-
}else {
614-
actionString = [NSString stringWithFormat:@"action=inner_define&channel=0&cmd=get_device_st&type=live&%@",qualityTypeString];
615-
}
616-
617-
[[TIoTCoreXP2PBridge sharedInstance] getCommandRequestWithAsync:self.NVRDeviceName?:@"" cmd:actionString?:@"" timeout:2*1000*1000 completion:^(NSString * _Nonnull jsonList) {
618-
NSArray *responseArray = [NSArray yy_modelArrayWithClass:[TIoTDemoDeviceStatusModel class] json:jsonList];
619-
TIoTDemoDeviceStatusModel *responseModel = responseArray.firstObject;
620-
if ([responseModel.status isEqualToString:@"0"]) {
611+
// NSString *qualityTypeString = @"quality=high";
612+
// NSString *actionString = @"";
613+
//
614+
// if (self.isNVRType == YES) {
615+
// actionString = [NSString stringWithFormat:@"action=inner_define&channel=%@&cmd=get_device_st&type=live&%@",model.Channel?:@"",qualityTypeString];
616+
// }else {
617+
// actionString = [NSString stringWithFormat:@"action=inner_define&channel=0&cmd=get_device_st&type=live&%@",qualityTypeString];
618+
// }
619+
//
620+
// [[TIoTCoreXP2PBridge sharedInstance] getCommandRequestWithAsync:self.NVRDeviceName?:@"" cmd:actionString?:@"" timeout:2*1000*1000 completion:^(NSString * _Nonnull jsonList) {
621+
// NSArray *responseArray = [NSArray yy_modelArrayWithClass:[TIoTDemoDeviceStatusModel class] json:jsonList];
622+
// TIoTDemoDeviceStatusModel *responseModel = responseArray.firstObject;
623+
// if ([responseModel.status isEqualToString:@"0"]) {
621624
//直播
622-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
623-
624-
if (self.isNVRType == YES) {
625-
NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:self.NVRDeviceName?:@""];
626-
NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live&channel=%@&quality=high",urlString,model.Channel?:@""];
627-
[self playVideoWithIndex:index-1 deviceName:self.NVRDeviceName withUrlString:urlStringTemp];
628-
}else {
629-
NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:model.DeviceName?:@""];
630-
NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live&channel=0&quality=high",urlString];
631-
[self playVideoWithIndex:index-1 deviceName:model.DeviceName withUrlString:urlStringTemp];
632-
}
633-
634-
});
635-
}else {
636-
//设备状态异常提示
637-
[TIoTCoreUtil showDeviceStatusError:responseModel commandInfo:[NSString stringWithFormat:@"发送信令: %@\n\n接收: %@",actionString,jsonList]];
638-
}
639-
}];
625+
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
626+
627+
// if (self.isNVRType == YES) {
628+
// NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:self.NVRDeviceName?:@""];
629+
// NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live&channel=%@&quality=high",urlString,model.Channel?:@""];
630+
// [self playVideoWithIndex:index-1 deviceName:self.NVRDeviceName withUrlString:urlStringTemp];
631+
// }else {
632+
// NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:model.DeviceName?:@""];
633+
// NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live&channel=0&quality=high",urlString];
634+
// [self playVideoWithIndex:index-1 deviceName:model.DeviceName withUrlString:urlStringTemp];
635+
// }
636+
637+
// });
638+
// }else {
639+
// //设备状态异常提示
640+
// [TIoTCoreUtil showDeviceStatusError:responseModel commandInfo:[NSString stringWithFormat:@"发送信令: %@\n\n接收: %@",actionString,jsonList]];
641+
// }
642+
// }];
640643
}
641644

642645
- (void)requestXp2pInfoWithDeviceName:(NSString *)deviceName isReconnection:(BOOL)isReconnection {
@@ -878,45 +881,11 @@ - (void)responseP2PdisConnect:(NSNotification *)notify {
878881

879882
- (void)refushVideo:(NSNotification *)notify {
880883

881-
NSString *DeviceName = [notify.userInfo objectForKey:@"id"];
882-
883-
NSString *appVersion = [TIoTCoreXP2PBridge getSDKVersion];
884-
if (appVersion.floatValue < 2.1) {
885-
886-
[self.videoArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
887-
TIoTExploreOrVideoDeviceModel *model = obj;
888-
if ([DeviceName isEqualToString:model.DeviceName]) {
889-
890-
NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:model.DeviceName]?:@"";
891-
892-
NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live",urlString];
893-
[self playVideoWithIndex:idx deviceName:model.DeviceName withUrlString:urlStringTemp];
894-
}
895-
}];
896-
897-
}else {
898-
[self.videoArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
899-
TIoTExploreOrVideoDeviceModel *model = obj;
900-
if ([DeviceName isEqualToString:model.DeviceName]) {
901-
902-
NSString *qualityTypeString = @"quality=high";
903-
NSString *actionString = [NSString stringWithFormat:@"action=inner_define&channel=0&cmd=get_device_st&type=live&%@",qualityTypeString];
904-
905-
[[TIoTCoreXP2PBridge sharedInstance] getCommandRequestWithAsync:model.DeviceName cmd:actionString timeout:2*1000*1000 completion:^(NSString * _Nonnull jsonList) {
906-
NSArray *responseArray = [NSArray yy_modelArrayWithClass:[TIoTDemoDeviceStatusModel class] json:jsonList];
907-
TIoTDemoDeviceStatusModel *responseModel = responseArray.firstObject;
908-
if ([responseModel.status isEqualToString:@"0"]) {
909-
NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:model.DeviceName?:@""];
910-
NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live&channel=0&quality=high",urlString];
911-
[self playVideoWithIndex:idx deviceName:model.DeviceName withUrlString:urlStringTemp];
912-
}else {
913-
//设备状态异常提示
914-
[TIoTCoreUtil showDeviceStatusError:responseModel commandInfo:[NSString stringWithFormat:@"发送信令: %@\n\n接收: %@",actionString,jsonList]];
915-
}
916-
}];
917-
}
918-
}];
919-
}
884+
[self.videoArray enumerateObjectsUsingBlock:^(TIoTExploreOrVideoDeviceModel *obj, NSUInteger idx, BOOL * _Nonnull stop) {
885+
NSString *urlString = [[TIoTCoreXP2PBridge sharedInstance] getUrlForHttpFlv:self.NVRDeviceName];
886+
NSString *urlStringTemp = [NSString stringWithFormat:@"%@ipc.flv?action=live&channel=%@&quality=high",urlString,obj.Channel];
887+
[self playVideoWithIndex:idx deviceName:obj.DeviceName withUrlString:urlStringTemp];
888+
}];
920889
}
921890

922891
- (void)playVideoWithIndex:(NSInteger)idx deviceName:(NSString *)deviceName withUrlString:(NSString *)urlString {

0 commit comments

Comments
 (0)