shaka-player 4.7.13 → 4.8.1

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.
Files changed (114) hide show
  1. package/AUTHORS +2 -0
  2. package/CONTRIBUTORS +2 -0
  3. package/LICENSE +54 -0
  4. package/README.md +22 -1
  5. package/dist/controls.css +1 -1
  6. package/dist/controls.css.map +1 -1
  7. package/dist/deps.js +34 -23
  8. package/dist/locales.js +41 -31
  9. package/dist/shaka-player.compiled.d.ts +196 -45
  10. package/dist/shaka-player.compiled.debug.d.ts +196 -45
  11. package/dist/shaka-player.compiled.debug.externs.js +491 -348
  12. package/dist/shaka-player.compiled.debug.js +969 -847
  13. package/dist/shaka-player.compiled.debug.map +4 -4
  14. package/dist/shaka-player.compiled.externs.js +491 -348
  15. package/dist/shaka-player.compiled.js +1238 -1171
  16. package/dist/shaka-player.compiled.map +4 -4
  17. package/dist/shaka-player.ui.d.ts +259 -48
  18. package/dist/shaka-player.ui.debug.d.ts +259 -48
  19. package/dist/shaka-player.ui.debug.externs.js +598 -377
  20. package/dist/shaka-player.ui.debug.js +1185 -980
  21. package/dist/shaka-player.ui.debug.map +4 -4
  22. package/dist/shaka-player.ui.externs.js +598 -377
  23. package/dist/shaka-player.ui.js +1526 -1408
  24. package/dist/shaka-player.ui.map +4 -4
  25. package/externs/device_sensor_event.js +18 -0
  26. package/externs/hisense.js +16 -0
  27. package/externs/playstation.js +31 -0
  28. package/externs/shaka/abr_manager.js +3 -1
  29. package/externs/shaka/ads.js +5 -0
  30. package/externs/shaka/codecs.js +13 -0
  31. package/externs/shaka/manifest.js +58 -6
  32. package/externs/shaka/net.js +13 -1
  33. package/externs/shaka/player.js +184 -13
  34. package/externs/shaka/text.js +19 -0
  35. package/externs/tizen.js +41 -0
  36. package/externs/webos.js +19 -0
  37. package/externs/xbox.js +43 -0
  38. package/lib/abr/simple_abr_manager.js +9 -1
  39. package/lib/ads/ad_manager.js +19 -2
  40. package/lib/ads/client_side_ad_manager.js +5 -3
  41. package/lib/ads/media_tailor_ad_manager.js +9 -0
  42. package/lib/cast/cast_receiver.js +0 -14
  43. package/lib/cast/cast_utils.js +1 -0
  44. package/lib/cea/mp4_cea_parser.js +6 -1
  45. package/lib/dash/content_protection.js +97 -53
  46. package/lib/dash/dash_parser.js +237 -177
  47. package/lib/dash/mpd_utils.js +72 -65
  48. package/lib/dash/segment_base.js +27 -21
  49. package/lib/dash/segment_list.js +18 -16
  50. package/lib/dash/segment_template.js +45 -22
  51. package/lib/hls/hls_parser.js +358 -164
  52. package/lib/media/buffering_observer.js +25 -1
  53. package/lib/media/drm_engine.js +91 -71
  54. package/lib/media/manifest_filterer.js +220 -0
  55. package/lib/media/media_source_engine.js +34 -5
  56. package/lib/media/preload_manager.js +827 -0
  57. package/lib/media/presentation_timeline.js +11 -0
  58. package/lib/media/segment_index.js +93 -47
  59. package/lib/media/segment_prefetch.js +140 -43
  60. package/lib/media/segment_reference.js +43 -8
  61. package/lib/media/segment_utils.js +208 -25
  62. package/lib/media/streaming_engine.js +355 -66
  63. package/lib/mss/content_protection.js +31 -25
  64. package/lib/mss/mss_parser.js +79 -55
  65. package/lib/net/networking_engine.js +49 -4
  66. package/lib/offline/storage.js +3 -3
  67. package/lib/player.js +882 -672
  68. package/lib/polyfill/media_capabilities.js +16 -1
  69. package/lib/text/simple_text_displayer.js +9 -0
  70. package/lib/text/stub_text_displayer.js +7 -0
  71. package/lib/text/text_engine.js +16 -3
  72. package/lib/text/ttml_text_parser.js +116 -114
  73. package/lib/text/ui_text_displayer.js +28 -11
  74. package/lib/text/vtt_text_parser.js +54 -115
  75. package/lib/transmuxer/opus.js +91 -0
  76. package/lib/transmuxer/ts_transmuxer.js +115 -0
  77. package/lib/util/cmcd_manager.js +153 -3
  78. package/lib/util/dom_utils.js +11 -0
  79. package/lib/util/error.js +5 -0
  80. package/lib/util/fake_event.js +2 -0
  81. package/lib/util/manifest_parser_utils.js +97 -3
  82. package/lib/util/mp4_box_parsers.js +346 -17
  83. package/lib/util/mp4_generator.js +23 -0
  84. package/lib/util/periods.js +19 -0
  85. package/lib/util/platform.js +161 -9
  86. package/lib/util/player_configuration.js +79 -13
  87. package/lib/util/stats.js +16 -0
  88. package/lib/util/stream_utils.js +22 -8
  89. package/lib/util/string_utils.js +36 -0
  90. package/lib/util/tXml.js +814 -0
  91. package/lib/util/ts_parser.js +50 -0
  92. package/lib/util/xml_utils.js +10 -338
  93. package/package.json +2 -2
  94. package/shaka-player.uncompiled.js +8 -0
  95. package/ui/controls.js +187 -5
  96. package/ui/enums.js +2 -0
  97. package/ui/externs/ui.js +30 -3
  98. package/ui/gl_matrix/matrix_4x4.js +568 -0
  99. package/ui/gl_matrix/matrix_quaternion.js +45 -0
  100. package/ui/less/containers.less +11 -0
  101. package/ui/locales/en-GB.json +2 -0
  102. package/ui/locales/en.json +2 -0
  103. package/ui/locales/es-419.json +2 -0
  104. package/ui/locales/es.json +2 -0
  105. package/ui/locales/source.json +8 -0
  106. package/ui/recenter_vr.js +126 -0
  107. package/ui/resolution_selection.js +25 -5
  108. package/ui/statistics_button.js +12 -0
  109. package/ui/text_selection.js +1 -1
  110. package/ui/toggle_stereoscopic.js +127 -0
  111. package/ui/ui.js +74 -38
  112. package/ui/vr_manager.js +557 -0
  113. package/ui/vr_utils.js +232 -0
  114. package/ui/vr_webgl.js +697 -0
package/ui/vr_utils.js ADDED
@@ -0,0 +1,232 @@
1
+ /*! @license
2
+ * Shaka Player
3
+ * Copyright 2016 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+
8
+ goog.provide('shaka.ui.VRUtils');
9
+
10
+
11
+ shaka.ui.VRUtils = class {
12
+ /**
13
+ * @param {number} resolution
14
+ * @return {{vertices: !Array.<number>, textureCoords: !Array.<number>,
15
+ * indices: !Array.<number>}}
16
+ */
17
+ static generateSphere(resolution) {
18
+ /** @type {!Array.<number>} */
19
+ const vertices = [];
20
+ /** @type {!Array.<number>} */
21
+ const textureCoords = [];
22
+ /** @type {!Array.<number>} */
23
+ const indices = [];
24
+
25
+ for (let i = 0; i <= resolution; i++) {
26
+ const v = i / resolution;
27
+ const phi = v * Math.PI;
28
+ const sinPhi = Math.sin(phi);
29
+ const cosPhi = Math.cos(phi);
30
+
31
+ for (let j = 0; j <= resolution; j++) {
32
+ const u = j / resolution;
33
+ const theta = u * Math.PI * 2;
34
+
35
+ const sinTheta = Math.sin(theta);
36
+ const cosTheta = Math.cos(theta);
37
+
38
+ const x = -1 * cosTheta * sinPhi;
39
+ const y = cosPhi;
40
+ const z = sinTheta * sinPhi;
41
+
42
+ vertices.push(x, y, z);
43
+
44
+ textureCoords.push(u);
45
+ textureCoords.push(v);
46
+ }
47
+ }
48
+
49
+ for (let i = 0; i < resolution; i++) {
50
+ for (let j = 0; j < resolution; j++) {
51
+ const a = i * (resolution + 1) + j;
52
+ const b = a + 1;
53
+ const c = (i + 1) * (resolution + 1) + j;
54
+ const d = c + 1;
55
+
56
+ indices.push(a, c, b);
57
+ indices.push(b, c, d);
58
+ }
59
+ }
60
+
61
+ return {vertices, textureCoords, indices};
62
+ }
63
+
64
+ /**
65
+ * @return {{vertices: !Array.<number>, textureCoords: !Array.<number>,
66
+ * indices: !Array.<number>}}
67
+ */
68
+ static generateCube() {
69
+ /** @type {!Array.<number>} */
70
+ const vertices = [
71
+ // order : left top back right bottom front
72
+ // Front face 3
73
+ -1.0, -1.0, -1.0,
74
+ -1.0, -1.0, 1.0,
75
+ -1.0, 1.0, 1.0,
76
+ -1.0, 1.0, -1.0,
77
+ // Back face 2
78
+ -1.0, 1.0, -1.0,
79
+ -1.0, 1.0, 1.0,
80
+ 1.0, 1.0, 1.0,
81
+ 1.0, 1.0, -1.0,
82
+ // Top face 6
83
+ -1.0, -1.0, 1.0,
84
+ 1.0, -1.0, 1.0,
85
+ 1.0, 1.0, 1.0,
86
+ -1.0, 1.0, 1.0,
87
+ // Bottom face 1
88
+ 1.0, -1.0, -1.0,
89
+ 1.0, 1.0, -1.0,
90
+ 1.0, 1.0, 1.0,
91
+ 1.0, -1.0, 1.0,
92
+ // Right face 4
93
+ -1.0, -1.0, -1.0,
94
+ 1.0, -1.0, -1.0,
95
+ 1.0, -1.0, 1.0,
96
+ -1.0, -1.0, 1.0,
97
+ // Left face 5
98
+ -1.0, -1.0, -1.0,
99
+ -1.0, 1.0, -1.0,
100
+ 1.0, 1.0, -1.0,
101
+ 1.0, -1.0, -1.0,
102
+ ];
103
+ /** @type {!Array.<number>} */
104
+ const textureCoords = [
105
+ // Left Face
106
+ 2 / 3, 0.5,
107
+ 1 / 3, 0.5,
108
+ 1 / 3, 0.0,
109
+ 2 / 3, 0.0,
110
+ // Top Face
111
+ 2 / 3, 0.5,
112
+ 2 / 3, 0.0,
113
+ 1.0, 0.0,
114
+ 1.0, 0.5,
115
+ // Back Face
116
+ 1.0, 1.0,
117
+ 2 / 3, 1.0,
118
+ 2 / 3, 0.5,
119
+ 1.0, 0.5,
120
+ // Right Face
121
+ 0.0, 0.5,
122
+ 0.0, 0.0,
123
+ 1 / 3, 0.0,
124
+ 1 / 3, 0.5,
125
+ // Bottom Face
126
+ 0.0, 0.5,
127
+ 1 / 3, 0.5,
128
+ 1 / 3, 1.0,
129
+ 0.0, 1.0,
130
+ // Front Face
131
+ 1 / 3, 1.0,
132
+ 1 / 3, 0.5,
133
+ 2 / 3, 0.5,
134
+ 2 / 3, 1.0,
135
+ ];
136
+ /** @type {!Array.<number>} */
137
+ const indices = [
138
+ // Front face
139
+ 0, 1, 2,
140
+ 0, 2, 3,
141
+ // Back face
142
+ 4, 5, 6,
143
+ 4, 6, 7,
144
+ // Top face
145
+ 8, 9, 10,
146
+ 8, 10, 11,
147
+ // Bottom face
148
+ 12, 13, 14,
149
+ 12, 14, 15,
150
+ // Right face
151
+ 16, 17, 18,
152
+ 16, 18, 19,
153
+ // Left face
154
+ 20, 21, 22,
155
+ 20, 22, 23,
156
+ ];
157
+
158
+ return {vertices, textureCoords, indices};
159
+ }
160
+ };
161
+
162
+ /**
163
+ * Sphere vertex shader.
164
+ *
165
+ * @constant {string}
166
+ */
167
+ shaka.ui.VRUtils.VERTEX_SPHERE_SHADER =
168
+ `attribute vec4 a_vPosition;
169
+ // Per-vertex texture coordinate info
170
+ attribute vec2 a_TexCoordinate;
171
+ uniform mat4 u_VPMatrix;
172
+ // Passed into the fragment shader.
173
+ varying vec2 v_TexCoordinate;
174
+ varying vec3 pass_position;
175
+ void main()
176
+ {
177
+ gl_Position = u_VPMatrix * a_vPosition;
178
+ // Pass through texture coord
179
+ v_TexCoordinate = a_TexCoordinate;
180
+ pass_position = a_vPosition.xyz;
181
+ }`;
182
+
183
+ /**
184
+ * Sphere fragment shader.
185
+ *
186
+ * @constant {string}
187
+ */
188
+ shaka.ui.VRUtils.FRAGMENT_SPHERE_SHADER =
189
+ `precision highp float;
190
+ #define PI 3.141592653589793238462643383279
191
+ varying vec2 v_TexCoordinate;
192
+ varying vec3 pass_position;
193
+ uniform sampler2D uSampler;
194
+ void main(void) {
195
+ highp float xValue =
196
+ (PI + atan(pass_position.z, pass_position.x)) / (2.0 * PI);
197
+ vec2 tc = vec2(xValue, v_TexCoordinate.t);
198
+ tc = vec2(tc.x , tc.y);
199
+ highp vec4 texelColor =
200
+ texture2D(uSampler, tc);
201
+ gl_FragColor = vec4(texelColor.rgb, texelColor.a);
202
+ }`;
203
+
204
+ /**
205
+ * Cube vertex shader.
206
+ *
207
+ * @constant {string}
208
+ */
209
+ shaka.ui.VRUtils.VERTEX_CUBE_SHADER =
210
+ `attribute vec4 aVertexPosition;
211
+ attribute vec2 aTextureCoord;
212
+ uniform mat4 uModelViewMatrix;
213
+ uniform mat4 uProjectionMatrix;
214
+ varying highp vec2 vTextureCoord;
215
+ varying highp vec3 vLighting;
216
+ void main(void) {
217
+ gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;
218
+ vTextureCoord = aTextureCoord;
219
+ }`;
220
+
221
+ /**
222
+ * Cube fragment shader.
223
+ *
224
+ * @constant {string}
225
+ */
226
+ shaka.ui.VRUtils.FRAGMENT_CUBE_SHADER =
227
+ `varying highp vec2 vTextureCoord;
228
+ uniform sampler2D uSampler;
229
+ void main(void) {
230
+ highp vec4 texelColor = texture2D(uSampler, vTextureCoord);
231
+ gl_FragColor = vec4(texelColor.rgb , texelColor.a);
232
+ }`;