mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-28 05:59:05 +03:00
create fallback turn server option
This commit is contained in:
parent
948566c625
commit
3bfab87a87
8 changed files with 48 additions and 3 deletions
1
changelog.d/2329.feature
Normal file
1
changelog.d/2329.feature
Normal file
|
@ -0,0 +1 @@
|
|||
Add setting to enable using turn.matrix.org as a fallback measure.
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
<!-- server urls -->
|
||||
<string name="matrix_org_server_url" translatable="false">https://matrix.org</string>
|
||||
<string name="fallback_stun_server_url" translatable="false">turn.matrix.org</string>
|
||||
|
||||
<!-- Rageshake configuration -->
|
||||
<string name="bug_report_url" translatable="false">https://riot.im/bugreports/submit</string>
|
||||
|
|
|
@ -19,6 +19,8 @@ package im.vector.app.features.call.webrtc
|
|||
import android.content.Context
|
||||
import android.hardware.camera2.CameraManager
|
||||
import androidx.core.content.getSystemService
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.services.CallService
|
||||
import im.vector.app.core.utils.PublishDataSource
|
||||
import im.vector.app.core.utils.TextUtils.formatDuration
|
||||
|
@ -35,6 +37,7 @@ import im.vector.app.features.call.utils.awaitSetLocalDescription
|
|||
import im.vector.app.features.call.utils.awaitSetRemoteDescription
|
||||
import im.vector.app.features.call.utils.mapToCallCandidate
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.lib.core.utils.flow.chunk
|
||||
import im.vector.lib.core.utils.timer.CountUpTimer
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -111,7 +114,9 @@ class WebRtcCall(
|
|||
private val sessionProvider: Provider<Session?>,
|
||||
private val peerConnectionFactoryProvider: Provider<PeerConnectionFactory?>,
|
||||
private val onCallBecomeActive: (WebRtcCall) -> Unit,
|
||||
private val onCallEnded: (String, EndCallReason, Boolean) -> Unit
|
||||
private val onCallEnded: (String, EndCallReason, Boolean) -> Unit,
|
||||
private var vectorPreferences: VectorPreferences,
|
||||
private val stringProvider: StringProvider
|
||||
) : MxCall.StateListener {
|
||||
|
||||
interface Listener : MxCall.StateListener {
|
||||
|
@ -295,6 +300,14 @@ class WebRtcCall(
|
|||
)
|
||||
}
|
||||
}
|
||||
if ((turnServerResponse == null || turnServerResponse.uris.isNullOrEmpty()) && vectorPreferences.useFallbackTurnServer()) {
|
||||
add(
|
||||
PeerConnection
|
||||
.IceServer
|
||||
.builder("stun:" + stringProvider.getString(R.string.fallback_stun_server_url))
|
||||
.createIceServer()
|
||||
)
|
||||
}
|
||||
}
|
||||
Timber.tag(loggerTag.value).v("creating peer connection...with iceServers $iceServers ")
|
||||
val rtcConfig = PeerConnection.RTCConfiguration(iceServers).apply {
|
||||
|
|
|
@ -21,6 +21,7 @@ import androidx.lifecycle.DefaultLifecycleObserver
|
|||
import androidx.lifecycle.LifecycleOwner
|
||||
import im.vector.app.ActiveSessionDataSource
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.services.CallService
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.CallEnded
|
||||
|
@ -32,6 +33,7 @@ import im.vector.app.features.call.lookup.CallUserMapper
|
|||
import im.vector.app.features.call.utils.EglUtils
|
||||
import im.vector.app.features.call.vectorCallService
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.push.fcm.FcmHelper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
|
@ -72,7 +74,9 @@ private val loggerTag = LoggerTag("WebRtcCallManager", LoggerTag.VOIP)
|
|||
class WebRtcCallManager @Inject constructor(
|
||||
private val context: Context,
|
||||
private val activeSessionDataSource: ActiveSessionDataSource,
|
||||
private val analyticsTracker: AnalyticsTracker
|
||||
private val analyticsTracker: AnalyticsTracker,
|
||||
private var vectorPreferences: VectorPreferences,
|
||||
private val stringProvider: StringProvider
|
||||
) : CallListener,
|
||||
DefaultLifecycleObserver {
|
||||
|
||||
|
@ -332,7 +336,9 @@ class WebRtcCallManager @Inject constructor(
|
|||
},
|
||||
sessionProvider = { currentSession },
|
||||
onCallBecomeActive = this::onCallActive,
|
||||
onCallEnded = this::onCallEnded
|
||||
onCallEnded = this::onCallEnded,
|
||||
vectorPreferences = vectorPreferences,
|
||||
stringProvider = stringProvider
|
||||
)
|
||||
advertisedCalls.add(mxCall.callId)
|
||||
callsByCallId[mxCall.callId] = webRtcCall
|
||||
|
|
|
@ -138,6 +138,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||
|
||||
// Calls
|
||||
const val SETTINGS_CALL_PREVENT_ACCIDENTAL_CALL_KEY = "SETTINGS_CALL_PREVENT_ACCIDENTAL_CALL_KEY"
|
||||
const val SETTINGS_CALL_USE_FALLBACK_CALL_ASSIST_SERVER_KEY = "SETTINGS_CALL_USE_FALLBACK_CALL_ASSIST_SERVER_KEY"
|
||||
const val SETTINGS_CALL_RINGTONE_USE_RIOT_PREFERENCE_KEY = "SETTINGS_CALL_RINGTONE_USE_RIOT_PREFERENCE_KEY"
|
||||
const val SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY = "SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY"
|
||||
|
||||
|
@ -721,6 +722,13 @@ class VectorPreferences @Inject constructor(private val context: Context) {
|
|||
return defaultPrefs.getBoolean(SETTINGS_CALL_PREVENT_ACCIDENTAL_CALL_KEY, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if turn.matrix should be used during calls as a fallback
|
||||
*/
|
||||
fun useFallbackTurnServer(): Boolean {
|
||||
return defaultPrefs.getBoolean(SETTINGS_CALL_USE_FALLBACK_CALL_ASSIST_SERVER_KEY, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the read receipts should be shown
|
||||
*
|
||||
|
|
|
@ -43,6 +43,9 @@ class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() {
|
|||
private val mCallRingtonePreference by lazy {
|
||||
findPreference<VectorPreference>(VectorPreferences.SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY)!!
|
||||
}
|
||||
private val useDefaultStunPreference by lazy {
|
||||
findPreference<SwitchPreference>(VectorPreferences.SETTINGS_CALL_USE_FALLBACK_CALL_ASSIST_SERVER_KEY)!!
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -56,6 +59,11 @@ class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() {
|
|||
false
|
||||
}
|
||||
|
||||
useDefaultStunPreference.let {
|
||||
val stun = getString(R.string.fallback_stun_server_url)
|
||||
it.summary = getString(R.string.settings_call_ringtone_use_default_stun_summary, stun)
|
||||
}
|
||||
|
||||
mCallRingtonePreference.let {
|
||||
activity?.let { activity -> it.summary = getCallRingtoneName(activity) }
|
||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
|
|
|
@ -548,6 +548,8 @@
|
|||
<string name="settings_call_category">Calls</string>
|
||||
<string name="settings_call_show_confirmation_dialog_title">Prevent accidental call</string>
|
||||
<string name="settings_call_show_confirmation_dialog_summary">Ask for confirmation before starting a call</string>
|
||||
<string name="settings_call_ringtone_use_default_stun_title">Allow fallback call assist server</string>
|
||||
<string name="settings_call_ringtone_use_default_stun_summary">Will use %s as assist when your homeserver does not offer one (your IP address will be seen by the stun server during a call)</string>
|
||||
<!-- Note to translators: the translation MUST contain the string "${app_name}", which will be replaced by the application name -->
|
||||
<string name="settings_call_ringtone_use_app_ringtone">Use default ${app_name} ringtone for incoming calls</string>
|
||||
<string name="settings_call_ringtone_title">Incoming call ringtone</string>
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
android:summary="@string/settings_call_show_confirmation_dialog_summary"
|
||||
android:title="@string/settings_call_show_confirmation_dialog_title" />
|
||||
|
||||
<im.vector.app.core.preference.VectorSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="SETTINGS_CALL_USE_FALLBACK_CALL_ASSIST_SERVER_KEY"
|
||||
android:summary="@string/settings_call_ringtone_use_default_stun_summary"
|
||||
android:title="@string/settings_call_ringtone_use_default_stun_title" />
|
||||
|
||||
<im.vector.app.core.preference.VectorSwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:disableDependentsState="true"
|
||||
|
|
Loading…
Reference in a new issue