mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 17:05:39 +03:00
Merge remote-tracking branch 'CicadaCinema/fallback-turn-server' into sc
Change-Id: I07acecb8587ee3bdf6b2eef1e130ffd578739416 Conflicts: vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt vector/src/main/res/xml/vector_settings_voice_video.xml
This commit is contained in:
commit
0cc0a191bc
7 changed files with 50 additions and 3 deletions
|
@ -229,4 +229,9 @@
|
|||
|
||||
<string name="action_send_as_sticker">Send as sticker</string>
|
||||
|
||||
<!-- SC-TMP, until merged upstream: https://github.com/vector-im/element-android/pull/5781 -->
|
||||
<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>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -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://rageshake.schildi.chat/api/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.CallAndroidService
|
||||
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
|
||||
|
@ -114,7 +117,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 {
|
||||
|
@ -299,6 +304,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.core.pushers.UnifiedPushHelper
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.services.CallAndroidService
|
||||
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 kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
|
@ -74,6 +76,8 @@ class WebRtcCallManager @Inject constructor(
|
|||
private val analyticsTracker: AnalyticsTracker,
|
||||
private val unifiedPushHelper: UnifiedPushHelper,
|
||||
private val voipConfig: VoipConfig,
|
||||
private var vectorPreferences: VectorPreferences,
|
||||
private val stringProvider: StringProvider,
|
||||
) : CallListener,
|
||||
DefaultLifecycleObserver {
|
||||
|
||||
|
@ -336,7 +340,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
|
||||
|
|
|
@ -176,6 +176,7 @@ class VectorPreferences @Inject constructor(
|
|||
|
||||
// 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"
|
||||
|
||||
|
@ -859,6 +860,13 @@ class VectorPreferences @Inject constructor(
|
|||
return defaultPrefs.getBoolean(SETTINGS_CALL_PREVENT_ACCIDENTAL_CALL_KEY, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -46,6 +46,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)
|
||||
|
@ -59,6 +62,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 {
|
||||
it.summary = ringtoneUtils.getCallRingtoneName()
|
||||
it.onPreferenceClickListener = Preference.OnPreferenceClickListener {
|
||||
|
|
|
@ -18,6 +18,12 @@
|
|||
android:title="@string/settings_hide_call_buttons"
|
||||
android:summary="@string/settings_hide_call_buttons_summary" />
|
||||
|
||||
<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"
|
||||
|
@ -33,4 +39,4 @@
|
|||
|
||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue