shaka-player 4.7.13 → 4.8.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/AUTHORS +1 -0
- package/CONTRIBUTORS +1 -0
- package/LICENSE +54 -0
- package/README.md +22 -1
- package/dist/controls.css +1 -1
- package/dist/controls.css.map +1 -1
- package/dist/deps.js +34 -23
- package/dist/locales.js +44 -34
- package/dist/shaka-player.compiled.d.ts +194 -44
- package/dist/shaka-player.compiled.debug.d.ts +194 -44
- package/dist/shaka-player.compiled.debug.externs.js +474 -337
- package/dist/shaka-player.compiled.debug.js +949 -832
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +474 -337
- package/dist/shaka-player.compiled.js +1237 -1171
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +257 -47
- package/dist/shaka-player.ui.debug.d.ts +257 -47
- package/dist/shaka-player.ui.debug.externs.js +591 -376
- package/dist/shaka-player.ui.debug.js +1165 -965
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +591 -376
- package/dist/shaka-player.ui.js +1521 -1404
- package/dist/shaka-player.ui.map +4 -4
- package/externs/device_sensor_event.js +18 -0
- package/externs/hisense.js +16 -0
- package/externs/playstation.js +31 -0
- package/externs/shaka/abr_manager.js +3 -1
- package/externs/shaka/ads.js +5 -0
- package/externs/shaka/codecs.js +13 -0
- package/externs/shaka/manifest.js +58 -6
- package/externs/shaka/net.js +13 -1
- package/externs/shaka/player.js +184 -13
- package/externs/shaka/text.js +19 -0
- package/externs/tizen.js +41 -0
- package/externs/webos.js +19 -0
- package/externs/xbox.js +43 -0
- package/lib/abr/simple_abr_manager.js +9 -1
- package/lib/ads/ad_manager.js +19 -2
- package/lib/ads/client_side_ad_manager.js +5 -3
- package/lib/ads/media_tailor_ad_manager.js +9 -0
- package/lib/cast/cast_receiver.js +0 -14
- package/lib/cast/cast_utils.js +1 -0
- package/lib/cea/mp4_cea_parser.js +6 -1
- package/lib/dash/content_protection.js +97 -53
- package/lib/dash/dash_parser.js +230 -176
- package/lib/dash/mpd_utils.js +72 -65
- package/lib/dash/segment_base.js +27 -21
- package/lib/dash/segment_list.js +18 -16
- package/lib/dash/segment_template.js +26 -21
- package/lib/hls/hls_parser.js +358 -164
- package/lib/media/buffering_observer.js +25 -1
- package/lib/media/drm_engine.js +91 -71
- package/lib/media/manifest_filterer.js +220 -0
- package/lib/media/media_source_engine.js +34 -5
- package/lib/media/preload_manager.js +827 -0
- package/lib/media/presentation_timeline.js +11 -0
- package/lib/media/segment_index.js +40 -30
- package/lib/media/segment_prefetch.js +140 -43
- package/lib/media/segment_reference.js +31 -8
- package/lib/media/segment_utils.js +208 -25
- package/lib/media/streaming_engine.js +319 -63
- package/lib/mss/content_protection.js +31 -25
- package/lib/mss/mss_parser.js +74 -55
- package/lib/net/networking_engine.js +49 -4
- package/lib/offline/storage.js +3 -3
- package/lib/player.js +882 -673
- package/lib/polyfill/media_capabilities.js +16 -1
- package/lib/text/simple_text_displayer.js +9 -0
- package/lib/text/stub_text_displayer.js +7 -0
- package/lib/text/text_engine.js +16 -3
- package/lib/text/ttml_text_parser.js +116 -114
- package/lib/text/ui_text_displayer.js +28 -11
- package/lib/text/vtt_text_parser.js +54 -115
- package/lib/transmuxer/opus.js +91 -0
- package/lib/transmuxer/ts_transmuxer.js +115 -0
- package/lib/util/cmcd_manager.js +152 -3
- package/lib/util/dom_utils.js +11 -0
- package/lib/util/error.js +5 -0
- package/lib/util/fake_event.js +2 -0
- package/lib/util/manifest_parser_utils.js +97 -3
- package/lib/util/mp4_box_parsers.js +346 -17
- package/lib/util/mp4_generator.js +23 -0
- package/lib/util/periods.js +19 -0
- package/lib/util/platform.js +161 -9
- package/lib/util/player_configuration.js +61 -3
- package/lib/util/stats.js +16 -0
- package/lib/util/stream_utils.js +16 -6
- package/lib/util/string_utils.js +36 -0
- package/lib/util/tXml.js +814 -0
- package/lib/util/ts_parser.js +50 -0
- package/lib/util/xml_utils.js +10 -338
- package/package.json +2 -2
- package/shaka-player.uncompiled.js +8 -0
- package/ui/controls.js +187 -5
- package/ui/enums.js +2 -0
- package/ui/externs/ui.js +30 -3
- package/ui/gl_matrix/matrix_4x4.js +568 -0
- package/ui/gl_matrix/matrix_quaternion.js +45 -0
- package/ui/less/containers.less +11 -0
- package/ui/locales/en-GB.json +2 -0
- package/ui/locales/en.json +2 -0
- package/ui/locales/es-419.json +2 -0
- package/ui/locales/es.json +2 -0
- package/ui/locales/source.json +8 -0
- package/ui/recenter_vr.js +126 -0
- package/ui/resolution_selection.js +25 -5
- package/ui/statistics_button.js +12 -0
- package/ui/text_selection.js +1 -1
- package/ui/toggle_stereoscopic.js +127 -0
- package/ui/ui.js +74 -38
- package/ui/vr_manager.js +557 -0
- package/ui/vr_utils.js +232 -0
- package/ui/vr_webgl.js +697 -0
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
/*! @license
|
|
2
|
+
* glMatrix: https://github.com/toji/gl-matrix/
|
|
3
|
+
* Copyright 2015-2021, Brandon Jones, Colin MacKenzie IV
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
goog.provide('shaka.ui.Matrix4x4');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 4x4 Matrix
|
|
12
|
+
* Format: column-major, when typed out it looks like row-major
|
|
13
|
+
* The matrices are being post multiplied.
|
|
14
|
+
*/
|
|
15
|
+
shaka.ui.Matrix4x4 = class {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new identity 4x4 Matrix
|
|
18
|
+
*
|
|
19
|
+
* @return {!Float32Array} a new 4x4 matrix
|
|
20
|
+
*/
|
|
21
|
+
static create() {
|
|
22
|
+
const out = new Float32Array(16);
|
|
23
|
+
out[0] = 1;
|
|
24
|
+
out[5] = 1;
|
|
25
|
+
out[10] = 1;
|
|
26
|
+
out[15] = 1;
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generates a look-at matrix with the given eye position, focal point, and
|
|
32
|
+
* up axis.
|
|
33
|
+
*
|
|
34
|
+
* @param {!Float32Array} out 4x4 matrix frustum matrix will be written into
|
|
35
|
+
* @param {!Array.<number>} eye Position of the viewer
|
|
36
|
+
* @param {!Array.<number>} center Point the viewer is looking at
|
|
37
|
+
* @param {!Array.<number>} up Vector pointing up
|
|
38
|
+
*/
|
|
39
|
+
static lookAt(out, eye, center, up) {
|
|
40
|
+
let x0;
|
|
41
|
+
let x1;
|
|
42
|
+
let x2;
|
|
43
|
+
let y0;
|
|
44
|
+
let y1;
|
|
45
|
+
let y2;
|
|
46
|
+
let z0;
|
|
47
|
+
let z1;
|
|
48
|
+
let z2;
|
|
49
|
+
let len;
|
|
50
|
+
const eyex = eye[0];
|
|
51
|
+
const eyey = eye[1];
|
|
52
|
+
const eyez = eye[2];
|
|
53
|
+
const upx = up[0];
|
|
54
|
+
const upy = up[1];
|
|
55
|
+
const upz = up[2];
|
|
56
|
+
const centerx = center[0];
|
|
57
|
+
const centery = center[1];
|
|
58
|
+
const centerz = center[2];
|
|
59
|
+
|
|
60
|
+
if (Math.abs(eyex - centerx) < shaka.ui.Matrix4x4.EPSILON_ &&
|
|
61
|
+
Math.abs(eyey - centery) < shaka.ui.Matrix4x4.EPSILON_ &&
|
|
62
|
+
Math.abs(eyez - centerz) < shaka.ui.Matrix4x4.EPSILON_) {
|
|
63
|
+
return shaka.ui.Matrix4x4.identity_(out);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
z0 = eyex - centerx;
|
|
67
|
+
z1 = eyey - centery;
|
|
68
|
+
z2 = eyez - centerz;
|
|
69
|
+
|
|
70
|
+
len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
|
|
71
|
+
z0 *= len;
|
|
72
|
+
z1 *= len;
|
|
73
|
+
z2 *= len;
|
|
74
|
+
|
|
75
|
+
x0 = upy * z2 - upz * z1;
|
|
76
|
+
x1 = upz * z0 - upx * z2;
|
|
77
|
+
x2 = upx * z1 - upy * z0;
|
|
78
|
+
len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
|
79
|
+
if (!len) {
|
|
80
|
+
x0 = 0;
|
|
81
|
+
x1 = 0;
|
|
82
|
+
x2 = 0;
|
|
83
|
+
} else {
|
|
84
|
+
len = 1 / len;
|
|
85
|
+
x0 *= len;
|
|
86
|
+
x1 *= len;
|
|
87
|
+
x2 *= len;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
y0 = z1 * x2 - z2 * x1;
|
|
91
|
+
y1 = z2 * x0 - z0 * x2;
|
|
92
|
+
y2 = z0 * x1 - z1 * x0;
|
|
93
|
+
|
|
94
|
+
len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
|
|
95
|
+
if (!len) {
|
|
96
|
+
y0 = 0;
|
|
97
|
+
y1 = 0;
|
|
98
|
+
y2 = 0;
|
|
99
|
+
} else {
|
|
100
|
+
len = 1 / len;
|
|
101
|
+
y0 *= len;
|
|
102
|
+
y1 *= len;
|
|
103
|
+
y2 *= len;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
out[0] = x0;
|
|
107
|
+
out[1] = y0;
|
|
108
|
+
out[2] = z0;
|
|
109
|
+
out[3] = 0;
|
|
110
|
+
out[4] = x1;
|
|
111
|
+
out[5] = y1;
|
|
112
|
+
out[6] = z1;
|
|
113
|
+
out[7] = 0;
|
|
114
|
+
out[8] = x2;
|
|
115
|
+
out[9] = y2;
|
|
116
|
+
out[10] = z2;
|
|
117
|
+
out[11] = 0;
|
|
118
|
+
out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
|
|
119
|
+
out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
|
|
120
|
+
out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
|
|
121
|
+
out[15] = 1;
|
|
122
|
+
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Scales the 4x4 matrix by the dimensions in the given vector not using
|
|
128
|
+
* vectorization
|
|
129
|
+
*
|
|
130
|
+
* @param {!Float32Array} out the receiving matrix
|
|
131
|
+
* @param {!Float32Array} a the matrix to scale
|
|
132
|
+
* @param {!Array.<number>} v the vector to scale the matrix by
|
|
133
|
+
*/
|
|
134
|
+
static scale(out, a, v) {
|
|
135
|
+
const x = v[0];
|
|
136
|
+
const y = v[1];
|
|
137
|
+
const z = v[2];
|
|
138
|
+
|
|
139
|
+
out[0] = a[0] * x;
|
|
140
|
+
out[1] = a[1] * x;
|
|
141
|
+
out[2] = a[2] * x;
|
|
142
|
+
out[3] = a[3] * x;
|
|
143
|
+
out[4] = a[4] * y;
|
|
144
|
+
out[5] = a[5] * y;
|
|
145
|
+
out[6] = a[6] * y;
|
|
146
|
+
out[7] = a[7] * y;
|
|
147
|
+
out[8] = a[8] * z;
|
|
148
|
+
out[9] = a[9] * z;
|
|
149
|
+
out[10] = a[10] * z;
|
|
150
|
+
out[11] = a[11] * z;
|
|
151
|
+
out[12] = a[12];
|
|
152
|
+
out[13] = a[13];
|
|
153
|
+
out[14] = a[14];
|
|
154
|
+
out[15] = a[15];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Generates a perspective projection matrix with the given bounds.
|
|
159
|
+
* The near/far clip planes correspond to a normalized device coordinate Z
|
|
160
|
+
* range of [-1, 1], which matches WebGL's clip volume.
|
|
161
|
+
* Passing null/undefined/no value for far will generate infinite projection
|
|
162
|
+
* matrix.
|
|
163
|
+
*
|
|
164
|
+
* @param {!Float32Array} out 4x4 matrix frustum matrix will be written into
|
|
165
|
+
* @param {number} fovy Vertical field of view in radians
|
|
166
|
+
* @param {number} aspect Aspect ratio. typically viewport width/height
|
|
167
|
+
* @param {number} near Near bound of the frustum
|
|
168
|
+
* @param {number} far Far bound of the frustum, can be null or Infinity
|
|
169
|
+
*/
|
|
170
|
+
static perspective(out, fovy, aspect, near, far) {
|
|
171
|
+
const f = 1.0 / Math.tan(fovy / 2);
|
|
172
|
+
out[0] = f / aspect;
|
|
173
|
+
out[1] = 0;
|
|
174
|
+
out[2] = 0;
|
|
175
|
+
out[3] = 0;
|
|
176
|
+
out[4] = 0;
|
|
177
|
+
out[5] = f;
|
|
178
|
+
out[6] = 0;
|
|
179
|
+
out[7] = 0;
|
|
180
|
+
out[8] = 0;
|
|
181
|
+
out[9] = 0;
|
|
182
|
+
out[11] = -1;
|
|
183
|
+
out[12] = 0;
|
|
184
|
+
out[13] = 0;
|
|
185
|
+
out[15] = 0;
|
|
186
|
+
if (far != null && far !== Infinity) {
|
|
187
|
+
const nf = 1 / (near - far);
|
|
188
|
+
out[10] = (far + near) * nf;
|
|
189
|
+
out[14] = 2 * far * near * nf;
|
|
190
|
+
} else {
|
|
191
|
+
out[10] = -1;
|
|
192
|
+
out[14] = -2 * near;
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Multiplies two 4x4 matrix
|
|
199
|
+
*
|
|
200
|
+
* @param {!Float32Array} out the receiving matrix
|
|
201
|
+
* @param {!Float32Array} a the first operand
|
|
202
|
+
* @param {!Float32Array} b the second operand
|
|
203
|
+
*/
|
|
204
|
+
static multiply(out, a, b) {
|
|
205
|
+
const a00 = a[0];
|
|
206
|
+
const a01 = a[1];
|
|
207
|
+
const a02 = a[2];
|
|
208
|
+
const a03 = a[3];
|
|
209
|
+
const a10 = a[4];
|
|
210
|
+
const a11 = a[5];
|
|
211
|
+
const a12 = a[6];
|
|
212
|
+
const a13 = a[7];
|
|
213
|
+
const a20 = a[8];
|
|
214
|
+
const a21 = a[9];
|
|
215
|
+
const a22 = a[10];
|
|
216
|
+
const a23 = a[11];
|
|
217
|
+
const a30 = a[12];
|
|
218
|
+
const a31 = a[13];
|
|
219
|
+
const a32 = a[14];
|
|
220
|
+
const a33 = a[15];
|
|
221
|
+
|
|
222
|
+
// Cache only the current line of the second matrix
|
|
223
|
+
let b0 = b[0];
|
|
224
|
+
let b1 = b[1];
|
|
225
|
+
let b2 = b[2];
|
|
226
|
+
let b3 = b[3];
|
|
227
|
+
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
228
|
+
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
229
|
+
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
230
|
+
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
231
|
+
|
|
232
|
+
b0 = b[4];
|
|
233
|
+
b1 = b[5];
|
|
234
|
+
b2 = b[6];
|
|
235
|
+
b3 = b[7];
|
|
236
|
+
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
237
|
+
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
238
|
+
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
239
|
+
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
240
|
+
|
|
241
|
+
b0 = b[8];
|
|
242
|
+
b1 = b[9];
|
|
243
|
+
b2 = b[10];
|
|
244
|
+
b3 = b[11];
|
|
245
|
+
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
246
|
+
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
247
|
+
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
248
|
+
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
249
|
+
|
|
250
|
+
b0 = b[12];
|
|
251
|
+
b1 = b[13];
|
|
252
|
+
b2 = b[14];
|
|
253
|
+
b3 = b[15];
|
|
254
|
+
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
255
|
+
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
256
|
+
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
257
|
+
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Generates a frustum matrix with the given bounds
|
|
262
|
+
*
|
|
263
|
+
* @param {!Float32Array} out 4x4 matrix frustum matrix will be written into
|
|
264
|
+
* @param {number} left Left bound of the frustum
|
|
265
|
+
* @param {number} right Right bound of the frustum
|
|
266
|
+
* @param {number} bottom Bottom bound of the frustum
|
|
267
|
+
* @param {number} top Top bound of the frustum
|
|
268
|
+
* @param {number} near Near bound of the frustum
|
|
269
|
+
* @param {number} far Far bound of the frustum
|
|
270
|
+
*/
|
|
271
|
+
static frustum(out, left, right, bottom, top, near, far) {
|
|
272
|
+
const rl = 1 / (right - left);
|
|
273
|
+
const tb = 1 / (top - bottom);
|
|
274
|
+
const nf = 1 / (near - far);
|
|
275
|
+
out[0] = near * 2 * rl;
|
|
276
|
+
out[1] = 0;
|
|
277
|
+
out[2] = 0;
|
|
278
|
+
out[3] = 0;
|
|
279
|
+
out[4] = 0;
|
|
280
|
+
out[5] = near * 2 * tb;
|
|
281
|
+
out[6] = 0;
|
|
282
|
+
out[7] = 0;
|
|
283
|
+
out[8] = (right + left) * rl;
|
|
284
|
+
out[9] = (top + bottom) * tb;
|
|
285
|
+
out[10] = (far + near) * nf;
|
|
286
|
+
out[11] = -1;
|
|
287
|
+
out[12] = 0;
|
|
288
|
+
out[13] = 0;
|
|
289
|
+
out[14] = far * near * 2 * nf;
|
|
290
|
+
out[15] = 0;
|
|
291
|
+
return out;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Rotates a matrix by the given angle around the X axis
|
|
296
|
+
*
|
|
297
|
+
* @param {!Float32Array} out the receiving matrix
|
|
298
|
+
* @param {!Float32Array} a the matrix to rotate
|
|
299
|
+
* @param {number} rad the angle to rotate the matrix by
|
|
300
|
+
*/
|
|
301
|
+
static rotateX(out, a, rad) {
|
|
302
|
+
const s = Math.sin(rad);
|
|
303
|
+
const c = Math.cos(rad);
|
|
304
|
+
const a10 = a[4];
|
|
305
|
+
const a11 = a[5];
|
|
306
|
+
const a12 = a[6];
|
|
307
|
+
const a13 = a[7];
|
|
308
|
+
const a20 = a[8];
|
|
309
|
+
const a21 = a[9];
|
|
310
|
+
const a22 = a[10];
|
|
311
|
+
const a23 = a[11];
|
|
312
|
+
|
|
313
|
+
if (a !== out) {
|
|
314
|
+
// If the source and destination differ, copy the unchanged rows
|
|
315
|
+
out[0] = a[0];
|
|
316
|
+
out[1] = a[1];
|
|
317
|
+
out[2] = a[2];
|
|
318
|
+
out[3] = a[3];
|
|
319
|
+
out[12] = a[12];
|
|
320
|
+
out[13] = a[13];
|
|
321
|
+
out[14] = a[14];
|
|
322
|
+
out[15] = a[15];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Perform axis-specific matrix multiplication
|
|
326
|
+
out[4] = a10 * c + a20 * s;
|
|
327
|
+
out[5] = a11 * c + a21 * s;
|
|
328
|
+
out[6] = a12 * c + a22 * s;
|
|
329
|
+
out[7] = a13 * c + a23 * s;
|
|
330
|
+
out[8] = a20 * c - a10 * s;
|
|
331
|
+
out[9] = a21 * c - a11 * s;
|
|
332
|
+
out[10] = a22 * c - a12 * s;
|
|
333
|
+
out[11] = a23 * c - a13 * s;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Rotates a matrix by the given angle around the Y axis
|
|
338
|
+
*
|
|
339
|
+
* @param {!Float32Array} out the receiving matrix
|
|
340
|
+
* @param {!Float32Array} a the matrix to rotate
|
|
341
|
+
* @param {number} rad the angle to rotate the matrix by
|
|
342
|
+
*/
|
|
343
|
+
static rotateY(out, a, rad) {
|
|
344
|
+
const s = Math.sin(rad);
|
|
345
|
+
const c = Math.cos(rad);
|
|
346
|
+
const a00 = a[0];
|
|
347
|
+
const a01 = a[1];
|
|
348
|
+
const a02 = a[2];
|
|
349
|
+
const a03 = a[3];
|
|
350
|
+
const a20 = a[8];
|
|
351
|
+
const a21 = a[9];
|
|
352
|
+
const a22 = a[10];
|
|
353
|
+
const a23 = a[11];
|
|
354
|
+
|
|
355
|
+
if (a !== out) {
|
|
356
|
+
// If the source and destination differ, copy the unchanged rows
|
|
357
|
+
out[4] = a[4];
|
|
358
|
+
out[5] = a[5];
|
|
359
|
+
out[6] = a[6];
|
|
360
|
+
out[7] = a[7];
|
|
361
|
+
out[12] = a[12];
|
|
362
|
+
out[13] = a[13];
|
|
363
|
+
out[14] = a[14];
|
|
364
|
+
out[15] = a[15];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// Perform axis-specific matrix multiplication
|
|
368
|
+
out[0] = a00 * c - a20 * s;
|
|
369
|
+
out[1] = a01 * c - a21 * s;
|
|
370
|
+
out[2] = a02 * c - a22 * s;
|
|
371
|
+
out[3] = a03 * c - a23 * s;
|
|
372
|
+
out[8] = a00 * s + a20 * c;
|
|
373
|
+
out[9] = a01 * s + a21 * c;
|
|
374
|
+
out[10] = a02 * s + a22 * c;
|
|
375
|
+
out[11] = a03 * s + a23 * c;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Rotates a matrix by the given angle around the Z axis
|
|
380
|
+
*
|
|
381
|
+
* @param {!Float32Array} out the receiving matrix
|
|
382
|
+
* @param {!Float32Array} a the matrix to rotate
|
|
383
|
+
* @param {number} rad the angle to rotate the matrix by
|
|
384
|
+
*/
|
|
385
|
+
static rotateZ(out, a, rad) {
|
|
386
|
+
const s = Math.sin(rad);
|
|
387
|
+
const c = Math.cos(rad);
|
|
388
|
+
const a00 = a[0];
|
|
389
|
+
const a01 = a[1];
|
|
390
|
+
const a02 = a[2];
|
|
391
|
+
const a03 = a[3];
|
|
392
|
+
const a10 = a[4];
|
|
393
|
+
const a11 = a[5];
|
|
394
|
+
const a12 = a[6];
|
|
395
|
+
const a13 = a[7];
|
|
396
|
+
|
|
397
|
+
if (a !== out) {
|
|
398
|
+
// If the source and destination differ, copy the unchanged last row
|
|
399
|
+
out[8] = a[8];
|
|
400
|
+
out[9] = a[9];
|
|
401
|
+
out[10] = a[10];
|
|
402
|
+
out[11] = a[11];
|
|
403
|
+
out[12] = a[12];
|
|
404
|
+
out[13] = a[13];
|
|
405
|
+
out[14] = a[14];
|
|
406
|
+
out[15] = a[15];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Perform axis-specific matrix multiplication
|
|
410
|
+
out[0] = a00 * c + a10 * s;
|
|
411
|
+
out[1] = a01 * c + a11 * s;
|
|
412
|
+
out[2] = a02 * c + a12 * s;
|
|
413
|
+
out[3] = a03 * c + a13 * s;
|
|
414
|
+
out[4] = a10 * c - a00 * s;
|
|
415
|
+
out[5] = a11 * c - a01 * s;
|
|
416
|
+
out[6] = a12 * c - a02 * s;
|
|
417
|
+
out[7] = a13 * c - a03 * s;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Returns a quaternion representing the rotational component
|
|
422
|
+
* of a transformation matrix. If a matrix is built with
|
|
423
|
+
* fromRotationTranslation, the returned quaternion will be the
|
|
424
|
+
* same as the quaternion originally supplied.
|
|
425
|
+
* @param {!Float32Array} out Quaternion to receive the rotation component
|
|
426
|
+
* @param {!Float32Array} mat Matrix to be decomposed (input)
|
|
427
|
+
*/
|
|
428
|
+
static getRotation(out, mat) {
|
|
429
|
+
const scaling = new Float32Array(3);
|
|
430
|
+
shaka.ui.Matrix4x4.getScaling_(scaling, mat);
|
|
431
|
+
|
|
432
|
+
const is1 = 1 / scaling[0];
|
|
433
|
+
const is2 = 1 / scaling[1];
|
|
434
|
+
const is3 = 1 / scaling[2];
|
|
435
|
+
|
|
436
|
+
const sm11 = mat[0] * is1;
|
|
437
|
+
const sm12 = mat[1] * is2;
|
|
438
|
+
const sm13 = mat[2] * is3;
|
|
439
|
+
const sm21 = mat[4] * is1;
|
|
440
|
+
const sm22 = mat[5] * is2;
|
|
441
|
+
const sm23 = mat[6] * is3;
|
|
442
|
+
const sm31 = mat[8] * is1;
|
|
443
|
+
const sm32 = mat[9] * is2;
|
|
444
|
+
const sm33 = mat[10] * is3;
|
|
445
|
+
|
|
446
|
+
const trace = sm11 + sm22 + sm33;
|
|
447
|
+
let S = 0;
|
|
448
|
+
|
|
449
|
+
if (trace > 0) {
|
|
450
|
+
S = Math.sqrt(trace + 1.0) * 2;
|
|
451
|
+
out[3] = 0.25 * S;
|
|
452
|
+
out[0] = (sm23 - sm32) / S;
|
|
453
|
+
out[1] = (sm31 - sm13) / S;
|
|
454
|
+
out[2] = (sm12 - sm21) / S;
|
|
455
|
+
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
456
|
+
S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
|
|
457
|
+
out[3] = (sm23 - sm32) / S;
|
|
458
|
+
out[0] = 0.25 * S;
|
|
459
|
+
out[1] = (sm12 + sm21) / S;
|
|
460
|
+
out[2] = (sm31 + sm13) / S;
|
|
461
|
+
} else if (sm22 > sm33) {
|
|
462
|
+
S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
|
|
463
|
+
out[3] = (sm31 - sm13) / S;
|
|
464
|
+
out[0] = (sm12 + sm21) / S;
|
|
465
|
+
out[1] = 0.25 * S;
|
|
466
|
+
out[2] = (sm23 + sm32) / S;
|
|
467
|
+
} else {
|
|
468
|
+
S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
|
|
469
|
+
out[3] = (sm12 - sm21) / S;
|
|
470
|
+
out[0] = (sm31 + sm13) / S;
|
|
471
|
+
out[1] = (sm23 + sm32) / S;
|
|
472
|
+
out[2] = 0.25 * S;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return out;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Calculates a 4x4 matrix from the given quaternion
|
|
480
|
+
*
|
|
481
|
+
* @param {!Float32Array} out 4x4 matrix receiving operation result
|
|
482
|
+
* @param {!Float32Array} q Quaternion to create matrix from
|
|
483
|
+
*/
|
|
484
|
+
static fromQuat(out, q) {
|
|
485
|
+
const x = q[0];
|
|
486
|
+
const y = q[1];
|
|
487
|
+
const z = q[2];
|
|
488
|
+
const w = q[3];
|
|
489
|
+
const x2 = x + x;
|
|
490
|
+
const y2 = y + y;
|
|
491
|
+
const z2 = z + z;
|
|
492
|
+
|
|
493
|
+
const xx = x * x2;
|
|
494
|
+
const yx = y * x2;
|
|
495
|
+
const yy = y * y2;
|
|
496
|
+
const zx = z * x2;
|
|
497
|
+
const zy = z * y2;
|
|
498
|
+
const zz = z * z2;
|
|
499
|
+
const wx = w * x2;
|
|
500
|
+
const wy = w * y2;
|
|
501
|
+
const wz = w * z2;
|
|
502
|
+
|
|
503
|
+
out[0] = 1 - yy - zz;
|
|
504
|
+
out[1] = yx + wz;
|
|
505
|
+
out[2] = zx - wy;
|
|
506
|
+
out[3] = 0;
|
|
507
|
+
|
|
508
|
+
out[4] = yx - wz;
|
|
509
|
+
out[5] = 1 - xx - zz;
|
|
510
|
+
out[6] = zy + wx;
|
|
511
|
+
out[7] = 0;
|
|
512
|
+
|
|
513
|
+
out[8] = zx + wy;
|
|
514
|
+
out[9] = zy - wx;
|
|
515
|
+
out[10] = 1 - xx - yy;
|
|
516
|
+
out[11] = 0;
|
|
517
|
+
|
|
518
|
+
out[12] = 0;
|
|
519
|
+
out[13] = 0;
|
|
520
|
+
out[14] = 0;
|
|
521
|
+
out[15] = 1;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Set a 4x4 matrix to the identity matrix
|
|
527
|
+
*
|
|
528
|
+
* @param {!Float32Array} out the receiving matrix
|
|
529
|
+
* @private
|
|
530
|
+
*/
|
|
531
|
+
static identity_(out) {
|
|
532
|
+
for (let i = 0; i < 16; i++) {
|
|
533
|
+
out[i] = (i % 5) == 0 ? 1 : 0;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Returns the scaling factor component of a transformation
|
|
539
|
+
* matrix. If a matrix is built with fromRotationTranslationScale
|
|
540
|
+
* with a normalized Quaternion paramter, the returned vector will be
|
|
541
|
+
* the same as the scaling vector
|
|
542
|
+
* originally supplied.
|
|
543
|
+
* @param {!Float32Array} out Vector to receive scaling factor component
|
|
544
|
+
* @param {!Float32Array} mat Matrix to be decomposed (input)
|
|
545
|
+
* @private
|
|
546
|
+
*/
|
|
547
|
+
static getScaling_(out, mat) {
|
|
548
|
+
const m11 = mat[0];
|
|
549
|
+
const m12 = mat[1];
|
|
550
|
+
const m13 = mat[2];
|
|
551
|
+
const m21 = mat[4];
|
|
552
|
+
const m22 = mat[5];
|
|
553
|
+
const m23 = mat[6];
|
|
554
|
+
const m31 = mat[8];
|
|
555
|
+
const m32 = mat[9];
|
|
556
|
+
const m33 = mat[10];
|
|
557
|
+
|
|
558
|
+
out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);
|
|
559
|
+
out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);
|
|
560
|
+
out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* @const {number}
|
|
566
|
+
* @private
|
|
567
|
+
*/
|
|
568
|
+
shaka.ui.Matrix4x4.EPSILON_ = 0.000001;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*! @license
|
|
2
|
+
* glMatrix: https://github.com/toji/gl-matrix/
|
|
3
|
+
* Copyright 2015-2021, Brandon Jones, Colin MacKenzie IV
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
goog.provide('shaka.ui.MatrixQuaternion');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Quaternion in the format XYZW
|
|
12
|
+
*/
|
|
13
|
+
shaka.ui.MatrixQuaternion = class {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new identity quaternion
|
|
16
|
+
*
|
|
17
|
+
* @return {!Float32Array} a new quaternion
|
|
18
|
+
*/
|
|
19
|
+
static create() {
|
|
20
|
+
const out = new Float32Array(4);
|
|
21
|
+
out[3] = 1;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Normalize a quaternion
|
|
27
|
+
*
|
|
28
|
+
* @param {!Float32Array} out the receiving quaternion
|
|
29
|
+
* @param {!Float32Array} a quaternion to normalize
|
|
30
|
+
*/
|
|
31
|
+
static normalize(out, a) {
|
|
32
|
+
const x = a[0];
|
|
33
|
+
const y = a[1];
|
|
34
|
+
const z = a[2];
|
|
35
|
+
const w = a[3];
|
|
36
|
+
let len = x * x + y * y + z * z + w * w;
|
|
37
|
+
if (len > 0) {
|
|
38
|
+
len = 1 / Math.sqrt(len);
|
|
39
|
+
}
|
|
40
|
+
out[0] = x * len;
|
|
41
|
+
out[1] = y * len;
|
|
42
|
+
out[2] = z * len;
|
|
43
|
+
out[3] = w * len;
|
|
44
|
+
}
|
|
45
|
+
};
|
package/ui/less/containers.less
CHANGED
|
@@ -110,6 +110,17 @@
|
|
|
110
110
|
pointer-events: none;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/* A container for VR
|
|
114
|
+
* Sits inside .shaka-video-container, on top of (Z axis) .shaka-video, and
|
|
115
|
+
* below (Y axis) .shaka-play-button-container. */
|
|
116
|
+
.shaka-vr-canvas-container {
|
|
117
|
+
.overlay-child();
|
|
118
|
+
|
|
119
|
+
/* Make sure pointer events can reach the video element in the case of native
|
|
120
|
+
* controls. */
|
|
121
|
+
pointer-events: none;
|
|
122
|
+
}
|
|
123
|
+
|
|
113
124
|
/* Container for controls positioned at the bottom of the video container:
|
|
114
125
|
* controls button panel and the seek bar. */
|
|
115
126
|
.shaka-bottom-controls {
|
package/ui/locales/en-GB.json
CHANGED
|
@@ -26,11 +26,13 @@
|
|
|
26
26
|
"PICTURE_IN_PICTURE": "Picture-in-picture",
|
|
27
27
|
"PLAY": "Play",
|
|
28
28
|
"PLAYBACK_RATE": "Playback speed",
|
|
29
|
+
"RECENTER_VR": "Recenter",
|
|
29
30
|
"RESOLUTION": "Resolution",
|
|
30
31
|
"REWIND": "Rewind",
|
|
31
32
|
"SEEK": "Seek",
|
|
32
33
|
"SKIP_AD": "Skip ad",
|
|
33
34
|
"SKIP_TO_LIVE": "Skip ahead to live",
|
|
35
|
+
"TOGGLE_STEREOSCOPIC": "Toggle stereoscopic",
|
|
34
36
|
"UNDETERMINED_LANGUAGE": "Undetermined",
|
|
35
37
|
"UNMUTE": "Unmute",
|
|
36
38
|
"UNRECOGNIZED_LANGUAGE": "Unrecognised",
|
package/ui/locales/en.json
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"PLAY": "Play",
|
|
29
29
|
"PLAYBACK_RATE": "Playback speed",
|
|
30
30
|
"QUALITY": "Quality",
|
|
31
|
+
"RECENTER_VR": "Recenter",
|
|
31
32
|
"REPLAY": "Replay",
|
|
32
33
|
"RESOLUTION": "Resolution",
|
|
33
34
|
"REWIND": "Rewind",
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"STATISTICS": "Statistics",
|
|
38
39
|
"SUBTITLE_FORCED": "Forced",
|
|
39
40
|
"SURROUND": "Surround",
|
|
41
|
+
"TOGGLE_STEREOSCOPIC": "Toggle stereoscopic",
|
|
40
42
|
"UNDETERMINED_LANGUAGE": "Undetermined",
|
|
41
43
|
"UNMUTE": "Unmute",
|
|
42
44
|
"UNRECOGNIZED_LANGUAGE": "Unrecognized",
|
package/ui/locales/es-419.json
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"PICTURE_IN_PICTURE": "Pantalla en pantalla",
|
|
27
27
|
"PLAY": "Reproducir",
|
|
28
28
|
"PLAYBACK_RATE": "Velocidad de reproducción",
|
|
29
|
+
"RECENTER_VR": "Recentrar",
|
|
29
30
|
"RESOLUTION": "Resolución",
|
|
30
31
|
"REWIND": "Retroceder",
|
|
31
32
|
"SEEK": "Buscar",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"SKIP_TO_LIVE": "Adelantar hasta la transmisión en vivo",
|
|
34
35
|
"SUBTITLE_FORCED": "Forzado",
|
|
35
36
|
"SURROUND": "Envolvente",
|
|
37
|
+
"TOGGLE_STEREOSCOPIC": "Alternar estereoscópico",
|
|
36
38
|
"UNDETERMINED_LANGUAGE": "Sin especificar",
|
|
37
39
|
"UNMUTE": "Dejar de silenciar",
|
|
38
40
|
"UNRECOGNIZED_LANGUAGE": "No reconocida",
|
package/ui/locales/es.json
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"PICTURE_IN_PICTURE": "Imagen en imagen",
|
|
27
27
|
"PLAY": "Reproducir",
|
|
28
28
|
"PLAYBACK_RATE": "Velocidad de reproducción",
|
|
29
|
+
"RECENTER_VR": "Recentrar",
|
|
29
30
|
"RESOLUTION": "Resolución",
|
|
30
31
|
"REWIND": "Rebobinar",
|
|
31
32
|
"SEEK": "Buscar",
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"SKIP_TO_LIVE": "Ir al vídeo en directo",
|
|
34
35
|
"SUBTITLE_FORCED": "Forzado",
|
|
35
36
|
"SURROUND": "Envolvente",
|
|
37
|
+
"TOGGLE_STEREOSCOPIC": "Alternar estereoscópico",
|
|
36
38
|
"UNDETERMINED_LANGUAGE": "Sin especificar",
|
|
37
39
|
"UNMUTE": "Activar sonido",
|
|
38
40
|
"UNRECOGNIZED_LANGUAGE": "No reconocida",
|
package/ui/locales/source.json
CHANGED
|
@@ -118,6 +118,10 @@
|
|
|
118
118
|
"meaning": "Audio quality",
|
|
119
119
|
"message": "Quality"
|
|
120
120
|
},
|
|
121
|
+
"RECENTER_VR": {
|
|
122
|
+
"description": "Label for a button used to recenter the VR view.",
|
|
123
|
+
"message": "Recenter"
|
|
124
|
+
},
|
|
121
125
|
"REPLAY": {
|
|
122
126
|
"description": "Label for a button used to replay the video in a video player.",
|
|
123
127
|
"message": "Replay"
|
|
@@ -155,6 +159,10 @@
|
|
|
155
159
|
"description": "Label used to identify a audio track that has surround audio.",
|
|
156
160
|
"message": "Surround"
|
|
157
161
|
},
|
|
162
|
+
"TOGGLE_STEREOSCOPIC": {
|
|
163
|
+
"description": "Label for a button that toggle between monoscopic and stereoscopic.",
|
|
164
|
+
"message": "Toggle stereoscopic"
|
|
165
|
+
},
|
|
158
166
|
"UNDETERMINED_LANGUAGE": {
|
|
159
167
|
"description": "Label for a button used to select an audio track whose language is undetermined or unknown.",
|
|
160
168
|
"message": "Undetermined"
|