|
@@ -27,8 +27,6 @@
|
|
|
|
|
|
@property (nonatomic, copy) KSRTCCallback error;
|
|
|
|
|
|
-@property (nonatomic, strong) TRTCCloud *engine;
|
|
|
-
|
|
|
@end
|
|
|
|
|
|
@implementation TXRTCService
|
|
@@ -43,6 +41,9 @@
|
|
|
return service;
|
|
|
}
|
|
|
|
|
|
+- (void)refreshGSMode {
|
|
|
+ [[TRTCCloud sharedInstance] setGravitySensorAdaptiveMode:TRTCGravitySensorAdaptiveMode_Disable];
|
|
|
+}
|
|
|
- (void)defaultAudioSetting {
|
|
|
self.ANS = 0;
|
|
|
self.AEC = 100;
|
|
@@ -70,8 +71,8 @@
|
|
|
if (error) {
|
|
|
self.error = error;
|
|
|
}
|
|
|
- [self.engine enterRoom:[self getTRTCRoomConfig:roomId] appScene:TRTCAppSceneVideoCall];
|
|
|
- self.engine.delegate = self;
|
|
|
+ [[TRTCCloud sharedInstance] enterRoom:[self getTRTCRoomConfig:roomId] appScene:TRTCAppSceneVideoCall];
|
|
|
+ [[TRTCCloud sharedInstance] addDelegate:self];
|
|
|
[self configDefaultHardwareStatus];
|
|
|
}
|
|
|
|
|
@@ -92,9 +93,9 @@
|
|
|
if (callback) {
|
|
|
self.success = callback;
|
|
|
}
|
|
|
- [self.engine exitRoom];
|
|
|
- _engine = nil;
|
|
|
- [TRTCCloud destroySharedIntance];
|
|
|
+ [[TRTCCloud sharedInstance] exitRoom];
|
|
|
+ [[TRTCCloud sharedInstance] removeDelegate:self]; // 移除代理
|
|
|
+ [TRTCCloud destroySharedInstance];
|
|
|
if (callback) {
|
|
|
callback(1);
|
|
|
}
|
|
@@ -104,18 +105,16 @@
|
|
|
- (void)publishStream {
|
|
|
NSString *currentUserID = [ClassroomService sharedService].currentRoom.currentMemberId;
|
|
|
NSString *streamId = [NSString stringWithFormat:@"%@_%@", self.roomID, currentUserID];
|
|
|
- [self.engine startPublishing:streamId type:TRTCVideoStreamTypeBig];
|
|
|
+ [[TRTCCloud sharedInstance] startPublishing:streamId type:TRTCVideoStreamTypeBig];
|
|
|
}
|
|
|
|
|
|
- (void)configVideoAndAudioSetting {
|
|
|
- [self.engine startLocalAudio:TRTCAudioQualityMusic];
|
|
|
+ [[TRTCCloud sharedInstance] startLocalAudio:TRTCAudioQualityMusic];
|
|
|
TRTCVideoEncParam *videoEncParams = [[TRTCVideoEncParam alloc] init];
|
|
|
videoEncParams.videoFps = 15.0f;
|
|
|
videoEncParams.resMode = TRTCVideoResolutionModeLandscape;
|
|
|
videoEncParams.videoResolution = TRTCVideoResolution_640_480;
|
|
|
- [self.engine setVideoEncoderParam:videoEncParams];
|
|
|
- [self.engine setGSensorMode:TRTCGSensorMode_UIFixLayout];
|
|
|
-// [self.engine setVideoMuteImage:[self generalCloseImage] fps:5];
|
|
|
+ [[TRTCCloud sharedInstance] setVideoEncoderParam:videoEncParams];
|
|
|
[self config3AWithANS:self.ANS AEC:self.AEC AGC:self.AGC];
|
|
|
}
|
|
|
|
|
@@ -154,26 +153,26 @@
|
|
|
|
|
|
- (void)renderLocalUserInView:(UIView *)displayView isCameraEnable:(BOOL)cameraEnable {
|
|
|
if (cameraEnable) {
|
|
|
- [self.engine setLocalRenderParams:[self getRenderParms:YES]];
|
|
|
- [self.engine startLocalPreview:[self isFrontCamera] view:displayView];
|
|
|
+ [[TRTCCloud sharedInstance] setLocalRenderParams:[self getRenderParms:YES]];
|
|
|
+ [[TRTCCloud sharedInstance] startLocalPreview:[self isFrontCamera] view:displayView];
|
|
|
}
|
|
|
else {
|
|
|
[self stopLocalPreview];
|
|
|
}
|
|
|
}
|
|
|
- (void)stopLocalPreview {
|
|
|
- [self.engine stopLocalPreview];
|
|
|
+ [[TRTCCloud sharedInstance] stopLocalPreview];
|
|
|
}
|
|
|
- (void)renderRemoteUser:(NSString *)userId inView:(UIView *)displayView {
|
|
|
[self cancleRenderUserVideo:userId];
|
|
|
- [self.engine setRemoteRenderParams:userId streamType:TRTCVideoStreamTypeBig params:[self getRenderParms:NO]];
|
|
|
- [self.engine startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:displayView];
|
|
|
+ [[TRTCCloud sharedInstance] setRemoteRenderParams:userId streamType:TRTCVideoStreamTypeBig params:[self getRenderParms:NO]];
|
|
|
+ [[TRTCCloud sharedInstance] startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:displayView];
|
|
|
}
|
|
|
|
|
|
- (void)cancleRenderUserVideo:(NSString *)userId {
|
|
|
NSString *currentUserID = [ClassroomService sharedService].currentRoom.currentMemberId;
|
|
|
if (![userId isEqualToString:currentUserID]) {
|
|
|
- [self.engine stopRemoteView:userId streamType:TRTCVideoStreamTypeBig];
|
|
|
+ [[TRTCCloud sharedInstance] stopRemoteView:userId streamType:TRTCVideoStreamTypeBig];
|
|
|
}
|
|
|
else {
|
|
|
|
|
@@ -213,7 +212,7 @@
|
|
|
[dic setValue:subDic forKey:@"params"];
|
|
|
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:kNilOptions error:nil];
|
|
|
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
|
- [self.engine callExperimentalAPI:jsonString];
|
|
|
+ [[TRTCCloud sharedInstance] callExperimentalAPI:jsonString];
|
|
|
}
|
|
|
|
|
|
// 回声消除
|
|
@@ -232,7 +231,7 @@
|
|
|
[dic setValue:subDic forKey:@"params"];
|
|
|
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:kNilOptions error:nil];
|
|
|
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
|
- [self.engine callExperimentalAPI:jsonString];
|
|
|
+ [[TRTCCloud sharedInstance] callExperimentalAPI:jsonString];
|
|
|
}
|
|
|
|
|
|
// 自动增益
|
|
@@ -251,7 +250,7 @@
|
|
|
[dic setValue:subDic forKey:@"params"];
|
|
|
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:kNilOptions error:nil];
|
|
|
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
|
- [self.engine callExperimentalAPI:jsonString];
|
|
|
+ [[TRTCCloud sharedInstance] callExperimentalAPI:jsonString];
|
|
|
}
|
|
|
|
|
|
#pragma mark --- TRTCCloudDelegate
|
|
@@ -263,9 +262,8 @@
|
|
|
}
|
|
|
else {
|
|
|
if (self.error) {
|
|
|
- [self.engine exitRoom];
|
|
|
- _engine = nil;
|
|
|
- [TRTCCloud destroySharedIntance];
|
|
|
+ [[TRTCCloud sharedInstance] exitRoom];
|
|
|
+ [TRTCCloud destroySharedInstance];
|
|
|
self.error(result);
|
|
|
}
|
|
|
}
|
|
@@ -324,10 +322,10 @@
|
|
|
for (RoomMember *member in memberList) {
|
|
|
if (member.role == RoleStudent) {
|
|
|
if ([member.userId isEqualToString:studentId]) {
|
|
|
- [self.engine setRemoteAudioVolume:member.userId volume:100];
|
|
|
+ [[TRTCCloud sharedInstance] setRemoteAudioVolume:member.userId volume:100];
|
|
|
}
|
|
|
else {
|
|
|
- [self.engine setRemoteAudioVolume:member.userId volume:0];
|
|
|
+ [[TRTCCloud sharedInstance] setRemoteAudioVolume:member.userId volume:0];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -337,7 +335,7 @@
|
|
|
NSMutableArray *memberList = [[ClassroomService sharedService].currentRoom.memberList mutableCopy];
|
|
|
for (RoomMember *member in memberList) {
|
|
|
if (member.role == RoleStudent) {
|
|
|
- [self.engine setRemoteAudioVolume:member.userId volume:100];
|
|
|
+ [[TRTCCloud sharedInstance] setRemoteAudioVolume:member.userId volume:100];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -355,11 +353,11 @@
|
|
|
*/
|
|
|
- (void)setMicrophoneDisable:(BOOL)disable {
|
|
|
if (disable) {
|
|
|
- [self.engine setAudioCaptureVolume:0];
|
|
|
+ [[TRTCCloud sharedInstance] setAudioCaptureVolume:0];
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
- [self.engine setAudioCaptureVolume:100];
|
|
|
+ [[TRTCCloud sharedInstance] setAudioCaptureVolume:100];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -369,21 +367,21 @@
|
|
|
@param disable YES 关闭,否则打开
|
|
|
*/
|
|
|
- (void)setCameraDisable:(BOOL)disable {
|
|
|
- [self.engine muteLocalVideo:TRTCVideoStreamTypeBig mute:disable];
|
|
|
+ [[TRTCCloud sharedInstance] muteLocalVideo:TRTCVideoStreamTypeBig mute:disable];
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
切换前后摄像头
|
|
|
*/
|
|
|
- (void)switchCamera {
|
|
|
- TXDeviceManager *deviceManager = [self.engine getDeviceManager];
|
|
|
+ TXDeviceManager *deviceManager = [[TRTCCloud sharedInstance] getDeviceManager];
|
|
|
BOOL isFrontCamera = [deviceManager isFrontCamera];
|
|
|
[deviceManager switchCamera:!isFrontCamera];
|
|
|
}
|
|
|
|
|
|
|
|
|
- (BOOL)isFrontCamera {
|
|
|
- TXDeviceManager *deviceManager = [self.engine getDeviceManager];
|
|
|
+ TXDeviceManager *deviceManager = [[TRTCCloud sharedInstance] getDeviceManager];
|
|
|
BOOL isFrontCamera = [deviceManager isFrontCamera];
|
|
|
return isFrontCamera;
|
|
|
}
|
|
@@ -392,7 +390,7 @@
|
|
|
切换使用外放/听筒
|
|
|
*/
|
|
|
- (void)useSpeaker:(BOOL)useSpeaker {
|
|
|
- TXDeviceManager *deviceManager = [self.engine getDeviceManager];
|
|
|
+ TXDeviceManager *deviceManager = [[TRTCCloud sharedInstance] getDeviceManager];
|
|
|
TXAudioRoute route = useSpeaker ? TXAudioRouteSpeakerphone :TXAudioRouteEarpiece;
|
|
|
[deviceManager setAudioRoute:route];
|
|
|
}
|
|
@@ -404,10 +402,4 @@
|
|
|
return parms;
|
|
|
}
|
|
|
|
|
|
-- (TRTCCloud *)engine {
|
|
|
- if (!_engine) {
|
|
|
- _engine = [TRTCCloud sharedInstance];
|
|
|
- }
|
|
|
- return _engine;
|
|
|
-}
|
|
|
@end
|