shaka-player 3.1.4 → 3.3.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/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
- package/.github/ISSUE_TEMPLATE/question.md +1 -1
- package/AUTHORS +6 -5
- package/CHANGELOG.md +363 -0
- package/CONTRIBUTORS +4 -2
- package/README.md +4 -4
- package/build/types/core +3 -0
- package/build/types/offline +1 -0
- package/build/types/polyfill +2 -0
- package/build/types/ui +2 -0
- package/demo/common/asset.js +9 -7
- package/demo/common/assets.js +28 -1
- package/demo/common/message_ids.js +15 -2
- package/demo/config.js +35 -2
- package/demo/index.html +1 -1
- package/demo/locales/en.json +14 -1
- package/demo/locales/source.json +56 -4
- package/demo/main.js +2 -1
- package/dist/controls.css +26 -2
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +24 -21
- package/dist/demo.compiled.debug.map +3 -3
- package/dist/demo.compiled.js +24 -21
- package/dist/demo.compiled.map +3 -3
- package/dist/deps.js +33 -25
- package/dist/locales.js +31 -29
- package/dist/receiver.compiled.debug.js +14 -12
- package/dist/receiver.compiled.debug.map +3 -3
- package/dist/receiver.compiled.js +14 -12
- package/dist/receiver.compiled.map +3 -3
- package/dist/shaka-player.compiled.d.ts +258 -20
- package/dist/shaka-player.compiled.debug.d.ts +258 -20
- package/dist/shaka-player.compiled.debug.externs.js +1005 -695
- package/dist/shaka-player.compiled.debug.js +720 -640
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +1005 -695
- package/dist/shaka-player.compiled.js +850 -817
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +274 -21
- package/dist/shaka-player.ui.debug.d.ts +274 -21
- package/dist/shaka-player.ui.debug.externs.js +766 -429
- package/dist/shaka-player.ui.debug.js +863 -765
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +766 -429
- package/dist/shaka-player.ui.js +1042 -996
- package/dist/shaka-player.ui.map +4 -4
- package/docs/design/bg-fetch-after.gv +29 -0
- package/docs/design/bg-fetch-after.gv.png +0 -0
- package/docs/design/bg-fetch-before.gv +18 -0
- package/docs/design/bg-fetch-before.gv.png +0 -0
- package/docs/design/bg-fetch.md +134 -0
- package/docs/tutorials/blob-url.md +15 -0
- package/docs/tutorials/index.json +1 -0
- package/docs/tutorials/ui-customization.md +66 -0
- package/docs/tutorials/ui.md +5 -5
- package/externs/aria.js +6 -0
- package/externs/ima.js +3 -0
- package/externs/shaka/ads.js +29 -1
- package/externs/shaka/manifest.js +18 -2
- package/externs/shaka/manifest_parser.js +10 -1
- package/externs/shaka/net.js +20 -4
- package/externs/shaka/offline.js +36 -2
- package/externs/shaka/player.js +182 -13
- package/externs/shaka/text.js +24 -10
- package/externs/texttrack.js +3 -0
- package/externs/webcrypto.js +18 -0
- package/lib/abr/ewma.js +14 -0
- package/lib/abr/ewma_bandwidth_estimator.js +16 -2
- package/lib/abr/simple_abr_manager.js +6 -0
- package/lib/ads/ad_manager.js +16 -15
- package/lib/ads/client_side_ad.js +8 -0
- package/lib/ads/client_side_ad_manager.js +14 -6
- package/lib/ads/server_side_ad.js +7 -0
- package/lib/ads/server_side_ad_manager.js +19 -2
- package/lib/cast/cast_proxy.js +8 -0
- package/lib/cast/cast_utils.js +7 -1
- package/lib/cea/cea608_data_channel.js +56 -56
- package/lib/cea/cea608_memory.js +33 -33
- package/lib/cea/cea708_service.js +43 -43
- package/lib/cea/cea708_window.js +38 -38
- package/lib/cea/cea_decoder.js +13 -14
- package/lib/cea/cea_utils.js +23 -23
- package/lib/cea/dtvcc_packet_builder.js +7 -7
- package/lib/cea/i_caption_decoder.js +2 -3
- package/lib/cea/i_cea_parser.js +2 -2
- package/lib/cea/mp4_cea_parser.js +6 -6
- package/lib/dash/dash_parser.js +53 -14
- package/lib/dash/segment_base.js +25 -1
- package/lib/dash/segment_list.js +18 -9
- package/lib/dash/segment_template.js +23 -10
- package/lib/hls/hls_parser.js +210 -30
- package/lib/media/closed_caption_parser.js +1 -2
- package/lib/media/drm_engine.js +162 -192
- package/lib/media/quality_observer.js +291 -0
- package/lib/media/segment_index.js +9 -1
- package/lib/media/segment_reference.js +37 -5
- package/lib/media/streaming_engine.js +48 -10
- package/lib/net/http_fetch_plugin.js +31 -11
- package/lib/net/http_plugin_utils.js +1 -0
- package/lib/net/http_xhr_plugin.js +40 -14
- package/lib/net/networking_engine.js +82 -18
- package/lib/offline/download_info.js +68 -0
- package/lib/offline/download_manager.js +14 -7
- package/lib/offline/indexeddb/base_storage_cell.js +35 -0
- package/lib/offline/indexeddb/storage_mechanism.js +1 -1
- package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
- package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
- package/lib/offline/indexeddb/v5_storage_cell.js +5 -0
- package/lib/offline/manifest_converter.js +3 -1
- package/lib/offline/storage.js +404 -297
- package/lib/offline/stored_content_utils.js +2 -0
- package/lib/player.js +622 -153
- package/lib/polyfill/aria.js +82 -0
- package/lib/polyfill/random_uuid.js +52 -0
- package/lib/routing/walker.js +2 -3
- package/lib/text/cue.js +12 -0
- package/lib/text/srt_text_parser.js +4 -4
- package/lib/text/text_engine.js +2 -2
- package/lib/text/ttml_text_parser.js +25 -2
- package/lib/text/ui_text_displayer.js +2 -2
- package/lib/text/vtt_text_parser.js +2 -2
- package/lib/text/web_vtt_generator.js +55 -12
- package/lib/util/cmcd_manager.js +826 -0
- package/lib/util/error.js +12 -0
- package/lib/util/language_utils.js +12 -0
- package/lib/util/manifest_parser_utils.js +1 -0
- package/lib/util/mp4_box_parsers.js +20 -20
- package/lib/util/multi_map.js +8 -0
- package/lib/util/mutex.js +52 -0
- package/lib/util/periods.js +98 -64
- package/lib/util/player_configuration.js +31 -1
- package/lib/util/stream_utils.js +140 -85
- package/lib/util/xml_utils.js +31 -12
- package/package.json +1 -1
- package/roadmap.md +24 -22
- package/shaka-player.uncompiled.js +4 -0
- package/test/cast/cast_utils_unit.js +1 -0
- package/test/cea/cea608_memory_unit.js +1 -1
- package/test/cea/cea708_service_unit.js +8 -8
- package/test/cea/cea708_window_unit.js +6 -6
- package/test/cea/cea_decoder_unit.js +1 -1
- package/test/cea/dtvcc_packet_builder_unit.js +2 -2
- package/test/dash/dash_parser_content_protection_unit.js +2 -0
- package/test/dash/dash_parser_live_unit.js +101 -1
- package/test/dash/dash_parser_manifest_unit.js +78 -2
- package/test/dash/dash_parser_segment_base_unit.js +2 -0
- package/test/dash/dash_parser_segment_list_unit.js +2 -1
- package/test/dash/dash_parser_segment_template_unit.js +2 -1
- package/test/hls/hls_live_unit.js +2 -0
- package/test/hls/hls_parser_unit.js +252 -0
- package/test/media/drm_engine_integration.js +86 -12
- package/test/media/drm_engine_unit.js +310 -450
- package/test/media/quality_observer_unit.js +139 -0
- package/test/media/segment_reference_unit.js +16 -1
- package/test/media/streaming_engine_integration.js +2 -1
- package/test/media/streaming_engine_unit.js +2 -0
- package/test/net/http_plugin_unit.js +20 -15
- package/test/offline/manifest_convert_unit.js +2 -0
- package/test/offline/storage_integration.js +117 -23
- package/test/player_integration.js +151 -0
- package/test/player_src_equals_integration.js +52 -0
- package/test/player_unit.js +11 -33
- package/test/test/assets/chapters.srt +11 -0
- package/test/test/assets/chapters.vtt +10 -0
- package/test/test/util/cea_utils.js +12 -12
- package/test/test/util/dash_parser_util.js +4 -0
- package/test/test/util/fake_ad.js +7 -0
- package/test/test/util/fake_ad_manager.js +7 -0
- package/test/test/util/fake_drm_engine.js +9 -2
- package/test/test/util/manifest_generator.js +5 -2
- package/test/test/util/manifest_parser_util.js +3 -1
- package/test/test/util/test_scheme.js +14 -1
- package/test/text/ttml_text_parser_unit.js +47 -0
- package/test/text/web_vtt_generator_unit.js +81 -7
- package/test/ui/ui_unit.js +250 -0
- package/test/util/cmcd_manager_unit.js +277 -0
- package/test/util/stream_utils_unit.js +118 -10
- package/ui/airplay_button.js +2 -1
- package/ui/audio_language_selection.js +9 -5
- package/ui/cast_button.js +5 -6
- package/ui/constants.js +0 -3
- package/ui/context_menu.js +109 -0
- package/ui/controls.js +41 -7
- package/ui/controls.less +1 -0
- package/ui/enums.js +4 -0
- package/ui/externs/ui.js +28 -1
- package/ui/fast_forward_button.js +16 -8
- package/ui/fullscreen_button.js +2 -3
- package/ui/language_utils.js +1 -1
- package/ui/less/buttons.less +0 -4
- package/ui/less/containers.less +74 -0
- package/ui/less/overflow_menu.less +0 -10
- package/ui/less/tooltip.less +97 -0
- package/ui/locales/en.json +1 -0
- package/ui/locales/source.json +4 -0
- package/ui/loop_button.js +6 -3
- package/ui/mute_button.js +3 -4
- package/ui/overflow_menu.js +7 -28
- package/ui/pip_button.js +10 -7
- package/ui/play_button.js +2 -2
- package/ui/playback_rate_selection.js +11 -15
- package/ui/presentation_time.js +1 -3
- package/ui/resolution_selection.js +11 -7
- package/ui/rewind_button.js +17 -9
- package/ui/seek_bar.js +6 -6
- package/ui/settings_menu.js +36 -4
- package/ui/small_play_button.js +1 -0
- package/ui/spacer.js +1 -1
- package/ui/statistics_button.js +253 -0
- package/ui/text_selection.js +19 -15
- package/ui/ui.js +30 -0
- package/ui/ui_utils.js +1 -1
- package/ui/volume_bar.js +2 -4
|
@@ -64,6 +64,9 @@ shaka.ads.ServerSideAdManager = class {
|
|
|
64
64
|
/** @private {string} */
|
|
65
65
|
this.backupUrl_ = '';
|
|
66
66
|
|
|
67
|
+
/** @private {!Array.<!shaka.extern.AdCuePoint>} */
|
|
68
|
+
this.currentCuePoints_ = [];
|
|
69
|
+
|
|
67
70
|
/** @private {shaka.util.EventManager} */
|
|
68
71
|
this.eventManager_ = new shaka.util.EventManager();
|
|
69
72
|
|
|
@@ -212,6 +215,7 @@ shaka.ads.ServerSideAdManager = class {
|
|
|
212
215
|
// this.streamManager_.reset();
|
|
213
216
|
this.backupUrl_ = '';
|
|
214
217
|
this.snapForwardTime_ = null;
|
|
218
|
+
this.currentCuePoints_ = [];
|
|
215
219
|
}
|
|
216
220
|
|
|
217
221
|
/** @override */
|
|
@@ -249,6 +253,13 @@ shaka.ads.ServerSideAdManager = class {
|
|
|
249
253
|
}
|
|
250
254
|
}
|
|
251
255
|
|
|
256
|
+
/**
|
|
257
|
+
* @return {!Array.<!shaka.extern.AdCuePoint>}
|
|
258
|
+
*/
|
|
259
|
+
getCuePoints() {
|
|
260
|
+
return this.currentCuePoints_;
|
|
261
|
+
}
|
|
262
|
+
|
|
252
263
|
/**
|
|
253
264
|
* If a seek jumped over the ad break, return to the start of the
|
|
254
265
|
* ad break, then complete the seek after the ad played through.
|
|
@@ -376,13 +387,19 @@ shaka.ads.ServerSideAdManager = class {
|
|
|
376
387
|
onCuePointsChanged_(e) {
|
|
377
388
|
const streamData = e.getStreamData();
|
|
378
389
|
|
|
379
|
-
/** @type {!Array.<!shaka.
|
|
390
|
+
/** @type {!Array.<!shaka.extern.AdCuePoint>} */
|
|
380
391
|
const cuePoints = [];
|
|
381
392
|
for (const point of streamData.cuepoints) {
|
|
382
|
-
|
|
393
|
+
/** @type {shaka.extern.AdCuePoint} */
|
|
394
|
+
const shakaCuePoint = {
|
|
395
|
+
start: point.start,
|
|
396
|
+
end: point.end,
|
|
397
|
+
};
|
|
383
398
|
cuePoints.push(shakaCuePoint);
|
|
384
399
|
}
|
|
385
400
|
|
|
401
|
+
this.currentCuePoints_ = cuePoints;
|
|
402
|
+
|
|
386
403
|
this.onEvent_(new shaka.util.FakeEvent(
|
|
387
404
|
shaka.ads.AdManager.CUEPOINTS_CHANGED,
|
|
388
405
|
(new Map()).set('cuepoints', cuePoints)));
|
package/lib/cast/cast_proxy.js
CHANGED
|
@@ -648,6 +648,14 @@ shaka.cast.CastProxy = class extends shaka.util.FakeEventTarget {
|
|
|
648
648
|
return () => this.localPlayer_.getNetworkingEngine();
|
|
649
649
|
}
|
|
650
650
|
|
|
651
|
+
if (name == 'getDrmEngine') {
|
|
652
|
+
// Always returns a local instance.
|
|
653
|
+
if (this.sender_.isCasting()) {
|
|
654
|
+
shaka.log.warning('NOTE: getDrmEngine() is always local!');
|
|
655
|
+
}
|
|
656
|
+
return () => this.localPlayer_.getDrmEngine();
|
|
657
|
+
}
|
|
658
|
+
|
|
651
659
|
if (name == 'getAdManager') {
|
|
652
660
|
// Always returns a local instance.
|
|
653
661
|
if (this.sender_.isCasting()) {
|
package/lib/cast/cast_utils.js
CHANGED
|
@@ -305,10 +305,11 @@ shaka.cast.CastUtils.PlayerGetterMethods = {
|
|
|
305
305
|
'getAssetUri': 2,
|
|
306
306
|
'getAudioLanguages': 4,
|
|
307
307
|
'getAudioLanguagesAndRoles': 4,
|
|
308
|
+
'getBufferFullness': 1,
|
|
308
309
|
'getBufferedInfo': 2,
|
|
309
310
|
// NOTE: The 'getSharedConfiguration' property is not proxied as it would
|
|
310
311
|
// not be possible to share a reference.
|
|
311
|
-
'getConfiguration':
|
|
312
|
+
'getConfiguration': 4,
|
|
312
313
|
'getExpiration': 2,
|
|
313
314
|
'getKeyStatuses': 2,
|
|
314
315
|
// NOTE: The 'getManifest' property is not proxied, as it is very large.
|
|
@@ -371,10 +372,13 @@ shaka.cast.CastUtils.PlayerInitAfterLoadState = [
|
|
|
371
372
|
* @const {!Array.<string>}
|
|
372
373
|
*/
|
|
373
374
|
shaka.cast.CastUtils.PlayerVoidMethods = [
|
|
375
|
+
'addChaptersTrack',
|
|
374
376
|
'addTextTrack',
|
|
375
377
|
'addTextTrackAsync',
|
|
376
378
|
'cancelTrickPlay',
|
|
377
379
|
'configure',
|
|
380
|
+
'getChapters',
|
|
381
|
+
'getChaptersTracks',
|
|
378
382
|
'resetConfiguration',
|
|
379
383
|
'retryStreaming',
|
|
380
384
|
'selectAudioLanguage',
|
|
@@ -384,6 +388,8 @@ shaka.cast.CastUtils.PlayerVoidMethods = [
|
|
|
384
388
|
'selectVariantsByLabel',
|
|
385
389
|
'setTextTrackVisibility',
|
|
386
390
|
'trickPlay',
|
|
391
|
+
'updateStartTime',
|
|
392
|
+
'goToLive',
|
|
387
393
|
];
|
|
388
394
|
|
|
389
395
|
|
|
@@ -9,7 +9,7 @@ goog.provide('shaka.cea.Cea608DataChannel');
|
|
|
9
9
|
goog.require('shaka.cea.Cea608Memory');
|
|
10
10
|
goog.require('shaka.cea.CeaUtils');
|
|
11
11
|
goog.require('shaka.log');
|
|
12
|
-
goog.requireType('shaka.cea.ICaptionDecoder
|
|
12
|
+
goog.requireType('shaka.cea.ICaptionDecoder');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -17,8 +17,8 @@ goog.requireType('shaka.cea.ICaptionDecoder.ClosedCaption');
|
|
|
17
17
|
*/
|
|
18
18
|
shaka.cea.Cea608DataChannel = class {
|
|
19
19
|
/**
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
20
|
+
* @param {number} fieldNum Field number.
|
|
21
|
+
* @param {number} channelNum Channel number.
|
|
22
22
|
*/
|
|
23
23
|
constructor(fieldNum, channelNum) {
|
|
24
24
|
/**
|
|
@@ -58,7 +58,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* End time of the previous caption, serves as start time of next caption.
|
|
61
|
-
* @private {
|
|
61
|
+
* @private {number}
|
|
62
62
|
*/
|
|
63
63
|
this.prevEndTime_ = 0;
|
|
64
64
|
|
|
@@ -83,9 +83,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Gets the row index from a Preamble Address Code byte pair.
|
|
86
|
-
* @param {
|
|
87
|
-
* @param {
|
|
88
|
-
* @return {
|
|
86
|
+
* @param {number} b1 Byte 1.
|
|
87
|
+
* @param {number} b2 Byte 2.
|
|
88
|
+
* @return {number} Row index.
|
|
89
89
|
* @private
|
|
90
90
|
*/
|
|
91
91
|
pacToRow_(b1, b2) {
|
|
@@ -106,8 +106,8 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
106
106
|
* PAC - Preamble Address Code.
|
|
107
107
|
* b1 is of the form |P|0|0|1|C|0|ROW|
|
|
108
108
|
* b2 is of the form |P|1|N|ATTRIBUTE|U|
|
|
109
|
-
* @param {
|
|
110
|
-
* @param {
|
|
109
|
+
* @param {number} b1 Byte 1.
|
|
110
|
+
* @param {number} b2 Byte 2.
|
|
111
111
|
* @private
|
|
112
112
|
*/
|
|
113
113
|
controlPac_(b1, b2) {
|
|
@@ -165,7 +165,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* Mid-Row control code handler.
|
|
168
|
-
* @param {
|
|
168
|
+
* @param {number} b2 Byte #2.
|
|
169
169
|
* @private
|
|
170
170
|
*/
|
|
171
171
|
controlMidrow_(b2) {
|
|
@@ -198,8 +198,8 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
200
|
* Background attribute control code handler.
|
|
201
|
-
* @param {
|
|
202
|
-
* @param {
|
|
201
|
+
* @param {number} b1 Byte #1
|
|
202
|
+
* @param {number} b2 Byte #2.
|
|
203
203
|
* @private
|
|
204
204
|
*/
|
|
205
205
|
controlBackgroundAttribute_(b1, b2) {
|
|
@@ -279,7 +279,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
279
279
|
* CR only affects scroll windows (Rollup and Text modes).
|
|
280
280
|
* Any currently buffered line needs to be emitted, along
|
|
281
281
|
* with a window scroll action.
|
|
282
|
-
* @param {
|
|
282
|
+
* @param {number} pts in seconds.
|
|
283
283
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
284
284
|
* @private
|
|
285
285
|
*/
|
|
@@ -311,8 +311,8 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
311
311
|
* Handles RU2, RU3, RU4 - Roll-Up, N rows.
|
|
312
312
|
* If in TEXT, POPON or PAINTON, any displayed captions are erased.
|
|
313
313
|
* This means must force emit entire display buffer.
|
|
314
|
-
* @param {
|
|
315
|
-
* @param {
|
|
314
|
+
* @param {number} scrollSize New scroll window size.
|
|
315
|
+
* @param {number} pts
|
|
316
316
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
317
317
|
* @private
|
|
318
318
|
*/
|
|
@@ -356,7 +356,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
356
356
|
* Handles EDM - Erase Displayed Mem
|
|
357
357
|
* Mode check:
|
|
358
358
|
* EDM affects all captioning modes (but not Text mode);
|
|
359
|
-
* @param {
|
|
359
|
+
* @param {number} pts
|
|
360
360
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
361
361
|
* @private
|
|
362
362
|
*/
|
|
@@ -375,7 +375,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
375
375
|
/**
|
|
376
376
|
* Handles RDC - Resume Direct Captions. Initiates Paint-On captioning mode.
|
|
377
377
|
* RDC does not affect current display, so nothing needs to be forced out yet.
|
|
378
|
-
* @param {
|
|
378
|
+
* @param {number} pts in seconds
|
|
379
379
|
* @private
|
|
380
380
|
*/
|
|
381
381
|
controlRdc_(pts) {
|
|
@@ -403,7 +403,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
403
403
|
* Handles EOC - End Of Caption (flip mem)
|
|
404
404
|
* This forces Pop-On mode, and swaps the displayed and nondisplayed memories.
|
|
405
405
|
* @private
|
|
406
|
-
* @param {
|
|
406
|
+
* @param {number} pts
|
|
407
407
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
408
408
|
*/
|
|
409
409
|
controlEoc_(pts) {
|
|
@@ -472,8 +472,8 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
472
472
|
|
|
473
473
|
/**
|
|
474
474
|
* Handles a Basic North American byte pair.
|
|
475
|
-
* @param {
|
|
476
|
-
* @param {
|
|
475
|
+
* @param {number} b1 Byte 1.
|
|
476
|
+
* @param {number} b2 Byte 2.
|
|
477
477
|
*/
|
|
478
478
|
handleBasicNorthAmericanChar(b1, b2) {
|
|
479
479
|
this.curbuf_.addChar(
|
|
@@ -484,8 +484,8 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
484
484
|
|
|
485
485
|
/**
|
|
486
486
|
* Handles an Extended Western European byte pair.
|
|
487
|
-
* @param {
|
|
488
|
-
* @param {
|
|
487
|
+
* @param {number} b1 Byte 1.
|
|
488
|
+
* @param {number} b2 Byte 2.
|
|
489
489
|
* @private
|
|
490
490
|
*/
|
|
491
491
|
handleExtendedWesternEuropeanChar_(b1, b2) {
|
|
@@ -539,9 +539,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
539
539
|
|
|
540
540
|
/**
|
|
541
541
|
* Checks if this is a Miscellaneous control code.
|
|
542
|
-
* @param {
|
|
543
|
-
* @param {
|
|
544
|
-
* @return {
|
|
542
|
+
* @param {number} b1 Byte 1.
|
|
543
|
+
* @param {number} b2 Byte 2.
|
|
544
|
+
* @return {boolean}
|
|
545
545
|
* @private
|
|
546
546
|
*/
|
|
547
547
|
isMiscellaneous_(b1, b2) {
|
|
@@ -553,9 +553,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
553
553
|
|
|
554
554
|
/**
|
|
555
555
|
* Checks if this is a PAC control code.
|
|
556
|
-
* @param {
|
|
557
|
-
* @param {
|
|
558
|
-
* @return {
|
|
556
|
+
* @param {number} b1 Byte 1.
|
|
557
|
+
* @param {number} b2 Byte 2.
|
|
558
|
+
* @return {boolean}
|
|
559
559
|
* @private
|
|
560
560
|
*/
|
|
561
561
|
isPAC_(b1, b2) {
|
|
@@ -567,9 +567,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
567
567
|
|
|
568
568
|
/**
|
|
569
569
|
* Checks if this is a Midrow style change control code.
|
|
570
|
-
* @param {
|
|
571
|
-
* @param {
|
|
572
|
-
* @return {
|
|
570
|
+
* @param {number} b1 Byte 1.
|
|
571
|
+
* @param {number} b2 Byte 2.
|
|
572
|
+
* @return {boolean}
|
|
573
573
|
* @private
|
|
574
574
|
*/
|
|
575
575
|
isMidrowStyleChange_(b1, b2) {
|
|
@@ -581,9 +581,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
581
581
|
|
|
582
582
|
/**
|
|
583
583
|
* Checks if this is a background attribute control code.
|
|
584
|
-
* @param {
|
|
585
|
-
* @param {
|
|
586
|
-
* @return {
|
|
584
|
+
* @param {number} b1 Byte 1.
|
|
585
|
+
* @param {number} b2 Byte 2.
|
|
586
|
+
* @return {boolean}
|
|
587
587
|
* @private
|
|
588
588
|
*/
|
|
589
589
|
isBackgroundAttribute_(b1, b2) {
|
|
@@ -596,9 +596,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
596
596
|
|
|
597
597
|
/**
|
|
598
598
|
* Checks if the character is in the Special North American char. set.
|
|
599
|
-
* @param {
|
|
600
|
-
* @param {
|
|
601
|
-
* @return {
|
|
599
|
+
* @param {number} b1 Byte 1.
|
|
600
|
+
* @param {number} b2 Byte 2.
|
|
601
|
+
* @return {boolean}
|
|
602
602
|
* @private
|
|
603
603
|
*/
|
|
604
604
|
isSpecialNorthAmericanChar_(b1, b2) {
|
|
@@ -610,9 +610,9 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
610
610
|
|
|
611
611
|
/**
|
|
612
612
|
* Checks if the character is in the Extended Western European char. set.
|
|
613
|
-
* @param {
|
|
614
|
-
* @param {
|
|
615
|
-
* @return {
|
|
613
|
+
* @param {number} b1 Byte 1.
|
|
614
|
+
* @param {number} b2 Byte 2.
|
|
615
|
+
* @return {boolean}
|
|
616
616
|
* @private
|
|
617
617
|
*/
|
|
618
618
|
isExtendedWesternEuropeanChar_(b1, b2) {
|
|
@@ -624,8 +624,8 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
624
624
|
|
|
625
625
|
/**
|
|
626
626
|
* Checks if the data contains a control code.
|
|
627
|
-
* @param {
|
|
628
|
-
* @return {
|
|
627
|
+
* @param {number} b1 Byte 1.
|
|
628
|
+
* @return {boolean}
|
|
629
629
|
*/
|
|
630
630
|
static isControlCode(b1) {
|
|
631
631
|
// For control codes, the first byte takes the following form:
|
|
@@ -636,7 +636,7 @@ shaka.cea.Cea608DataChannel = class {
|
|
|
636
636
|
|
|
637
637
|
/**
|
|
638
638
|
* Command codes.
|
|
639
|
-
* @enum {
|
|
639
|
+
* @enum {number}
|
|
640
640
|
* @private
|
|
641
641
|
*/
|
|
642
642
|
shaka.cea.Cea608DataChannel.MiscCmd_ = {
|
|
@@ -691,7 +691,7 @@ shaka.cea.Cea608DataChannel.MiscCmd_ = {
|
|
|
691
691
|
|
|
692
692
|
/**
|
|
693
693
|
* Caption type.
|
|
694
|
-
* @private @const @enum {
|
|
694
|
+
* @private @const @enum {number}
|
|
695
695
|
*/
|
|
696
696
|
shaka.cea.Cea608DataChannel.CaptionType = {
|
|
697
697
|
NONE: 0,
|
|
@@ -702,7 +702,7 @@ shaka.cea.Cea608DataChannel.CaptionType = {
|
|
|
702
702
|
};
|
|
703
703
|
|
|
704
704
|
/**
|
|
705
|
-
* @const {!Array
|
|
705
|
+
* @const {!Array<string>}
|
|
706
706
|
*/
|
|
707
707
|
shaka.cea.Cea608DataChannel.BG_COLORS = [
|
|
708
708
|
'black',
|
|
@@ -716,7 +716,7 @@ shaka.cea.Cea608DataChannel.BG_COLORS = [
|
|
|
716
716
|
];
|
|
717
717
|
|
|
718
718
|
/**
|
|
719
|
-
* @const {!Array
|
|
719
|
+
* @const {!Array<string>}
|
|
720
720
|
*/
|
|
721
721
|
shaka.cea.Cea608DataChannel.TEXT_COLORS = [
|
|
722
722
|
'white',
|
|
@@ -743,20 +743,20 @@ shaka.cea.Cea608DataChannel.Style;
|
|
|
743
743
|
/**
|
|
744
744
|
* CEA closed captions packet.
|
|
745
745
|
* @typedef {{
|
|
746
|
-
* pts:
|
|
747
|
-
* type:
|
|
748
|
-
* ccData1:
|
|
749
|
-
* ccData2:
|
|
750
|
-
* order:
|
|
746
|
+
* pts: number,
|
|
747
|
+
* type: number,
|
|
748
|
+
* ccData1: number,
|
|
749
|
+
* ccData2: number,
|
|
750
|
+
* order: number
|
|
751
751
|
* }}
|
|
752
752
|
*
|
|
753
|
-
* @property {
|
|
753
|
+
* @property {number} pts
|
|
754
754
|
* Presentation timestamp (in second) at which this packet was received.
|
|
755
|
-
* @property {
|
|
755
|
+
* @property {number} type
|
|
756
756
|
* Type of the packet. Either 0 or 1, representing the CEA-608 field.
|
|
757
|
-
* @property {
|
|
758
|
-
* @property {
|
|
759
|
-
* @property {
|
|
757
|
+
* @property {number} ccData1 CEA-608 byte 1.
|
|
758
|
+
* @property {number} ccData2 CEA-608 byte 2.
|
|
759
|
+
* @property {number} order
|
|
760
760
|
* A number indicating the order this packet was received in a sequence
|
|
761
761
|
* of packets. Used to break ties in a stable sorting algorithm
|
|
762
762
|
*/
|
package/lib/cea/cea608_memory.js
CHANGED
|
@@ -8,7 +8,7 @@ goog.provide('shaka.cea.Cea608Memory');
|
|
|
8
8
|
|
|
9
9
|
goog.require('shaka.cea.CeaUtils');
|
|
10
10
|
goog.require('shaka.text.Cue');
|
|
11
|
-
goog.requireType('shaka.cea.ICaptionDecoder
|
|
11
|
+
goog.requireType('shaka.cea.ICaptionDecoder');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -16,8 +16,8 @@ goog.requireType('shaka.cea.ICaptionDecoder.ClosedCaption');
|
|
|
16
16
|
*/
|
|
17
17
|
shaka.cea.Cea608Memory = class {
|
|
18
18
|
/**
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
19
|
+
* @param {number} fieldNum Field number.
|
|
20
|
+
* @param {number} channelNum Channel number.
|
|
21
21
|
*/
|
|
22
22
|
constructor(fieldNum, channelNum) {
|
|
23
23
|
/**
|
|
@@ -28,45 +28,45 @@ shaka.cea.Cea608Memory = class {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Current row.
|
|
31
|
-
* @private {
|
|
31
|
+
* @private {number}
|
|
32
32
|
*/
|
|
33
33
|
this.row_ = 1;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Number of rows in the scroll window. Used for rollup mode.
|
|
37
|
-
* @private {
|
|
37
|
+
* @private {number}
|
|
38
38
|
*/
|
|
39
39
|
this.scrollRows_ = 0;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Field number.
|
|
43
|
-
* @private {
|
|
43
|
+
* @private {number}
|
|
44
44
|
*/
|
|
45
45
|
this.fieldNum_ = fieldNum;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Channel number.
|
|
49
|
-
* @private {
|
|
49
|
+
* @private {number}
|
|
50
50
|
*/
|
|
51
51
|
this.channelNum_ = channelNum;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* @private {
|
|
54
|
+
* @private {boolean}
|
|
55
55
|
*/
|
|
56
56
|
this.underline_ = false;
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* @private {
|
|
59
|
+
* @private {boolean}
|
|
60
60
|
*/
|
|
61
61
|
this.italics_ = false;
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* @private {
|
|
64
|
+
* @private {string}
|
|
65
65
|
*/
|
|
66
66
|
this.textColor_ = shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* @private {
|
|
69
|
+
* @private {string}
|
|
70
70
|
*/
|
|
71
71
|
this.backgroundColor_ = shaka.cea.CeaUtils.DEFAULT_BG_COLOR;
|
|
72
72
|
|
|
@@ -75,8 +75,8 @@ shaka.cea.Cea608Memory = class {
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Emits a closed caption based on the state of the buffer.
|
|
78
|
-
* @param {
|
|
79
|
-
* @param {
|
|
78
|
+
* @param {number} startTime Start time of the cue.
|
|
79
|
+
* @param {number} endTime End time of the cue.
|
|
80
80
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
81
81
|
*/
|
|
82
82
|
forceEmit(startTime, endTime) {
|
|
@@ -96,28 +96,28 @@ shaka.cea.Cea608Memory = class {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* @return {
|
|
99
|
+
* @return {number}
|
|
100
100
|
*/
|
|
101
101
|
getRow() {
|
|
102
102
|
return this.row_;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* @param {
|
|
106
|
+
* @param {number} row
|
|
107
107
|
*/
|
|
108
108
|
setRow(row) {
|
|
109
109
|
this.row_ = row;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
* @return {
|
|
113
|
+
* @return {number}
|
|
114
114
|
*/
|
|
115
115
|
getScrollSize() {
|
|
116
116
|
return this.scrollRows_;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* @param {
|
|
120
|
+
* @param {number} scrollRows
|
|
121
121
|
*/
|
|
122
122
|
setScrollSize(scrollRows) {
|
|
123
123
|
this.scrollRows_ = scrollRows;
|
|
@@ -126,7 +126,7 @@ shaka.cea.Cea608Memory = class {
|
|
|
126
126
|
/**
|
|
127
127
|
* Adds a character to the buffer.
|
|
128
128
|
* @param {!shaka.cea.Cea608Memory.CharSet} set Character set.
|
|
129
|
-
* @param {
|
|
129
|
+
* @param {number} b CC byte to add.
|
|
130
130
|
*/
|
|
131
131
|
addChar(set, b) {
|
|
132
132
|
// Valid chars are in the range [0x20, 0x7f]
|
|
@@ -179,9 +179,9 @@ shaka.cea.Cea608Memory = class {
|
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Moves rows of characters.
|
|
182
|
-
* @param {
|
|
183
|
-
* @param {
|
|
184
|
-
* @param {
|
|
182
|
+
* @param {number} dst Destination row index.
|
|
183
|
+
* @param {number} src Source row index.
|
|
184
|
+
* @param {number} count Count of rows to move.
|
|
185
185
|
*/
|
|
186
186
|
moveRows(dst, src, count) {
|
|
187
187
|
if (dst >= src) {
|
|
@@ -197,8 +197,8 @@ shaka.cea.Cea608Memory = class {
|
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
199
|
* Resets rows of characters.
|
|
200
|
-
* @param {
|
|
201
|
-
* @param {
|
|
200
|
+
* @param {number} idx Starting index.
|
|
201
|
+
* @param {number} count Count of rows to reset.
|
|
202
202
|
*/
|
|
203
203
|
resetRows(idx, count) {
|
|
204
204
|
for (let i = 0; i <= count; i++) {
|
|
@@ -223,28 +223,28 @@ shaka.cea.Cea608Memory = class {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
* @param {
|
|
226
|
+
* @param {boolean} underline
|
|
227
227
|
*/
|
|
228
228
|
setUnderline(underline) {
|
|
229
229
|
this.underline_ = underline;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
/**
|
|
233
|
-
* @param {
|
|
233
|
+
* @param {boolean} italics
|
|
234
234
|
*/
|
|
235
235
|
setItalics(italics) {
|
|
236
236
|
this.italics_ = italics;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
|
-
* @param {
|
|
240
|
+
* @param {string} color
|
|
241
241
|
*/
|
|
242
242
|
setTextColor(color) {
|
|
243
243
|
this.textColor_ = color;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
* @param {
|
|
247
|
+
* @param {string} color
|
|
248
248
|
*/
|
|
249
249
|
setBackgroundColor(color) {
|
|
250
250
|
this.backgroundColor_ = color;
|
|
@@ -253,13 +253,13 @@ shaka.cea.Cea608Memory = class {
|
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* Maximum number of rows in the buffer.
|
|
256
|
-
* @const {
|
|
256
|
+
* @const {number}
|
|
257
257
|
*/
|
|
258
258
|
shaka.cea.Cea608Memory.CC_ROWS = 15;
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
261
|
* Characters sets.
|
|
262
|
-
* @const @enum {
|
|
262
|
+
* @const @enum {number}
|
|
263
263
|
*/
|
|
264
264
|
shaka.cea.Cea608Memory.CharSet = {
|
|
265
265
|
BASIC_NORTH_AMERICAN: 0,
|
|
@@ -270,7 +270,7 @@ shaka.cea.Cea608Memory.CharSet = {
|
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* Basic North American char set deviates from ASCII with these exceptions.
|
|
273
|
-
* @private @const {!Map
|
|
273
|
+
* @private @const {!Map<number, string>}
|
|
274
274
|
*/
|
|
275
275
|
shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars = new Map([
|
|
276
276
|
[0x27, '’'], [0x2a, 'á'], [0x5c, 'é'], [0x5c, 'é'], [0x5e, 'í'], [0x5f, 'ó'],
|
|
@@ -280,7 +280,7 @@ shaka.cea.Cea608Memory.CharSet.BasicNorthAmericanChars = new Map([
|
|
|
280
280
|
/**
|
|
281
281
|
* Special North American char set.
|
|
282
282
|
* Note: Transparent Space is currently implemented as a regular space.
|
|
283
|
-
* @private @const {!Map
|
|
283
|
+
* @private @const {!Map<number, string>}
|
|
284
284
|
*/
|
|
285
285
|
shaka.cea.Cea608Memory.CharSet.SpecialNorthAmericanChars = new Map([
|
|
286
286
|
[0x30, '®'], [0x31, '°'], [0x32, '½'], [0x33, '¿'], [0x34, '™'], [0x35, '¢'],
|
|
@@ -290,7 +290,7 @@ shaka.cea.Cea608Memory.CharSet.SpecialNorthAmericanChars = new Map([
|
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
292
|
* Extended Spanish/Misc/French char set.
|
|
293
|
-
* @private @const {!Map
|
|
293
|
+
* @private @const {!Map<number, string>}
|
|
294
294
|
*/
|
|
295
295
|
shaka.cea.Cea608Memory.CharSet.ExtendedSpanishFrench = new Map([
|
|
296
296
|
[0x20, 'Á'], [0x21, 'É'], [0x22, 'Ó'], [0x23, 'Ú'], [0x24, 'Ü'], [0x25, 'ü'],
|
|
@@ -303,7 +303,7 @@ shaka.cea.Cea608Memory.CharSet.ExtendedSpanishFrench = new Map([
|
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
305
|
* Extended Portuguese/German/Danish char set.
|
|
306
|
-
* @private @const {!Map
|
|
306
|
+
* @private @const {!Map<number, string>}
|
|
307
307
|
*/
|
|
308
308
|
shaka.cea.Cea608Memory.CharSet.ExtendedPortugueseGerman = new Map([
|
|
309
309
|
[0x20, 'Ã'], [0x21, 'ã'], [0x22, 'Í'], [0x23, 'Ì'], [0x24, 'ì'], [0x25, 'Ò'],
|