|
|
|
|
@ -21,7 +21,6 @@ import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.viewinterop.AndroidView |
|
|
|
|
import androidx.core.content.ContextCompat |
|
|
|
|
import com.utun.chat.R |
|
|
|
|
import com.utun.chat.data.H264AnnexB |
|
|
|
|
import com.utun.chat.data.LogManager |
|
|
|
|
import com.utun.chat.data.NativeLib |
|
|
|
|
import com.utun.chat.data.StreamController |
|
|
|
|
@ -31,7 +30,6 @@ import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
import org.json.JSONArray |
|
|
|
|
import org.json.JSONObject |
|
|
|
|
|
|
|
|
|
private data class LiveSource(val id: Long, val name: String, val epoch: String) |
|
|
|
|
|
|
|
|
|
@ -63,15 +61,10 @@ fun StreamScreen(channelId: String, channelName: String, onBack: () -> Unit) {
|
|
|
|
|
while (true) { |
|
|
|
|
if (NativeLib.isReady()) sources = withContext(Dispatchers.IO) { |
|
|
|
|
try { |
|
|
|
|
val json = JSONArray(NativeLib.getChannelMembers(channelId)) |
|
|
|
|
(0 until json.length()).mapNotNull { i -> |
|
|
|
|
val json = JSONArray(NativeLib.streamSources(group)) |
|
|
|
|
(0 until json.length()).map { i -> |
|
|
|
|
val member = json.getJSONObject(i) |
|
|
|
|
val profile = JSONObject(member.optString("ui").ifEmpty { "{}" }) |
|
|
|
|
val source = profile.optString("stream_source") |
|
|
|
|
val fields = source.split(':') |
|
|
|
|
if (fields.size != 4 || fields[0].length != 16 || fields[0].toULongOrNull(16) == null || |
|
|
|
|
member.optInt("dl") != 0 || member.optInt("on") == 0) null |
|
|
|
|
else LiveSource(member.getLong("ni"), member.optString("n"), fields[0]) |
|
|
|
|
LiveSource(member.getString("id").toULong().toLong(), member.getString("name"), member.getString("epoch")) |
|
|
|
|
} |
|
|
|
|
} catch (e: Exception) { LogManager.addLog("WARN", "stream", "stream list: ${e.message}"); emptyList() } |
|
|
|
|
} else sources = emptyList() |
|
|
|
|
|