mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-25 17:25:21 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25cbdcb504 | |||
| 14ed45e833 | |||
| e365e0219e |
@@ -5,6 +5,16 @@ import com.google.android.exoplayer2.util.Log
|
||||
class Stopwatch {
|
||||
var startTime = System.nanoTime()
|
||||
|
||||
val elapsedMs: Double get() {
|
||||
val now = System.nanoTime()
|
||||
val diff = now - startTime
|
||||
return diff / 1000000.0
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
startTime = System.nanoTime()
|
||||
}
|
||||
|
||||
fun logAndNext(tag: String, message: String): Long {
|
||||
val now = System.nanoTime()
|
||||
val diff = now - startTime
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ class ImportSubscriptionsFragment : MainFragment() {
|
||||
|
||||
|
||||
override fun onShownWithView(parameter: Any?, isBack: Boolean) {
|
||||
super.onShown(parameter, isBack);
|
||||
super.onShownWithView(parameter, isBack);
|
||||
_view?.onShown(parameter, isBack);
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -94,6 +94,7 @@ import com.google.android.exoplayer2.Format
|
||||
import com.google.android.exoplayer2.ui.PlayerControlView
|
||||
import com.google.android.exoplayer2.ui.TimeBar
|
||||
import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException
|
||||
import com.google.common.base.Stopwatch
|
||||
import com.google.protobuf.ByteString
|
||||
import kotlinx.coroutines.*
|
||||
import userpackage.Protocol
|
||||
@@ -930,12 +931,21 @@ class VideoDetailView : ConstraintLayout {
|
||||
val me = this;
|
||||
fragment.lifecycleScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val tracker = video.getPlaybackTracker() ?: StatePlatform.instance.getPlaybackTracker(video.url);
|
||||
val stopwatch = com.futo.platformplayer.debug.Stopwatch()
|
||||
var tracker = video.getPlaybackTracker()
|
||||
Logger.i(TAG, "video.getPlaybackTracker took ${stopwatch.elapsedMs}ms")
|
||||
|
||||
if (tracker == null) {
|
||||
stopwatch.reset()
|
||||
tracker = StatePlatform.instance.getPlaybackTracker(video.url);
|
||||
Logger.i(TAG, "StatePlatform.instance.getPlaybackTracker took ${stopwatch.elapsedMs}ms")
|
||||
}
|
||||
|
||||
if(me.video == video)
|
||||
me._playbackTracker = tracker;
|
||||
}
|
||||
catch(ex: Throwable) {
|
||||
fragment.lifecycleScope.launch(Dispatchers.Main) {
|
||||
withContext(Dispatchers.Main) {
|
||||
UIDialogs.showGeneralErrorDialog(context, "Failed to get Playback Tracker", ex);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class StatePlatform {
|
||||
private val _enabledClients : ArrayList<IPlatformClient> = ArrayList();
|
||||
|
||||
private val _clientPools: HashMap<IPlatformClient, PlatformClientPool> = hashMapOf();
|
||||
private val _trackerClientPools: HashMap<IPlatformClient, PlatformClientPool> = hashMapOf();
|
||||
|
||||
private val _primaryClientPersistent = FragmentedStorage.get<StringStorage>("primaryClient");
|
||||
private var _primaryClientObj : IPlatformClient? = null;
|
||||
@@ -246,6 +247,22 @@ class StatePlatform {
|
||||
};
|
||||
return pool.getClient(capacity);
|
||||
}
|
||||
fun getTrackerClientPooled(parentClient: IPlatformClient, capacity: Int): IPlatformClient {
|
||||
val pool = synchronized(_trackerClientPools) {
|
||||
if(!_trackerClientPools.containsKey(parentClient))
|
||||
_trackerClientPools[parentClient] = PlatformClientPool(parentClient).apply {
|
||||
this.onDead.subscribe { client, pool ->
|
||||
synchronized(_trackerClientPools) {
|
||||
if(_trackerClientPools[parentClient] == pool)
|
||||
_trackerClientPools.remove(parentClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
_trackerClientPools[parentClient]!!;
|
||||
};
|
||||
return pool.getClient(capacity);
|
||||
}
|
||||
|
||||
fun getClientsByClaimType(claimType: Int): List<IPlatformClient> {
|
||||
return getEnabledClients().filter { it.isClaimTypeSupported(claimType) };
|
||||
}
|
||||
@@ -572,6 +589,7 @@ class StatePlatform {
|
||||
pagers.put(it.searchChannels(query), 1f);
|
||||
}
|
||||
catch(ex: Throwable) {
|
||||
Logger.e(TAG, "Failed search channels", ex)
|
||||
UIDialogs.toast("Failed search channels on [${it.name}]\n(${ex.message})");
|
||||
}
|
||||
};
|
||||
@@ -604,7 +622,12 @@ class StatePlatform {
|
||||
}
|
||||
|
||||
fun getPlaybackTracker(url: String): IPlaybackTracker? {
|
||||
return getContentClientOrNull(url)?.getPlaybackTracker(url);
|
||||
val baseClient = getContentClientOrNull(url) ?: return null;
|
||||
if (baseClient !is JSClient) {
|
||||
return baseClient.getPlaybackTracker(url);
|
||||
}
|
||||
val client = getTrackerClientPooled(baseClient, 1);
|
||||
return client.getPlaybackTracker(url);
|
||||
}
|
||||
|
||||
fun hasEnabledChannelClient(url : String) : Boolean = getEnabledClients().any { it.isChannelUrl(url) };
|
||||
|
||||
Submodule app/src/stable/assets/sources/rumble updated: 16c09b9e21...4b5d9f12a7
Submodule app/src/stable/assets/sources/twitch updated: 7e8ce3a2ed...7645b88a76
Submodule app/src/unstable/assets/sources/rumble updated: 16c09b9e21...4b5d9f12a7
Submodule app/src/unstable/assets/sources/twitch updated: 7e8ce3a2ed...7645b88a76
Reference in New Issue
Block a user