mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
convert CallActivity to kotlin
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
b5529f869a
commit
a941945400
@ -141,7 +141,6 @@ import com.nextcloud.talk.webrtc.PeerConnectionWrapper
|
|||||||
import com.nextcloud.talk.webrtc.PeerConnectionWrapper.PeerConnectionObserver
|
import com.nextcloud.talk.webrtc.PeerConnectionWrapper.PeerConnectionObserver
|
||||||
import com.nextcloud.talk.webrtc.WebRtcAudioManager
|
import com.nextcloud.talk.webrtc.WebRtcAudioManager
|
||||||
import com.nextcloud.talk.webrtc.WebRtcAudioManager.AudioDevice
|
import com.nextcloud.talk.webrtc.WebRtcAudioManager.AudioDevice
|
||||||
import com.nextcloud.talk.webrtc.WebRtcAudioManager.AudioManagerListener
|
|
||||||
import com.nextcloud.talk.webrtc.WebSocketConnectionHelper
|
import com.nextcloud.talk.webrtc.WebSocketConnectionHelper
|
||||||
import com.nextcloud.talk.webrtc.WebSocketInstance
|
import com.nextcloud.talk.webrtc.WebSocketInstance
|
||||||
import com.wooplr.spotlight.SpotlightView
|
import com.wooplr.spotlight.SpotlightView
|
||||||
@ -183,6 +182,7 @@ import javax.inject.Inject
|
|||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication::class)
|
@AutoInjector(NextcloudTalkApplication::class)
|
||||||
|
@Suppress("TooManyFunctions")
|
||||||
class CallActivity : CallBaseActivity() {
|
class CallActivity : CallBaseActivity() {
|
||||||
@JvmField
|
@JvmField
|
||||||
@Inject
|
@Inject
|
||||||
@ -348,7 +348,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!rationaleList.isEmpty()) {
|
if (rationaleList.isNotEmpty()) {
|
||||||
showRationaleDialogForSettings(rationaleList)
|
showRationaleDialogForSettings(rationaleList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,7 +404,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
binding!!.lowerHandButton.visibility = View.GONE
|
binding!!.lowerHandButton.visibility = View.GONE
|
||||||
raised = false
|
raised = false
|
||||||
}
|
}
|
||||||
if (isConnectionEstablished && peerConnectionWrapperList != null) {
|
if (isConnectionEstablished) {
|
||||||
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
||||||
peerConnectionWrapper.raiseHand(raised)
|
peerConnectionWrapper.raiseHand(raised)
|
||||||
}
|
}
|
||||||
@ -436,12 +436,12 @@ class CallActivity : CallBaseActivity() {
|
|||||||
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(R.string.record_stop_confirm_title)
|
.setTitle(R.string.record_stop_confirm_title)
|
||||||
.setMessage(R.string.record_stop_confirm_message)
|
.setMessage(R.string.record_stop_confirm_message)
|
||||||
.setPositiveButton(
|
.setPositiveButton(R.string.record_stop_description) { _: DialogInterface?, _: Int ->
|
||||||
R.string.record_stop_description
|
callRecordingViewModel!!.stopRecording()
|
||||||
) { dialog: DialogInterface?, which: Int -> callRecordingViewModel!!.stopRecording() }
|
}
|
||||||
.setNegativeButton(
|
.setNegativeButton(R.string.nc_common_dismiss) { _: DialogInterface?, _: Int ->
|
||||||
R.string.nc_common_dismiss
|
callRecordingViewModel!!.dismissStopRecording()
|
||||||
) { dialog: DialogInterface?, which: Int -> callRecordingViewModel!!.dismissStopRecording() }
|
}
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, dialogBuilder)
|
||||||
val dialog = dialogBuilder.show()
|
val dialog = dialogBuilder.show()
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
viewThemeUtils.platform.colorTextButtons(
|
||||||
@ -483,7 +483,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
|
|
||||||
fun sendReaction(emoji: String?) {
|
fun sendReaction(emoji: String?) {
|
||||||
addReactionForAnimation(emoji, conversationUser!!.displayName)
|
addReactionForAnimation(emoji, conversationUser!!.displayName)
|
||||||
if (isConnectionEstablished && peerConnectionWrapperList != null) {
|
if (isConnectionEstablished) {
|
||||||
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
||||||
peerConnectionWrapper.sendReaction(emoji)
|
peerConnectionWrapper.sendReaction(emoji)
|
||||||
}
|
}
|
||||||
@ -521,18 +521,21 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initClickListeners() {
|
private fun initClickListeners() {
|
||||||
binding!!.pictureInPictureButton.setOnClickListener { l: View? -> enterPipMode() }
|
binding!!.pictureInPictureButton.setOnClickListener { enterPipMode() }
|
||||||
binding!!.audioOutputButton.setOnClickListener { v: View? ->
|
|
||||||
|
binding!!.audioOutputButton.setOnClickListener {
|
||||||
audioOutputDialog = AudioOutputDialog(this)
|
audioOutputDialog = AudioOutputDialog(this)
|
||||||
audioOutputDialog!!.show()
|
audioOutputDialog!!.show()
|
||||||
}
|
}
|
||||||
binding!!.moreCallActions.setOnClickListener { v: View? ->
|
|
||||||
|
binding!!.moreCallActions.setOnClickListener {
|
||||||
moreCallActionsDialog = MoreCallActionsDialog(this)
|
moreCallActionsDialog = MoreCallActionsDialog(this)
|
||||||
moreCallActionsDialog!!.show()
|
moreCallActionsDialog!!.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canPublishAudioStream) {
|
if (canPublishAudioStream) {
|
||||||
binding!!.microphoneButton.setOnClickListener { l: View? -> onMicrophoneClick() }
|
binding!!.microphoneButton.setOnClickListener { onMicrophoneClick() }
|
||||||
binding!!.microphoneButton.setOnLongClickListener { l: View? ->
|
binding!!.microphoneButton.setOnLongClickListener {
|
||||||
if (!microphoneOn) {
|
if (!microphoneOn) {
|
||||||
callControlHandler.removeCallbacksAndMessages(null)
|
callControlHandler.removeCallbacksAndMessages(null)
|
||||||
callInfosHandler.removeCallbacksAndMessages(null)
|
callInfosHandler.removeCallbacksAndMessages(null)
|
||||||
@ -547,7 +550,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding!!.microphoneButton.setOnClickListener { l: View? ->
|
binding!!.microphoneButton.setOnClickListener {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
context,
|
context,
|
||||||
R.string.nc_not_allowed_to_activate_audio,
|
R.string.nc_not_allowed_to_activate_audio,
|
||||||
@ -555,10 +558,11 @@ class CallActivity : CallBaseActivity() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canPublishVideoStream) {
|
if (canPublishVideoStream) {
|
||||||
binding!!.cameraButton.setOnClickListener { l: View? -> onCameraClick() }
|
binding!!.cameraButton.setOnClickListener { onCameraClick() }
|
||||||
} else {
|
} else {
|
||||||
binding!!.cameraButton.setOnClickListener { l: View? ->
|
binding!!.cameraButton.setOnClickListener {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
context,
|
context,
|
||||||
R.string.nc_not_allowed_to_activate_video,
|
R.string.nc_not_allowed_to_activate_video,
|
||||||
@ -566,22 +570,22 @@ class CallActivity : CallBaseActivity() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding!!.hangupButton.setOnClickListener { l: View? -> hangup(true) }
|
binding!!.hangupButton.setOnClickListener { hangup(true) }
|
||||||
binding!!.switchSelfVideoButton.setOnClickListener { l: View? -> switchCamera() }
|
binding!!.switchSelfVideoButton.setOnClickListener { switchCamera() }
|
||||||
binding!!.gridview.onItemClickListener =
|
binding!!.gridview.onItemClickListener =
|
||||||
AdapterView.OnItemClickListener { parent: AdapterView<*>?, view: View?, position: Int, id: Long ->
|
AdapterView.OnItemClickListener { _: AdapterView<*>?, _: View?, _: Int, _: Long ->
|
||||||
animateCallControls(
|
animateCallControls(
|
||||||
true,
|
true,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
binding!!.callStates.callStateRelativeLayout.setOnClickListener { l: View? ->
|
binding!!.callStates.callStateRelativeLayout.setOnClickListener {
|
||||||
if (currentCallStatus === CallStatus.CALLING_TIMEOUT) {
|
if (currentCallStatus === CallStatus.CALLING_TIMEOUT) {
|
||||||
setCallState(CallStatus.RECONNECTING)
|
setCallState(CallStatus.RECONNECTING)
|
||||||
hangupNetworkCalls(false)
|
hangupNetworkCalls(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding!!.callRecordingIndicator.setOnClickListener { l: View? ->
|
binding!!.callRecordingIndicator.setOnClickListener {
|
||||||
if (isAllowedToStartOrStopRecording) {
|
if (isAllowedToStartOrStopRecording) {
|
||||||
if (callRecordingViewModel!!.viewState.value is RecordingStartingState) {
|
if (callRecordingViewModel!!.viewState.value is RecordingStartingState) {
|
||||||
if (moreCallActionsDialog == null) {
|
if (moreCallActionsDialog == null) {
|
||||||
@ -644,14 +648,12 @@ class CallActivity : CallBaseActivity() {
|
|||||||
// Store existing audio settings and change audio mode to
|
// Store existing audio settings and change audio mode to
|
||||||
// MODE_IN_COMMUNICATION for best possible VoIP performance.
|
// MODE_IN_COMMUNICATION for best possible VoIP performance.
|
||||||
Log.d(TAG, "Starting the audio manager...")
|
Log.d(TAG, "Starting the audio manager...")
|
||||||
audioManager!!.start(
|
audioManager!!.start { currentDevice: AudioDevice, availableDevices: Set<AudioDevice> ->
|
||||||
AudioManagerListener { currentDevice: AudioDevice, availableDevices: Set<AudioDevice> ->
|
|
||||||
onAudioManagerDevicesChanged(
|
onAudioManagerDevicesChanged(
|
||||||
currentDevice,
|
currentDevice,
|
||||||
availableDevices
|
availableDevices
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
if (isVoiceOnlyCall) {
|
if (isVoiceOnlyCall) {
|
||||||
setAudioOutputChannel(AudioDevice.EARPIECE)
|
setAudioOutputChannel(AudioDevice.EARPIECE)
|
||||||
} else {
|
} else {
|
||||||
@ -776,14 +778,14 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
initSelfVideoView()
|
initSelfVideoView()
|
||||||
}
|
}
|
||||||
binding!!.gridview.setOnTouchListener { v, me ->
|
binding!!.gridview.setOnTouchListener { _, me ->
|
||||||
val action = me.actionMasked
|
val action = me.actionMasked
|
||||||
if (action == MotionEvent.ACTION_DOWN) {
|
if (action == MotionEvent.ACTION_DOWN) {
|
||||||
animateCallControls(true, 0)
|
animateCallControls(true, 0)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
binding!!.conversationRelativeLayout.setOnTouchListener { v, me ->
|
binding!!.conversationRelativeLayout.setOnTouchListener { _, me ->
|
||||||
val action = me.actionMasked
|
val action = me.actionMasked
|
||||||
if (action == MotionEvent.ACTION_DOWN) {
|
if (action == MotionEvent.ACTION_DOWN) {
|
||||||
animateCallControls(true, 0)
|
animateCallControls(true, 0)
|
||||||
@ -881,7 +883,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
if (!videoOn) {
|
if (!videoOn) {
|
||||||
onCameraClick()
|
onCameraClick()
|
||||||
}
|
}
|
||||||
if (cameraEnumerator!!.deviceNames.size == 0) {
|
if (cameraEnumerator!!.deviceNames.isEmpty()) {
|
||||||
binding!!.cameraButton.visibility = View.GONE
|
binding!!.cameraButton.visibility = View.GONE
|
||||||
}
|
}
|
||||||
if (cameraEnumerator!!.deviceNames.size > 1) {
|
if (cameraEnumerator!!.deviceNames.size > 1) {
|
||||||
@ -904,8 +906,8 @@ class CallActivity : CallBaseActivity() {
|
|||||||
permissionsToRequest.add(Manifest.permission.BLUETOOTH_CONNECT)
|
permissionsToRequest.add(Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!permissionsToRequest.isEmpty()) {
|
if (permissionsToRequest.isNotEmpty()) {
|
||||||
if (!rationaleList.isEmpty()) {
|
if (rationaleList.isNotEmpty()) {
|
||||||
showRationaleDialog(permissionsToRequest, rationaleList)
|
showRationaleDialog(permissionsToRequest, rationaleList)
|
||||||
} else {
|
} else {
|
||||||
requestPermissionLauncher.launch(permissionsToRequest.toTypedArray())
|
requestPermissionLauncher.launch(permissionsToRequest.toTypedArray())
|
||||||
@ -932,12 +934,8 @@ class CallActivity : CallBaseActivity() {
|
|||||||
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(R.string.nc_permissions_rationale_dialog_title)
|
.setTitle(R.string.nc_permissions_rationale_dialog_title)
|
||||||
.setMessage(rationalesWithLineBreaks)
|
.setMessage(rationalesWithLineBreaks)
|
||||||
.setPositiveButton(
|
.setPositiveButton(R.string.nc_permissions_ask) { _, _ ->
|
||||||
R.string.nc_permissions_ask
|
requestPermissionLauncher.launch(permissionsToRequest.toTypedArray())
|
||||||
) { dialog: DialogInterface?, which: Int ->
|
|
||||||
requestPermissionLauncher.launch(
|
|
||||||
permissionsToRequest.toTypedArray()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
.setNegativeButton(R.string.nc_common_dismiss, null)
|
.setNegativeButton(R.string.nc_common_dismiss, null)
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, dialogBuilder)
|
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, dialogBuilder)
|
||||||
@ -956,7 +954,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
val dialogBuilder = MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(R.string.nc_permissions_rationale_dialog_title)
|
.setTitle(R.string.nc_permissions_rationale_dialog_title)
|
||||||
.setMessage(rationalesWithLineBreaks)
|
.setMessage(rationalesWithLineBreaks)
|
||||||
.setPositiveButton(R.string.nc_permissions_settings) { dialog: DialogInterface?, which: Int ->
|
.setPositiveButton(R.string.nc_permissions_settings) { _, _ ->
|
||||||
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||||
intent.data = Uri.fromParts("package", packageName, null)
|
intent.data = Uri.fromParts("package", packageName, null)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
@ -973,11 +971,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
currentDevice: AudioDevice,
|
currentDevice: AudioDevice,
|
||||||
availableDevices: Set<AudioDevice>
|
availableDevices: Set<AudioDevice>
|
||||||
) {
|
) {
|
||||||
Log.d(
|
Log.d(TAG, "onAudioManagerDevicesChanged: $availableDevices, currentDevice: $currentDevice")
|
||||||
TAG,
|
|
||||||
"onAudioManagerDevicesChanged: " + availableDevices + ", " +
|
|
||||||
"currentDevice: " + currentDevice
|
|
||||||
)
|
|
||||||
val shouldDisableProximityLock =
|
val shouldDisableProximityLock =
|
||||||
currentDevice == AudioDevice.WIRED_HEADSET ||
|
currentDevice == AudioDevice.WIRED_HEADSET ||
|
||||||
currentDevice == AudioDevice.SPEAKER_PHONE ||
|
currentDevice == AudioDevice.SPEAKER_PHONE ||
|
||||||
@ -1065,26 +1059,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
if (permissionUtil!!.isMicrophonePermissionGranted()) {
|
if (permissionUtil!!.isMicrophonePermissionGranted()) {
|
||||||
if (!appPreferences.pushToTalkIntroShown) {
|
if (!appPreferences.pushToTalkIntroShown) {
|
||||||
val primary = viewThemeUtils.getScheme(binding!!.audioOutputButton.context).primary
|
spotlightView = getSpotlightView()
|
||||||
spotlightView = SpotlightView.Builder(this)
|
|
||||||
.introAnimationDuration(300)
|
|
||||||
.enableRevealAnimation(true)
|
|
||||||
.performClick(false)
|
|
||||||
.fadeinTextDuration(400)
|
|
||||||
.headingTvColor(primary)
|
|
||||||
.headingTvSize(20)
|
|
||||||
.headingTvText(resources.getString(R.string.nc_push_to_talk))
|
|
||||||
.subHeadingTvColor(resources.getColor(R.color.bg_default, null))
|
|
||||||
.subHeadingTvSize(16)
|
|
||||||
.subHeadingTvText(resources.getString(R.string.nc_push_to_talk_desc))
|
|
||||||
.maskColor(Color.parseColor("#dc000000"))
|
|
||||||
.target(binding!!.microphoneButton)
|
|
||||||
.lineAnimDuration(400)
|
|
||||||
.lineAndArcColor(primary)
|
|
||||||
.enableDismissAfterShown(true)
|
|
||||||
.dismissOnBackPress(true)
|
|
||||||
.usageId("pushToTalk")
|
|
||||||
.show()
|
|
||||||
appPreferences.pushToTalkIntroShown = true
|
appPreferences.pushToTalkIntroShown = true
|
||||||
}
|
}
|
||||||
if (!isPushToTalkActive) {
|
if (!isPushToTalkActive) {
|
||||||
@ -1120,7 +1095,30 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onCameraClick() {
|
private fun getSpotlightView(): SpotlightView? {
|
||||||
|
val primary = viewThemeUtils.getScheme(binding!!.audioOutputButton.context).primary
|
||||||
|
return SpotlightView.Builder(this)
|
||||||
|
.introAnimationDuration(300)
|
||||||
|
.enableRevealAnimation(true)
|
||||||
|
.performClick(false)
|
||||||
|
.fadeinTextDuration(400)
|
||||||
|
.headingTvColor(primary)
|
||||||
|
.headingTvSize(20)
|
||||||
|
.headingTvText(resources.getString(R.string.nc_push_to_talk))
|
||||||
|
.subHeadingTvColor(resources.getColor(R.color.bg_default, null))
|
||||||
|
.subHeadingTvSize(16)
|
||||||
|
.subHeadingTvText(resources.getString(R.string.nc_push_to_talk_desc))
|
||||||
|
.maskColor(Color.parseColor("#dc000000"))
|
||||||
|
.target(binding!!.microphoneButton)
|
||||||
|
.lineAnimDuration(400)
|
||||||
|
.lineAndArcColor(primary)
|
||||||
|
.enableDismissAfterShown(true)
|
||||||
|
.dismissOnBackPress(true)
|
||||||
|
.usageId("pushToTalk")
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onCameraClick() {
|
||||||
if (!canPublishVideoStream) {
|
if (!canPublishVideoStream) {
|
||||||
videoOn = false
|
videoOn = false
|
||||||
binding!!.cameraButton.setImageResource(R.drawable.ic_videocam_off_white_24px)
|
binding!!.cameraButton.setImageResource(R.drawable.ic_videocam_off_white_24px)
|
||||||
@ -1156,7 +1154,9 @@ class CallActivity : CallBaseActivity() {
|
|||||||
binding!!.selfVideoRenderer.setMirror(currentCameraIsFront)
|
binding!!.selfVideoRenderer.setMirror(currentCameraIsFront)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCameraSwitchError(s: String) {}
|
override fun onCameraSwitchError(s: String) {
|
||||||
|
Log.e(TAG, "Error while switching camera: $s")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1198,7 +1198,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
localStream!!.audioTracks[0].setEnabled(enable)
|
localStream!!.audioTracks[0].setEnabled(enable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isConnectionEstablished && peerConnectionWrapperList != null) {
|
if (isConnectionEstablished) {
|
||||||
if (!hasMCU) {
|
if (!hasMCU) {
|
||||||
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
||||||
peerConnectionWrapper.sendChannelData(DataChannelMessage(message))
|
peerConnectionWrapper.sendChannelData(DataChannelMessage(message))
|
||||||
@ -1348,12 +1348,8 @@ class CallActivity : CallBaseActivity() {
|
|||||||
signalingSettingsOverall.ocs!!.settings != null
|
signalingSettingsOverall.ocs!!.settings != null
|
||||||
) {
|
) {
|
||||||
externalSignalingServer = ExternalSignalingServer()
|
externalSignalingServer = ExternalSignalingServer()
|
||||||
if (!TextUtils.isEmpty(
|
if (!TextUtils.isEmpty(signalingSettingsOverall.ocs!!.settings!!.externalSignalingServer) &&
|
||||||
signalingSettingsOverall.ocs!!.settings!!.externalSignalingServer
|
!TextUtils.isEmpty(signalingSettingsOverall.ocs!!.settings!!.externalSignalingTicket)
|
||||||
) &&
|
|
||||||
!TextUtils.isEmpty(
|
|
||||||
signalingSettingsOverall.ocs!!.settings!!.externalSignalingTicket
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
externalSignalingServer = ExternalSignalingServer()
|
externalSignalingServer = ExternalSignalingServer()
|
||||||
externalSignalingServer!!.externalSignalingServer =
|
externalSignalingServer!!.externalSignalingServer =
|
||||||
@ -1365,6 +1361,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
hasExternalSignalingServer = false
|
hasExternalSignalingServer = false
|
||||||
}
|
}
|
||||||
Log.d(TAG, " hasExternalSignalingServer: $hasExternalSignalingServer")
|
Log.d(TAG, " hasExternalSignalingServer: $hasExternalSignalingServer")
|
||||||
|
|
||||||
if ("?" != conversationUser!!.userId && conversationUser!!.id != null) {
|
if ("?" != conversationUser!!.userId && conversationUser!!.id != null) {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
@ -1380,6 +1377,26 @@ class CallActivity : CallBaseActivity() {
|
|||||||
} else {
|
} else {
|
||||||
conversationUser!!.externalSignalingServer = externalSignalingServer
|
conversationUser!!.externalSignalingServer = externalSignalingServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addIceServers(signalingSettingsOverall, apiVersion)
|
||||||
|
}
|
||||||
|
checkCapabilities()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
Log.e(TAG, e.message, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addIceServers(
|
||||||
|
signalingSettingsOverall: SignalingSettingsOverall,
|
||||||
|
apiVersion: Int
|
||||||
|
) {
|
||||||
if (signalingSettingsOverall.ocs!!.settings!!.stunServers != null) {
|
if (signalingSettingsOverall.ocs!!.settings!!.stunServers != null) {
|
||||||
val stunServers = signalingSettingsOverall.ocs!!.settings!!.stunServers
|
val stunServers = signalingSettingsOverall.ocs!!.settings!!.stunServers
|
||||||
if (apiVersion == ApiUtils.APIv3) {
|
if (apiVersion == ApiUtils.APIv3) {
|
||||||
@ -1400,36 +1417,19 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signalingSettingsOverall.ocs!!.settings!!.turnServers != null) {
|
if (signalingSettingsOverall.ocs!!.settings!!.turnServers != null) {
|
||||||
val turnServers = signalingSettingsOverall.ocs!!.settings!!.turnServers
|
val turnServers = signalingSettingsOverall.ocs!!.settings!!.turnServers
|
||||||
for ((_, urls, username, credential) in turnServers!!) {
|
for ((_, urls, username, credential) in turnServers!!) {
|
||||||
if (urls != null) {
|
if (urls != null) {
|
||||||
for (url in urls) {
|
for (url in urls) {
|
||||||
Log.d(TAG, " TURN server url: $url")
|
Log.d(TAG, " TURN server url: $url")
|
||||||
iceServers!!.add(
|
iceServers!!.add(PeerConnection.IceServer(url, username, credential))
|
||||||
PeerConnection.IceServer(
|
|
||||||
url,
|
|
||||||
username,
|
|
||||||
credential
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkCapabilities()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
Log.e(TAG, e.message, e)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkCapabilities() {
|
private fun checkCapabilities() {
|
||||||
ncApi!!.getCapabilities(credentials, ApiUtils.getUrlForCapabilities(baseUrl))
|
ncApi!!.getCapabilities(credentials, ApiUtils.getUrlForCapabilities(baseUrl))
|
||||||
@ -1527,6 +1527,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
callParticipantList = CallParticipantList(signalingMessageReceiver)
|
callParticipantList = CallParticipantList(signalingMessageReceiver)
|
||||||
callParticipantList!!.addObserver(callParticipantListObserver)
|
callParticipantList!!.addObserver(callParticipantListObserver)
|
||||||
|
|
||||||
val apiVersion = ApiUtils.getCallApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
val apiVersion = ApiUtils.getCallApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||||
ncApi!!.joinCall(
|
ncApi!!.joinCall(
|
||||||
credentials,
|
credentials,
|
||||||
@ -1557,9 +1558,25 @@ class CallActivity : CallBaseActivity() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (!hasExternalSignalingServer) {
|
if (!hasExternalSignalingServer) {
|
||||||
val signalingApiVersion =
|
pullSignalingMessages()
|
||||||
ApiUtils.getSignalingApiVersion(conversationUser, intArrayOf(ApiUtils.APIv3, 2, 1))
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onError(e: Throwable) {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onComplete() {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun pullSignalingMessages() {
|
||||||
|
val signalingApiVersion = ApiUtils.getSignalingApiVersion(conversationUser, intArrayOf(ApiUtils.APIv3, 2, 1))
|
||||||
val delayOnError = AtomicInteger(0)
|
val delayOnError = AtomicInteger(0)
|
||||||
|
|
||||||
ncApi!!.pullSignalingMessages(
|
ncApi!!.pullSignalingMessages(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForSignaling(
|
ApiUtils.getUrlForSignaling(
|
||||||
@ -1574,8 +1591,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
.takeWhile { isConnectionEstablished }
|
.takeWhile { isConnectionEstablished }
|
||||||
.doOnNext { delayOnError.set(0) }
|
.doOnNext { delayOnError.set(0) }
|
||||||
.retryWhen { errors: Observable<Throwable?> ->
|
.retryWhen { errors: Observable<Throwable?> ->
|
||||||
errors
|
errors.flatMap { error: Throwable? ->
|
||||||
.flatMap { error: Throwable? ->
|
|
||||||
if (!isConnectionEstablished) {
|
if (!isConnectionEstablished) {
|
||||||
return@flatMap Observable.error<Long>(error)
|
return@flatMap Observable.error<Long>(error)
|
||||||
}
|
}
|
||||||
@ -1592,9 +1608,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
signalingDisposable = d
|
signalingDisposable = d
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(
|
override fun onNext(signalingOverall: SignalingOverall) {
|
||||||
signalingOverall: SignalingOverall
|
|
||||||
) {
|
|
||||||
receivedSignalingMessages(signalingOverall.ocs!!.signalings)
|
receivedSignalingMessages(signalingOverall.ocs!!.signalings)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1607,18 +1621,6 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onComplete() {
|
|
||||||
// unused atm
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupAndInitiateWebSocketsConnection() {
|
private fun setupAndInitiateWebSocketsConnection() {
|
||||||
if (webSocketConnectionHelper == null) {
|
if (webSocketConnectionHelper == null) {
|
||||||
@ -1722,15 +1724,20 @@ class CallActivity : CallBaseActivity() {
|
|||||||
if (!isConnectionEstablished && currentCallStatus !== CallStatus.CONNECTING) {
|
if (!isConnectionEstablished && currentCallStatus !== CallStatus.CONNECTING) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ("usersInRoom" == messageType) {
|
|
||||||
|
when (messageType) {
|
||||||
|
"usersInRoom" ->
|
||||||
internalSignalingMessageReceiver.process(signaling.messageWrapper as List<Map<String?, Any?>?>?)
|
internalSignalingMessageReceiver.process(signaling.messageWrapper as List<Map<String?, Any?>?>?)
|
||||||
} else if ("message" == messageType) {
|
|
||||||
|
"message" -> {
|
||||||
val ncSignalingMessage = LoganSquare.parse(
|
val ncSignalingMessage = LoganSquare.parse(
|
||||||
signaling.messageWrapper.toString(),
|
signaling.messageWrapper.toString(),
|
||||||
NCSignalingMessage::class.java
|
NCSignalingMessage::class.java
|
||||||
)
|
)
|
||||||
internalSignalingMessageReceiver.process(ncSignalingMessage)
|
internalSignalingMessageReceiver.process(ncSignalingMessage)
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
else ->
|
||||||
Log.e(TAG, "unexpected message type when receiving signaling message")
|
Log.e(TAG, "unexpected message type when receiving signaling message")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1742,6 +1749,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
stopCallingSound()
|
stopCallingSound()
|
||||||
dispose(null)
|
dispose(null)
|
||||||
|
|
||||||
if (shutDownView) {
|
if (shutDownView) {
|
||||||
if (videoCapturer != null) {
|
if (videoCapturer != null) {
|
||||||
try {
|
try {
|
||||||
@ -1775,25 +1783,27 @@ class CallActivity : CallBaseActivity() {
|
|||||||
WebSocketConnectionHelper.deleteExternalSignalingInstanceForUserEntity(-1)
|
WebSocketConnectionHelper.deleteExternalSignalingInstanceForUserEntity(-1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val peerConnectionIdsToEnd: MutableList<String> = ArrayList(
|
|
||||||
peerConnectionWrapperList!!.size
|
val peerConnectionIdsToEnd: MutableList<String> = ArrayList(peerConnectionWrapperList.size)
|
||||||
)
|
|
||||||
for (wrapper in peerConnectionWrapperList) {
|
for (wrapper in peerConnectionWrapperList) {
|
||||||
peerConnectionIdsToEnd.add(wrapper.sessionId)
|
peerConnectionIdsToEnd.add(wrapper.sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sessionId in peerConnectionIdsToEnd) {
|
for (sessionId in peerConnectionIdsToEnd) {
|
||||||
endPeerConnection(sessionId, "video")
|
endPeerConnection(sessionId, "video")
|
||||||
endPeerConnection(sessionId, "screen")
|
endPeerConnection(sessionId, "screen")
|
||||||
}
|
}
|
||||||
val callParticipantIdsToEnd: MutableList<String> = ArrayList(
|
|
||||||
peerConnectionWrapperList.size
|
val callParticipantIdsToEnd: MutableList<String> = ArrayList(peerConnectionWrapperList.size)
|
||||||
)
|
|
||||||
for (callParticipant in callParticipants.values) {
|
for (callParticipant in callParticipants.values) {
|
||||||
callParticipantIdsToEnd.add(callParticipant!!.callParticipantModel.sessionId)
|
callParticipantIdsToEnd.add(callParticipant!!.callParticipantModel.sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sessionId in callParticipantIdsToEnd) {
|
for (sessionId in callParticipantIdsToEnd) {
|
||||||
removeCallParticipant(sessionId)
|
removeCallParticipant(sessionId)
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().isInCall = false
|
ApplicationWideCurrentRoomHolder.getInstance().isInCall = false
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().isDialing = false
|
ApplicationWideCurrentRoomHolder.getInstance().isDialing = false
|
||||||
hangupNetworkCalls(shutDownView)
|
hangupNetworkCalls(shutDownView)
|
||||||
@ -1851,6 +1861,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Detekt.ComplexMethod")
|
||||||
private fun handleCallParticipantsChanged(
|
private fun handleCallParticipantsChanged(
|
||||||
joined: Collection<Participant>,
|
joined: Collection<Participant>,
|
||||||
updated: Collection<Participant>,
|
updated: Collection<Participant>,
|
||||||
@ -1867,12 +1878,15 @@ class CallActivity : CallBaseActivity() {
|
|||||||
currentSessionId = webSocketClient!!.sessionId
|
currentSessionId = webSocketClient!!.sessionId
|
||||||
}
|
}
|
||||||
Log.d(TAG, " currentSessionId is $currentSessionId")
|
Log.d(TAG, " currentSessionId is $currentSessionId")
|
||||||
|
|
||||||
val participantsInCall: MutableList<Participant> = ArrayList()
|
val participantsInCall: MutableList<Participant> = ArrayList()
|
||||||
participantsInCall.addAll(joined)
|
participantsInCall.addAll(joined)
|
||||||
participantsInCall.addAll(updated)
|
participantsInCall.addAll(updated)
|
||||||
participantsInCall.addAll(unchanged)
|
participantsInCall.addAll(unchanged)
|
||||||
|
|
||||||
var isSelfInCall = false
|
var isSelfInCall = false
|
||||||
var selfParticipant: Participant? = null
|
var selfParticipant: Participant? = null
|
||||||
|
|
||||||
for (participant in participantsInCall) {
|
for (participant in participantsInCall) {
|
||||||
val inCallFlag = participant.inCall
|
val inCallFlag = participant.inCall
|
||||||
if (participant.sessionId != currentSessionId) {
|
if (participant.sessionId != currentSessionId) {
|
||||||
@ -1889,6 +1903,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
selfParticipant = participant
|
selfParticipant = participant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSelfInCall &&
|
if (!isSelfInCall &&
|
||||||
currentCallStatus !== CallStatus.LEAVING &&
|
currentCallStatus !== CallStatus.LEAVING &&
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().isInCall
|
ApplicationWideCurrentRoomHolder.getInstance().isInCall
|
||||||
@ -1897,6 +1912,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
hangup(true)
|
hangup(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSelfInCall) {
|
if (!isSelfInCall) {
|
||||||
Log.d(TAG, "Self not in call, disconnecting from all other sessions")
|
Log.d(TAG, "Self not in call, disconnecting from all other sessions")
|
||||||
for ((_, _, _, _, _, _, _, _, _, _, sessionId) in participantsInCall) {
|
for ((_, _, _, _, _, _, _, _, _, _, sessionId) in participantsInCall) {
|
||||||
@ -1932,19 +1948,22 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
Log.d(TAG, " newSession joined: $sessionId")
|
Log.d(TAG, " newSession joined: $sessionId")
|
||||||
addCallParticipant(sessionId)
|
addCallParticipant(sessionId)
|
||||||
|
|
||||||
val userId = participant.userId
|
val userId = participant.userId
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
callParticipants[sessionId]!!.setUserId(userId)
|
callParticipants[sessionId]!!.setUserId(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (participant.internal != null) {
|
if (participant.internal != null) {
|
||||||
callParticipants[sessionId]!!.setInternal(participant.internal)
|
callParticipants[sessionId]!!.setInternal(participant.internal)
|
||||||
}
|
}
|
||||||
var nick: String?
|
|
||||||
nick = if (hasExternalSignalingServer) {
|
val nick: String? = if (hasExternalSignalingServer) {
|
||||||
webSocketClient!!.getDisplayNameForSession(sessionId)
|
webSocketClient!!.getDisplayNameForSession(sessionId)
|
||||||
} else {
|
} else {
|
||||||
if (offerAnswerNickProviders[sessionId] != null) offerAnswerNickProviders[sessionId]?.nick else ""
|
if (offerAnswerNickProviders[sessionId] != null) offerAnswerNickProviders[sessionId]?.nick else ""
|
||||||
}
|
}
|
||||||
|
|
||||||
callParticipants[sessionId]!!.setNick(nick)
|
callParticipants[sessionId]!!.setNick(nick)
|
||||||
val participantHasAudioOrVideo = participantInCallFlagsHaveAudioOrVideo(participant)
|
val participantHasAudioOrVideo = participantInCallFlagsHaveAudioOrVideo(participant)
|
||||||
|
|
||||||
@ -1952,16 +1971,14 @@ class CallActivity : CallBaseActivity() {
|
|||||||
// remote session ID. However, if the other participant does not have audio nor video that participant
|
// remote session ID. However, if the other participant does not have audio nor video that participant
|
||||||
// will not send an offer, so no connection is actually established when the remote participant has a
|
// will not send an offer, so no connection is actually established when the remote participant has a
|
||||||
// higher session ID but is not publishing media.
|
// higher session ID but is not publishing media.
|
||||||
if (hasMCU && participantHasAudioOrVideo || !hasMCU && selfParticipantHasAudioOrVideo && (
|
if (hasMCU && participantHasAudioOrVideo ||
|
||||||
!participantHasAudioOrVideo || sessionId.compareTo(
|
!hasMCU && selfParticipantHasAudioOrVideo &&
|
||||||
currentSessionId!!
|
(!participantHasAudioOrVideo || sessionId < currentSessionId!!)
|
||||||
) < 0
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
getOrCreatePeerConnectionWrapperForSessionIdAndType(sessionId, VIDEO_STREAM_TYPE_VIDEO, false)
|
getOrCreatePeerConnectionWrapperForSessionIdAndType(sessionId, VIDEO_STREAM_TYPE_VIDEO, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val othersInCall = if (selfJoined) joined.size > 1 else joined.size > 0
|
val othersInCall = if (selfJoined) joined.size > 1 else joined.isNotEmpty()
|
||||||
if (othersInCall && currentCallStatus !== CallStatus.IN_CONVERSATION) {
|
if (othersInCall && currentCallStatus !== CallStatus.IN_CONVERSATION) {
|
||||||
setCallState(CallStatus.IN_CONVERSATION)
|
setCallState(CallStatus.IN_CONVERSATION)
|
||||||
}
|
}
|
||||||
@ -1984,7 +2001,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getPeerConnectionWrapperForSessionIdAndType(sessionId: String?, type: String): PeerConnectionWrapper? {
|
private fun getPeerConnectionWrapperForSessionIdAndType(sessionId: String?, type: String): PeerConnectionWrapper? {
|
||||||
for (wrapper in peerConnectionWrapperList!!) {
|
for (wrapper in peerConnectionWrapperList) {
|
||||||
if (wrapper.sessionId == sessionId && wrapper.videoStreamType == type) {
|
if (wrapper.sessionId == sessionId && wrapper.videoStreamType == type) {
|
||||||
return wrapper
|
return wrapper
|
||||||
}
|
}
|
||||||
@ -2072,7 +2089,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
peerConnectionWrapperList!!.add(peerConnectionWrapper)
|
peerConnectionWrapperList.add(peerConnectionWrapper)
|
||||||
if (!publisher) {
|
if (!publisher) {
|
||||||
var callParticipant = callParticipants[sessionId]
|
var callParticipant = callParticipants[sessionId]
|
||||||
if (callParticipant == null) {
|
if (callParticipant == null) {
|
||||||
@ -2144,7 +2161,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
peerConnectionWrapper.removePeerConnection()
|
peerConnectionWrapper.removePeerConnection()
|
||||||
peerConnectionWrapperList!!.remove(peerConnectionWrapper)
|
peerConnectionWrapperList.remove(peerConnectionWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeCallParticipant(sessionId: String?) {
|
private fun removeCallParticipant(sessionId: String?) {
|
||||||
@ -2202,8 +2219,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
val screenWidthPx = displayMetrics.widthPixels
|
val screenWidthPx = displayMetrics.widthPixels
|
||||||
val screenWidthDp = DisplayUtils.convertPixelToDp(screenWidthPx.toFloat(), applicationContext).toInt()
|
val screenWidthDp = DisplayUtils.convertPixelToDp(screenWidthPx.toFloat(), applicationContext).toInt()
|
||||||
var newXafterRotate = 0f
|
var newXafterRotate = 0f
|
||||||
val newYafterRotate: Float
|
val newYafterRotate: Float = if (binding!!.callInfosLinearLayout.visibility == View.VISIBLE) {
|
||||||
newYafterRotate = if (binding!!.callInfosLinearLayout.visibility == View.VISIBLE) {
|
|
||||||
250f
|
250f
|
||||||
} else {
|
} else {
|
||||||
20f
|
20f
|
||||||
@ -2247,7 +2263,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
nickChangedPayload["userid"] = conversationUser!!.userId!!
|
nickChangedPayload["userid"] = conversationUser!!.userId!!
|
||||||
nickChangedPayload["name"] = conversationUser!!.displayName!!
|
nickChangedPayload["name"] = conversationUser!!.displayName!!
|
||||||
dataChannelMessage.payloadMap = nickChangedPayload.toMap()
|
dataChannelMessage.payloadMap = nickChangedPayload.toMap()
|
||||||
for (peerConnectionWrapper in peerConnectionWrapperList!!) {
|
for (peerConnectionWrapper in peerConnectionWrapperList) {
|
||||||
if (peerConnectionWrapper.isMCUPublisher) {
|
if (peerConnectionWrapper.isMCUPublisher) {
|
||||||
Observable
|
Observable
|
||||||
.interval(1, TimeUnit.SECONDS)
|
.interval(1, TimeUnit.SECONDS)
|
||||||
@ -2455,14 +2471,12 @@ class CallActivity : CallBaseActivity() {
|
|||||||
binding!!.callStates.errorImageView.visibility = View.GONE
|
binding!!.callStates.errorImageView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val descriptionForCallType: String
|
private val descriptionForCallType: String
|
||||||
private get() {
|
get() {
|
||||||
val appName = resources.getString(R.string.nc_app_product_name)
|
val appName = resources.getString(R.string.nc_app_product_name)
|
||||||
return if (isVoiceOnlyCall) {
|
return if (isVoiceOnlyCall) {
|
||||||
String.format(resources.getString(R.string.nc_call_voice), appName)
|
String.format(resources.getString(R.string.nc_call_voice), appName)
|
||||||
@ -2473,14 +2487,10 @@ class CallActivity : CallBaseActivity() {
|
|||||||
|
|
||||||
private fun playCallingSound() {
|
private fun playCallingSound() {
|
||||||
stopCallingSound()
|
stopCallingSound()
|
||||||
val ringtoneUri: Uri?
|
val ringtoneUri: Uri? = if (isIncomingCallFromNotification) {
|
||||||
ringtoneUri = if (isIncomingCallFromNotification) {
|
|
||||||
getCallRingtoneUri(applicationContext, appPreferences)
|
getCallRingtoneUri(applicationContext, appPreferences)
|
||||||
} else {
|
} else {
|
||||||
Uri.parse(
|
Uri.parse("android.resource://" + applicationContext.packageName + "/raw/tr110_1_kap8_3_freiton1")
|
||||||
"android.resource://" + applicationContext.packageName + "/raw" +
|
|
||||||
"/tr110_1_kap8_3_freiton1"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (ringtoneUri != null) {
|
if (ringtoneUri != null) {
|
||||||
mediaPlayer = MediaPlayer()
|
mediaPlayer = MediaPlayer()
|
||||||
@ -2554,8 +2564,13 @@ class CallActivity : CallBaseActivity() {
|
|||||||
onOfferOrAnswer(nick)
|
onOfferOrAnswer(nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCandidate(sdpMid: String, sdpMLineIndex: Int, sdp: String) {}
|
override fun onCandidate(sdpMid: String, sdpMLineIndex: Int, sdp: String) {
|
||||||
override fun onEndOfCandidates() {}
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEndOfCandidates() {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onOfferOrAnswer(nick: String) {
|
private fun onOfferOrAnswer(nick: String) {
|
||||||
@ -2568,16 +2583,28 @@ class CallActivity : CallBaseActivity() {
|
|||||||
|
|
||||||
private inner class CallActivityCallParticipantMessageListener(private val sessionId: String?) :
|
private inner class CallActivityCallParticipantMessageListener(private val sessionId: String?) :
|
||||||
CallParticipantMessageListener {
|
CallParticipantMessageListener {
|
||||||
override fun onRaiseHand(state: Boolean, timestamp: Long) {}
|
override fun onRaiseHand(state: Boolean, timestamp: Long) {
|
||||||
override fun onReaction(reaction: String) {}
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReaction(reaction: String) {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
override fun onUnshareScreen() {
|
override fun onUnshareScreen() {
|
||||||
endPeerConnection(sessionId, "screen")
|
endPeerConnection(sessionId, "screen")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class CallActivitySelfPeerConnectionObserver : PeerConnectionObserver {
|
private inner class CallActivitySelfPeerConnectionObserver : PeerConnectionObserver {
|
||||||
override fun onStreamAdded(mediaStream: MediaStream) {}
|
override fun onStreamAdded(mediaStream: MediaStream) {
|
||||||
override fun onStreamRemoved(mediaStream: MediaStream) {}
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStreamRemoved(mediaStream: MediaStream) {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
|
|
||||||
override fun onIceConnectionStateChanged(iceConnectionState: IceConnectionState) {
|
override fun onIceConnectionStateChanged(iceConnectionState: IceConnectionState) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
updateSelfVideoViewIceConnectionState(iceConnectionState)
|
updateSelfVideoViewIceConnectionState(iceConnectionState)
|
||||||
@ -2604,7 +2631,9 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReaction(reaction: String) {}
|
override fun onReaction(reaction: String) {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class CallParticipantEventDisplayer(private val callParticipantModel: CallParticipantModel) :
|
private inner class CallParticipantEventDisplayer(private val callParticipantModel: CallParticipantModel) :
|
||||||
@ -2640,8 +2669,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
private inner class InternalSignalingMessageSender : SignalingMessageSender {
|
private inner class InternalSignalingMessageSender : SignalingMessageSender {
|
||||||
override fun send(ncSignalingMessage: NCSignalingMessage) {
|
override fun send(ncSignalingMessage: NCSignalingMessage) {
|
||||||
addLocalParticipantNickIfNeeded(ncSignalingMessage)
|
addLocalParticipantNickIfNeeded(ncSignalingMessage)
|
||||||
val serializedNcSignalingMessage: String
|
val serializedNcSignalingMessage: String = try {
|
||||||
serializedNcSignalingMessage = try {
|
|
||||||
LoganSquare.serialize(ncSignalingMessage)
|
LoganSquare.serialize(ncSignalingMessage)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
Log.e(TAG, "Failed to serialize signaling message", e)
|
Log.e(TAG, "Failed to serialize signaling message", e)
|
||||||
@ -2686,7 +2714,9 @@ class CallActivity : CallBaseActivity() {
|
|||||||
Log.e(TAG, "", e)
|
Log.e(TAG, "", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {}
|
override fun onComplete() {
|
||||||
|
// unused atm
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2772,7 +2802,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updatePictureInPictureActions(
|
private fun updatePictureInPictureActions(
|
||||||
@DrawableRes iconId: Int,
|
@DrawableRes iconId: Int,
|
||||||
title: String?,
|
title: String?,
|
||||||
requestCode: Int
|
requestCode: Int
|
||||||
@ -2780,8 +2810,7 @@ class CallActivity : CallBaseActivity() {
|
|||||||
if (isGreaterEqualOreo && isPipModePossible) {
|
if (isGreaterEqualOreo && isPipModePossible) {
|
||||||
val actions = ArrayList<RemoteAction>()
|
val actions = ArrayList<RemoteAction>()
|
||||||
val icon = Icon.createWithResource(this, iconId)
|
val icon = Icon.createWithResource(this, iconId)
|
||||||
val intentFlag: Int
|
val intentFlag: Int = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
intentFlag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_IMMUTABLE
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
@ -2869,7 +2898,8 @@ class CallActivity : CallBaseActivity() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var active = false
|
var active = false
|
||||||
const val VIDEO_STREAM_TYPE_SCREEN = "screen"
|
|
||||||
|
// const val VIDEO_STREAM_TYPE_SCREEN = "screen"
|
||||||
const val VIDEO_STREAM_TYPE_VIDEO = "video"
|
const val VIDEO_STREAM_TYPE_VIDEO = "video"
|
||||||
const val TAG = "CallActivity"
|
const val TAG = "CallActivity"
|
||||||
private val PERMISSIONS_CAMERA = arrayOf(
|
private val PERMISSIONS_CAMERA = arrayOf(
|
||||||
|
Loading…
Reference in New Issue
Block a user