-
-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1010 from nielsvanvelzen/auto-bitrate
Fix auto bitrate issues
- Loading branch information
Showing
5 changed files
with
29 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
app/src/main/java/org/jellyfin/androidtv/util/AutoBitrate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
package org.jellyfin.androidtv.util | ||
|
||
import org.jellyfin.androidtv.util.apiclient.callApi | ||
import org.jellyfin.apiclient.interaction.ApiClient | ||
import org.jellyfin.sdk.api.client.KtorClient | ||
import org.jellyfin.sdk.api.client.extensions.detectBitrate | ||
import org.jellyfin.sdk.api.operations.MediaInfoApi | ||
import timber.log.Timber | ||
|
||
/** | ||
* Small utility class to store and automatically detect a preferred bitrate. | ||
*/ | ||
class AutoBitrate( | ||
private val apiClient: ApiClient | ||
private val apiClient: KtorClient | ||
) { | ||
private val mediaInfoApi = MediaInfoApi(apiClient) | ||
|
||
var bitrate: Long? = null | ||
private set | ||
|
||
suspend fun detect() { | ||
bitrate = callApi<Long> { apiClient.detectBitrate(it) } | ||
val measurement = mediaInfoApi.detectBitrate() | ||
bitrate = measurement.bitrate | ||
|
||
Timber.i("Auto bitrate set to: %d", bitrate) | ||
} | ||
|
||
fun getOr(default: Long) = bitrate ?: default | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters