声网服务调试
This commit is contained in:
@@ -104,6 +104,7 @@
|
|||||||
E81C27A226EF23490031E639 /* XPEnum.h in Sources */ = {isa = PBXBuildFile; fileRef = E81C27A126EF23370031E639 /* XPEnum.h */; };
|
E81C27A226EF23490031E639 /* XPEnum.h in Sources */ = {isa = PBXBuildFile; fileRef = E81C27A126EF23370031E639 /* XPEnum.h */; };
|
||||||
E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */; };
|
E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */; };
|
||||||
E81C27AE26EF39AB0031E639 /* AppDelegate+ThirdConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AD26EF39AB0031E639 /* AppDelegate+ThirdConfig.m */; };
|
E81C27AE26EF39AB0031E639 /* AppDelegate+ThirdConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AD26EF39AB0031E639 /* AppDelegate+ThirdConfig.m */; };
|
||||||
|
E81D587E271FC1EB003063FE /* XPRoomViewController+SDKConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E81D587D271FC1EB003063FE /* XPRoomViewController+SDKConfig.m */; };
|
||||||
E82109AD26F1C8A000FC3319 /* CountDownHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E82109AC26F1C8A000FC3319 /* CountDownHelper.m */; };
|
E82109AD26F1C8A000FC3319 /* CountDownHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E82109AC26F1C8A000FC3319 /* CountDownHelper.m */; };
|
||||||
E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E82109AF26F1D83500FC3319 /* LoginBindPhonePresent.m */; };
|
E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E82109AF26F1D83500FC3319 /* LoginBindPhonePresent.m */; };
|
||||||
E824543526F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E824543426F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m */; };
|
E824543526F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E824543426F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m */; };
|
||||||
@@ -418,6 +419,9 @@
|
|||||||
E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ThirdUserInfo.m; sourceTree = "<group>"; };
|
E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ThirdUserInfo.m; sourceTree = "<group>"; };
|
||||||
E81C27AC26EF39AB0031E639 /* AppDelegate+ThirdConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+ThirdConfig.h"; sourceTree = "<group>"; };
|
E81C27AC26EF39AB0031E639 /* AppDelegate+ThirdConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+ThirdConfig.h"; sourceTree = "<group>"; };
|
||||||
E81C27AD26EF39AB0031E639 /* AppDelegate+ThirdConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+ThirdConfig.m"; sourceTree = "<group>"; };
|
E81C27AD26EF39AB0031E639 /* AppDelegate+ThirdConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+ThirdConfig.m"; sourceTree = "<group>"; };
|
||||||
|
E81D587B271FBC3B003063FE /* RtcInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcInterface.h; sourceTree = "<group>"; };
|
||||||
|
E81D587C271FC1EB003063FE /* XPRoomViewController+SDKConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XPRoomViewController+SDKConfig.h"; sourceTree = "<group>"; };
|
||||||
|
E81D587D271FC1EB003063FE /* XPRoomViewController+SDKConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "XPRoomViewController+SDKConfig.m"; sourceTree = "<group>"; };
|
||||||
E82109AB26F1C8A000FC3319 /* CountDownHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CountDownHelper.h; sourceTree = "<group>"; };
|
E82109AB26F1C8A000FC3319 /* CountDownHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CountDownHelper.h; sourceTree = "<group>"; };
|
||||||
E82109AC26F1C8A000FC3319 /* CountDownHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CountDownHelper.m; sourceTree = "<group>"; };
|
E82109AC26F1C8A000FC3319 /* CountDownHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CountDownHelper.m; sourceTree = "<group>"; };
|
||||||
E82109AE26F1D83500FC3319 /* LoginBindPhonePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginBindPhonePresent.h; sourceTree = "<group>"; };
|
E82109AE26F1D83500FC3319 /* LoginBindPhonePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginBindPhonePresent.h; sourceTree = "<group>"; };
|
||||||
@@ -694,6 +698,7 @@
|
|||||||
18486216271EAB8C005FC5DC /* BaseRtcImpl.m */,
|
18486216271EAB8C005FC5DC /* BaseRtcImpl.m */,
|
||||||
18486233271EB794005FC5DC /* AgoraRtcImpl.h */,
|
18486233271EB794005FC5DC /* AgoraRtcImpl.h */,
|
||||||
18486234271EB794005FC5DC /* AgoraRtcImpl.m */,
|
18486234271EB794005FC5DC /* AgoraRtcImpl.m */,
|
||||||
|
E81D587B271FBC3B003063FE /* RtcInterface.h */,
|
||||||
);
|
);
|
||||||
path = RTC;
|
path = RTC;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1429,6 +1434,8 @@
|
|||||||
children = (
|
children = (
|
||||||
E88F5EAF271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.h */,
|
E88F5EAF271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.h */,
|
||||||
E88F5EAE271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.m */,
|
E88F5EAE271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.m */,
|
||||||
|
E81D587C271FC1EB003063FE /* XPRoomViewController+SDKConfig.h */,
|
||||||
|
E81D587D271FC1EB003063FE /* XPRoomViewController+SDKConfig.m */,
|
||||||
);
|
);
|
||||||
path = Category;
|
path = Category;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -1975,6 +1982,7 @@
|
|||||||
18E7B22626E8CDCF0064BC9B /* XplanFlutterBoostDelegate.m in Sources */,
|
18E7B22626E8CDCF0064BC9B /* XplanFlutterBoostDelegate.m in Sources */,
|
||||||
E8EEB8F326FC2050007C6EBA /* SDWaitingView.m in Sources */,
|
E8EEB8F326FC2050007C6EBA /* SDWaitingView.m in Sources */,
|
||||||
E8B846CB26FDD7CD00A777FE /* XPMineRechargeViewController.m in Sources */,
|
E8B846CB26FDD7CD00A777FE /* XPMineRechargeViewController.m in Sources */,
|
||||||
|
E81D587E271FC1EB003063FE /* XPRoomViewController+SDKConfig.m in Sources */,
|
||||||
E86596512701A1C000846EBD /* StatisticsService.m in Sources */,
|
E86596512701A1C000846EBD /* StatisticsService.m in Sources */,
|
||||||
E824544026F58F9400BE8163 /* XPMinePayPwdViewController.m in Sources */,
|
E824544026F58F9400BE8163 /* XPMinePayPwdViewController.m in Sources */,
|
||||||
E8AC723D26F4B6AA007D6E91 /* XPLoginBindPhoneResultViewController.m in Sources */,
|
E8AC723D26F4B6AA007D6E91 /* XPLoginBindPhoneResultViewController.m in Sources */,
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
<string>“耳萌”需要您的同意,才可以进行语音聊天</string>
|
||||||
<key>NSPhotoLibraryAddUsageDescription</key>
|
<key>NSPhotoLibraryAddUsageDescription</key>
|
||||||
<string>“音游”需要您的同意,才可以存储相片到相册</string>
|
<string>“音游”需要您的同意,才可以存储相片到相册</string>
|
||||||
<key>NSPhotoLibraryUsageDescription</key>
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "BaseRtcImpl.h"
|
#import "BaseRtcImpl.h"
|
||||||
|
#import "RtcDelegate.h"
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface AgoraRtcImpl : BaseRtcImpl
|
@interface AgoraRtcImpl : BaseRtcImpl
|
||||||
|
@@ -8,17 +8,18 @@
|
|||||||
#import "AgoraRtcImpl.h"
|
#import "AgoraRtcImpl.h"
|
||||||
#import "XPConstant.h"
|
#import "XPConstant.h"
|
||||||
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
|
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
|
||||||
|
#import "RtcInterface.h"
|
||||||
|
|
||||||
@interface AgoraRtcImpl()<AgoraRtcEngineDelegate>
|
@interface AgoraRtcImpl()<AgoraRtcEngineDelegate>
|
||||||
|
|
||||||
@property(nonatomic, strong) AgoraRtcEngineKit *engine;
|
@property(nonatomic, strong) AgoraRtcEngineKit *engine;
|
||||||
|
///声音的回调
|
||||||
|
@property(nonatomic, strong) NSMutableArray *speakingArray;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation AgoraRtcImpl
|
@implementation AgoraRtcImpl
|
||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init {
|
||||||
{
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_engine = [AgoraRtcEngineKit sharedEngineWithAppId:KeyWithType(KeyType_Agora) delegate:self];
|
_engine = [AgoraRtcEngineKit sharedEngineWithAppId:KeyWithType(KeyType_Agora) delegate:self];
|
||||||
@@ -38,16 +39,21 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - RtcDelegate impl
|
#pragma mark - RtcInterface impl
|
||||||
- (void)joinChannel:(nonnull NSString *)channelId {
|
- (void)joinChannel:(nonnull NSString *)channelId {
|
||||||
[self.engine setClientRole:AgoraClientRoleAudience];
|
[self.engine setClientRole:AgoraClientRoleAudience];
|
||||||
int code = [self.engine joinChannelByToken:nil channelId:channelId info:nil uid:[[[AccountInfoStorage instance] getUid] integerValue] joinSuccess:^(NSString * _Nonnull channel, NSUInteger uid, NSInteger elapsed) {
|
int code = [self.engine joinChannelByToken:nil channelId:channelId info:nil uid:[[[AccountInfoStorage instance] getUid] integerValue] joinSuccess:^(NSString * _Nonnull channel, NSUInteger uid, NSInteger elapsed) {
|
||||||
// TODO: success
|
// TODO: success
|
||||||
}];
|
}];
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
// TODO: fail
|
if (self.delegate && [self.delegate respondsToSelector:@selector(joinChannelFail)]) {
|
||||||
|
[self.delegate joinChannelFail];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(joinChannelSuccess)]) {
|
||||||
|
[self.delegate joinChannelSuccess];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)broadcast:(BOOL)on {
|
- (void)broadcast:(BOOL)on {
|
||||||
@@ -63,4 +69,61 @@
|
|||||||
[AgoraRtcEngineKit destroy];
|
[AgoraRtcEngineKit destroy];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - AgoraRtcEngineDelegate
|
||||||
|
///网络不好
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *)engine lastmileQuality:(AgoraNetworkQuality)quality {
|
||||||
|
if (quality >= 3) {
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(channelQualityDown)]) {
|
||||||
|
[self.delegate channelQualityDown];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///网络断开
|
||||||
|
- (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit *)engine {
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(channelQualityBad)]) {
|
||||||
|
[self.delegate channelQualityBad];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///声音的回调
|
||||||
|
- (void)rtcEngine:(AgoraRtcEngineKit *)engine reportAudioVolumeIndicationOfSpeakers:(NSArray *)speakers totalVolume:(NSInteger)totalVolume {
|
||||||
|
[self onSpeakingUsersReport:speakers];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)rtcEngineLocalAudioMixingDidFinish:(AgoraRtcEngineKit *)engine{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private Method
|
||||||
|
//光圈回调
|
||||||
|
- (void)onSpeakingUsersReport:(NSArray *)report {
|
||||||
|
NSMutableArray *uids = [NSMutableArray array];
|
||||||
|
if (report != nil && report.count > 0) {
|
||||||
|
for (AgoraRtcAudioVolumeInfo *userInfo in report) {
|
||||||
|
NSString *uid = [NSString stringWithFormat:@"%ld",(long)userInfo.uid];
|
||||||
|
if (userInfo.volume > 15){
|
||||||
|
if (uid.integerValue == 0) {
|
||||||
|
[uids addObject:[[AccountInfoStorage instance] getUid]];
|
||||||
|
}else {
|
||||||
|
[uids addObject:uid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.speakingArray = uids;
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(speakingUsersReportSuccess:)]) {
|
||||||
|
[self.delegate speakingUsersReportSuccess:self.speakingArray];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (self.speakingArray != nil) {
|
||||||
|
self.speakingArray = nil;
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(speakingUsersReportSuccess:)]) {
|
||||||
|
[self.delegate speakingUsersReportSuccess:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -6,13 +6,15 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "RtcInterface.h"
|
||||||
#import "RtcDelegate.h"
|
#import "RtcDelegate.h"
|
||||||
#import "AccountInfoStorage.h"
|
#import "AccountInfoStorage.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface BaseRtcImpl : NSObject <RtcDelegate>
|
@interface BaseRtcImpl : NSObject <RtcInterface>
|
||||||
|
///代理
|
||||||
|
@property (nonatomic,weak) id<RtcDelegate> delegate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -10,27 +10,19 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@protocol RtcDelegate <NSObject>
|
@protocol RtcDelegate <NSObject>
|
||||||
|
@optional
|
||||||
|
///加入成功
|
||||||
|
- (void)joinChannelSuccess;
|
||||||
|
///加入失败
|
||||||
|
- (void)joinChannelFail;
|
||||||
|
|
||||||
/**
|
///说话者声音的回调
|
||||||
加入频道(房间)
|
- (void)speakingUsersReportSuccess:(NSMutableArray * _Nullable)speakings;
|
||||||
*/
|
|
||||||
- (void)joinChannel:(NSString *)channelId;
|
///掉线
|
||||||
/**
|
- (void)channelQualityDown;
|
||||||
上下麦(说话)
|
///网络不好
|
||||||
*/
|
- (void)channelQualityBad;
|
||||||
- (void)broadcast:(BOOL)on;
|
|
||||||
/**
|
|
||||||
加入频道同时上麦
|
|
||||||
*/
|
|
||||||
- (void)joinChannel:(NSString *)channelId broadcast:(BOOL)on;
|
|
||||||
/**
|
|
||||||
退出频道
|
|
||||||
*/
|
|
||||||
- (void)exitChannel;
|
|
||||||
/**
|
|
||||||
销毁引擎
|
|
||||||
*/
|
|
||||||
- (void)destory;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
35
xplan-ios/Main/RTC/RtcInterface.h
Normal file
35
xplan-ios/Main/RTC/RtcInterface.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// RtcInterface.h
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by 冯硕 on 2021/10/20.
|
||||||
|
//
|
||||||
|
///需要暴露的接口
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@protocol RtcInterface <NSObject>
|
||||||
|
/**
|
||||||
|
加入频道(房间)
|
||||||
|
*/
|
||||||
|
- (void)joinChannel:(NSString *)channelId;
|
||||||
|
/**
|
||||||
|
上下麦(说话)
|
||||||
|
*/
|
||||||
|
- (void)broadcast:(BOOL)on;
|
||||||
|
/**
|
||||||
|
加入频道同时上麦
|
||||||
|
*/
|
||||||
|
- (void)joinChannel:(NSString *)channelId broadcast:(BOOL)on;
|
||||||
|
/**
|
||||||
|
退出频道
|
||||||
|
*/
|
||||||
|
- (void)exitChannel;
|
||||||
|
/**
|
||||||
|
销毁引擎
|
||||||
|
*/
|
||||||
|
- (void)destory;
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@@ -6,8 +6,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "RtcInterface.h"
|
||||||
#import "RtcDelegate.h"
|
#import "RtcDelegate.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
typedef enum : NSUInteger {
|
typedef enum : NSUInteger {
|
||||||
@@ -17,8 +17,10 @@ typedef enum : NSUInteger {
|
|||||||
RtcEngineType_AgoraFast,//声网急速
|
RtcEngineType_AgoraFast,//声网急速
|
||||||
} RtcEngineType;
|
} RtcEngineType;
|
||||||
|
|
||||||
@interface RtcManager : NSObject<RtcDelegate>
|
@interface RtcManager : NSObject
|
||||||
|
@property (nonatomic, strong, readonly) id<RtcInterface> engine;
|
||||||
|
///代理
|
||||||
|
@property (nonatomic,assign) id<RtcDelegate> delegate;
|
||||||
/**
|
/**
|
||||||
切换音频必须重新调用该方法重新初始化
|
切换音频必须重新调用该方法重新初始化
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +28,7 @@ typedef enum : NSUInteger {
|
|||||||
/**
|
/**
|
||||||
确保RtcEngineType正确,可以直接调用获取instance
|
确保RtcEngineType正确,可以直接调用获取instance
|
||||||
*/
|
*/
|
||||||
+ (instancetype _Nonnull)intance;
|
+ (instancetype _Nonnull)instance;
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
+ (instancetype)new NS_UNAVAILABLE;
|
+ (instancetype)new NS_UNAVAILABLE;
|
||||||
- (id)copy NS_UNAVAILABLE;
|
- (id)copy NS_UNAVAILABLE;
|
||||||
|
@@ -10,9 +10,10 @@
|
|||||||
|
|
||||||
@interface RtcManager()
|
@interface RtcManager()
|
||||||
|
|
||||||
@property (nonatomic, strong) id<RtcDelegate> engine;
|
@property (nonatomic, strong) id<RtcInterface> engine;
|
||||||
@property (nonatomic, assign) RtcEngineType engineType;
|
@property (nonatomic, assign) RtcEngineType engineType;
|
||||||
|
///声网的实现
|
||||||
|
@property (nonatomic,strong) AgoraRtcImpl *agoraImpl;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RtcManager
|
@implementation RtcManager
|
||||||
@@ -28,7 +29,7 @@ static RtcManager *instance = nil;
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (instancetype)intance {
|
+ (instancetype)instance {
|
||||||
dispatch_once(&onceToken,^{
|
dispatch_once(&onceToken,^{
|
||||||
instance = [[self alloc] init];
|
instance = [[self alloc] init];
|
||||||
});
|
});
|
||||||
@@ -44,16 +45,17 @@ static RtcManager *instance = nil;
|
|||||||
_engineType = type;
|
_engineType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id<RtcDelegate>)engine {
|
- (id<RtcInterface>)engine {
|
||||||
if (!_engine) {
|
if (!_engine) {
|
||||||
switch (_engineType) {
|
switch (_engineType) {
|
||||||
case RtcEngineType_Agora: {
|
case RtcEngineType_Agora:
|
||||||
_engine = [[AgoraRtcImpl alloc] init];
|
{
|
||||||
|
_engine = self.agoraImpl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
default: {
|
{
|
||||||
_engine = [[AgoraRtcImpl alloc] init];
|
_engine = self.agoraImpl;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -61,24 +63,14 @@ static RtcManager *instance = nil;
|
|||||||
return _engine;
|
return _engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)broadcast:(BOOL)on {
|
- (AgoraRtcImpl *)agoraImpl {
|
||||||
[self.engine broadcast:on];
|
if (!_agoraImpl) {
|
||||||
|
_agoraImpl = [[AgoraRtcImpl alloc] init];
|
||||||
|
_agoraImpl.delegate = self.delegate;
|
||||||
|
}
|
||||||
|
return _agoraImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)destory {
|
|
||||||
[self.engine destory];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)exitChannel {
|
|
||||||
[self.engine destory];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)joinChannel:(nonnull NSString *)channelId {
|
|
||||||
[self.engine joinChannel:channelId];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)joinChannel:(nonnull NSString *)channelId broadcast:(BOOL)on {
|
|
||||||
[self.engine joinChannel:channelId broadcast:on];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// XPRoomViewController+SDKConfig.h
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by 冯硕 on 2021/10/20.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "XPRoomViewController.h"
|
||||||
|
#import "RtcManager.h"
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface XPRoomViewController (SDKConfig)<RtcDelegate>
|
||||||
|
- (void)configEnterRoomSDK;
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// XPRoomViewController+SDKConfig.m
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by 冯硕 on 2021/10/20.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "XPRoomViewController+SDKConfig.h"
|
||||||
|
///Model
|
||||||
|
#import "RoomInfoModel.h"
|
||||||
|
|
||||||
|
@implementation XPRoomViewController (SDKConfig)
|
||||||
|
|
||||||
|
- (void)configEnterRoomSDK {
|
||||||
|
[RtcManager instance].delegate = self;
|
||||||
|
[[RtcManager instance].engine joinChannel:[NSString stringWithFormat:@"%ld", self.roomInfo.uid] broadcast:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - RtcDelegate
|
||||||
|
- (void)speakingUsersReportSuccess:(NSMutableArray *)speakings {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@@ -26,6 +26,7 @@
|
|||||||
#import "XPRoomProtocol.h"
|
#import "XPRoomProtocol.h"
|
||||||
///Category
|
///Category
|
||||||
#import "XPRoomViewController+RoomInfoContainerView.h"
|
#import "XPRoomViewController+RoomInfoContainerView.h"
|
||||||
|
#import "XPRoomViewController+SDKConfig.h"
|
||||||
|
|
||||||
@interface XPRoomViewController ()<XPRoomProtocol>
|
@interface XPRoomViewController ()<XPRoomProtocol>
|
||||||
///背景
|
///背景
|
||||||
@@ -145,6 +146,7 @@
|
|||||||
- (void)enterChatRoomWithUseInfo:(UserInfoModel *)userInfo {
|
- (void)enterChatRoomWithUseInfo:(UserInfoModel *)userInfo {
|
||||||
///进入房间的时候 必须要有用户信息 并且房间状态一切正常
|
///进入房间的时候 必须要有用户信息 并且房间状态一切正常
|
||||||
#warning to do - 进入云信房间的逻辑
|
#warning to do - 进入云信房间的逻辑
|
||||||
|
[self configEnterRoomSDK];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - XPRoomProtocol
|
#pragma mark - XPRoomProtocol
|
||||||
|
Reference in New Issue
Block a user