eyevinn-channel-engine 3.0.6 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/engine/session_live.js +18 -4
- package/package.json +1 -1
package/engine/session_live.js
CHANGED
|
@@ -964,8 +964,8 @@ class SessionLive {
|
|
|
964
964
|
// }
|
|
965
965
|
|
|
966
966
|
if (this.pushAmount >= 0) {
|
|
967
|
-
this.lastRequestedMediaSeqRaw = m3u.get("mediaSequence");
|
|
968
|
-
}
|
|
967
|
+
this.lastRequestedMediaSeqRaw = m3u.get("mediaSequence");
|
|
968
|
+
}
|
|
969
969
|
this.targetDuration = m3u.get("targetDuration");
|
|
970
970
|
let amountRemovedDiscSeqs = 0;
|
|
971
971
|
let startIdx = m3u.items.PlaylistItem.length - this.pushAmount;
|
|
@@ -1096,7 +1096,7 @@ class SessionLive {
|
|
|
1096
1096
|
throw new Error("No bandwidth provided");
|
|
1097
1097
|
}
|
|
1098
1098
|
const liveTargetBandwidth = this._findNearestBw(bw, Object.keys(this.mediaManifestURIs));
|
|
1099
|
-
const vodTargetBandwidth = this.
|
|
1099
|
+
const vodTargetBandwidth = this._getNearestBandwidth(bw, Object.keys(this.vodSegments));
|
|
1100
1100
|
debug(`[${this.sessionId}]: Client requesting manifest for bw=(${bw}). Nearest LiveBw=(${liveTargetBandwidth})`);
|
|
1101
1101
|
|
|
1102
1102
|
if (this.blockGenerateManifest) {
|
|
@@ -1219,6 +1219,20 @@ class SessionLive {
|
|
|
1219
1219
|
});
|
|
1220
1220
|
}
|
|
1221
1221
|
|
|
1222
|
+
_getNearestBandwidth(bandwidthToMatch, array) {
|
|
1223
|
+
const sortedBandwidths = array.sort((a, b) => a - b);
|
|
1224
|
+
const exactMatch = sortedBandwidths.find((a) => a == bandwidthToMatch);
|
|
1225
|
+
if (exactMatch) {
|
|
1226
|
+
return exactMatch;
|
|
1227
|
+
}
|
|
1228
|
+
for (let i = 0; i < sortedBandwidths.length; i++) {
|
|
1229
|
+
if (Number(bandwidthToMatch) <= Number(sortedBandwidths[i])) {
|
|
1230
|
+
return sortedBandwidths[i];
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return sortedBandwidths[sortedBandwidths.length - 1];
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1222
1236
|
_getFirstBwWithSegmentsInList(allSegments) {
|
|
1223
1237
|
const bandwidths = Object.keys(allSegments);
|
|
1224
1238
|
for (let i = 0; i < bandwidths.length; i++) {
|
|
@@ -1253,7 +1267,7 @@ class SessionLive {
|
|
|
1253
1267
|
const toKeep = new Set();
|
|
1254
1268
|
let newItem = {};
|
|
1255
1269
|
profiles.forEach((profile) => {
|
|
1256
|
-
let bwToKeep = this.
|
|
1270
|
+
let bwToKeep = this._getNearestBandwidth(profile.bw, Object.keys(this.mediaManifestURIs));
|
|
1257
1271
|
toKeep.add(bwToKeep);
|
|
1258
1272
|
});
|
|
1259
1273
|
toKeep.forEach((bw) => {
|