mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Merge branch 'marcus/exp-casting-device-pinning-fix' into 'master'
casting(experimental): ignore devices that are unsupported or fails to parse See merge request videostreaming/grayjay!150
This commit is contained in:
@@ -90,8 +90,7 @@ abstract class StateCasting {
|
|||||||
abstract fun start(context: Context)
|
abstract fun start(context: Context)
|
||||||
abstract fun stop()
|
abstract fun stop()
|
||||||
|
|
||||||
@Throws
|
abstract fun deviceFromInfo(deviceInfo: CastingDeviceInfo): CastingDevice?
|
||||||
abstract fun deviceFromInfo(deviceInfo: CastingDeviceInfo): CastingDevice
|
|
||||||
abstract fun startUpdateTimeJob(
|
abstract fun startUpdateTimeJob(
|
||||||
onTimeJobTimeChanged_s: Event1<Long>, setTime: (Long) -> Unit
|
onTimeJobTimeChanged_s: Event1<Long>, setTime: (Long) -> Unit
|
||||||
): Job?
|
): Job?
|
||||||
@@ -1288,9 +1287,11 @@ abstract class StateCasting {
|
|||||||
return listOf()
|
return listOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addRememberedDevice(deviceInfo: CastingDeviceInfo): CastingDeviceInfo {
|
fun addRememberedDevice(deviceInfo: CastingDeviceInfo): CastingDeviceInfo? {
|
||||||
val device = deviceFromInfo(deviceInfo);
|
return when (val device = deviceFromInfo(deviceInfo)) {
|
||||||
return addRememberedDevice(device);
|
null -> null
|
||||||
|
else -> addRememberedDevice(device)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addRememberedDevice(device: CastingDevice): CastingDeviceInfo {
|
fun addRememberedDevice(device: CastingDevice): CastingDeviceInfo {
|
||||||
@@ -1299,7 +1300,7 @@ abstract class StateCasting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getRememberedCastingDevices(): List<CastingDevice> {
|
fun getRememberedCastingDevices(): List<CastingDevice> {
|
||||||
return _storage.getDevices().map { deviceFromInfo(it) }
|
return _storage.getDevices().map { deviceFromInfo(it) }.filterNotNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRememberedCastingDeviceNames(): List<String> {
|
fun getRememberedCastingDeviceNames(): List<String> {
|
||||||
|
|||||||
@@ -151,21 +151,25 @@ class StateCastingExp : StateCasting() {
|
|||||||
setTime: (Long) -> Unit
|
setTime: (Long) -> Unit
|
||||||
): Job? = null
|
): Job? = null
|
||||||
|
|
||||||
override fun deviceFromInfo(deviceInfo: CastingDeviceInfo): CastingDeviceExp {
|
override fun deviceFromInfo(deviceInfo: CastingDeviceInfo): CastingDeviceExp? {
|
||||||
val rsAddrs =
|
try {
|
||||||
deviceInfo.addresses.map { org.fcast.sender_sdk.tryIpAddrFromStr(it) } // Throws!
|
val rsAddrs =
|
||||||
val rsDeviceInfo = RsDeviceInfo(
|
deviceInfo.addresses.map { org.fcast.sender_sdk.tryIpAddrFromStr(it) }
|
||||||
name = deviceInfo.name,
|
val rsDeviceInfo = RsDeviceInfo(
|
||||||
protocol = when (deviceInfo.type) {
|
name = deviceInfo.name,
|
||||||
com.futo.platformplayer.casting.CastProtocolType.CHROMECAST -> ProtocolType.CHROMECAST
|
protocol = when (deviceInfo.type) {
|
||||||
com.futo.platformplayer.casting.CastProtocolType.FCAST -> ProtocolType.F_CAST
|
com.futo.platformplayer.casting.CastProtocolType.CHROMECAST -> ProtocolType.CHROMECAST
|
||||||
else -> throw IllegalArgumentException()
|
com.futo.platformplayer.casting.CastProtocolType.FCAST -> ProtocolType.F_CAST
|
||||||
},
|
else -> throw IllegalArgumentException()
|
||||||
addresses = rsAddrs,
|
},
|
||||||
port = deviceInfo.port.toUShort(),
|
addresses = rsAddrs,
|
||||||
)
|
port = deviceInfo.port.toUShort(),
|
||||||
|
)
|
||||||
|
|
||||||
return CastingDeviceExp(_context.createDeviceFromInfo(rsDeviceInfo))
|
return CastingDeviceExp(_context.createDeviceFromInfo(rsDeviceInfo))
|
||||||
|
} catch (_: Throwable) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ class StateCastingLegacy : StateCasting() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
connectDevice(deviceFromInfo(foundInfo))
|
if (foundInfo != null) {
|
||||||
|
connectDevice(deviceFromInfo(foundInfo))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|||||||
Reference in New Issue
Block a user