I'm trying to correctly handle screen rotation during WebRTC call on Android. But after first rotation local video translation stopping. After creating (or recreating) activty I am creating SurfaceViewRenderers for local & remote views:
ourView.init(eglBase.eglBaseContext, null)
ourView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
ourView.setZOrderMediaOverlay(true)
ourView.setEnableHardwareScaler(true)
ourView.setMirror(true)
theirView.init(eglBase.eglBaseContext, null)
theirView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
theirView.setEnableHardwareScaler(false)
theirView.setMirror(true)
localVideoSyncer.setTarget(ourView)
remoteVideoSyncer.setTarget(theirView)
After that, if this is a first time when connection must be created, I am initializing peer connection:
iceConnected = false
val dataChannelParameters = CallUtils.createChannelParameters()
peerConnectionParameters = CallUtils.createConnectionParameters(videoWidth, videoHeight, dataChannelParameters)
if(appRTCClient == null) {
appRTCClient = CallUtils.createAppRTCClient(roomId, this, info?.ice ?: emptyList())
}
roomConnectionParameters = CallUtils.createRoomConnectionParameters(info?.address, roomId)
if(peerConnectionClient == null) {
peerConnectionClient = PeerConnectionClient(
applicationContext, eglBase, peerConnectionParameters, this)
}
val options = PeerConnectionFactory.Options()
peerConnectionClient!!.createPeerConnectionFactory(options)
if (appRTCClient == null) {
NetworkLogger.log(TAG,"AppRTC client is not allocated for a call.")
return
}
if(callStartedTimeMs == 0L)
callStartedTimeMs = System.currentTimeMillis()
appRTCClient!!.connectToRoom(roomConnectionParameters!!)
if(audioManager == null)
audioManager = AppRTCAudioManager(applicationContext)
If activity is recreated, PeerConnectionClient is no longer can send video to remote target. I tried to reassign localRender & videoCapturer, but that has no effect. Is it possible to reuse existing connection after activity recreated?