add dual track support for wbstream's vp8
This commit is contained in:
1 parent
62da620ec0
commit
5b98351e58
36 files changed
+636
-85
No files matched your search
@@ -506,17 +506,26 @@ class MainActivity :
|
||||
private fun fullReset() {
|
||||
connected = false
|
||||
lastStatus = null
|
||||
closeActiveHeadlessController()
|
||||
val controller = activeHeadlessController
|
||||
activeHeadlessController = null
|
||||
val vpn = TunnelVpnService.instance
|
||||
val proxy = ProxyService.instance
|
||||
removeJoinFragment()
|
||||
setJoinOverlayVisible(false)
|
||||
mainFragment()?.onConnectedChanged(false)
|
||||
TunnelVpnService.instance?.stop()
|
||||
ProxyService.instance?.stop()
|
||||
thread(name = "full-reset-shutdown") {
|
||||
controller?.close()
|
||||
vpn?.stop()
|
||||
proxy?.stop()
|
||||
}
|
||||
}
|
||||
|
||||
private fun closeActiveHeadlessController() {
|
||||
activeHeadlessController?.close()
|
||||
val controller = activeHeadlessController
|
||||
activeHeadlessController = null
|
||||
if (controller != null) {
|
||||
thread(name = "headless-shutdown") { controller.close() }
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeJoinFragment() {
|
||||
|
||||
@@ -40,6 +40,7 @@ class HeadlessJoinController(
|
||||
put("displayName", Prefs.autofillName)
|
||||
put("vp8Fps", Prefs.vp8Fps)
|
||||
put("vp8Batch", Prefs.vp8Batch)
|
||||
put("dualTrack", Prefs.dualTrack)
|
||||
when (platform) {
|
||||
CallPlatform.TELEMOST -> put("joinLink", url)
|
||||
CallPlatform.WBSTREAM -> {
|
||||
|
||||
@@ -121,6 +121,7 @@ class HeadlessRelayController(
|
||||
put("tunnelMode", tunnelMode)
|
||||
put("vp8Fps", bypass.whitelist.util.Prefs.vp8Fps)
|
||||
put("vp8Batch", bypass.whitelist.util.Prefs.vp8Batch)
|
||||
put("dualTrack", bypass.whitelist.util.Prefs.dualTrack)
|
||||
}
|
||||
writeStdin("AUTH:$json")
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ class ProxyService : Service() {
|
||||
|
||||
override fun onDestroy() {
|
||||
stop()
|
||||
if (instance === this) {
|
||||
instance = null
|
||||
}
|
||||
onDisconnect = null
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ class TunnelVpnService : VpnService() {
|
||||
|
||||
override fun onDestroy() {
|
||||
stop()
|
||||
if (instance === this) {
|
||||
instance = null
|
||||
}
|
||||
onDisconnect = null
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@@ -72,7 +76,7 @@ class TunnelVpnService : VpnService() {
|
||||
vpnFd = null
|
||||
@Suppress("DEPRECATION")
|
||||
stopForeground(true)
|
||||
stopSelf()
|
||||
//stopSelf()
|
||||
onDisconnect?.invoke()
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ class SettingsScreenFragment : Fragment(R.layout.fragment_settings_screen) {
|
||||
}
|
||||
}
|
||||
|
||||
addRow(card, R.drawable.ic_setting_vp8, getString(R.string.settings_row_vp8), getString(R.string.settings_row_vp8_sub, Prefs.vp8Fps, Prefs.vp8Batch), null) {
|
||||
val vp8SubRes = if (Prefs.dualTrack) R.string.settings_row_vp8_sub_dual else R.string.settings_row_vp8_sub
|
||||
addRow(card, R.drawable.ic_setting_vp8, getString(R.string.settings_row_vp8), getString(vp8SubRes, Prefs.vp8Fps, Prefs.vp8Batch), null) {
|
||||
Vp8ActionSheet.show(parentFragmentManager) { rebuild() }
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import bypass.whitelist.R
|
||||
import bypass.whitelist.tunnel.SplitTunnelingMode
|
||||
import bypass.whitelist.tunnel.TunnelVpnService
|
||||
import bypass.whitelist.util.Prefs
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class SplitTunnelingScreenFragment : Fragment() {
|
||||
|
||||
@@ -122,10 +123,13 @@ class SplitTunnelingScreenFragment : Fragment() {
|
||||
}
|
||||
loadingBar.visibility = View.VISIBLE
|
||||
appsListContainer.visibility = View.GONE
|
||||
val ctx = context ?: return
|
||||
val pm = ctx.packageManager
|
||||
val ownPackage = ctx.packageName
|
||||
val selectedSnapshot = packages.toSet()
|
||||
val act = activity ?: return
|
||||
val weakSelf = WeakReference(this)
|
||||
Thread {
|
||||
val context = context ?: return@Thread
|
||||
val pm = context.packageManager
|
||||
val ownPackage = context.packageName
|
||||
val loaded = pm.getInstalledApplications(PackageManager.GET_META_DATA)
|
||||
.filter { it.packageName != ownPackage }
|
||||
.mapNotNull { info ->
|
||||
@@ -134,29 +138,36 @@ class SplitTunnelingScreenFragment : Fragment() {
|
||||
val label = info.loadLabel(pm).toString().takeIf { it.isNotBlank() } ?: pkg
|
||||
SplitTunnelingAppItem(
|
||||
pkg, label, pm.getApplicationIcon(pkg),
|
||||
packages.contains(pkg),
|
||||
selectedSnapshot.contains(pkg),
|
||||
(info.flags and ApplicationInfo.FLAG_SYSTEM) == 0,
|
||||
)
|
||||
}
|
||||
.distinctBy { it.packageName }
|
||||
.sortedWith(compareByDescending<SplitTunnelingAppItem> { it.isSelected }.thenBy { it.label.lowercase() })
|
||||
activity?.runOnUiThread {
|
||||
if (!isAdded) return@runOnUiThread
|
||||
allApps = loaded
|
||||
loadingBar.visibility = View.GONE
|
||||
appsListContainer.visibility = View.VISIBLE
|
||||
val adapter = SplitTunnelingAdapter(layoutInflater, packages)
|
||||
appsList.adapter = adapter
|
||||
applyFilters()
|
||||
systemAppsCheckbox.isChecked = includeSystemApps
|
||||
systemAppsCheckbox.setOnCheckedChangeListener { _, checked ->
|
||||
includeSystemApps = checked
|
||||
applyFilters()
|
||||
if (weakSelf.get() == null) return@Thread
|
||||
act.runOnUiThread {
|
||||
val self = weakSelf.get() ?: return@runOnUiThread
|
||||
if (!self.isAdded) return@runOnUiThread
|
||||
self.allApps = loaded
|
||||
self.loadingBar.visibility = View.GONE
|
||||
self.appsListContainer.visibility = View.VISIBLE
|
||||
val adapter = SplitTunnelingAdapter(self.layoutInflater, self.packages)
|
||||
self.appsList.adapter = adapter
|
||||
self.applyFilters()
|
||||
self.systemAppsCheckbox.isChecked = self.includeSystemApps
|
||||
self.systemAppsCheckbox.setOnCheckedChangeListener { _, checked ->
|
||||
val s = weakSelf.get() ?: return@setOnCheckedChangeListener
|
||||
s.includeSystemApps = checked
|
||||
s.applyFilters()
|
||||
}
|
||||
searchInput.addTextChangedListener(object : TextWatcher {
|
||||
self.searchInput.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { applyFilters() }
|
||||
override fun afterTextChanged(s: Editable?) { updateSummary() }
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
weakSelf.get()?.applyFilters()
|
||||
}
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
weakSelf.get()?.updateSummary()
|
||||
}
|
||||
})
|
||||
}
|
||||
}.start()
|
||||
|
||||
@@ -11,6 +11,7 @@ import bypass.whitelist.util.Callback
|
||||
import bypass.whitelist.util.Prefs
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
|
||||
class Vp8ActionSheet : BottomSheetDialogFragment() {
|
||||
|
||||
@@ -25,13 +26,16 @@ class Vp8ActionSheet : BottomSheetDialogFragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
val fps = view.findViewById<EditText>(R.id.vp8FpsInput)
|
||||
val batch = view.findViewById<EditText>(R.id.vp8BatchInput)
|
||||
val dualTrack = view.findViewById<MaterialSwitch>(R.id.vp8DualTrackSwitch)
|
||||
fps.setText(Prefs.vp8Fps.toString())
|
||||
batch.setText(Prefs.vp8Batch.toString())
|
||||
dualTrack.isChecked = Prefs.dualTrack
|
||||
|
||||
view.findViewById<MaterialButton>(R.id.vp8CancelButton).setOnClickListener { dismiss() }
|
||||
view.findViewById<MaterialButton>(R.id.vp8SaveButton).setOnClickListener {
|
||||
fps.text.toString().toIntOrNull()?.takeIf { it in 1..240 }?.let { Prefs.vp8Fps = it }
|
||||
batch.text.toString().toIntOrNull()?.takeIf { it in 1..256 }?.let { Prefs.vp8Batch = it }
|
||||
Prefs.dualTrack = dualTrack.isChecked
|
||||
onSaved?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ object PrefsKeys {
|
||||
const val DNS_SECONDARY = "dns_secondary"
|
||||
const val VP8_FPS = "vp8_fps"
|
||||
const val VP8_BATCH = "vp8_batch"
|
||||
const val DUAL_TRACK = "dual_track"
|
||||
const val SAVED_DESTINATIONS = "saved_destinations"
|
||||
const val ACTIVE_DESTINATION_ID = "active_destination_id"
|
||||
const val THEME_MODE = "theme_mode"
|
||||
|
||||
@@ -115,6 +115,10 @@ object Prefs {
|
||||
get() = prefs.getInt(PrefsKeys.VP8_BATCH, VP8Defaults.BATCH)
|
||||
set(value) = prefs.edit { putInt(PrefsKeys.VP8_BATCH, value) }
|
||||
|
||||
var dualTrack: Boolean
|
||||
get() = prefs.getBoolean(PrefsKeys.DUAL_TRACK, false)
|
||||
set(value) = prefs.edit { putBoolean(PrefsKeys.DUAL_TRACK, value) }
|
||||
|
||||
var savedDestinations: List<CallConfig>
|
||||
get() = CallConfig.listFromJson(prefs.getString(PrefsKeys.SAVED_DESTINATIONS, "") ?: "")
|
||||
set(value) = prefs.edit { putString(PrefsKeys.SAVED_DESTINATIONS, CallConfig.listToJson(value)) }
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/vp8_pacing_title"
|
||||
android:text="@string/vp8_settings_title"
|
||||
android:textColor="@color/ink"
|
||||
android:textSize="17sp"
|
||||
android:textStyle="bold" />
|
||||
@@ -24,7 +24,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/vp8_pacing_sub"
|
||||
android:text="@string/vp8_settings_sub"
|
||||
android:textColor="@color/ink_3"
|
||||
android:textSize="13sp" />
|
||||
|
||||
@@ -71,6 +71,49 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:background="@drawable/bg_destination_card"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="14dp"
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/vp8_dual_track_title"
|
||||
android:textColor="@color/ink"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:fontFamily="monospace"
|
||||
android:text="@string/vp8_dual_track_sub"
|
||||
android:textColor="@color/ink_3"
|
||||
android:textSize="11sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/vp8DualTrackSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:scaleX="0.85"
|
||||
android:scaleY="0.85" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -31,9 +31,11 @@
|
||||
<string name="dns_settings_title">DNS</string>
|
||||
<string name="dns_primary_hint">Primary DNS</string>
|
||||
<string name="dns_secondary_hint">Secondary DNS</string>
|
||||
<string name="vp8_pacing_title">VP8 pacing</string>
|
||||
<string name="vp8_settings_title">VP8 settings</string>
|
||||
<string name="vp8_fps_label">FPS</string>
|
||||
<string name="vp8_batch_label">Batch</string>
|
||||
<string name="vp8_dual_track_title">Dual track</string>
|
||||
<string name="vp8_dual_track_sub">Publish a second VP8 track as screen-share and shard outbound across both.</string>
|
||||
<string name="notification_vpn_title">VPN active</string>
|
||||
<string name="notification_proxy_title">Proxy active</string>
|
||||
<string name="notification_disconnect">Disconnect</string>
|
||||
@@ -90,8 +92,9 @@
|
||||
|
||||
|
||||
<string name="settings_row_tunnel_mode">Tunnel mode</string>
|
||||
<string name="settings_row_vp8">VP8 pacing</string>
|
||||
<string name="settings_row_vp8">VP8 settings</string>
|
||||
<string name="settings_row_vp8_sub" tools:ignore="PluralsCandidate">%1$d fps / %2$d batch</string>
|
||||
<string name="settings_row_vp8_sub_dual" tools:ignore="PluralsCandidate">%1$d fps / %2$d batch / dual</string>
|
||||
<string name="settings_row_autofill">Autofill</string>
|
||||
<string name="settings_row_autofill_off">Off</string>
|
||||
<string name="settings_row_split">Split tunneling</string>
|
||||
@@ -144,7 +147,7 @@
|
||||
<string name="autofill_enable_title">Enable autofill</string>
|
||||
<string name="autofill_enable_sub">Click join button + fill name automatically</string>
|
||||
<string name="autofill_name_field_label">Display name</string>
|
||||
<string name="vp8_pacing_sub">Tune the data-channel video framing. Lower fps + bigger batch reduces overhead, but may stutter.</string>
|
||||
<string name="vp8_settings_sub">Tune the data-channel video framing. Lower fps + bigger batch reduces overhead, but may stutter.</string>
|
||||
<string name="dns_sub">Pick a DNS resolver used inside the tunnel.</string>
|
||||
<string name="dns_primary_label">Primary</string>
|
||||
<string name="dns_secondary_label">Secondary</string>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
<style name="ThemeOverlay.WhitelistBypass.BottomSheetDialog" parent="ThemeOverlay.Material3.BottomSheetDialog">
|
||||
<item name="bottomSheetStyle">@style/Widget.WhitelistBypass.BottomSheet</item>
|
||||
<item name="android:windowAnimationStyle">@style/Animation.Design.BottomSheetDialog</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.WhitelistBypass.BottomSheet" parent="Widget.Material3.BottomSheet.Modal">
|
||||
|
||||
Reference in new issue
Block a user