aboutsummaryrefslogtreecommitdiff
path: root/web/script/player/profiles.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/script/player/profiles.ts')
-rw-r--r--web/script/player/profiles.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/web/script/player/profiles.ts b/web/script/player/profiles.ts
index 11b27c9..a768d47 100644
--- a/web/script/player/profiles.ts
+++ b/web/script/player/profiles.ts
@@ -1,5 +1,6 @@
import { OVar } from "../jshelper/mod.ts";
import { EncodingProfile, JhlsMetadata } from "./jhls.d.ts";
+import { Player } from "./player.ts";
const PROFILE_UP_FAC = 0.6
const PROFILE_DOWN_FAC = 0.8
@@ -11,7 +12,7 @@ export class ProfileSelector {
profiles_subtitles: EncodingProfileExt[] = []
remux_bandwidth = new Map<number, { size: number, duration: number }>()
- constructor(private bandwidth: OVar<number>, private metadata: JhlsMetadata) {
+ constructor(private player: Player, private bandwidth: OVar<number>, private metadata: JhlsMetadata) {
for (let id = 0; id < metadata.extra_profiles.length; id++) {
const p = metadata.extra_profiles[id];
if (p.audio) this.profiles_audio.push({ id, order: 0, ...p })
@@ -42,14 +43,21 @@ export class ProfileSelector {
if (current_bitrate > this.bandwidth.value * PROFILE_DOWN_FAC && co + 1 < profs.length) {
console.log("profile up");
profile.value = profs[co + 1]
+ this.log_change(track, profile.value)
}
if (next_bitrate < this.bandwidth.value * PROFILE_UP_FAC && co >= 0) {
console.log("profile down");
profile.value = profs[co - 1]
+ this.log_change(track, profile.value)
}
// profile.value = profs[0]
}
+
+ log_change(track: number, p: EncodingProfileExt | undefined) {
+ const ps = p ? `transcoding profile ${p.id}` : `remuxed original`
+ this.player.logger?.log(`Track #${track} switched to ${ps}`)
+ }
}
function profile_byterate(p?: EncodingProfile, fallback = 0): number {