实时音视频 SPARKRTC-本地流对象(LocalStream):setAudioProfile

时间:2024-03-25 20:33:11

setAudioProfile

setAudioProfile(profile: string|RTCAudioProfile): void

功能说明

设置音频流采样率、声道和码率等配置。如果未调用该接口设置,则SDK设置为默认值standard。

请求参数

profile:必选,string类型或RTCAudioProfile类型。 若为string类型,则相关的采样率、声道数、码率如表2所示。 若为RTCAudioProfile类型,则需要根据实际情况进行配置,推荐使用已定义的profile,输入不合法时,默认使用standard。
表2 profile对应的采样率、声道数和码率

profile

采样率(千赫兹/KHZ)

声道数

码率(Kbps)

low

16

1

24

standard

48

1

40

high

48

1

128

RTCAudioProfile类型定义为:{

  • sampleRate:可选,number类型,采样率。
  • channelCount:可选,number类型,音轨数。
  • bitrate:可选,number类型,码率,单位为bps。

}

返回参数

该方法需要在调用initialize之前调用。

需注意码表中单位为kbps,接口传参的单位为bps,实际调用接口时需进行转换。

support.huaweicloud.com/csdk-rtc/rtc_05_0141.html