mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-25 11:59:43 +00:00
feat: add relay toggle for answer and offer
This commit is contained in:
@@ -39,6 +39,7 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||||||
|
|
||||||
const val EXTRA_SDP = "WebRtcTestsActivity_EXTRA_SDP"
|
const val EXTRA_SDP = "WebRtcTestsActivity_EXTRA_SDP"
|
||||||
const val EXTRA_ADDRESS = "WebRtcTestsActivity_EXTRA_ADDRESS"
|
const val EXTRA_ADDRESS = "WebRtcTestsActivity_EXTRA_ADDRESS"
|
||||||
|
const val EXTRA_RELAY_USED = "WebRtcTestsActivity_EXTRA_RELAY_USED"
|
||||||
const val EXTRA_SDP_MLINE_INDEXES = "WebRtcTestsActivity_EXTRA_SDP_MLINE_INDEXES"
|
const val EXTRA_SDP_MLINE_INDEXES = "WebRtcTestsActivity_EXTRA_SDP_MLINE_INDEXES"
|
||||||
const val EXTRA_SDP_MIDS = "WebRtcTestsActivity_EXTRA_SDP_MIDS"
|
const val EXTRA_SDP_MIDS = "WebRtcTestsActivity_EXTRA_SDP_MIDS"
|
||||||
|
|
||||||
@@ -87,6 +88,8 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var callAddress: Address
|
private lateinit var callAddress: Address
|
||||||
|
private var relayUsed: Boolean = true
|
||||||
|
|
||||||
private val peerConnection by lazy {
|
private val peerConnection by lazy {
|
||||||
// TODO: in a lokinet world, ice servers shouldn't be needed as .loki addresses should suffice to p2p
|
// TODO: in a lokinet world, ice servers shouldn't be needed as .loki addresses should suffice to p2p
|
||||||
val server = PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer()
|
val server = PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer()
|
||||||
@@ -94,7 +97,11 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||||||
val server2 = PeerConnection.IceServer.builder("stun:stun2.l.google.com:19302").createIceServer()
|
val server2 = PeerConnection.IceServer.builder("stun:stun2.l.google.com:19302").createIceServer()
|
||||||
val server3 = PeerConnection.IceServer.builder("stun:stun3.l.google.com:19302").createIceServer()
|
val server3 = PeerConnection.IceServer.builder("stun:stun3.l.google.com:19302").createIceServer()
|
||||||
val server4 = PeerConnection.IceServer.builder("stun:stun4.l.google.com:19302").createIceServer()
|
val server4 = PeerConnection.IceServer.builder("stun:stun4.l.google.com:19302").createIceServer()
|
||||||
val rtcConfig = PeerConnection.RTCConfiguration(listOf(server, server1, server2, server3, server4))
|
val iceServers = mutableListOf(server,server1,server2,server3,server4)
|
||||||
|
if (relayUsed) {
|
||||||
|
// add relay server
|
||||||
|
}
|
||||||
|
val rtcConfig = PeerConnection.RTCConfiguration(iceServers)
|
||||||
rtcConfig.keyType = PeerConnection.KeyType.ECDSA
|
rtcConfig.keyType = PeerConnection.KeyType.ECDSA
|
||||||
connectionFactory.createPeerConnection(rtcConfig, this)!!
|
connectionFactory.createPeerConnection(rtcConfig, this)!!
|
||||||
}
|
}
|
||||||
@@ -103,6 +110,8 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||||||
super.onCreate(savedInstanceState, ready)
|
super.onCreate(savedInstanceState, ready)
|
||||||
setContentView(R.layout.activity_webrtc_tests)
|
setContentView(R.layout.activity_webrtc_tests)
|
||||||
|
|
||||||
|
relayUsed = intent.getBooleanExtra(EXTRA_RELAY_USED, true)
|
||||||
|
|
||||||
//TODO: better handling of permissions
|
//TODO: better handling of permissions
|
||||||
Permissions.with(this)
|
Permissions.with(this)
|
||||||
.request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
|
.request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
|
||||||
|
@@ -99,7 +99,7 @@ object ConversationMenuHelper {
|
|||||||
inflater.inflate(R.menu.menu_conversation_notification_settings, menu)
|
inflater.inflate(R.menu.menu_conversation_notification_settings, menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call Tests
|
// TODO: Call Tests
|
||||||
if (!isOpenGroup) {
|
if (!isOpenGroup) {
|
||||||
inflater.inflate(R.menu.menu_conversation_call, menu)
|
inflater.inflate(R.menu.menu_conversation_call, menu)
|
||||||
}
|
}
|
||||||
@@ -182,11 +182,25 @@ object ConversationMenuHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun call(context: Context, thread: Recipient) {
|
private fun call(context: Context, thread: Recipient) {
|
||||||
|
AlertDialog.Builder(context)
|
||||||
|
.setTitle("Call")
|
||||||
|
.setMessage("Use relay?")
|
||||||
|
.setPositiveButton("Use Relay") { d, w ->
|
||||||
val intent = Intent(context, WebRtcTestsActivity::class.java)
|
val intent = Intent(context, WebRtcTestsActivity::class.java)
|
||||||
intent.putExtra(WebRtcTestsActivity.EXTRA_ADDRESS, thread.address)
|
intent.putExtra(WebRtcTestsActivity.EXTRA_ADDRESS, thread.address)
|
||||||
|
intent.putExtra(WebRtcTestsActivity.EXTRA_RELAY_USED, false)
|
||||||
val activity = context as AppCompatActivity
|
val activity = context as AppCompatActivity
|
||||||
activity.startActivity(intent)
|
activity.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
.setNeutralButton("P2P only") { d, w ->
|
||||||
|
val intent = Intent(context, WebRtcTestsActivity::class.java)
|
||||||
|
intent.putExtra(WebRtcTestsActivity.EXTRA_ADDRESS, thread.address)
|
||||||
|
intent.putExtra(WebRtcTestsActivity.EXTRA_RELAY_USED, false)
|
||||||
|
val activity = context as AppCompatActivity
|
||||||
|
activity.startActivity(intent)
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private fun addShortcut(context: Context, thread: Recipient) {
|
private fun addShortcut(context: Context, thread: Recipient) {
|
||||||
|
@@ -53,6 +53,7 @@ class CallBottomSheet: BottomSheetDialogFragment() {
|
|||||||
val intent = Intent(requireContext(), WebRtcTestsActivity::class.java)
|
val intent = Intent(requireContext(), WebRtcTestsActivity::class.java)
|
||||||
val bundle = bundleOf(
|
val bundle = bundleOf(
|
||||||
WebRtcTestsActivity.EXTRA_ADDRESS to address,
|
WebRtcTestsActivity.EXTRA_ADDRESS to address,
|
||||||
|
WebRtcTestsActivity.EXTRA_RELAY_USED to relaySwitch.isChecked
|
||||||
)
|
)
|
||||||
intent.action = WebRtcTestsActivity.ACTION_ANSWER
|
intent.action = WebRtcTestsActivity.ACTION_ANSWER
|
||||||
bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdp)
|
bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdp)
|
||||||
|
@@ -40,6 +40,17 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_marginTop="@dimen/large_spacing"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Use relay in ICE"/>
|
||||||
|
|
||||||
|
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
|
android:id="@+id/relaySwitch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_marginTop="@dimen/medium_spacing"
|
android:layout_marginTop="@dimen/medium_spacing"
|
||||||
android:paddingVertical="@dimen/medium_spacing"
|
android:paddingVertical="@dimen/medium_spacing"
|
||||||
|
Reference in New Issue
Block a user