Skip to content

Commit

Permalink
assertType is no longer necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheeo committed Sep 10, 2024
1 parent 5ac60ac commit c62c331
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
5 changes: 1 addition & 4 deletions client/src/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {InterjectionPlayer} from "./interjection/Player";
import {BufferControl} from "./live/BufferCtrl";
import {MseWrapper} from "./live/MseWrapper";
import {API} from "live-video-streamer-common";
import {assertType} from "@ckitching/typescript-is";
import {EventDispatcher} from "./EventDispatcher";

/**
Expand Down Expand Up @@ -324,7 +323,6 @@ export class Player extends EventDispatcher<keyof PlayerEventMap, PlayerEventMap
switch (controlChunkType) {
case API.ControlChunkType.jsonObject:
const j = JSON.parse(new TextDecoder().decode(data));
assertType<API.JsonObjectControlChunk>(j);
this.onJsonObject(j);
break;
case API.ControlChunkType.userJsonObject:
Expand Down Expand Up @@ -356,8 +354,7 @@ export class Player extends EventDispatcher<keyof PlayerEventMap, PlayerEventMap
// Fetch the channel index
const channelIndexResponse: Response = await fetch(this.server + channelIndexPath);
if (channelIndexResponse.status === 200) {
const channelIndex: unknown = await channelIndexResponse.json();
assertType<API.ChannelIndex>(channelIndex);
const channelIndex = await channelIndexResponse.json() as API.ChannelIndex;

if (!first && JSON.stringify(this.channelIndex) !== JSON.stringify(this.channelIndex)) {
// The channel index has changed.
Expand Down
3 changes: 0 additions & 3 deletions client/src/interjection/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {MseWrapper} from "./MseWrapper";
import {Interjection, InterjectionSelection} from "./Selection";
import {waitForPts} from "../Util"
import {API, sleep} from "live-video-streamer-common";
import {assertType} from "@ckitching/typescript-is";
import {EventDispatcher} from "../EventDispatcher";
import {PlayerErrorEvent} from "../Player";

Expand Down Expand Up @@ -102,7 +101,6 @@ export class InterjectionPlayer extends EventDispatcher<keyof InterjectionPlayer
this.spawn(async (): Promise<void> => {
// Download the interjection set metadata.
const j = await this.download(`${this.request.setUrl}/interjection-set.json`, "json", "set metadata");
assertType<API.InterjectionSet>(j);
this.interjectionSet = j;

// Select and show the first selection of interjections.
Expand Down Expand Up @@ -286,7 +284,6 @@ export class InterjectionPlayer extends EventDispatcher<keyof InterjectionPlayer
/* Download the interjection metadata. */
const interjectionMetadata = await this.download(`${this.request.setUrl}/${name}/interjection.json`, "json",
"metadata");
assertType<API.Interjection>(interjectionMetadata);

/* Enqueue the downloading of the interjection's streams. */
const numSegments = Math.ceil(interjectionMetadata.contentDuration / interjectionMetadata.segmentDuration);
Expand Down
9 changes: 1 addition & 8 deletions client/src/live/MseWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {TimestampInfo} from "./Deinterleave";
import {API, waitForEvent} from "live-video-streamer-common";
import {assertType} from "@ckitching/typescript-is";
import {SegmentDownloader, ReceivedInfo} from "./SegmentDownloader";
import {getMediaSource} from "../MediaSource";
import {getFullMimeType, Stream, StreamStartEvent} from "../Stream";
Expand Down Expand Up @@ -174,17 +173,11 @@ export class MseWrapper extends EventDispatcher<keyof MseEventMap, MseEventMap>
}
}

private async setupStreams(manifest: string, videoInfo: any, videoInit: ArrayBuffer, audioInfo: any = null,
private async setupStreams(manifest: string, videoInfo: API.SegmentIndexDescriptor, videoInit: ArrayBuffer, audioInfo: any = null,
audioInit: ArrayBuffer | null = null): Promise<void> {
/* Clean up whatever already existed. */
this.cleanup();

/* Validate. */
assertType<API.SegmentIndexDescriptor>(videoInfo);
if (audioInfo !== null) {
assertType<API.SegmentIndexDescriptor>(audioInfo);
}

/* Create afresh. */
this.videoMediaSource = getMediaSource();
this.video.src = URL.createObjectURL(this.videoMediaSource);
Expand Down
4 changes: 1 addition & 3 deletions client/src/live/SegmentDownloader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {API, assertNonNull} from "live-video-streamer-common";
import {Deinterleaver} from "./Deinterleave";
import {Stream} from "../Stream";
import {assertType} from "@ckitching/typescript-is";
import {MseControlChunkEvent, MseEventMap, MseReceivedEvent, MseTimestampEvent} from "./MseWrapper";
import {EventDispatcher} from "../EventDispatcher";
import {PlayerErrorEvent} from "../Player";
Expand Down Expand Up @@ -71,8 +70,7 @@ export class SegmentDownloader extends EventDispatcher<keyof MseEventMap, MseEve
if (response.status !== 200) {
throw new Error(`Fetching stream index descriptor gave HTTP status code ${response.status}`);
}
const newInfo: unknown = await response.json();
assertType<API.SegmentIndexDescriptor>(newInfo);
const newInfo = await response.json();
this.setSegmentDownloadSchedule(newInfo);
} catch (ex: any) {
const e = ex as Error;
Expand Down

0 comments on commit c62c331

Please sign in to comment.