Skip to content

Commit

Permalink
chore: enable setting new option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nfrederiksen committed Aug 8, 2023
1 parent b548099 commit 0bdf4fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions engine/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface ChannelEngineOpts {
subtitleSliceEndpoint?: string;
useVTTSubtitles?: boolean;
alwaysNewSegments?: boolean;
alwaysMapBandwidthByNearest?: boolean;
diffCompensationRate?: number;
staticDirectory?: string;
averageSegmentDuration?: number;
Expand Down Expand Up @@ -181,6 +182,7 @@ export class ChannelEngine {
private subtitleSliceEndpoint: string;
private useVTTSubtitles: boolean;
private alwaysNewSegments: boolean;
private alwaysMapBandwidthByNearest: boolean;
private defaultSlateUri?: string;
private slateDuration?: number;
private assetMgr: IAssetManager;
Expand Down Expand Up @@ -220,6 +222,10 @@ export class ChannelEngine {
if (options && options.alwaysNewSegments) {
this.alwaysNewSegments = true;
}
this.alwaysMapBandwidthByNearest = false;
if (options && options.alwaysMapBandwidthByNearest) {
this.alwaysMapBandwidthByNearest = true;
}
if (options && options.defaultSlateUri) {
this.defaultSlateUri = options.defaultSlateUri;
this.slateRepetitions = options.slateRepetitions || 10;
Expand Down Expand Up @@ -453,6 +459,7 @@ export class ChannelEngine {
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
useVTTSubtitles: this.useVTTSubtitles,
alwaysNewSegments: options.alwaysNewSegments,
alwaysMapBandwidthByNearest: options.alwaysMapBandwidthByNearest,
noSessionDataTags: options.noSessionDataTags,
playheadDiffThreshold: channel.options && channel.options.playheadDiffThreshold ? channel.options.playheadDiffThreshold : this.streamerOpts.defaultPlayheadDiffThreshold,
maxTickInterval: channel.options && channel.options.maxTickInterval ? channel.options.maxTickInterval : this.streamerOpts.defaultMaxTickInterval,
Expand Down
17 changes: 13 additions & 4 deletions engine/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ class Session {
}
this.isAllowedToClearVodCache = null;
this.alwaysNewSegments = null;
this.alwaysMapBandwidthByNearest = null;
if (config) {
if (config.alwaysNewSegments) {
this.alwaysNewSegments = config.alwaysNewSegments;
}

if (config.alwaysMapBandwidthByNearest) {
this.alwaysMapBandwidthByNearest = config.alwaysMapBandwidthByNearest;
}

if (config.sessionId) {
this._sessionId = config.sessionId;
}
Expand Down Expand Up @@ -1325,7 +1330,8 @@ class Session {
dummySubtitleEndpoint: this.dummySubtitleEndpoint,
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
shouldContainSubtitles: this.use_vtt_subtitles,
expectedSubtitleTracks: this._subtitleTracks
expectedSubtitleTracks: this._subtitleTracks,
alwaysMapBandwidthByNearest: this.alwaysMapBandwidthByNearest
};
newVod = new HLSVod(vodResponse.uri, [], vodResponse.unixTs, vodResponse.offset * 1000, m3u8Header(this._instanceId), hlsOpts);
if (vodResponse.timedMetadata) {
Expand Down Expand Up @@ -1501,7 +1507,8 @@ class Session {
dummySubtitleEndpoint: this.dummySubtitleEndpoint,
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
shouldContainSubtitles: this.use_vtt_subtitles,
expectedSubtitleTracks: this._subtitleTracks
expectedSubtitleTracks: this._subtitleTracks,
alwaysMapBandwidthByNearest: this.alwaysMapBandwidthByNearest
};
newVod = new HLSVod(vodResponse.uri, null, vodResponse.unixTs, vodResponse.offset * 1000, m3u8Header(this._instanceId), hlsOpts);
if (vodResponse.timedMetadata) {
Expand Down Expand Up @@ -1748,7 +1755,8 @@ class Session {
dummySubtitleEndpoint: this.dummySubtitleEndpoint,
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
shouldContainSubtitles: this.use_vtt_subtitles,
expectedSubtitleTracks: this._subtitleTracks
expectedSubtitleTracks: this._subtitleTracks,
alwaysMapBandwidthByNearest: this.alwaysMapBandwidthByNearest
};
const timestamp = Date.now();
hlsVod = new HLSVod(this.slateUri, null, timestamp, null, m3u8Header(this._instanceId), hlsOpts);
Expand Down Expand Up @@ -1847,7 +1855,8 @@ class Session {
dummySubtitleEndpoint: this.dummySubtitleEndpoint,
subtitleSliceEndpoint: this.subtitleSliceEndpoint,
shouldContainSubtitles: this.use_vtt_subtitles,
expectedSubtitleTracks: this._subtitleTracks
expectedSubtitleTracks: this._subtitleTracks,
alwaysMapBandwidthByNearest: this.alwaysMapBandwidthByNearest
};
const timestamp = Date.now();
hlsVod = new HLSVod(nexVodUri, null, timestamp, null, m3u8Header(this._instanceId), hlsOpts);
Expand Down

0 comments on commit 0bdf4fd

Please sign in to comment.