shaka-player 3.1.3 → 3.2.2
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 +3 -0
- package/CHANGELOG.md +175 -3
- package/CONTRIBUTORS +3 -0
- package/README.md +4 -4
- package/build/generateExterns.js +1 -1
- package/build/types/polyfill +1 -0
- package/demo/common/asset.js +9 -7
- package/demo/common/assets.js +11 -2
- package/demo/common/message_ids.js +2 -1
- package/demo/config.js +5 -2
- package/demo/index.html +1 -1
- package/demo/locales/en.json +2 -1
- package/demo/locales/source.json +8 -4
- package/demo/main.js +2 -1
- package/dist/controls.css +2 -2
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +15 -15
- package/dist/demo.compiled.debug.map +2 -2
- package/dist/demo.compiled.js +15 -15
- package/dist/demo.compiled.map +2 -2
- package/dist/deps.js +22 -21
- package/dist/locales.js +36 -36
- package/dist/receiver.compiled.debug.js +9 -9
- package/dist/receiver.compiled.debug.map +2 -2
- package/dist/receiver.compiled.js +9 -9
- package/dist/receiver.compiled.map +2 -2
- package/dist/shaka-player.compiled.d.ts +58 -10
- package/dist/shaka-player.compiled.debug.d.ts +58 -10
- package/dist/shaka-player.compiled.debug.externs.js +777 -717
- package/dist/shaka-player.compiled.debug.js +639 -607
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +777 -717
- package/dist/shaka-player.compiled.js +826 -819
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +58 -10
- package/dist/shaka-player.ui.debug.d.ts +58 -10
- package/dist/shaka-player.ui.debug.externs.js +529 -469
- package/dist/shaka-player.ui.debug.js +676 -645
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +529 -469
- package/dist/shaka-player.ui.js +963 -955
- package/dist/shaka-player.ui.map +4 -4
- package/docs/tutorials/fairplay.md +1 -1
- package/docs/tutorials/ui.md +5 -5
- package/externs/aria.js +6 -0
- package/externs/shaka/ads.js +24 -1
- package/externs/shaka/manifest.js +6 -1
- package/externs/shaka/offline.js +5 -0
- package/externs/shaka/player.js +53 -9
- package/externs/shaka/text.js +10 -10
- package/externs/texttrack.js +3 -0
- package/karma.conf.js +1 -0
- package/lib/ads/ad_manager.js +16 -15
- package/lib/ads/client_side_ad_manager.js +52 -88
- package/lib/ads/server_side_ad_manager.js +26 -12
- package/lib/cast/cast_proxy.js +11 -2
- package/lib/cast/cast_receiver.js +2 -1
- package/lib/cast/cast_sender.js +2 -2
- package/lib/cast/cast_utils.js +6 -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 +98 -2
- package/lib/dash/segment_list.js +1 -1
- package/lib/dash/segment_template.js +1 -1
- package/lib/hls/hls_parser.js +159 -29
- package/lib/media/closed_caption_parser.js +1 -2
- package/lib/media/drm_engine.js +169 -192
- package/lib/media/gap_jumping_controller.js +4 -2
- package/lib/media/media_source_engine.js +1 -2
- package/lib/media/segment_index.js +3 -1
- package/lib/media/segment_reference.js +19 -2
- package/lib/media/streaming_engine.js +8 -7
- package/lib/net/networking_engine.js +3 -1
- package/lib/offline/download_manager.js +1 -2
- package/lib/offline/indexeddb/v1_storage_cell.js +1 -0
- package/lib/offline/indexeddb/v2_storage_cell.js +1 -0
- package/lib/offline/manifest_converter.js +3 -1
- package/lib/offline/storage.js +12 -14
- package/lib/player.js +437 -167
- package/lib/polyfill/aria.js +82 -0
- package/lib/polyfill/media_capabilities.js +7 -1
- package/lib/polyfill/mediasource.js +6 -0
- package/lib/polyfill/orientation.js +1 -1
- package/lib/polyfill/patchedmediakeys_apple.js +4 -4
- package/lib/polyfill/patchedmediakeys_ms.js +4 -4
- package/lib/polyfill/patchedmediakeys_webkit.js +4 -4
- package/lib/routing/walker.js +2 -3
- package/lib/text/mp4_ttml_parser.js +3 -0
- package/lib/text/srt_text_parser.js +4 -4
- package/lib/text/text_engine.js +16 -4
- package/lib/text/ttml_text_parser.js +5 -0
- package/lib/text/ui_text_displayer.js +85 -37
- package/lib/text/vtt_text_parser.js +2 -2
- package/lib/text/web_vtt_generator.js +55 -12
- package/lib/util/error.js +6 -0
- package/lib/util/fake_event.js +53 -7
- 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/periods.js +4 -1
- package/lib/util/platform.js +13 -1
- package/lib/util/player_configuration.js +13 -1
- package/lib/util/stream_utils.js +153 -85
- package/lib/util/xml_utils.js +31 -12
- package/package.json +1 -1
- package/roadmap.md +24 -22
- package/shaka-player.uncompiled.js +1 -0
- package/test/cast/cast_proxy_unit.js +12 -6
- package/test/cast/cast_utils_unit.js +2 -1
- 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_manifest_unit.js +230 -2
- package/test/hls/hls_parser_unit.js +255 -1
- package/test/media/closed_caption_parser_unit.js +6 -1
- package/test/media/drm_engine_integration.js +86 -12
- package/test/media/drm_engine_unit.js +353 -450
- package/test/offline/manifest_convert_unit.js +2 -0
- package/test/offline/storage_integration.js +9 -19
- package/test/player_integration.js +90 -0
- package/test/player_src_equals_integration.js +52 -0
- package/test/player_unit.js +11 -33
- package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
- package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
- package/test/test/assets/3675/dash_0.mpd +30 -0
- package/test/test/assets/3675/dash_1.mpd +30 -0
- package/test/test/assets/3675/dash_2.mpd +30 -0
- package/test/test/assets/3675/dash_3.mpd +30 -0
- package/test/test/assets/3675/dash_4.mpd +30 -0
- package/test/test/assets/3675/dash_5.mpd +26 -0
- package/test/test/assets/3675/init-stream0.m4s +0 -0
- 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/fake_ad_manager.js +8 -1
- package/test/test/util/manifest_generator.js +2 -0
- package/test/test/util/manifest_parser_util.js +3 -1
- package/test/text/ttml_text_parser_unit.js +9 -0
- package/test/text/ui_text_displayer_unit.js +29 -17
- package/test/text/web_vtt_generator_unit.js +81 -7
- package/test/ui/localization_unit.js +15 -14
- package/test/ui/text_displayer_layout_unit.js +13 -1
- package/test/util/stream_utils_unit.js +153 -10
- package/ui/airplay_button.js +1 -1
- package/ui/audio_language_selection.js +2 -5
- package/ui/cast_button.js +6 -9
- package/ui/constants.js +0 -3
- package/ui/controls.js +4 -6
- package/ui/fast_forward_button.js +2 -3
- package/ui/fullscreen_button.js +1 -3
- package/ui/language_utils.js +1 -1
- package/ui/less/containers.less +3 -7
- package/ui/locales/ru.json +6 -6
- package/ui/localization.js +28 -51
- package/ui/loop_button.js +1 -3
- package/ui/mute_button.js +1 -3
- package/ui/overflow_menu.js +2 -3
- package/ui/pip_button.js +7 -10
- package/ui/playback_rate_selection.js +3 -6
- package/ui/presentation_time.js +1 -3
- package/ui/resolution_selection.js +4 -7
- package/ui/rewind_button.js +2 -3
- package/ui/seek_bar.js +2 -4
- package/ui/spacer.js +1 -1
- package/ui/text_selection.js +8 -11
- package/ui/ui_utils.js +1 -1
- package/ui/volume_bar.js +1 -3
|
@@ -18,12 +18,12 @@ goog.require('shaka.util.Error');
|
|
|
18
18
|
*/
|
|
19
19
|
shaka.cea.Cea708Service = class {
|
|
20
20
|
/**
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {number} serviceNumber
|
|
22
22
|
*/
|
|
23
23
|
constructor(serviceNumber) {
|
|
24
24
|
/**
|
|
25
25
|
* Number for this specific service (1 - 63).
|
|
26
|
-
* @private {
|
|
26
|
+
* @private {number}
|
|
27
27
|
*/
|
|
28
28
|
this.serviceNumber_ = serviceNumber;
|
|
29
29
|
|
|
@@ -84,7 +84,7 @@ shaka.cea.Cea708Service = class {
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* Handles G0 group data.
|
|
87
|
-
* @param {
|
|
87
|
+
* @param {number} controlCode
|
|
88
88
|
* @private
|
|
89
89
|
*/
|
|
90
90
|
handleG0_(controlCode) {
|
|
@@ -102,7 +102,7 @@ shaka.cea.Cea708Service = class {
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Handles G1 group data.
|
|
105
|
-
* @param {
|
|
105
|
+
* @param {number} controlCode
|
|
106
106
|
* @private
|
|
107
107
|
*/
|
|
108
108
|
handleG1_(controlCode) {
|
|
@@ -115,7 +115,7 @@ shaka.cea.Cea708Service = class {
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* Handles G2 group data.
|
|
118
|
-
* @param {
|
|
118
|
+
* @param {number} controlCode
|
|
119
119
|
* @private
|
|
120
120
|
*/
|
|
121
121
|
handleG2_(controlCode) {
|
|
@@ -134,7 +134,7 @@ shaka.cea.Cea708Service = class {
|
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
* Handles G3 group data.
|
|
137
|
-
* @param {
|
|
137
|
+
* @param {number} controlCode
|
|
138
138
|
* @private
|
|
139
139
|
*/
|
|
140
140
|
handleG3_(controlCode) {
|
|
@@ -155,8 +155,8 @@ shaka.cea.Cea708Service = class {
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Handles C0 group data.
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {
|
|
158
|
+
* @param {number} controlCode
|
|
159
|
+
* @param {number} pts
|
|
160
160
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
161
161
|
* @private
|
|
162
162
|
*/
|
|
@@ -206,8 +206,8 @@ shaka.cea.Cea708Service = class {
|
|
|
206
206
|
* Processes C1 group data.
|
|
207
207
|
* These are caption commands.
|
|
208
208
|
* @param {!shaka.cea.DtvccPacket} dtvccPacket
|
|
209
|
-
* @param {
|
|
210
|
-
* @param {
|
|
209
|
+
* @param {number} captionCommand
|
|
210
|
+
* @param {number} pts in seconds
|
|
211
211
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
212
212
|
* @throws {!shaka.util.Error} a possible out-of-range buffer read.
|
|
213
213
|
* @private
|
|
@@ -255,7 +255,7 @@ shaka.cea.Cea708Service = class {
|
|
|
255
255
|
/**
|
|
256
256
|
* Handles C2 group data.
|
|
257
257
|
* @param {!shaka.cea.DtvccPacket} dtvccPacket
|
|
258
|
-
* @param {
|
|
258
|
+
* @param {number} controlCode
|
|
259
259
|
* @private
|
|
260
260
|
*/
|
|
261
261
|
handleC2_(dtvccPacket, controlCode) {
|
|
@@ -273,7 +273,7 @@ shaka.cea.Cea708Service = class {
|
|
|
273
273
|
/**
|
|
274
274
|
* Handles C3 group data.
|
|
275
275
|
* @param {!shaka.cea.DtvccPacket} dtvccPacket
|
|
276
|
-
* @param {
|
|
276
|
+
* @param {number} controlCode
|
|
277
277
|
* @private
|
|
278
278
|
*/
|
|
279
279
|
handleC3_(dtvccPacket, controlCode) {
|
|
@@ -287,7 +287,7 @@ shaka.cea.Cea708Service = class {
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
|
-
* @param {
|
|
290
|
+
* @param {number} windowNum
|
|
291
291
|
* @private
|
|
292
292
|
*/
|
|
293
293
|
setCurrentWindow_(windowNum) {
|
|
@@ -300,8 +300,8 @@ shaka.cea.Cea708Service = class {
|
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
302
|
* Yields each non-null window specified in the 8-bit bitmap.
|
|
303
|
-
* @param {
|
|
304
|
-
* @return {!Iterable
|
|
303
|
+
* @param {number} bitmap 8 bits corresponding to each of the 8 windows.
|
|
304
|
+
* @return {!Iterable.<number>}
|
|
305
305
|
* @private
|
|
306
306
|
*/
|
|
307
307
|
* getSpecifiedWindowIds_(bitmap) {
|
|
@@ -315,8 +315,8 @@ shaka.cea.Cea708Service = class {
|
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
/**
|
|
318
|
-
* @param {
|
|
319
|
-
* @param {
|
|
318
|
+
* @param {number} windowsBitmap
|
|
319
|
+
* @param {number} pts
|
|
320
320
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
321
321
|
* @private
|
|
322
322
|
*/
|
|
@@ -336,8 +336,8 @@ shaka.cea.Cea708Service = class {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
/**
|
|
339
|
-
* @param {
|
|
340
|
-
* @param {
|
|
339
|
+
* @param {number} windowsBitmap
|
|
340
|
+
* @param {number} pts
|
|
341
341
|
* @private
|
|
342
342
|
*/
|
|
343
343
|
displayWindows_(windowsBitmap, pts) {
|
|
@@ -353,8 +353,8 @@ shaka.cea.Cea708Service = class {
|
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
/**
|
|
356
|
-
* @param {
|
|
357
|
-
* @param {
|
|
356
|
+
* @param {number} windowsBitmap
|
|
357
|
+
* @param {number} pts
|
|
358
358
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
359
359
|
* @private
|
|
360
360
|
*/
|
|
@@ -374,8 +374,8 @@ shaka.cea.Cea708Service = class {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
/**
|
|
377
|
-
* @param {
|
|
378
|
-
* @param {
|
|
377
|
+
* @param {number} windowsBitmap
|
|
378
|
+
* @param {number} pts
|
|
379
379
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
380
380
|
* @private
|
|
381
381
|
*/
|
|
@@ -399,8 +399,8 @@ shaka.cea.Cea708Service = class {
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
|
-
* @param {
|
|
403
|
-
* @param {
|
|
402
|
+
* @param {number} windowsBitmap
|
|
403
|
+
* @param {number} pts
|
|
404
404
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
405
405
|
* @private
|
|
406
406
|
*/
|
|
@@ -422,7 +422,7 @@ shaka.cea.Cea708Service = class {
|
|
|
422
422
|
/**
|
|
423
423
|
* Emits anything currently present in any of the windows, and then
|
|
424
424
|
* deletes all windows, cancels all delays, reinitializes the service.
|
|
425
|
-
* @param {
|
|
425
|
+
* @param {number} pts
|
|
426
426
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
427
427
|
* @private
|
|
428
428
|
*/
|
|
@@ -559,8 +559,8 @@ shaka.cea.Cea708Service = class {
|
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
561
|
* @param {!shaka.cea.DtvccPacket} dtvccPacket
|
|
562
|
-
* @param {
|
|
563
|
-
* @param {
|
|
562
|
+
* @param {number} windowNum
|
|
563
|
+
* @param {number} pts
|
|
564
564
|
* @throws {!shaka.util.Error}
|
|
565
565
|
* @private
|
|
566
566
|
*/
|
|
@@ -612,10 +612,10 @@ shaka.cea.Cea708Service = class {
|
|
|
612
612
|
|
|
613
613
|
/**
|
|
614
614
|
* Maps 64 possible CEA-708 colors to 8 CSS colors.
|
|
615
|
-
* @param {
|
|
616
|
-
* @param {
|
|
617
|
-
* @param {
|
|
618
|
-
* @return {
|
|
615
|
+
* @param {number} red value from 0-3
|
|
616
|
+
* @param {number} green value from 0-3
|
|
617
|
+
* @param {number} blue value from 0-3
|
|
618
|
+
* @return {string}
|
|
619
619
|
* @private
|
|
620
620
|
*/
|
|
621
621
|
rgbColorToHex_(red, green, blue) {
|
|
@@ -636,34 +636,34 @@ shaka.cea.Cea708Service = class {
|
|
|
636
636
|
};
|
|
637
637
|
|
|
638
638
|
/**
|
|
639
|
-
* @private @const {
|
|
639
|
+
* @private @const {number}
|
|
640
640
|
*/
|
|
641
641
|
shaka.cea.Cea708Service.ASCII_BACKSPACE = 0x08;
|
|
642
642
|
|
|
643
643
|
/**
|
|
644
|
-
* @private @const {
|
|
644
|
+
* @private @const {number}
|
|
645
645
|
*/
|
|
646
646
|
shaka.cea.Cea708Service.ASCII_FORM_FEED = 0x0c;
|
|
647
647
|
|
|
648
648
|
/**
|
|
649
|
-
* @private @const {
|
|
649
|
+
* @private @const {number}
|
|
650
650
|
*/
|
|
651
651
|
shaka.cea.Cea708Service.ASCII_CARRIAGE_RETURN = 0x0d;
|
|
652
652
|
|
|
653
653
|
/**
|
|
654
|
-
* @private @const {
|
|
654
|
+
* @private @const {number}
|
|
655
655
|
*/
|
|
656
656
|
shaka.cea.Cea708Service.ASCII_HOR_CARRIAGE_RETURN = 0x0e;
|
|
657
657
|
|
|
658
658
|
/**
|
|
659
659
|
* For extended control codes in block_data on CEA-708, byte 1 is 0x10.
|
|
660
|
-
* @private @const {
|
|
660
|
+
* @private @const {number}
|
|
661
661
|
*/
|
|
662
662
|
shaka.cea.Cea708Service.EXT_CEA708_CTRL_CODE_BYTE1 = 0x10;
|
|
663
663
|
|
|
664
664
|
/**
|
|
665
665
|
* Holds characters mapping for bytes that are G2 control codes.
|
|
666
|
-
* @private @const {!Map
|
|
666
|
+
* @private @const {!Map<number, string>}
|
|
667
667
|
*/
|
|
668
668
|
shaka.cea.Cea708Service.G2Charset = new Map([
|
|
669
669
|
[0x20, ' '], [0x21, '\xa0'], [0x25, '…'], [0x2a, 'Š'], [0x2c, 'Œ'],
|
|
@@ -675,7 +675,7 @@ shaka.cea.Cea708Service.G2Charset = new Map([
|
|
|
675
675
|
|
|
676
676
|
/**
|
|
677
677
|
* An array of 8 colors that 64 colors can be quantized to. Order here matters.
|
|
678
|
-
* @private @const {!Array
|
|
678
|
+
* @private @const {!Array<string>}
|
|
679
679
|
*/
|
|
680
680
|
shaka.cea.Cea708Service.Colors = [
|
|
681
681
|
'black', 'blue', 'green', 'cyan',
|
|
@@ -691,12 +691,12 @@ shaka.cea.Cea708Service.Colors = [
|
|
|
691
691
|
* order: number
|
|
692
692
|
* }}
|
|
693
693
|
*
|
|
694
|
-
* @property {
|
|
694
|
+
* @property {number} pts
|
|
695
695
|
* Presentation timestamp (in second) at which this packet was received.
|
|
696
|
-
* @property {
|
|
696
|
+
* @property {number} type
|
|
697
697
|
* Type of the byte. Either 2 or 3, DTVCC Packet Data or a DTVCC Packet Start.
|
|
698
|
-
* @property {
|
|
699
|
-
* @property {
|
|
698
|
+
* @property {number} value The byte containing data relevant to the packet.
|
|
699
|
+
* @property {number} order
|
|
700
700
|
* A number indicating the order this packet was received in a sequence
|
|
701
701
|
* of packets. Used to break ties in a stable sorting algorithm
|
|
702
702
|
*/
|
package/lib/cea/cea708_window.js
CHANGED
|
@@ -18,38 +18,38 @@ goog.require('shaka.util.Functional');
|
|
|
18
18
|
*/
|
|
19
19
|
shaka.cea.Cea708Window = class {
|
|
20
20
|
/**
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {number} windowNum
|
|
22
22
|
*/
|
|
23
23
|
constructor(windowNum) {
|
|
24
24
|
/**
|
|
25
25
|
* A number from 0 - 7 indicating the window number in the
|
|
26
26
|
* service that owns this window.
|
|
27
|
-
* @private {
|
|
27
|
+
* @private {number}
|
|
28
28
|
*/
|
|
29
29
|
this.windowNum_ = windowNum;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Indicates whether this window is visible.
|
|
33
|
-
* @private {
|
|
33
|
+
* @private {boolean}
|
|
34
34
|
*/
|
|
35
35
|
this.visible_ = false;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Indicates whether the horizontal and vertical anchors coordinates specify
|
|
39
39
|
* a percentage of the screen, or physical coordinates on the screen.
|
|
40
|
-
* @private {
|
|
40
|
+
* @private {boolean}
|
|
41
41
|
*/
|
|
42
42
|
this.relativeToggle_ = false;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Horizontal anchor. Loosely corresponds to a WebVTT viewport X anchor.
|
|
46
|
-
* @private {
|
|
46
|
+
* @private {number}
|
|
47
47
|
*/
|
|
48
48
|
this.horizontalAnchor_ = 0;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Vertical anchor. Loosely corresponds to a WebVTT viewport Y anchor.
|
|
52
|
-
* @private {
|
|
52
|
+
* @private {number}
|
|
53
53
|
*/
|
|
54
54
|
this.verticalAnchor_ = 0;
|
|
55
55
|
|
|
@@ -62,19 +62,19 @@ shaka.cea.Cea708Window = class {
|
|
|
62
62
|
* 6________7________8
|
|
63
63
|
* Diagram is valid as per CEA-708-E section 8.4.4.
|
|
64
64
|
* Each of these locations corresponds to a WebVTT region's "region anchor".
|
|
65
|
-
* @private {
|
|
65
|
+
* @private {number}
|
|
66
66
|
*/
|
|
67
67
|
this.anchorId_ = 0;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Indicates the number of rows in this window's buffer/memory.
|
|
71
|
-
* @private {
|
|
71
|
+
* @private {number}
|
|
72
72
|
*/
|
|
73
73
|
this.rowCount_ = 0;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Indicates the number of columns in this window's buffer/memory.
|
|
77
|
-
* @private {
|
|
77
|
+
* @private {number}
|
|
78
78
|
*/
|
|
79
79
|
this.colCount_ = 0;
|
|
80
80
|
|
|
@@ -92,43 +92,43 @@ shaka.cea.Cea708Window = class {
|
|
|
92
92
|
this.memory_ = [];
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* @private {
|
|
95
|
+
* @private {number}
|
|
96
96
|
*/
|
|
97
97
|
this.startTime_ = 0;
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Row that the current pen is pointing at.
|
|
101
|
-
* @private {
|
|
101
|
+
* @private {number}
|
|
102
102
|
*/
|
|
103
103
|
this.row_ = 0;
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Column that the current pen is pointing at.
|
|
107
|
-
* @private {
|
|
107
|
+
* @private {number}
|
|
108
108
|
*/
|
|
109
109
|
this.col_ = 0;
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Indicates whether the current pen position is italicized.
|
|
113
|
-
* @private {
|
|
113
|
+
* @private {boolean}
|
|
114
114
|
*/
|
|
115
115
|
this.italics_ = false;
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* Indicates whether the current pen position is underlined.
|
|
119
|
-
* @private {
|
|
119
|
+
* @private {boolean}
|
|
120
120
|
*/
|
|
121
121
|
this.underline_ = false;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Indicates the text color at the current pen position.
|
|
125
|
-
* @private {
|
|
125
|
+
* @private {string}
|
|
126
126
|
*/
|
|
127
127
|
this.textColor_ = shaka.cea.CeaUtils.DEFAULT_TXT_COLOR;
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
130
|
* Indicates the background color at the current pen position.
|
|
131
|
-
* @private {
|
|
131
|
+
* @private {string}
|
|
132
132
|
*/
|
|
133
133
|
this.backgroundColor_ = shaka.cea.CeaUtils.DEFAULT_BG_COLOR;
|
|
134
134
|
|
|
@@ -141,13 +141,13 @@ shaka.cea.Cea708Window = class {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* @param {
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {
|
|
148
|
-
* @param {
|
|
149
|
-
* @param {
|
|
150
|
-
* @param {
|
|
144
|
+
* @param {boolean} visible
|
|
145
|
+
* @param {number} verticalAnchor
|
|
146
|
+
* @param {number} horizontalAnchor
|
|
147
|
+
* @param {number} anchorId
|
|
148
|
+
* @param {boolean} relativeToggle
|
|
149
|
+
* @param {number} rowCount
|
|
150
|
+
* @param {number} colCount
|
|
151
151
|
*/
|
|
152
152
|
defineWindow(visible, verticalAnchor, horizontalAnchor, anchorId,
|
|
153
153
|
relativeToggle, rowCount, colCount) {
|
|
@@ -185,7 +185,7 @@ shaka.cea.Cea708Window = class {
|
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
187
|
* Sets the unicode value for a char at the current pen location.
|
|
188
|
-
* @param {
|
|
188
|
+
* @param {string} char
|
|
189
189
|
*/
|
|
190
190
|
setCharacter(char) {
|
|
191
191
|
// Check if the pen is out of bounds.
|
|
@@ -238,7 +238,7 @@ shaka.cea.Cea708Window = class {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|
|
241
|
-
* @return {
|
|
241
|
+
* @return {boolean}
|
|
242
242
|
*/
|
|
243
243
|
isVisible() {
|
|
244
244
|
return this.visible_;
|
|
@@ -246,7 +246,7 @@ shaka.cea.Cea708Window = class {
|
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
248
|
* Moves up <count> rows in the buffer.
|
|
249
|
-
* @param {
|
|
249
|
+
* @param {number} count
|
|
250
250
|
* @private
|
|
251
251
|
*/
|
|
252
252
|
moveUpRows_(count) {
|
|
@@ -286,8 +286,8 @@ shaka.cea.Cea708Window = class {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
|
-
* @param {
|
|
290
|
-
* @param {
|
|
289
|
+
* @param {number} endTime
|
|
290
|
+
* @param {number} serviceNumber Number of the service emitting this caption.
|
|
291
291
|
* @return {?shaka.cea.ICaptionDecoder.ClosedCaption}
|
|
292
292
|
*/
|
|
293
293
|
forceEmit(endTime, serviceNumber) {
|
|
@@ -318,8 +318,8 @@ shaka.cea.Cea708Window = class {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
/**
|
|
321
|
-
* @param {
|
|
322
|
-
* @param {
|
|
321
|
+
* @param {number} row
|
|
322
|
+
* @param {number} col
|
|
323
323
|
*/
|
|
324
324
|
setPenLocation(row, col) {
|
|
325
325
|
this.row_ = row;
|
|
@@ -327,28 +327,28 @@ shaka.cea.Cea708Window = class {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
/**
|
|
330
|
-
* @param {
|
|
330
|
+
* @param {string} backgroundColor
|
|
331
331
|
*/
|
|
332
332
|
setPenBackgroundColor(backgroundColor) {
|
|
333
333
|
this.backgroundColor_ = backgroundColor;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
|
-
* @param {
|
|
337
|
+
* @param {string} textColor
|
|
338
338
|
*/
|
|
339
339
|
setPenTextColor(textColor) {
|
|
340
340
|
this.textColor_ = textColor;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
/**
|
|
344
|
-
* @param {
|
|
344
|
+
* @param {boolean} underline
|
|
345
345
|
*/
|
|
346
346
|
setPenUnderline(underline) {
|
|
347
347
|
this.underline_ = underline;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
/**
|
|
351
|
-
* @param {
|
|
351
|
+
* @param {boolean} italics
|
|
352
352
|
*/
|
|
353
353
|
setPenItalics(italics) {
|
|
354
354
|
this.italics_ = italics;
|
|
@@ -394,7 +394,7 @@ shaka.cea.Cea708Window = class {
|
|
|
394
394
|
|
|
395
395
|
/**
|
|
396
396
|
* Sets the start time for the cue to be emitted.
|
|
397
|
-
* @param {
|
|
397
|
+
* @param {number} pts
|
|
398
398
|
*/
|
|
399
399
|
setStartTime(pts) {
|
|
400
400
|
this.startTime_ = pts;
|
|
@@ -403,7 +403,7 @@ shaka.cea.Cea708Window = class {
|
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
405
|
* Caption type.
|
|
406
|
-
* @const @enum {
|
|
406
|
+
* @const @enum {number}
|
|
407
407
|
*/
|
|
408
408
|
shaka.cea.Cea708Window.TextJustification = {
|
|
409
409
|
LEFT: 0,
|
|
@@ -415,12 +415,12 @@ shaka.cea.Cea708Window.TextJustification = {
|
|
|
415
415
|
/**
|
|
416
416
|
* Can be indexed 0-31 for 4:3 format, and 0-41 for 16:9 formats.
|
|
417
417
|
* Thus the absolute maximum is 42 columns for the 16:9 format.
|
|
418
|
-
* @private @const {
|
|
418
|
+
* @private @const {number}
|
|
419
419
|
*/
|
|
420
420
|
shaka.cea.Cea708Window.MAX_COLS = 42;
|
|
421
421
|
|
|
422
422
|
/**
|
|
423
423
|
* Maximum of 15 rows that can be indexed from 0 to 14.
|
|
424
|
-
* @private @const {
|
|
424
|
+
* @private @const {number}
|
|
425
425
|
*/
|
|
426
426
|
shaka.cea.Cea708Window.MAX_ROWS = 15;
|
package/lib/cea/cea_decoder.js
CHANGED
|
@@ -6,15 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
goog.provide('shaka.cea.CeaDecoder');
|
|
8
8
|
|
|
9
|
-
goog.require('shaka.cea.Cea708Service');
|
|
10
9
|
goog.require('shaka.cea.Cea608DataChannel');
|
|
10
|
+
goog.require('shaka.cea.Cea708Service');
|
|
11
11
|
goog.require('shaka.cea.DtvccPacketBuilder');
|
|
12
12
|
goog.require('shaka.cea.ICaptionDecoder');
|
|
13
13
|
goog.require('shaka.log');
|
|
14
14
|
goog.require('shaka.util.DataViewReader');
|
|
15
15
|
goog.require('shaka.util.Error');
|
|
16
16
|
goog.requireType('shaka.cea.DtvccPacket');
|
|
17
|
-
goog.requireType('shaka.cea.ICaptionDecoder.ClosedCaption');
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
/**
|
|
@@ -44,13 +43,13 @@ shaka.cea.CeaDecoder = class {
|
|
|
44
43
|
|
|
45
44
|
/**
|
|
46
45
|
* Number of consecutive bad frames decoded on CEA-608.
|
|
47
|
-
* @private {
|
|
46
|
+
* @private {number}
|
|
48
47
|
*/
|
|
49
48
|
this.badFrames_ = 0;
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
51
|
* A map containing the stream for each mode.
|
|
53
|
-
* @private {!Map
|
|
52
|
+
* @private {!Map<string, !shaka.cea.Cea608DataChannel>}
|
|
54
53
|
*/
|
|
55
54
|
this.cea608ModeToStream_ = new Map([
|
|
56
55
|
['CC1', new shaka.cea.Cea608DataChannel(0, 0)], // F1 + C1 -> CC1
|
|
@@ -61,20 +60,20 @@ shaka.cea.CeaDecoder = class {
|
|
|
61
60
|
|
|
62
61
|
/**
|
|
63
62
|
* The current channel that is active on CEA-608 field 1.
|
|
64
|
-
* @private {
|
|
63
|
+
* @private {number}
|
|
65
64
|
*/
|
|
66
65
|
this.currentField1Channel_ = 0;
|
|
67
66
|
|
|
68
67
|
/**
|
|
69
68
|
* The current channel that is active on CEA-608 field 2.
|
|
70
|
-
* @private {
|
|
69
|
+
* @private {number}
|
|
71
70
|
*/
|
|
72
71
|
this.currentField2Channel_ = 0;
|
|
73
72
|
|
|
74
73
|
/**
|
|
75
74
|
* Map of service number to CEA-708 services, initially empty. Since there
|
|
76
75
|
* can be up to 63 services, they are created dynamically only when needed.
|
|
77
|
-
* @private {!Map
|
|
76
|
+
* @private {!Map<number, shaka.cea.Cea708Service>}
|
|
78
77
|
*/
|
|
79
78
|
this.serviceNumberToService_ = new Map();
|
|
80
79
|
|
|
@@ -361,8 +360,8 @@ shaka.cea.CeaDecoder = class {
|
|
|
361
360
|
|
|
362
361
|
/**
|
|
363
362
|
* Checks if a byte has odd parity (Odd number of 1s in binary).
|
|
364
|
-
* @param {
|
|
365
|
-
* @return {
|
|
363
|
+
* @param {number} byte
|
|
364
|
+
* @return {boolean} True if the byte has odd parity.
|
|
366
365
|
* @private
|
|
367
366
|
*/
|
|
368
367
|
isOddParity_(byte) {
|
|
@@ -377,29 +376,29 @@ shaka.cea.CeaDecoder = class {
|
|
|
377
376
|
|
|
378
377
|
/**
|
|
379
378
|
* itu_t_35_provider_code for ATSC user_data
|
|
380
|
-
* @private @const {
|
|
379
|
+
* @private @const {number}
|
|
381
380
|
*/
|
|
382
381
|
shaka.cea.CeaDecoder.ATSC_PROVIDER_CODE = 0x0031;
|
|
383
382
|
|
|
384
383
|
/**
|
|
385
384
|
* When provider is ATSC user data, the ATSC_user_identifier code
|
|
386
385
|
* for ATSC1_data is "GA94" (0x47413934)
|
|
387
|
-
* @private @const {
|
|
386
|
+
* @private @const {number}
|
|
388
387
|
*/
|
|
389
388
|
shaka.cea.CeaDecoder.ATSC1_USER_IDENTIFIER = 0x47413934;
|
|
390
389
|
|
|
391
390
|
/**
|
|
392
|
-
* @private @const {
|
|
391
|
+
* @private @const {number}
|
|
393
392
|
*/
|
|
394
393
|
shaka.cea.CeaDecoder.NTSC_CC_FIELD_1 = 0;
|
|
395
394
|
|
|
396
395
|
/**
|
|
397
|
-
* @private @const {
|
|
396
|
+
* @private @const {number}
|
|
398
397
|
*/
|
|
399
398
|
shaka.cea.CeaDecoder.NTSC_CC_FIELD_2 = 1;
|
|
400
399
|
|
|
401
400
|
/**
|
|
402
401
|
* 0xB5 is USA's code (Rec. ITU-T T.35)
|
|
403
|
-
* @private @const {
|
|
402
|
+
* @private @const {number}
|
|
404
403
|
*/
|
|
405
404
|
shaka.cea.CeaDecoder.USA_COUNTRY_CODE = 0xb5;
|