aboutsummaryrefslogtreecommitdiff
path: root/web/script/player
diff options
context:
space:
mode:
Diffstat (limited to 'web/script/player')
-rw-r--r--web/script/player/mod.ts4
-rw-r--r--web/script/player/player.ts2
-rw-r--r--web/script/player/profiles.ts10
3 files changed, 12 insertions, 4 deletions
diff --git a/web/script/player/mod.ts b/web/script/player/mod.ts
index b170c95..8473280 100644
--- a/web/script/player/mod.ts
+++ b/web/script/player/mod.ts
@@ -66,14 +66,14 @@ function initialize_player(el: HTMLElement, node_id: string) {
const pel = e("div", { class: "jsp" },
player.video,
- show_stats.map(do_show => player.tracks.map(tracks =>
+ show_stats.map(do_show => e("div", player.tracks.map(tracks =>
!do_show ? e("div") : e("div", { class: "jsp-stats" },
player.downloader.bandwidth.map(b => e("pre", `estimated bandwidth: ${show.metric(b, "B/s")} | ${show.metric(b * 8, "b/s")}`)),
...tracks.map((t, i) => t.profile.map(p =>
e("pre", `track ${i}: ` + (p ? `profile ${p.id} (${show_profile(p)})` : `remux`))
))
)
- )),
+ ))),
logger.element,
controls,
)
diff --git a/web/script/player/player.ts b/web/script/player/player.ts
index ff43ce2..4c1d9fc 100644
--- a/web/script/player/player.ts
+++ b/web/script/player/player.ts
@@ -81,7 +81,7 @@ export class Player {
this.duration.value = metadata.duration
this.video.src = URL.createObjectURL(this.media_source)
- this.profile_selector = new ProfileSelector(this.downloader.bandwidth, metadata)
+ this.profile_selector = new ProfileSelector(this, this.downloader.bandwidth, metadata)
this.media_source.addEventListener("sourceopen", async () => {
this.tracks.value.push(new PlayerTrack(this, this.node_id, 0, metadata.tracks[0]))
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 {