RtcManager 外部协议调整;新增内部协议
This commit is contained in:
@@ -384,6 +384,7 @@
|
|||||||
7DB00EC07F1D0ADFF900B38D /* Pods-xplan-ios.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.debug.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.debug.xcconfig"; sourceTree = "<group>"; };
|
7DB00EC07F1D0ADFF900B38D /* Pods-xplan-ios.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.debug.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; };
|
9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; };
|
||||||
9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; };
|
9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; };
|
||||||
|
9BB865B4272076140029CDE0 /* RtcImplDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcImplDelegate.h; sourceTree = "<group>"; };
|
||||||
B66633E061B1B34177CD011C /* Pods-xplan-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.release.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.release.xcconfig"; sourceTree = "<group>"; };
|
B66633E061B1B34177CD011C /* Pods-xplan-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.release.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
CACF623970097D653132D69A /* Pods_xplan_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_xplan_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
CACF623970097D653132D69A /* Pods_xplan_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_xplan_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E80487632717DDD9008595F2 /* XPRoomMenuItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMenuItem.h; sourceTree = "<group>"; };
|
E80487632717DDD9008595F2 /* XPRoomMenuItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMenuItem.h; sourceTree = "<group>"; };
|
||||||
@@ -710,6 +711,7 @@
|
|||||||
18486233271EB794005FC5DC /* AgoraRtcImpl.h */,
|
18486233271EB794005FC5DC /* AgoraRtcImpl.h */,
|
||||||
18486234271EB794005FC5DC /* AgoraRtcImpl.m */,
|
18486234271EB794005FC5DC /* AgoraRtcImpl.m */,
|
||||||
E81D587B271FBC3B003063FE /* RtcInterface.h */,
|
E81D587B271FBC3B003063FE /* RtcInterface.h */,
|
||||||
|
9BB865B4272076140029CDE0 /* RtcImplDelegate.h */,
|
||||||
);
|
);
|
||||||
path = RtcImpl;
|
path = RtcImpl;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@@ -10,10 +10,9 @@
|
|||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@protocol RtcDelegate <NSObject>
|
@protocol RtcDelegate <NSObject>
|
||||||
@optional
|
|
||||||
|
|
||||||
///说话者声音的回调
|
///说话者声音的回调
|
||||||
- (void)usersSpeaking:(NSMutableArray * _Nullable)speakings;
|
- (void)usersSpeaking:(NSMutableArray * _Nullable)uids;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
@implementation AgoraRtcImpl
|
@implementation AgoraRtcImpl
|
||||||
|
|
||||||
- (instancetype)init {
|
- (instancetype)initWithDelegate:(id<RtcImplDelegate>)delegate {
|
||||||
self = [super init];
|
self = [super initWithDelegate:delegate];
|
||||||
if (self) {
|
if (self) {
|
||||||
_engine = [AgoraRtcEngineKit sharedEngineWithAppId:KeyWithType(KeyType_Agora) delegate:self];
|
_engine = [AgoraRtcEngineKit sharedEngineWithAppId:KeyWithType(KeyType_Agora) delegate:self];
|
||||||
[_engine setChannelProfile:AgoraChannelProfileLiveBroadcasting];
|
[_engine setChannelProfile:AgoraChannelProfileLiveBroadcasting];
|
||||||
@@ -71,9 +71,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self.delegate && [self.delegate respondsToSelector:@selector(usersSpeaking:)]) {
|
[self.delegate usersSpeaking:uids];
|
||||||
[self.delegate usersSpeaking:uids];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,15 +7,16 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "RtcInterface.h"
|
#import "RtcInterface.h"
|
||||||
#import "RtcDelegate.h"
|
#import "RtcImplDelegate.h"
|
||||||
#import "AccountInfoStorage.h"
|
#import "AccountInfoStorage.h"
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface BaseRtcImpl : NSObject <RtcInterface>
|
@interface BaseRtcImpl : NSObject <RtcInterface>
|
||||||
|
|
||||||
///代理
|
@property (nonatomic,weak) id<RtcImplDelegate> delegate;
|
||||||
@property (nonatomic,weak) id<RtcDelegate> delegate;
|
|
||||||
|
- (instancetype)initWithDelegate:(id<RtcImplDelegate>)delegate;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -7,15 +7,30 @@
|
|||||||
|
|
||||||
#import "BaseRtcImpl.h"
|
#import "BaseRtcImpl.h"
|
||||||
|
|
||||||
@interface BaseRtcImpl()
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation BaseRtcImpl
|
@implementation BaseRtcImpl
|
||||||
|
|
||||||
- (BOOL)joinChannel:(NSString *)channelId broadcast:(BOOL)on {
|
- (instancetype)initWithDelegate:(id<RtcImplDelegate>)delegate{
|
||||||
[self broadcast:on];
|
self = [super init];
|
||||||
return [self joinChannel:channelId];
|
if (self) {
|
||||||
|
self.delegate = delegate;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)broadcast:(BOOL)on {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)destory {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)exitChannel {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)joinChannel:(nonnull NSString *)channelId {
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
19
xplan-ios/Main/RTC/RtcImpl/RtcImplDelegate.h
Normal file
19
xplan-ios/Main/RTC/RtcImpl/RtcImplDelegate.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// RtcImplDelegate.h
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by zu on 2021/10/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@protocol RtcImplDelegate <NSObject>
|
||||||
|
|
||||||
|
/** 发言用户回调。 */
|
||||||
|
- (void)usersSpeaking:(NSMutableArray * _Nullable)uids;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@@ -18,10 +18,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
上下麦(说话)
|
上下麦(说话)
|
||||||
*/
|
*/
|
||||||
- (void)broadcast:(BOOL)on;
|
- (void)broadcast:(BOOL)on;
|
||||||
/**
|
|
||||||
加入频道同时上麦
|
|
||||||
*/
|
|
||||||
- (BOOL)joinChannel:(NSString *)channelId broadcast:(BOOL)on;
|
|
||||||
/**
|
/**
|
||||||
退出频道
|
退出频道
|
||||||
*/
|
*/
|
||||||
|
@@ -16,6 +16,14 @@ typedef enum : NSUInteger {
|
|||||||
RtcEngineType_AgoraFast,//声网急速
|
RtcEngineType_AgoraFast,//声网急速
|
||||||
} RtcEngineType;
|
} RtcEngineType;
|
||||||
|
|
||||||
|
/** 音频服务管理单例,对所有音频服务 SDK 的封装。
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
|
||||||
|
- 外部调用者只需要调用 RtcManager 。
|
||||||
|
- 不要侵入 RctImpl 内的逻辑。
|
||||||
|
*/
|
||||||
|
|
||||||
@interface RtcManager : NSObject
|
@interface RtcManager : NSObject
|
||||||
|
|
||||||
/** 初始化/重新初始化 RtcManager 实例,设置音频服务类型和 RtcDelegate。
|
/** 初始化/重新初始化 RtcManager 实例,设置音频服务类型和 RtcDelegate。
|
||||||
@@ -48,16 +56,13 @@ typedef enum : NSUInteger {
|
|||||||
- (id)mutableCopy NS_UNAVAILABLE;
|
- (id)mutableCopy NS_UNAVAILABLE;
|
||||||
|
|
||||||
/** 加入频道(房间)*/
|
/** 加入频道(房间)*/
|
||||||
- (BOOL)joinChannel:(NSString *)channelId;
|
- (BOOL)enterRoom:(NSString *)roomUid;
|
||||||
|
|
||||||
/** 上下麦(说话)*/
|
/** 上下麦(说话)*/
|
||||||
- (void)broadcast:(BOOL)on;
|
- (void)broadcast:(BOOL)on;
|
||||||
|
|
||||||
/** 加入频道同时上麦 */
|
|
||||||
- (BOOL)joinChannel:(NSString *)channelId broadcast:(BOOL)on;
|
|
||||||
|
|
||||||
/** 退出频道 */
|
/** 退出频道 */
|
||||||
- (void)exitChannel;
|
- (void)exitRoom;
|
||||||
|
|
||||||
/** 销毁引擎(理论上不需要调用) */
|
/** 销毁引擎(理论上不需要调用) */
|
||||||
- (void)destory;
|
- (void)destory;
|
||||||
|
@@ -6,12 +6,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "RtcManager.h"
|
#import "RtcManager.h"
|
||||||
|
#import "RtcImplDelegate.h"
|
||||||
#import "AgoraRtcImpl.h"
|
#import "AgoraRtcImpl.h"
|
||||||
|
|
||||||
@interface RtcManager()
|
@interface RtcManager()<RtcImplDelegate>
|
||||||
|
|
||||||
@property (nonatomic, strong) id<RtcInterface> engine;
|
@property (nonatomic, strong) id<RtcInterface> engine;
|
||||||
@property (nonatomic,assign) id<RtcDelegate> engineDelegate;
|
@property (nonatomic, weak) id<RtcDelegate> engineDelegate;
|
||||||
@property (nonatomic, assign) RtcEngineType engineType;
|
@property (nonatomic, assign) RtcEngineType engineType;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -34,19 +35,15 @@
|
|||||||
return rtcManager;
|
return rtcManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)joinChannel:(NSString *)channelId {
|
- (BOOL)enterRoom:(NSString *)roomUid {
|
||||||
return [self.engine joinChannel:channelId];
|
return [self.engine joinChannel:roomUid];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)broadcast:(BOOL)on {
|
- (void)broadcast:(BOOL)on {
|
||||||
[self.engine broadcast:on];
|
[self.engine broadcast:on];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)joinChannel:(NSString *)channelId broadcast:(BOOL)on {
|
- (void)exitRoom {
|
||||||
return [self.engine joinChannel:channelId broadcast:on];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)exitChannel {
|
|
||||||
[self.engine exitChannel];
|
[self.engine exitChannel];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +51,12 @@
|
|||||||
[self.engine destory];
|
[self.engine destory];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)usersSpeaking:(NSMutableArray *)uids {
|
||||||
|
if (self.engineDelegate) {
|
||||||
|
[self.engineDelegate usersSpeaking:uids];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setEngineType:(RtcEngineType)type {
|
- (void)setEngineType:(RtcEngineType)type {
|
||||||
if (_engine && type != _engineType) {
|
if (_engine && type != _engineType) {
|
||||||
[_engine exitChannel];
|
[_engine exitChannel];
|
||||||
@@ -72,19 +75,16 @@
|
|||||||
switch (_engineType) {
|
switch (_engineType) {
|
||||||
case RtcEngineType_Agora:
|
case RtcEngineType_Agora:
|
||||||
{
|
{
|
||||||
_engine = [[AgoraRtcImpl alloc] init];
|
_engine = [[AgoraRtcImpl alloc] initWithDelegate:self];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
_engine = [[AgoraRtcImpl alloc] init];
|
_engine = [[AgoraRtcImpl alloc] initWithDelegate:self];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ([_engine isKindOfClass:[BaseRtcImpl class]]) {
|
|
||||||
((BaseRtcImpl*)_engine).delegate = self.engineDelegate;
|
|
||||||
}
|
|
||||||
return _engine;
|
return _engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,11 +13,12 @@
|
|||||||
|
|
||||||
- (void)configEnterRoomSDK {
|
- (void)configEnterRoomSDK {
|
||||||
[RtcManager initEngineWithType:RtcEngineType_Agora delegate:self];
|
[RtcManager initEngineWithType:RtcEngineType_Agora delegate:self];
|
||||||
[[RtcManager instance] joinChannel:[NSString stringWithFormat:@"%ld", (long)self.roomInfo.uid] broadcast:YES];
|
[[RtcManager instance] enterRoom:[NSString stringWithFormat:@"%ld", (long)self.roomInfo.uid]];
|
||||||
|
[[RtcManager instance] broadcast:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - RtcDelegate
|
#pragma mark - RtcDelegate
|
||||||
- (void)usersSpeaking:(NSMutableArray *)speakings {
|
- (void)usersSpeaking:(NSMutableArray *)uids {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user