Skip to content

Commit 66dee89

Browse files
committed
调通SDKDemo主动拨打的逻辑
Change-Id: I0b9aafc3bb60ffabcf0ac61f73b6540450dcbc41
1 parent a403dbf commit 66dee89

File tree

5 files changed

+61
-15
lines changed

5 files changed

+61
-15
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111

1212
NS_ASSUME_NONNULL_BEGIN
1313

14-
FOUNDATION_EXPORT NSString *const TIoTTRTCaudio_call_status;
15-
FOUNDATION_EXPORT NSString *const TIoTTRTCvideo_call_status;
16-
17-
typedef enum : NSUInteger {
18-
TIoTTRTCSessionCallType_audio,
19-
TIoTTRTCSessionCallType_video
20-
} TIoTTRTCSessionCallType;
21-
2214
@interface TIoTTRTCUIManage: NSObject <TIoTTRTCSessionUIDelegate>
2315
+ (instancetype)sharedManager ;
2416

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
#import "TIoTCoreUtil.h"
1111
#import "TIoTTRTCSessionManager.h"
1212

13-
14-
NSString *const TIoTTRTCaudio_call_status = @"_sys_audio_call_status";
15-
NSString *const TIoTTRTCvideo_call_status = @"_sys_video_call_status";
16-
17-
1813
@interface TIoTTRTCUIManage ()<TRTCCallingViewDelegate> {
1914
TRTCCallingAuidoViewController *_callAudioVC;
2015
TRTCCallingVideoViewController *_callVideoVC;

Source/LinkSDK/TRTC/TIoTTRTCSessionManager.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ typedef enum : NSUInteger {
2222
TIoTTRTCSessionType_end
2323
} TIoTTRTCSessionType;
2424

25+
26+
FOUNDATION_EXPORT NSString *const TIoTTRTCaudio_call_status;
27+
FOUNDATION_EXPORT NSString *const TIoTTRTCvideo_call_status;
28+
29+
typedef enum : NSUInteger {
30+
TIoTTRTCSessionCallType_audio,
31+
TIoTTRTCSessionCallType_video
32+
} TIoTTRTCSessionCallType;
33+
34+
2535
@protocol TIoTTRTCSessionUIDelegate <NSObject>
2636
//远端流进房间了,需要展示
2737
- (void)showRemoteUser:(NSString *)remoteUserID;

Source/LinkSDK/TRTC/TIoTTRTCSessionManager.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#import "YYModel.h"
1414
#import "TRTCCalling.h"
1515

16+
NSString *const TIoTTRTCaudio_call_status = @"_sys_audio_call_status";
17+
NSString *const TIoTTRTCvideo_call_status = @"_sys_video_call_status";
18+
1619
@interface TIoTTRTCSessionManager()<TRTCCallingDelegate>
1720
@end
1821

Source/LinkSDKDemo/Home/Controllers/Device/ControlDeviceVC.m

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,31 @@ - (void)refresh
118118
self.timing.text = self.ci.timingProject ? NSLocalizedString(@"display", @"显示") : NSLocalizedString(@"no_display", @"不显示");
119119

120120
[self.tableView reloadData];
121+
122+
123+
//这是trtc设备
124+
BOOL isTRTC = NO;
125+
for (NSDictionary *prototo in self.ci.zipData) {
126+
NSString *syskey = prototo[@"id"];
127+
if ([syskey isEqualToString:@"_sys_video_call_status"] || [syskey isEqualToString:@"_sys_audio_call_status"] ) {
128+
isTRTC = YES;
129+
break;
130+
}
131+
}
132+
133+
if (isTRTC) {
134+
UIBarButtonItem *testItem = [[UIBarButtonItem alloc] initWithTitle:@"TRTC打电话"
135+
style:UIBarButtonItemStylePlain
136+
target:self
137+
action:@selector(handleTestAction)];
138+
self.navigationItem.rightBarButtonItem = testItem;
139+
}
121140
}
122141

123-
142+
- (void)handleTestAction {
143+
[self callDeviceFromPanel:TIoTTRTCSessionCallType_video];
144+
[self sendControlData:@{@"_sys_video_call_status":@1}];
145+
}
124146
#pragma mark - tableView
125147

126148
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
@@ -268,7 +290,31 @@ - (void)receiveData:(NSDictionary *)deviceChange{
268290
}
269291
}
270292

271-
//主动呼叫的UI逻辑
293+
294+
- (void)callDeviceFromPanel: (TIoTTRTCSessionCallType)audioORvideo {
295+
UIViewController *topVC = [TIoTCoreUtil topViewController];
296+
if (_callAudioVC == topVC || _callVideoVC == topVC) {
297+
//正在主动呼叫中,或呼叫UI已启动
298+
return;
299+
}
300+
301+
if (audioORvideo == TIoTTRTCSessionCallType_audio) { //audio
302+
_callAudioVC = [[TRTCCallingAuidoViewController alloc] initWithOcUserID:nil];
303+
_callAudioVC.actionDelegate = self;
304+
_callAudioVC.modalPresentationStyle = UIModalPresentationFullScreen;
305+
[[TIoTCoreUtil topViewController] presentViewController:_callAudioVC animated:NO completion:^{}];
306+
307+
}else if (audioORvideo == TIoTTRTCSessionCallType_video) { //video
308+
309+
_callVideoVC = [[TRTCCallingVideoViewController alloc] initWithOcUserID:nil];
310+
_callVideoVC.actionDelegate = self;
311+
_callVideoVC.modalPresentationStyle = UIModalPresentationFullScreen;
312+
[[TIoTCoreUtil topViewController] presentViewController:_callVideoVC animated:NO completion:^{}];
313+
}
314+
}
315+
316+
317+
//被动呼叫的UI逻辑
272318
- (BOOL)isActiveCalling:(NSString *)deviceUserID {
273319
UIViewController *topVC = [TIoTCoreUtil topViewController];
274320
if (_callAudioVC == topVC || _callVideoVC == topVC) {

0 commit comments

Comments
 (0)