Skip to content

Commit

Permalink
添加openCamera提前预览接口
Browse files Browse the repository at this point in the history
Change-Id: I67771017a153628b8b9b99aa8191cf948e66ce95
  • Loading branch information
tonychanchen committed Apr 14, 2023
1 parent db99df2 commit cbd317b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ - (void)viewDidLoad {

NSString *productId = [TIoTCoreAppEnvironment shareEnvironment].cloudProductId?:@"";
NSString *deviceName= self.deviceName?:@"";
[self callDevice:productId devicename:deviceName];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self callDevice:productId devicename:deviceName];
// });

UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"静音" style:UIBarButtonItemStylePlain target:self action:@selector(showHudView:)];
self.navigationItem.rightBarButtonItem = right;

//设置代理,接受设备消息
[TIoTCoreXP2PBridge sharedInstance].delegate = self;
// [[TIoTCoreXP2PBridge sharedInstance] openCamera:AVCaptureDevicePositionFront view:self.imageView];
}

- (void)requestDiffDeviceDataWithXp2pInfo:(TRTCParams *)xp2pInfo {
Expand Down
4 changes: 4 additions & 0 deletions Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ extern NSNotificationName const TIoTCoreXP2PBridgeNotificationStreamEnd;
*/
+ (int)getStreamLinkMode:(NSString *)dev_name;

/*
* 打开本地预览
*/
- (void)openCamera:(AVCaptureDevicePosition)videoPosition view:(UIView *)previewView;
@end

NS_ASSUME_NONNULL_END
10 changes: 8 additions & 2 deletions Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ - (XP2PErrCode)startAppWith:(NSString *)pro_id dev_name:(NSString *)dev_name {

[TRTCCloud sharedInstance].delegate = self;
[[TRTCCloud sharedInstance] enterRoom:self.params appScene:TRTCAppSceneVideoCall];

[[TRTCCloud sharedInstance] muteLocalVideo:TRTCVideoStreamTypeBig mute:YES];
return XP2P_ERR_NONE;


Expand Down Expand Up @@ -371,7 +373,10 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
// fileHandle = [NSFileHandle fileHandleForWritingAtPath:audioFile];
self.audioConfig = audio_config;
self.videoConfig = video_config;
[[TRTCCloud sharedInstance] muteLocalVideo:TRTCVideoStreamTypeBig mute:NO];
[[TRTCCloud sharedInstance] stopLocalPreview];
[[TRTCCloud sharedInstance] startLocalPreview:(video_config.videoPosition == AVCaptureDevicePositionFront)?YES:NO view:video_config.localView];

[[TRTCCloud sharedInstance] startLocalAudio:TRTCAudioQualitySpeech];
return;

Expand Down Expand Up @@ -529,8 +534,9 @@ + (int)getStreamLinkMode:(NSString *)dev_name {
}




- (void)openCamera:(AVCaptureDevicePosition)videoPosition view:(UIView *)previewView {
[[TRTCCloud sharedInstance] startLocalPreview:(videoPosition == AVCaptureDevicePositionFront)?YES:NO view:previewView];
}

#pragma mark -TRTCCloudDelegate
- (void)onEnterRoom:(NSInteger)result {
Expand Down

0 comments on commit cbd317b

Please sign in to comment.