rx-player 3.27.0-dev.2022032800 → 3.27.0
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/CHANGELOG.md +3 -2
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/get_start_date.d.ts +30 -0
- package/dist/_esm5.processed/compat/get_start_date.js +44 -0
- package/dist/_esm5.processed/compat/index.d.ts +2 -1
- package/dist/_esm5.processed/compat/index.js +2 -1
- package/dist/_esm5.processed/config.d.ts +1 -2
- package/dist/_esm5.processed/core/api/public_api.js +25 -25
- package/dist/_esm5.processed/core/segment_buffers/garbage_collector.js +4 -1
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +2 -1
- package/dist/_esm5.processed/core/stream/period/period_stream.js +9 -3
- package/dist/_esm5.processed/core/stream/representation/force_garbage_collection.js +3 -2
- package/dist/_esm5.processed/core/stream/representation/get_buffer_status.d.ts +2 -2
- package/dist/_esm5.processed/core/stream/representation/get_buffer_status.js +9 -3
- package/dist/_esm5.processed/core/stream/representation/get_needed_segments.d.ts +11 -1
- package/dist/_esm5.processed/core/stream/representation/get_needed_segments.js +27 -45
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +6 -4
- package/dist/_esm5.processed/default_config.d.ts +2 -8
- package/dist/_esm5.processed/default_config.js +2 -8
- package/dist/_esm5.processed/transports/dash/add_segment_integrity_checks_to_loader.js +39 -38
- package/dist/_esm5.processed/utils/reference.js +0 -2
- package/dist/_esm5.processed/utils/task_canceller.d.ts +8 -1
- package/dist/_esm5.processed/utils/task_canceller.js +9 -1
- package/dist/rx-player.js +198 -145
- package/dist/rx-player.min.js +1 -1
- package/package.json +1 -1
- package/sonar-project.properties +1 -1
- package/src/compat/get_start_date.ts +48 -0
- package/src/compat/index.ts +2 -0
- package/src/core/api/public_api.ts +23 -27
- package/src/core/segment_buffers/garbage_collector.ts +4 -0
- package/src/core/stream/orchestrator/stream_orchestrator.ts +2 -1
- package/src/core/stream/period/period_stream.ts +9 -4
- package/src/core/stream/representation/force_garbage_collection.ts +4 -1
- package/src/core/stream/representation/get_buffer_status.ts +21 -13
- package/src/core/stream/representation/get_needed_segments.ts +40 -55
- package/src/core/stream/representation/representation_stream.ts +6 -4
- package/src/default_config.ts +20 -27
- package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +41 -44
- package/src/utils/reference.ts +0 -2
- package/src/utils/task_canceller.ts +16 -1
|
@@ -36,53 +36,54 @@ import inferSegmentContainer from "../utils/infer_segment_container";
|
|
|
36
36
|
*/
|
|
37
37
|
export default function addSegmentIntegrityChecks(segmentLoader) {
|
|
38
38
|
return function (url, content, initialCancelSignal, callbacks) {
|
|
39
|
-
return new Promise(function (
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* If the data's seems to be corrupted, cancel the loading task and reject
|
|
48
|
-
* with an `INTEGRITY_ERROR` error.
|
|
49
|
-
* @param {*} data
|
|
50
|
-
*/
|
|
51
|
-
function cancelAndRejectOnBadIntegrity(data) {
|
|
52
|
-
if (!(data instanceof Array) && !(data instanceof Uint8Array) ||
|
|
53
|
-
inferSegmentContainer(content.adaptation.type, content.representation) !== "mp4") {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
checkISOBMFFIntegrity(new Uint8Array(data), content.segment.isInit);
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
unregisterCancelLstnr();
|
|
61
|
-
canceller.cancel();
|
|
62
|
-
rej(err);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
segmentLoader(url, content, canceller.signal, __assign(__assign({}, callbacks), { onNewChunk: function (data) {
|
|
66
|
-
cancelAndRejectOnBadIntegrity(data);
|
|
67
|
-
if (!canceller.isUsed) {
|
|
39
|
+
return new Promise(function (resolve, reject) {
|
|
40
|
+
var requestCanceller = new TaskCanceller({ cancelOn: initialCancelSignal });
|
|
41
|
+
// Reject the `CancellationError` when `requestCanceller`'s signal emits
|
|
42
|
+
// `stopRejectingOnCancel` here is a function allowing to stop this mechanism
|
|
43
|
+
var stopRejectingOnCancel = requestCanceller.signal.register(reject);
|
|
44
|
+
segmentLoader(url, content, requestCanceller.signal, __assign(__assign({}, callbacks), { onNewChunk: function (data) {
|
|
45
|
+
try {
|
|
46
|
+
trowOnIntegrityError(data);
|
|
68
47
|
callbacks.onNewChunk(data);
|
|
69
48
|
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
// Do not reject with a `CancellationError` after cancelling the request
|
|
51
|
+
stopRejectingOnCancel();
|
|
52
|
+
// Cancel the request
|
|
53
|
+
requestCanceller.cancel();
|
|
54
|
+
// Reject with thrown error
|
|
55
|
+
reject(err);
|
|
56
|
+
}
|
|
70
57
|
} })).then(function (info) {
|
|
71
|
-
if (
|
|
58
|
+
if (requestCanceller.isUsed) {
|
|
72
59
|
return;
|
|
73
60
|
}
|
|
74
|
-
|
|
61
|
+
stopRejectingOnCancel();
|
|
75
62
|
if (info.resultType === "segment-loaded") {
|
|
76
|
-
|
|
63
|
+
try {
|
|
64
|
+
trowOnIntegrityError(info.resultData.responseData);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
reject(err);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
77
70
|
}
|
|
78
|
-
|
|
71
|
+
resolve(info);
|
|
79
72
|
}, function (error) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
unregisterCancelLstnr();
|
|
83
|
-
rej(error);
|
|
84
|
-
}
|
|
73
|
+
stopRejectingOnCancel();
|
|
74
|
+
reject(error);
|
|
85
75
|
});
|
|
86
76
|
});
|
|
77
|
+
/**
|
|
78
|
+
* If the data's seems to be corrupted, throws an `INTEGRITY_ERROR` error.
|
|
79
|
+
* @param {*} data
|
|
80
|
+
*/
|
|
81
|
+
function trowOnIntegrityError(data) {
|
|
82
|
+
if (!(data instanceof ArrayBuffer) && !(data instanceof Uint8Array) ||
|
|
83
|
+
inferSegmentContainer(content.adaptation.type, content.representation) !== "mp4") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
checkISOBMFFIntegrity(new Uint8Array(data), content.segment.isInit);
|
|
87
|
+
}
|
|
87
88
|
};
|
|
88
89
|
}
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Observable, } from "rxjs";
|
|
17
|
-
import log from "../log";
|
|
18
17
|
/**
|
|
19
18
|
* Create an `ISharedReference` object encapsulating the mutable `initialValue`
|
|
20
19
|
* value of type T.
|
|
@@ -61,7 +60,6 @@ export function createSharedReference(initialValue) {
|
|
|
61
60
|
throw new Error("Finished shared references cannot be updated");
|
|
62
61
|
}
|
|
63
62
|
else {
|
|
64
|
-
log.error("Finished shared references cannot be updated");
|
|
65
63
|
return;
|
|
66
64
|
}
|
|
67
65
|
}
|
|
@@ -131,8 +131,15 @@ export default class TaskCanceller {
|
|
|
131
131
|
* Creates a new `TaskCanceller`, with its own `CancellationSignal` created
|
|
132
132
|
* as its `signal` provide.
|
|
133
133
|
* You can then pass this property to async task you wish to be cancellable.
|
|
134
|
+
* @param {Object|undefined} options
|
|
134
135
|
*/
|
|
135
|
-
constructor(
|
|
136
|
+
constructor(options?: {
|
|
137
|
+
/**
|
|
138
|
+
* If set the TaskCanceller created here will automatically be triggered
|
|
139
|
+
* when that signal emits.
|
|
140
|
+
*/
|
|
141
|
+
cancelOn?: CancellationSignal | undefined;
|
|
142
|
+
} | undefined);
|
|
136
143
|
/**
|
|
137
144
|
* "Trigger" the `TaskCanceller`, notify through its associated
|
|
138
145
|
* `CancellationSignal` (its `signal` property) that a task should be aborted.
|
|
@@ -132,12 +132,20 @@ var TaskCanceller = /** @class */ (function () {
|
|
|
132
132
|
* Creates a new `TaskCanceller`, with its own `CancellationSignal` created
|
|
133
133
|
* as its `signal` provide.
|
|
134
134
|
* You can then pass this property to async task you wish to be cancellable.
|
|
135
|
+
* @param {Object|undefined} options
|
|
135
136
|
*/
|
|
136
|
-
function TaskCanceller() {
|
|
137
|
+
function TaskCanceller(options) {
|
|
138
|
+
var _this = this;
|
|
137
139
|
var _a = createCancellationFunctions(), trigger = _a[0], register = _a[1];
|
|
138
140
|
this.isUsed = false;
|
|
139
141
|
this._trigger = trigger;
|
|
140
142
|
this.signal = new CancellationSignal(register);
|
|
143
|
+
if ((options === null || options === void 0 ? void 0 : options.cancelOn) !== undefined) {
|
|
144
|
+
var unregisterParent = options.cancelOn.register(function () {
|
|
145
|
+
_this.cancel();
|
|
146
|
+
});
|
|
147
|
+
this.signal.register(unregisterParent);
|
|
148
|
+
}
|
|
141
149
|
}
|
|
142
150
|
/**
|
|
143
151
|
* "Trigger" the `TaskCanceller`, notify through its associated
|