feat: add relay toggle for answer and offer
This commit is contained in:
parent
f6eafccd7b
commit
287fa9918c
|
@ -39,6 +39,7 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||
|
||||
const val EXTRA_SDP = "WebRtcTestsActivity_EXTRA_SDP"
|
||||
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_MIDS = "WebRtcTestsActivity_EXTRA_SDP_MIDS"
|
||||
|
||||
|
@ -87,6 +88,8 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||
}
|
||||
|
||||
private lateinit var callAddress: Address
|
||||
private var relayUsed: Boolean = true
|
||||
|
||||
private val peerConnection by lazy {
|
||||
// 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()
|
||||
|
@ -94,7 +97,11 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||
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 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
|
||||
connectionFactory.createPeerConnection(rtcConfig, this)!!
|
||||
}
|
||||
|
@ -103,6 +110,8 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
|||
super.onCreate(savedInstanceState, ready)
|
||||
setContentView(R.layout.activity_webrtc_tests)
|
||||
|
||||
relayUsed = intent.getBooleanExtra(EXTRA_RELAY_USED, true)
|
||||
|
||||
//TODO: better handling of permissions
|
||||
Permissions.with(this)
|
||||
.request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
|
||||
|
|
|
@ -99,7 +99,7 @@ object ConversationMenuHelper {
|
|||
inflater.inflate(R.menu.menu_conversation_notification_settings, menu)
|
||||
}
|
||||
|
||||
// Call Tests
|
||||
// TODO: Call Tests
|
||||
if (!isOpenGroup) {
|
||||
inflater.inflate(R.menu.menu_conversation_call, menu)
|
||||
}
|
||||
|
@ -182,10 +182,24 @@ object ConversationMenuHelper {
|
|||
}
|
||||
|
||||
private fun call(context: Context, thread: Recipient) {
|
||||
val intent = Intent(context, WebRtcTestsActivity::class.java)
|
||||
intent.putExtra(WebRtcTestsActivity.EXTRA_ADDRESS, thread.address)
|
||||
val activity = context as AppCompatActivity
|
||||
activity.startActivity(intent)
|
||||
AlertDialog.Builder(context)
|
||||
.setTitle("Call")
|
||||
.setMessage("Use relay?")
|
||||
.setPositiveButton("Use Relay") { 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)
|
||||
}
|
||||
.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")
|
||||
|
|
|
@ -53,6 +53,7 @@ class CallBottomSheet: BottomSheetDialogFragment() {
|
|||
val intent = Intent(requireContext(), WebRtcTestsActivity::class.java)
|
||||
val bundle = bundleOf(
|
||||
WebRtcTestsActivity.EXTRA_ADDRESS to address,
|
||||
WebRtcTestsActivity.EXTRA_RELAY_USED to relaySwitch.isChecked
|
||||
)
|
||||
intent.action = WebRtcTestsActivity.ACTION_ANSWER
|
||||
bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdp)
|
||||
|
|
|
@ -40,6 +40,17 @@
|
|||
|
||||
</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
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:paddingVertical="@dimen/medium_spacing"
|
||||
|
|
Loading…
Reference in New Issue