mediabunny 1.0.6 → 1.1.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/dist/bundles/mediabunny.cjs +68 -9
- package/dist/bundles/mediabunny.min.cjs +3 -3
- package/dist/bundles/mediabunny.min.mjs +3 -3
- package/dist/bundles/mediabunny.mjs +68 -9
- package/dist/mediabunny.d.ts +15 -0
- package/dist/modules/media-sink.d.ts.map +1 -1
- package/dist/modules/media-sink.js +1 -0
- package/dist/modules/sample.d.ts +15 -0
- package/dist/modules/sample.d.ts.map +1 -1
- package/dist/modules/sample.js +70 -10
- package/package.json +1 -1
- package/src/media-sink.ts +1 -0
- package/src/sample.ts +111 -2
|
@@ -7369,18 +7369,52 @@ ${cue.notes ?? ""}`;
|
|
|
7369
7369
|
});
|
|
7370
7370
|
}
|
|
7371
7371
|
}
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7372
|
+
draw(context, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
|
|
7373
|
+
let sx = 0;
|
|
7374
|
+
let sy = 0;
|
|
7375
|
+
let sWidth = this.displayWidth;
|
|
7376
|
+
let sHeight = this.displayHeight;
|
|
7377
|
+
let dx = 0;
|
|
7378
|
+
let dy = 0;
|
|
7379
|
+
let dWidth = this.displayWidth;
|
|
7380
|
+
let dHeight = this.displayHeight;
|
|
7381
|
+
if (arg5 !== void 0) {
|
|
7382
|
+
sx = arg1;
|
|
7383
|
+
sy = arg2;
|
|
7384
|
+
sWidth = arg3;
|
|
7385
|
+
sHeight = arg4;
|
|
7386
|
+
dx = arg5;
|
|
7387
|
+
dy = arg6;
|
|
7388
|
+
if (arg7 !== void 0) {
|
|
7389
|
+
dWidth = arg7;
|
|
7390
|
+
dHeight = arg8;
|
|
7391
|
+
} else {
|
|
7392
|
+
dWidth = sWidth;
|
|
7393
|
+
dHeight = sHeight;
|
|
7394
|
+
}
|
|
7395
|
+
} else {
|
|
7396
|
+
dx = arg1;
|
|
7397
|
+
dy = arg2;
|
|
7398
|
+
if (arg3 !== void 0) {
|
|
7399
|
+
dWidth = arg3;
|
|
7400
|
+
dHeight = arg4;
|
|
7401
|
+
}
|
|
7402
|
+
}
|
|
7381
7403
|
if (!(typeof CanvasRenderingContext2D !== "undefined" && context instanceof CanvasRenderingContext2D || typeof OffscreenCanvasRenderingContext2D !== "undefined" && context instanceof OffscreenCanvasRenderingContext2D)) {
|
|
7382
7404
|
throw new TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");
|
|
7383
7405
|
}
|
|
7406
|
+
if (!Number.isFinite(sx)) {
|
|
7407
|
+
throw new TypeError("sx must be a number.");
|
|
7408
|
+
}
|
|
7409
|
+
if (!Number.isFinite(sy)) {
|
|
7410
|
+
throw new TypeError("sy must be a number.");
|
|
7411
|
+
}
|
|
7412
|
+
if (!Number.isFinite(sWidth) || sWidth < 0) {
|
|
7413
|
+
throw new TypeError("sWidth must be a non-negative number.");
|
|
7414
|
+
}
|
|
7415
|
+
if (!Number.isFinite(sHeight) || sHeight < 0) {
|
|
7416
|
+
throw new TypeError("sHeight must be a non-negative number.");
|
|
7417
|
+
}
|
|
7384
7418
|
if (!Number.isFinite(dx)) {
|
|
7385
7419
|
throw new TypeError("dx must be a number.");
|
|
7386
7420
|
}
|
|
@@ -7396,6 +7430,26 @@ ${cue.notes ?? ""}`;
|
|
|
7396
7430
|
if (this._closed) {
|
|
7397
7431
|
throw new Error("VideoSample is closed.");
|
|
7398
7432
|
}
|
|
7433
|
+
if (this.rotation === 90) {
|
|
7434
|
+
[sx, sy, sWidth, sHeight] = [
|
|
7435
|
+
sy,
|
|
7436
|
+
this.codedHeight - sx - sWidth,
|
|
7437
|
+
sHeight,
|
|
7438
|
+
sWidth
|
|
7439
|
+
];
|
|
7440
|
+
} else if (this.rotation === 180) {
|
|
7441
|
+
[sx, sy] = [
|
|
7442
|
+
this.codedWidth - sx - sWidth,
|
|
7443
|
+
this.codedHeight - sy - sHeight
|
|
7444
|
+
];
|
|
7445
|
+
} else if (this.rotation === 270) {
|
|
7446
|
+
[sx, sy, sWidth, sHeight] = [
|
|
7447
|
+
this.codedWidth - sy - sHeight,
|
|
7448
|
+
sx,
|
|
7449
|
+
sHeight,
|
|
7450
|
+
sWidth
|
|
7451
|
+
];
|
|
7452
|
+
}
|
|
7399
7453
|
const source = this.toCanvasImageSource();
|
|
7400
7454
|
context.save();
|
|
7401
7455
|
const centerX = dx + dWidth / 2;
|
|
@@ -7406,6 +7460,10 @@ ${cue.notes ?? ""}`;
|
|
|
7406
7460
|
context.scale(1 / aspectRatioChange, aspectRatioChange);
|
|
7407
7461
|
context.drawImage(
|
|
7408
7462
|
source,
|
|
7463
|
+
sx,
|
|
7464
|
+
sy,
|
|
7465
|
+
sWidth,
|
|
7466
|
+
sHeight,
|
|
7409
7467
|
-dWidth / 2,
|
|
7410
7468
|
-dHeight / 2,
|
|
7411
7469
|
dWidth,
|
|
@@ -8370,6 +8428,7 @@ ${cue.notes ?? ""}`;
|
|
|
8370
8428
|
finalizeAndEmitSample(sample) {
|
|
8371
8429
|
sample.setTimestamp(Math.round(sample.timestamp * this.timeResolution) / this.timeResolution);
|
|
8372
8430
|
sample.setDuration(Math.round(sample.duration * this.timeResolution) / this.timeResolution);
|
|
8431
|
+
sample.setRotation(this.rotation);
|
|
8373
8432
|
this.onSample(sample);
|
|
8374
8433
|
}
|
|
8375
8434
|
getDecodeQueueSize() {
|