human: 如何处理七牛云的实时音视频QNRTCConfiguration

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > iOS >QNRTCConfiguration

#  QNRTCConfiguration

最近更新时间: 2023-10-20 15:10:18

RTC 相关配置

Index

Core Properties

  * policy
  * maintainResolutionEnabled
  * communicationModeOn
  * audioScene
  * reconnectionTimeout
  * encoderType
  * mcuDomains

Core Methods

  * defaultConfiguration
  * initWithPolicy[1/6]
  * initWithPolicy[2/6]
  * initWithPolicy[3/6]
  * initWithPolicy[4/6]
  * initWithPolicy[5/6]
  * initWithPolicy[6/6]

Core Properties

policy

  * @property (nonatomic, assign, readonly) [QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254) policy;
  * 媒体流的连接方式，默认 [QNRTCPolicyForceUDP](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254)

maintainResolutionEnabled

  * @property (nonatomic, assign, readonly) BOOL maintainResolutionEnabled;
  * 固定分辨率，默认为 NO

> 该接口已废弃，请使用
> [QNVideoEncoderConfig.initWithBitrate[4/4]](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
> iOS/11944)

communicationModeOn

  * @property (nonatomic, assign, readonly) BOOL communicationModeOn;
  * 是否使用通话模式，默认为 YES

使用声卡并配戴耳机的情况下，建议关闭该配置，可解决声卡模式不匹配带来的音频异常无效等问题

关闭该模式将直接关闭硬件回声消除，不佩戴耳机的情况下连麦，可能出现回声

> 该接口已废弃，请使用
> [QNRTCConfiguration.initWithPolicy[4/4]](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
> iOS/8838)

audioScene

  * @property (nonatomic, assign, readonly) [QNAudioScene](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254) audioScene;
  * 音频场景，默认为 [QNAudioSceneDefault](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254)

可通过 QNRTC 调用 setAudioScene 动态设置

reconnectionTimeout

  * @property (nonatomic, assign, readonly) int reconnectionTimeout;
  * SDK 与七牛服务器由于网络原因断开后，内部尝试重连的超时时间，单位： ms，默认 30s

建议在重连超时收到 QNRTCErrorNetworkTimeout 后做新的业务处理

encoderType

  * @property (nonatomic, assign, readonly) [QNVideoEncoderType](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254) encoderType;
  * 设置编码器类型，默认使用 [QNVideoEncoderToolboxH264](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254)

mcuDomains

  * @property (nonatomic, strong) NSArray* mcuDomains;
  * 预设登录服务器域名。当设置 mcuDomain 自定义域名，默认优先访问自定义域名，自定义域名访问异常时，内部会自动会切到默认域名进行访

Core Methods

defaultConfiguration

  * \+ (instancetype)defaultConfiguration;
  * 使用默认 UDP 的媒体流连接方式，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

initWithPolicy[1/6]

  * \- (instancetype)initWithPolicy:([QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))policy;
  * 指定媒体流的连接方式，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

initWithPolicy[2/6]

  * \- (instancetype)initWithPolicy:([QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))policy maintainResolutionEnabled:(BOOL)maintainResolutionEnabled;
  * 指定媒体流的连接方式、是否开关固定分辨率，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

> 该接口已废弃，请使用
> [QNVideoEncoderConfig.initWithBitrate[4/4]](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
> iOS/11944)

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

initWithPolicy[3/6]

  * \- (instancetype)initWithPolicy:([QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))policy maintainResolutionEnabled:(BOOL)maintainResolutionEnabled communicationModeOn:(BOOL)communicationModeOn;
  * 指定媒体流的连接方式、是否开关固定分辨率、是否使用通话模式，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

> 该接口已废弃，请使用
> QNVideoEncoderConfig.initWithBitrate[4/4]、[QNRTCConfiguration.initWithPolicy[4/4]](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
> iOS/8838)

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

initWithPolicy[4/6]

  * \- (instancetype)initWithPolicy:([QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))policy audioScene:([QNAudioScene](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))audioScene;
  * 用指定的 policy 、audioScene，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

initWithPolicy[5/6]

  * \- (instancetype)initWithPolicy:([QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))policy audioScene:([QNAudioScene](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))audioScene reconnectionTimeout:(int)reconnectionTimeout;
  * 用指定的 policy 、audioScene，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

initWithPolicy[6/6]

  * \- (instancetype)initWithPolicy:([QNRTCPolicy](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))policy audioScene:(QNAudioScene)audioScene reconnectionTimeout:(int)reconnectionTimeout encoderType:([QNVideoEncoderType](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/9254))encoderType;
  * 用指定的 policy 、audioScene、reconnectionTimeout、encoderType，创建 [QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-iOS/8838/QNRTCConfiguration-iOS) 对象

Returns
[QNRTCConfiguration](https://developer.qiniu.com/rtc/8838/QNRTCConfiguration-
iOS/8838/QNRTCConfiguration-iOS)

以上内容是否对您有帮助？