webrtc-sdk / android

WebRTC pre-compiled library for android.
MIT License
143 stars 22 forks source link

How to turn on the simulcast? #15

Open AkaneAzumi opened 1 year ago

AkaneAzumi commented 1 year ago

Hi, I used your SDK in my code and everything is fine with the push stream. But when I added the simulcast related configuration to the code, there was only one stream when played. Here's my code. Is my configuration incorrect? ` val encodings= mutableListOf() encodings.add(RtpParameters.Encoding("h", true, 1.0)) encodings.add(RtpParameters.Encoding("m", true, 2.0)) encodings.add(RtpParameters.Encoding("l", true, 4.0))

        val init = RtpTransceiver.RtpTransceiverInit(
            RtpTransceiver.RtpTransceiverDirection.SEND_RECV, Collections.emptyList(), encodings
        )

        peerConnection!!.addTransceiver(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO, init)`

`val decoderFactory: VideoDecoderFactory = DefaultVideoDecoderFactory(eglBase!!.eglBaseContext) val encoderFactory: VideoEncoderFactory = DefaultVideoEncoderFactory( eglBase!!.eglBaseContext, true, true )

    val simulcastVideo = SimulcastVideoEncoderFactory(encoderFactory,encoderFactory)

    PeerConnectionFactory.initialize(
        PeerConnectionFactory.InitializationOptions
            .builder(context)
            .createInitializationOptions()
    )
    PeerConnectionFactory.builder()
        .setOptions(PeerConnectionFactory.Options())
        .setAudioDeviceModule(JavaAudioDeviceModule.builder(context).createAudioDeviceModule())
        .setVideoEncoderFactory(simulcastVideo)
        .setVideoDecoderFactory(decoderFactory)
        .createPeerConnectionFactory()`