Improved how TextureViews are handled in calls & confs
This commit is contained in:
parent
76334e03e6
commit
666a4f1ad0
7 changed files with 41 additions and 29 deletions
|
@ -247,7 +247,7 @@ dependencies {
|
||||||
implementation 'org.linphone:linphone-sdk-android:5.2+'
|
implementation 'org.linphone:linphone-sdk-android:5.2+'
|
||||||
|
|
||||||
// Only enable leak canary prior to release
|
// Only enable leak canary prior to release
|
||||||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
||||||
}
|
}
|
||||||
|
|
||||||
task generateContactsXml(type: Copy) {
|
task generateContactsXml(type: Copy) {
|
||||||
|
|
|
@ -62,8 +62,6 @@ class CallsListFragment : GenericVideoPreviewFragment<VoipCallsListFragmentBindi
|
||||||
|
|
||||||
binding.controlsViewModel = controlsViewModel
|
binding.controlsViewModel = controlsViewModel
|
||||||
|
|
||||||
setupLocalViewPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
|
||||||
|
|
||||||
binding.setCancelClickListener {
|
binding.setCancelClickListener {
|
||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
|
@ -96,6 +94,18 @@ class CallsListFragment : GenericVideoPreviewFragment<VoipCallsListFragmentBindi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
|
||||||
|
setupLocalVideoPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
|
||||||
|
cleanUpLocalVideoPreview(binding.localPreviewVideoSurface)
|
||||||
|
}
|
||||||
|
|
||||||
private fun showCallMenu(anchor: View, callData: CallData) {
|
private fun showCallMenu(anchor: View, callData: CallData) {
|
||||||
val popupView: VoipCallContextMenuBindingImpl = DataBindingUtil.inflate(
|
val popupView: VoipCallContextMenuBindingImpl = DataBindingUtil.inflate(
|
||||||
LayoutInflater.from(requireContext()),
|
LayoutInflater.from(requireContext()),
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.navigation.navGraphViewModels
|
import androidx.navigation.navGraphViewModels
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.voip.ConferenceDisplayMode
|
import org.linphone.activities.voip.ConferenceDisplayMode
|
||||||
import org.linphone.activities.voip.viewmodels.ConferenceViewModel
|
import org.linphone.activities.voip.viewmodels.ConferenceViewModel
|
||||||
|
@ -45,8 +44,6 @@ class ConferenceLayoutFragment : GenericVideoPreviewFragment<VoipConferenceLayou
|
||||||
|
|
||||||
binding.controlsViewModel = controlsViewModel
|
binding.controlsViewModel = controlsViewModel
|
||||||
|
|
||||||
setupLocalViewPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
|
||||||
|
|
||||||
binding.setCancelClickListener {
|
binding.setCancelClickListener {
|
||||||
goBack()
|
goBack()
|
||||||
}
|
}
|
||||||
|
@ -84,7 +81,13 @@ class ConferenceLayoutFragment : GenericVideoPreviewFragment<VoipConferenceLayou
|
||||||
showTooManyParticipantsForMosaicLayoutDialog()
|
showTooManyParticipantsForMosaicLayoutDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
setupLocalVideoPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
|
||||||
|
cleanUpLocalVideoPreview(binding.localPreviewVideoSurface)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showTooManyParticipantsForMosaicLayoutDialog() {
|
private fun showTooManyParticipantsForMosaicLayoutDialog() {
|
||||||
|
|
|
@ -23,7 +23,6 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.navigation.navGraphViewModels
|
import androidx.navigation.navGraphViewModels
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.navigateToAddParticipants
|
import org.linphone.activities.navigateToAddParticipants
|
||||||
import org.linphone.activities.voip.viewmodels.ConferenceViewModel
|
import org.linphone.activities.voip.viewmodels.ConferenceViewModel
|
||||||
|
@ -49,8 +48,6 @@ class ConferenceParticipantsFragment : GenericVideoPreviewFragment<VoipConferenc
|
||||||
|
|
||||||
binding.controlsViewModel = controlsViewModel
|
binding.controlsViewModel = controlsViewModel
|
||||||
|
|
||||||
setupLocalViewPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
|
||||||
|
|
||||||
conferenceViewModel.conferenceExists.observe(
|
conferenceViewModel.conferenceExists.observe(
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) { exists ->
|
) { exists ->
|
||||||
|
@ -90,12 +87,13 @@ class ConferenceParticipantsFragment : GenericVideoPreviewFragment<VoipConferenc
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
skipEvents = false
|
skipEvents = false
|
||||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
setupLocalVideoPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
|
||||||
skipEvents = true
|
skipEvents = true
|
||||||
|
cleanUpLocalVideoPreview(binding.localPreviewVideoSurface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ abstract class GenericVideoPreviewFragment<T : ViewDataBinding> : GenericFragmen
|
||||||
private var switchY: Float = 0f
|
private var switchY: Float = 0f
|
||||||
|
|
||||||
private var switchCameraImageView: ImageView? = null
|
private var switchCameraImageView: ImageView? = null
|
||||||
private lateinit var videoPreviewTextureView: TextureView
|
|
||||||
|
|
||||||
private val previewTouchListener = View.OnTouchListener { view, event ->
|
private val previewTouchListener = View.OnTouchListener { view, event ->
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
|
@ -67,17 +66,13 @@ abstract class GenericVideoPreviewFragment<T : ViewDataBinding> : GenericFragmen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun setupLocalViewPreview(localVideoPreview: TextureView, switchCamera: ImageView?) {
|
protected fun setupLocalVideoPreview(localVideoPreview: TextureView, switchCamera: ImageView?) {
|
||||||
videoPreviewTextureView = localVideoPreview
|
|
||||||
switchCameraImageView = switchCamera
|
switchCameraImageView = switchCamera
|
||||||
videoPreviewTextureView.setOnTouchListener(previewTouchListener)
|
localVideoPreview.setOnTouchListener(previewTouchListener)
|
||||||
|
coreContext.core.nativePreviewWindowId = localVideoPreview
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
protected fun cleanUpLocalVideoPreview(localVideoPreview: TextureView) {
|
||||||
super.onResume()
|
localVideoPreview.setOnTouchListener(null)
|
||||||
|
|
||||||
if (::videoPreviewTextureView.isInitialized) {
|
|
||||||
coreContext.core.nativePreviewWindowId = videoPreviewTextureView
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import android.os.SystemClock
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Chronometer
|
import android.widget.Chronometer
|
||||||
import androidx.navigation.navGraphViewModels
|
import androidx.navigation.navGraphViewModels
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
import org.linphone.activities.navigateToActiveCall
|
import org.linphone.activities.navigateToActiveCall
|
||||||
import org.linphone.activities.voip.viewmodels.CallsViewModel
|
import org.linphone.activities.voip.viewmodels.CallsViewModel
|
||||||
|
@ -46,8 +45,6 @@ class OutgoingCallFragment : GenericVideoPreviewFragment<VoipCallOutgoingFragmen
|
||||||
|
|
||||||
binding.callsViewModel = callsViewModel
|
binding.callsViewModel = callsViewModel
|
||||||
|
|
||||||
setupLocalViewPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
|
||||||
|
|
||||||
callsViewModel.callConnectedEvent.observe(
|
callsViewModel.callConnectedEvent.observe(
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) {
|
) {
|
||||||
|
@ -79,7 +76,7 @@ class OutgoingCallFragment : GenericVideoPreviewFragment<VoipCallOutgoingFragmen
|
||||||
viewLifecycleOwner
|
viewLifecycleOwner
|
||||||
) {
|
) {
|
||||||
if (it) {
|
if (it) {
|
||||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
setupLocalVideoPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,11 +84,17 @@ class OutgoingCallFragment : GenericVideoPreviewFragment<VoipCallOutgoingFragmen
|
||||||
// We don't want the proximity sensor to turn screen OFF in this fragment
|
// We don't want the proximity sensor to turn screen OFF in this fragment
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
controlsViewModel.forceDisableProximitySensor.value = true
|
controlsViewModel.forceDisableProximitySensor.value = true
|
||||||
|
if (controlsViewModel.isOutgoingEarlyMedia.value == true) {
|
||||||
|
setupLocalVideoPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
controlsViewModel.forceDisableProximitySensor.value = false
|
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
|
||||||
|
controlsViewModel.forceDisableProximitySensor.value = false
|
||||||
|
cleanUpLocalVideoPreview(binding.localPreviewVideoSurface)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,6 @@ class SingleCallFragment : GenericVideoPreviewFragment<VoipSingleCallFragmentBin
|
||||||
|
|
||||||
binding.lifecycleOwner = viewLifecycleOwner
|
binding.lifecycleOwner = viewLifecycleOwner
|
||||||
|
|
||||||
setupLocalViewPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
|
||||||
|
|
||||||
binding.controlsViewModel = controlsViewModel
|
binding.controlsViewModel = controlsViewModel
|
||||||
|
|
||||||
binding.callsViewModel = callsViewModel
|
binding.callsViewModel = callsViewModel
|
||||||
|
@ -193,15 +191,20 @@ class SingleCallFragment : GenericVideoPreviewFragment<VoipSingleCallFragmentBin
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
|
||||||
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
coreContext.core.nativeVideoWindowId = binding.remoteVideoSurface
|
||||||
coreContext.core.nativePreviewWindowId = binding.localPreviewVideoSurface
|
setupLocalVideoPreview(binding.localPreviewVideoSurface, binding.switchCamera)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
|
||||||
controlsViewModel.hideExtraButtons(true)
|
controlsViewModel.hideExtraButtons(true)
|
||||||
|
cleanUpLocalVideoPreview(binding.localPreviewVideoSurface)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showCallVideoUpdateDialog(call: Call) {
|
private fun showCallVideoUpdateDialog(call: Call) {
|
||||||
|
|
Loading…
Reference in a new issue