diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-16 15:15:20 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-16 15:15:20 +0100 |
commit | 079fbf62ad125cfe69853c0bf543db7225d41020 (patch) | |
tree | 1445daa006936ad83edef1b217f05a9dc43e33bc /web | |
parent | abe663807337faa717f9485b047c8f0e808f2a09 (diff) | |
download | jellything-079fbf62ad125cfe69853c0bf543db7225d41020.tar jellything-079fbf62ad125cfe69853c0bf543db7225d41020.tar.bz2 jellything-079fbf62ad125cfe69853c0bf543db7225d41020.tar.zst |
dont leak media paths, fix jsp profile selection and add small hack to accept relative timestamps from transcoding
Diffstat (limited to 'web')
-rw-r--r-- | web/script/player/mediacaps.ts | 6 | ||||
-rw-r--r-- | web/script/player/profiles.ts | 5 | ||||
-rw-r--r-- | web/script/player/track/mse.ts | 3 |
3 files changed, 9 insertions, 5 deletions
diff --git a/web/script/player/mediacaps.ts b/web/script/player/mediacaps.ts index 61ad398..e44b92b 100644 --- a/web/script/player/mediacaps.ts +++ b/web/script/player/mediacaps.ts @@ -107,9 +107,9 @@ const FFMPEG_ENCODER_CODEC_MAP: { [key: string]: string } = { export type TrackKind = "audio" | "video" | "subtitles" export function get_track_kind(track: SourceTrackKind): TrackKind { - //@ts-ignore // TODO clean this mess up please - // TODO why is the subtitle encoded diffenrently sometimes?! - if (track == "subtitles" || track["subtitles"]) return "subtitles" + // TODO why different encodings for "subtitles"? + if (track == "subtitles") return "subtitles" + if ("subtitles" in track) return "subtitles" if ("audio" in track) return "audio" if ("video" in track) return "video" throw new Error("invalid track"); diff --git a/web/script/player/profiles.ts b/web/script/player/profiles.ts index 3344ef6..5ebdeb4 100644 --- a/web/script/player/profiles.ts +++ b/web/script/player/profiles.ts @@ -5,7 +5,8 @@ */ /// <reference lib="dom" /> import { OVar } from "../jshelper/mod.ts"; -import { EncodingProfile } from "./jhls.d.ts"; +import { EncodingProfile, SourceTrackKind } from "./jhls.d.ts"; +import { get_track_kind } from "./mediacaps.ts"; import { profile_to_partial_track, test_media_capability } from "./mediacaps.ts"; import { Player } from "./player.ts"; import { MSEPlayerTrack } from "./track/mse.ts"; @@ -27,6 +28,8 @@ export class ProfileSelector { async init() { for (let id = 0; id < this.track.index!.extra_profiles.length; id++) { const p = this.track.index!.extra_profiles[id]; + // TODO hacky type casting solution + if (get_track_kind(this.track.metadata.kind) != get_track_kind(p as unknown as SourceTrackKind)) continue if (!await test_media_capability(profile_to_partial_track(p))) continue this.profiles.push({ id, order: 0, ...p }) } diff --git a/web/script/player/track/mse.ts b/web/script/player/track/mse.ts index 5d1842f..ec036b4 100644 --- a/web/script/player/track/mse.ts +++ b/web/script/player/track/mse.ts @@ -25,7 +25,7 @@ export class MSEPlayerTrack extends PlayerTrack { private player: Player, private node_id: string, track_index: number, - private metadata: SourceTrack, + public metadata: SourceTrack, ) { super(track_index); this.profile_selector = new ProfileSelector(player, this, player.downloader.bandwidth_avail); @@ -147,6 +147,7 @@ export class MSEPlayerTrack extends PlayerTrack { this.current_load = frag; // TODO why is appending so unreliable?! sometimes it does not add it this.source_buffer.changeType(track_to_content_type(this.track_from_profile())!); + this.source_buffer.timestampOffset = this.profile ? frag.start : 0 console.log(`append track ${this.track_index}`); this.source_buffer.appendBuffer(frag.buf); } |