wbstream support
This commit is contained in:
1 parent
b48b0cb927
commit
3b3ffed0b3
49 files changed
+3060
-151
No files matched your search
@@ -21,6 +21,7 @@ import bypass.whitelist.tunnel.ProxyService
|
||||
import bypass.whitelist.tunnel.TunnelVpnService
|
||||
import bypass.whitelist.tunnel.VpnStatus
|
||||
import bypass.whitelist.ui.HeadlessTelemostFragment
|
||||
import bypass.whitelist.ui.HeadlessWBStreamFragment
|
||||
import bypass.whitelist.ui.HeadlessVkFragment
|
||||
import bypass.whitelist.ui.JoinFragmentHost
|
||||
import bypass.whitelist.ui.JsHookJoinFragment
|
||||
@@ -168,7 +169,7 @@ class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinF
|
||||
if (url.isEmpty()) return
|
||||
|
||||
val platform = CallPlatform.fromUrl(url)
|
||||
if (Prefs.tunnelMode == TunnelMode.DC && platform != CallPlatform.VK) {
|
||||
if (Prefs.tunnelMode == TunnelMode.DC && platform == CallPlatform.TELEMOST) {
|
||||
Prefs.tunnelMode = TunnelMode.VIDEO
|
||||
statusCtrl.tunnelMode = TunnelMode.VIDEO
|
||||
Toast.makeText(this, R.string.dc_mode_not_supported, Toast.LENGTH_SHORT).show()
|
||||
@@ -186,10 +187,11 @@ class MainActivity : AppCompatActivity(), SettingsDialogFragment.Listener, JoinF
|
||||
Prefs.lastUrl = url
|
||||
}
|
||||
|
||||
val fragment = if (Prefs.headless) {
|
||||
when (CallPlatform.fromUrl(url)) {
|
||||
val fragment = if (Prefs.headless || platform == CallPlatform.WBSTREAM) {
|
||||
when (platform) {
|
||||
CallPlatform.VK -> HeadlessVkFragment.newInstance(url)
|
||||
CallPlatform.TELEMOST -> HeadlessTelemostFragment.newInstance(url)
|
||||
CallPlatform.WBSTREAM -> HeadlessWBStreamFragment.newInstance(url)
|
||||
}
|
||||
} else {
|
||||
JsHookJoinFragment.newInstance(url)
|
||||
|
||||
@@ -2,10 +2,17 @@ package bypass.whitelist.tunnel
|
||||
|
||||
enum class CallPlatform(val id: String, val urlMarker: String) {
|
||||
VK("vk", ""),
|
||||
TELEMOST("telemost", "telemost.yandex");
|
||||
TELEMOST("telemost", "telemost.yandex"),
|
||||
WBSTREAM("wbstream", "wbstream://");
|
||||
|
||||
companion object {
|
||||
fun fromUrl(url: String): CallPlatform =
|
||||
if (url.contains(TELEMOST.urlMarker)) TELEMOST else VK
|
||||
fun fromUrl(url: String): CallPlatform = when {
|
||||
url.contains(WBSTREAM.urlMarker) -> WBSTREAM
|
||||
url.contains(TELEMOST.urlMarker) -> TELEMOST
|
||||
else -> VK
|
||||
}
|
||||
|
||||
fun extractRoomId(url: String): String =
|
||||
url.removePrefix(WBSTREAM.urlMarker).trim()
|
||||
}
|
||||
}
|
||||
@@ -118,10 +118,8 @@ class HeadlessRelayController(
|
||||
put("joinLink", joinLink)
|
||||
put("displayName", displayName)
|
||||
put("tunnelMode", tunnelMode)
|
||||
if (bypass.whitelist.util.Prefs.vp8PacingEnabled) {
|
||||
put("vp8Fps", bypass.whitelist.util.Prefs.vp8Fps)
|
||||
put("vp8Batch", bypass.whitelist.util.Prefs.vp8Batch)
|
||||
}
|
||||
put("vp8Fps", bypass.whitelist.util.Prefs.vp8Fps)
|
||||
put("vp8Batch", bypass.whitelist.util.Prefs.vp8Batch)
|
||||
}
|
||||
writeStdin("AUTH:$json")
|
||||
}
|
||||
|
||||
@@ -41,10 +41,8 @@ class HeadlessTelemostFragment : Fragment() {
|
||||
val params = JSONObject().apply {
|
||||
put("joinLink", joinLink)
|
||||
put("displayName", displayName)
|
||||
if (Prefs.vp8PacingEnabled) {
|
||||
put("vp8Fps", Prefs.vp8Fps)
|
||||
put("vp8Batch", Prefs.vp8Batch)
|
||||
}
|
||||
put("vp8Fps", Prefs.vp8Fps)
|
||||
put("vp8Batch", Prefs.vp8Batch)
|
||||
}
|
||||
relay.sendJoinParams(params.toString())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package bypass.whitelist.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import bypass.whitelist.R
|
||||
import bypass.whitelist.tunnel.CallPlatform
|
||||
import bypass.whitelist.tunnel.HeadlessRelayController
|
||||
import bypass.whitelist.tunnel.VpnStatus
|
||||
import bypass.whitelist.util.Prefs
|
||||
import org.json.JSONObject
|
||||
|
||||
class HeadlessWBStreamFragment : Fragment() {
|
||||
|
||||
private lateinit var relay: HeadlessRelayController
|
||||
|
||||
private val host: JoinFragmentHost?
|
||||
get() = activity as? JoinFragmentHost
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?,
|
||||
): View = inflater.inflate(R.layout.fragment_headless_wbstream, container, false)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
val rawUrl = requireArguments().getString(ARG_URL, "")
|
||||
val roomId = CallPlatform.extractRoomId(rawUrl)
|
||||
val displayName = Prefs.autoclickName
|
||||
|
||||
relay = HeadlessRelayController(
|
||||
requireContext().applicationInfo.nativeLibraryDir,
|
||||
relayMode = "wbstream-headless-joiner",
|
||||
onLog = { host?.appendLog(it) },
|
||||
onStatus = { status ->
|
||||
Log.d("WB-HEADLESS", "status: $status")
|
||||
host?.onJoinStatus(status)
|
||||
when (status) {
|
||||
VpnStatus.STARTING -> {
|
||||
val params = JSONObject().apply {
|
||||
put("roomId", roomId)
|
||||
put("displayName", displayName)
|
||||
put("tunnelMode", Prefs.tunnelMode.relayArg)
|
||||
put("vp8Fps", Prefs.vp8Fps)
|
||||
put("vp8Batch", Prefs.vp8Batch)
|
||||
}
|
||||
relay.sendJoinParams(params.toString())
|
||||
}
|
||||
VpnStatus.TUNNEL_ACTIVE -> activity?.runOnUiThread { host?.requestVpn() }
|
||||
else -> {}
|
||||
}
|
||||
},
|
||||
)
|
||||
relay.start()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
if (::relay.isInitialized) relay.stop()
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ARG_URL = "url"
|
||||
|
||||
fun newInstance(url: String): HeadlessWBStreamFragment {
|
||||
return HeadlessWBStreamFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putString(ARG_URL, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-25
@@ -2,50 +2,31 @@ package bypass.whitelist.ui
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import bypass.whitelist.R
|
||||
import bypass.whitelist.util.Prefs
|
||||
import bypass.whitelist.util.VP8Defaults
|
||||
|
||||
class Vp8PacingSettingsDialogFragment : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val view = layoutInflater.inflate(R.layout.dialog_vp8_pacing_settings, null)
|
||||
|
||||
val enabledCheckbox = view.findViewById<CheckBox>(R.id.vp8PacingEnabledCheckbox)
|
||||
val inputsContainer = view.findViewById<LinearLayout>(R.id.vp8PacingInputs)
|
||||
val fpsInput = view.findViewById<EditText>(R.id.vp8FpsInput)
|
||||
val batchInput = view.findViewById<EditText>(R.id.vp8BatchInput)
|
||||
|
||||
enabledCheckbox.isChecked = Prefs.vp8PacingEnabled
|
||||
inputsContainer.visibility = if (Prefs.vp8PacingEnabled) View.VISIBLE else View.GONE
|
||||
fpsInput.setText(Prefs.vp8Fps.toString())
|
||||
batchInput.setText(Prefs.vp8Batch.toString())
|
||||
|
||||
enabledCheckbox.setOnCheckedChangeListener { _, checked ->
|
||||
inputsContainer.visibility = if (checked) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
return AlertDialog.Builder(requireContext())
|
||||
.setTitle(R.string.vp8_pacing_title)
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
Prefs.vp8PacingEnabled = enabledCheckbox.isChecked
|
||||
if (enabledCheckbox.isChecked) {
|
||||
val fps = fpsInput.text.toString().toIntOrNull()
|
||||
if (fps != null && fps in 1..240) {
|
||||
Prefs.vp8Fps = fps
|
||||
}
|
||||
val batch = batchInput.text.toString().toIntOrNull()
|
||||
if (batch != null && batch in 1..256) {
|
||||
Prefs.vp8Batch = batch
|
||||
}
|
||||
}
|
||||
val fps = fpsInput.text.toString().toIntOrNull()
|
||||
if (fps != null && fps in 1..240) Prefs.vp8Fps = fps
|
||||
val batch = batchInput.text.toString().toIntOrNull()
|
||||
if (batch != null && batch in 1..256) Prefs.vp8Batch = batch
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
@@ -53,7 +34,5 @@ class Vp8PacingSettingsDialogFragment : DialogFragment() {
|
||||
|
||||
companion object {
|
||||
const val TAG = "Vp8PacingSettingsDialog"
|
||||
|
||||
fun defaults(): Pair<Int, Int> = VP8Defaults.FPS to VP8Defaults.BATCH
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,6 @@ object PrefsKeys {
|
||||
const val DNS_MODE = "dns_mode"
|
||||
const val DNS_PRIMARY = "dns_primary"
|
||||
const val DNS_SECONDARY = "dns_secondary"
|
||||
const val VP8_PACING_ENABLED = "vp8_pacing_enabled"
|
||||
const val VP8_FPS = "vp8_fps"
|
||||
const val VP8_BATCH = "vp8_batch"
|
||||
}
|
||||
|
||||
@@ -110,10 +110,6 @@ object Prefs {
|
||||
get() = prefs.getString(PrefsKeys.DNS_SECONDARY, Vpn.DNS_SECONDARY)!!
|
||||
set(value) = prefs.edit { putString(PrefsKeys.DNS_SECONDARY, value) }
|
||||
|
||||
var vp8PacingEnabled: Boolean
|
||||
get() = prefs.getBoolean(PrefsKeys.VP8_PACING_ENABLED, false)
|
||||
set(value) = prefs.edit { putBoolean(PrefsKeys.VP8_PACING_ENABLED, value) }
|
||||
|
||||
var vp8Fps: Int
|
||||
get() = prefs.getInt(PrefsKeys.VP8_FPS, VP8Defaults.FPS)
|
||||
set(value) = prefs.edit { putInt(PrefsKeys.VP8_FPS, value) }
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -5,56 +5,31 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/vp8PacingEnabledCheckbox"
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/vp8_pacing_enabled_label"
|
||||
android:textSize="16sp" />
|
||||
android:text="@string/vp8_fps_label"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/vp8FpsInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/vp8_fps_hint"
|
||||
android:inputType="number" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/vp8_pacing_hint"
|
||||
android:textSize="12sp"
|
||||
android:alpha="0.7" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/vp8_batch_label"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/vp8PacingInputs"
|
||||
<EditText
|
||||
android:id="@+id/vp8BatchInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:paddingTop="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/vp8_fps_label"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/vp8FpsInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/vp8_fps_hint"
|
||||
android:inputType="number" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/vp8_batch_label"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/vp8BatchInput"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/vp8_batch_hint"
|
||||
android:inputType="number" />
|
||||
|
||||
</LinearLayout>
|
||||
android:hint="@string/vp8_batch_hint"
|
||||
android:inputType="number" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
@@ -59,12 +59,10 @@
|
||||
<string name="dns_secondary_hint">Secondary DNS</string>
|
||||
<string name="menu_vp8_pacing">VP8 pacing</string>
|
||||
<string name="vp8_pacing_title">VP8 pacing</string>
|
||||
<string name="vp8_pacing_enabled_label">Override VP8 pacing</string>
|
||||
<string name="vp8_pacing_hint">When off, defaults are used (fps=25, batch=1). Higher batch = higher throughput.</string>
|
||||
<string name="vp8_fps_label">FPS</string>
|
||||
<string name="vp8_fps_hint">e.g. 25</string>
|
||||
<string name="vp8_fps_hint">e.g. 24</string>
|
||||
<string name="vp8_batch_label">Batch</string>
|
||||
<string name="vp8_batch_hint">e.g. 1, 8, 16</string>
|
||||
<string name="vp8_batch_hint">e.g. 1, 8, 30</string>
|
||||
<string name="notification_vpn_title">VPN active</string>
|
||||
<string name="notification_proxy_title">Proxy active</string>
|
||||
<string name="notification_disconnect">Disconnect</string>
|
||||
|
||||
Reference in new issue
Block a user