跳转到主要内容

PreOptionScreen

PreOptionScreen 类中包含 ScreenCaptureOptions、VideoPublishOptions 两个属性
ScreenCaptureOptions屏幕采集配置参数
VideoPublishOptions视频流发布配置参数

ScreenCaptureOptions

ScreenCaptureOptions 类主要用于配置频屏幕采集参数,具体参数如下
deviceIdString 类型,设备 id
widthInt 类型,屏幕采集画面宽
heightInt 类型,屏幕采集画面高
maxFpsInt 类型,最大帧率
maxBitrateInt 类型,最大码率

VideoPublishOptions

VideoPublishOptions 类主要用于配置视频流发布参数,具体参数如下
descString 类型,轨道描述
codecCodecType 类型,编码格式
CodecType.unknow:未知
CodecType.H264:h264 格式
CodecType.H265:h265 格式
maxBitrateInt 类型,最大码率
widthInt 类型,发布的画面宽度
heightInt 类型,发布的画面高度
maxFpsInt 类型,最大帧率
propsAny 类型,自定义属性。可空
simulcastsMutableList<VideoPublishOptions> 类型。
+ 目前只有摄像头流存在发布多路流的情况,所以此处用不上这个属性

PublishCustomOptions

PublishCustomOptions 类是用于在发布时对 desc、props 这两个参数做修改
descString 类型,轨道描述。
+ 可空,表示不做修改
propsAny 类型,自定义属性。
+ 可空,表示不做修改
simulcastsMutableList<PublishCustomOptions> 类型。
+ 目前只有摄像头流存在发布多路流的情况,所以此处用不上这个属性

预设值

目前预设值只有一个 PreOptionScreen.def
  • 可以在发布流时通过 PublishCustomOptions 参数对 desc、props 参数做修改
  • 可以通过直接修改 PreOptionScreen.def 获取到的实例的参数值,然后使用。
// 获取默认预设值
val preOpt: PreOptionScreen = PreOptionScreen.def
// 修改采集配置中的最大帧率
preOpt.capture.maxFps = 10
// 修改发布配置中的编码格式
preOpt.publish.codec = CodecType.H264
// 使用修改后的预设值
screenTrack = rtcEngine.getLocalScreenTrack(requireContext(), preOpt)
...
// 创建 publishCustomOptions 实例,其中有对轨道描述和扩展信息进行配置
val publishCustomOptions = PublishCustomOptions(TrackDesc.TRACK_SHARE.value, null, null)
// 在发布时使用 publishCustomOptions 修改轨道描述和扩展信息
rtcEngine.publishLocalVideo(track, publishCustomOptions, null)
```kotlin

### PreOptionScreen.def
配置如下:

```kotlin
val def = PreOptionScreen(
    ScreenCaptureOptions(
        deviceId = "screenCapDef",
        width = 1280,
        height = 720,
        maxFps = 15,
        maxBitrate = 1024*1024
    ),
    VideoPublishOptions(
        desc = TrackDesc.TRACK_SHARE.value,
        codec = CodecType.H264,
        maxBitrate = 1024*1024,
        width = 1280,
        height = 720,
        maxFps = 15,
        props = null,
        simulcasts = null
    )
)