shaka-player 3.2.2 → 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 +247 -0
- package/CONTRIBUTORS +4 -2
- package/build/types/core +3 -0
- package/build/types/offline +1 -0
- package/build/types/polyfill +1 -0
- package/build/types/ui +2 -0
- package/demo/common/assets.js +18 -0
- package/demo/common/message_ids.js +13 -1
- package/demo/config.js +31 -1
- package/demo/index.html +1 -1
- package/demo/locales/en.json +12 -0
- package/demo/locales/source.json +48 -0
- package/dist/controls.css +26 -2
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +19 -16
- package/dist/demo.compiled.debug.map +3 -3
- package/dist/demo.compiled.js +19 -16
- package/dist/demo.compiled.map +3 -3
- package/dist/deps.js +18 -11
- package/dist/locales.js +28 -26
- package/dist/receiver.compiled.debug.js +11 -9
- package/dist/receiver.compiled.debug.map +3 -3
- package/dist/receiver.compiled.js +11 -9
- package/dist/receiver.compiled.map +3 -3
- package/dist/shaka-player.compiled.d.ts +205 -15
- package/dist/shaka-player.compiled.debug.d.ts +205 -15
- package/dist/shaka-player.compiled.debug.externs.js +256 -6
- package/dist/shaka-player.compiled.debug.js +406 -354
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +256 -6
- package/dist/shaka-player.compiled.js +826 -800
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +221 -16
- package/dist/shaka-player.ui.debug.d.ts +221 -16
- package/dist/shaka-player.ui.debug.externs.js +283 -6
- package/dist/shaka-player.ui.debug.js +547 -476
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +283 -6
- package/dist/shaka-player.ui.js +1019 -980
- 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/ima.js +3 -0
- package/externs/shaka/ads.js +5 -0
- package/externs/shaka/manifest.js +12 -1
- package/externs/shaka/manifest_parser.js +10 -1
- package/externs/shaka/net.js +20 -4
- package/externs/shaka/offline.js +31 -2
- package/externs/shaka/player.js +130 -5
- package/externs/shaka/text.js +14 -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/client_side_ad.js +8 -0
- package/lib/ads/client_side_ad_manager.js +8 -4
- package/lib/ads/server_side_ad.js +7 -0
- package/lib/cast/cast_utils.js +1 -0
- package/lib/dash/dash_parser.js +48 -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 +86 -23
- package/lib/media/quality_observer.js +291 -0
- package/lib/media/segment_index.js +6 -0
- package/lib/media/segment_reference.js +18 -3
- package/lib/media/streaming_engine.js +42 -4
- 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 +81 -18
- package/lib/offline/download_info.js +68 -0
- package/lib/offline/download_manager.js +13 -5
- package/lib/offline/indexeddb/base_storage_cell.js +35 -0
- package/lib/offline/indexeddb/storage_mechanism.js +1 -1
- package/lib/offline/indexeddb/v5_storage_cell.js +5 -0
- package/lib/offline/storage.js +393 -284
- package/lib/offline/stored_content_utils.js +2 -0
- package/lib/player.js +206 -7
- package/lib/polyfill/random_uuid.js +52 -0
- package/lib/text/cue.js +12 -0
- package/lib/text/ttml_text_parser.js +25 -2
- package/lib/text/ui_text_displayer.js +2 -2
- package/lib/util/cmcd_manager.js +826 -0
- package/lib/util/error.js +6 -0
- package/lib/util/language_utils.js +12 -0
- package/lib/util/mutex.js +52 -0
- package/lib/util/periods.js +98 -64
- package/lib/util/player_configuration.js +18 -0
- package/package.json +1 -1
- package/shaka-player.uncompiled.js +3 -0
- 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 +35 -1
- 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 +2 -0
- 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/storage_integration.js +108 -4
- package/test/player_integration.js +99 -0
- package/test/test/util/dash_parser_util.js +4 -0
- package/test/test/util/fake_ad.js +7 -0
- package/test/test/util/fake_drm_engine.js +9 -2
- package/test/test/util/manifest_generator.js +3 -2
- package/test/test/util/test_scheme.js +14 -1
- package/test/text/ttml_text_parser_unit.js +47 -0
- package/test/ui/ui_unit.js +250 -0
- package/test/util/cmcd_manager_unit.js +277 -0
- package/ui/airplay_button.js +1 -0
- package/ui/audio_language_selection.js +7 -0
- package/ui/cast_button.js +1 -0
- 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 +14 -5
- package/ui/fullscreen_button.js +1 -0
- 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 +5 -0
- package/ui/mute_button.js +2 -1
- package/ui/overflow_menu.js +5 -25
- package/ui/pip_button.js +5 -0
- package/ui/play_button.js +2 -2
- package/ui/playback_rate_selection.js +8 -9
- package/ui/resolution_selection.js +7 -0
- package/ui/rewind_button.js +15 -6
- package/ui/seek_bar.js +4 -2
- package/ui/settings_menu.js +36 -4
- package/ui/small_play_button.js +1 -0
- package/ui/statistics_button.js +253 -0
- package/ui/text_selection.js +11 -4
- package/ui/ui.js +30 -0
- package/ui/volume_bar.js +1 -1
package/externs/shaka/player.js
CHANGED
|
@@ -468,6 +468,48 @@ shaka.extern.ID3Metadata;
|
|
|
468
468
|
*/
|
|
469
469
|
shaka.extern.TimelineRegionInfo;
|
|
470
470
|
|
|
471
|
+
/**
|
|
472
|
+
* @typedef {{
|
|
473
|
+
* audioSamplingRate: ?number,
|
|
474
|
+
* bandwidth: number,
|
|
475
|
+
* codecs: string,
|
|
476
|
+
* contentType: string,
|
|
477
|
+
* frameRate: ?number,
|
|
478
|
+
* height: ?number,
|
|
479
|
+
* mimeType: ?string,
|
|
480
|
+
* channelsCount: ?number,
|
|
481
|
+
* pixelAspectRatio: ?string,
|
|
482
|
+
* width: ?number
|
|
483
|
+
* }}
|
|
484
|
+
*
|
|
485
|
+
* @description
|
|
486
|
+
* Contains information about the quality of an audio or video media stream.
|
|
487
|
+
*
|
|
488
|
+
* @property {?number} audioSamplingRate
|
|
489
|
+
* Specifies the maximum sampling rate of the content.
|
|
490
|
+
* @property {number} bandwidth
|
|
491
|
+
* The bandwidth in bits per second.
|
|
492
|
+
* @property {string} codecs
|
|
493
|
+
* The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be
|
|
494
|
+
* compatible with the Stream's MIME type.
|
|
495
|
+
* @property {string} contentType
|
|
496
|
+
* The type of content, which may be "video" or "audio".
|
|
497
|
+
* @property {?number} frameRate
|
|
498
|
+
* The video frame rate.
|
|
499
|
+
* @property {?number} height
|
|
500
|
+
* The video height in pixels.
|
|
501
|
+
* @property {string} mimeType
|
|
502
|
+
* The MIME type.
|
|
503
|
+
* @property {?number} channelsCount
|
|
504
|
+
* The number of audio channels, or null if unknown.
|
|
505
|
+
* @property {?string} pixelAspectRatio
|
|
506
|
+
* The pixel aspect ratio value; e.g "1:1".
|
|
507
|
+
* @property {?number} width
|
|
508
|
+
* The video width in pixels.
|
|
509
|
+
* @exportDoc
|
|
510
|
+
*/
|
|
511
|
+
shaka.extern.MediaQualityInfo;
|
|
512
|
+
|
|
471
513
|
|
|
472
514
|
/**
|
|
473
515
|
* @typedef {{
|
|
@@ -698,7 +740,9 @@ shaka.extern.DashManifestConfiguration;
|
|
|
698
740
|
* @typedef {{
|
|
699
741
|
* ignoreTextStreamFailures: boolean,
|
|
700
742
|
* ignoreImageStreamFailures: boolean,
|
|
701
|
-
* useFullSegmentsForStartTime: boolean
|
|
743
|
+
* useFullSegmentsForStartTime: boolean,
|
|
744
|
+
* defaultAudioCodec: string,
|
|
745
|
+
* defaultVideoCodec: string
|
|
702
746
|
* }}
|
|
703
747
|
*
|
|
704
748
|
* @property {boolean} ignoreTextStreamFailures
|
|
@@ -710,6 +754,12 @@ shaka.extern.DashManifestConfiguration;
|
|
|
710
754
|
* @property {boolean} useFullSegmentsForStartTime
|
|
711
755
|
* If <code>true</code>, force HlsParser to use a full segment request for
|
|
712
756
|
* determining start time in case the server does not support partial requests
|
|
757
|
+
* @property {string} defaultAudioCodec
|
|
758
|
+
* The default audio codec if it is not specified in the HLS playlist.
|
|
759
|
+
* <i>Defaults to <code>'mp4a.40.2'</code>.</i>
|
|
760
|
+
* @property {string} defaultVideoCodec
|
|
761
|
+
* The default video codec if it is not specified in the HLS playlist.
|
|
762
|
+
* <i>Defaults to <code>'avc1.42E01E'</code>.</i>
|
|
713
763
|
* @exportDoc
|
|
714
764
|
*/
|
|
715
765
|
shaka.extern.HlsManifestConfiguration;
|
|
@@ -790,7 +840,9 @@ shaka.extern.ManifestConfiguration;
|
|
|
790
840
|
* autoLowLatencyMode: boolean,
|
|
791
841
|
* forceHTTPS: boolean,
|
|
792
842
|
* preferNativeHls: boolean,
|
|
793
|
-
* updateIntervalSeconds: number
|
|
843
|
+
* updateIntervalSeconds: number,
|
|
844
|
+
* dispatchAllEmsgBoxes: boolean,
|
|
845
|
+
* observeQualityChanges: boolean
|
|
794
846
|
* }}
|
|
795
847
|
*
|
|
796
848
|
* @description
|
|
@@ -899,7 +951,11 @@ shaka.extern.ManifestConfiguration;
|
|
|
899
951
|
* If true, prefer native HLS playback when possible, regardless of platform.
|
|
900
952
|
* @property {number} updateIntervalSeconds
|
|
901
953
|
* The minimum number of seconds to see if the manifest has changes.
|
|
902
|
-
*
|
|
954
|
+
* @property {boolean} dispatchAllEmsgBoxes
|
|
955
|
+
* If true, all emsg boxes are parsed and dispatched.
|
|
956
|
+
* @property {boolean} observeQualityChanges
|
|
957
|
+
* If true, monitor media quality changes and emit
|
|
958
|
+
* <code.shaka.Player.MediaQualityChangedEvent</code>.
|
|
903
959
|
* @exportDoc
|
|
904
960
|
*/
|
|
905
961
|
shaka.extern.StreamingConfiguration;
|
|
@@ -913,7 +969,8 @@ shaka.extern.StreamingConfiguration;
|
|
|
913
969
|
* restrictions: shaka.extern.Restrictions,
|
|
914
970
|
* switchInterval: number,
|
|
915
971
|
* bandwidthUpgradeTarget: number,
|
|
916
|
-
* bandwidthDowngradeTarget: number
|
|
972
|
+
* bandwidthDowngradeTarget: number,
|
|
973
|
+
* advanced: shaka.extern.AdvancedAbrConfiguration
|
|
917
974
|
* }}
|
|
918
975
|
*
|
|
919
976
|
* @property {boolean} enabled
|
|
@@ -930,7 +987,7 @@ shaka.extern.StreamingConfiguration;
|
|
|
930
987
|
* automatically, but will still appear in the track list and can still be
|
|
931
988
|
* selected via <code>selectVariantTrack()</code>. If no tracks meet these
|
|
932
989
|
* restrictions, AbrManager should not fail, but choose a low-res or
|
|
933
|
-
* low-bandwidth variant instead. It is the
|
|
990
|
+
* low-bandwidth variant instead. It is the responsibility of AbrManager
|
|
934
991
|
* implementations to follow these rules and implement this behavior.
|
|
935
992
|
* @property {number} switchInterval
|
|
936
993
|
* The minimum amount of time that must pass between switches, in
|
|
@@ -941,11 +998,76 @@ shaka.extern.StreamingConfiguration;
|
|
|
941
998
|
* @property {number} bandwidthDowngradeTarget
|
|
942
999
|
* The largest fraction of the estimated bandwidth we should use. We should
|
|
943
1000
|
* downgrade to avoid this.
|
|
1001
|
+
* @property {shaka.extern.AdvancedAbrConfiguration} advanced
|
|
1002
|
+
* Advanced ABR configuration.
|
|
944
1003
|
* @exportDoc
|
|
945
1004
|
*/
|
|
946
1005
|
shaka.extern.AbrConfiguration;
|
|
947
1006
|
|
|
948
1007
|
|
|
1008
|
+
/**
|
|
1009
|
+
* @typedef {{
|
|
1010
|
+
* minTotalBytes: number,
|
|
1011
|
+
* minBytes: number,
|
|
1012
|
+
* fastHalfLife: number,
|
|
1013
|
+
* slowHalfLife: number
|
|
1014
|
+
* }}
|
|
1015
|
+
*
|
|
1016
|
+
* @property {number} minTotalBytes
|
|
1017
|
+
* Minimum number of bytes sampled before we trust the estimate. If we have
|
|
1018
|
+
* not sampled much data, our estimate may not be accurate enough to trust.
|
|
1019
|
+
* @property {number} minBytes
|
|
1020
|
+
* Minimum number of bytes, under which samples are discarded. Our models
|
|
1021
|
+
* do not include latency information, so connection startup time (time to
|
|
1022
|
+
* first byte) is considered part of the download time. Because of this, we
|
|
1023
|
+
* should ignore very small downloads which would cause our estimate to be
|
|
1024
|
+
* too low.
|
|
1025
|
+
* @property {number} fastHalfLife
|
|
1026
|
+
* The quantity of prior samples (by weight) used when creating a new
|
|
1027
|
+
* estimate, in seconds. Those prior samples make up half of the
|
|
1028
|
+
* new estimate.
|
|
1029
|
+
* @property {number} slowHalfLife
|
|
1030
|
+
* The quantity of prior samples (by weight) used when creating a new
|
|
1031
|
+
* estimate, in seconds. Those prior samples make up half of the
|
|
1032
|
+
* new estimate.
|
|
1033
|
+
* @exportDoc
|
|
1034
|
+
*/
|
|
1035
|
+
shaka.extern.AdvancedAbrConfiguration;
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* @typedef {{
|
|
1040
|
+
* enabled: boolean,
|
|
1041
|
+
* useHeaders: boolean,
|
|
1042
|
+
* sessionId: string,
|
|
1043
|
+
* contentId: string
|
|
1044
|
+
* }}
|
|
1045
|
+
*
|
|
1046
|
+
* @description
|
|
1047
|
+
* Common Media Client Data (CMCD) configuration.
|
|
1048
|
+
*
|
|
1049
|
+
* @property {boolean} enabled
|
|
1050
|
+
* If <code>true</code>, enable CMCD data to be sent with media requests.
|
|
1051
|
+
* Defaults to <code>false</code>.
|
|
1052
|
+
* @property {boolean} useHeaders
|
|
1053
|
+
* If <code>true</code>, send CMCD data using the header transmission mode
|
|
1054
|
+
* instead of query args. Defaults to <code>false</code>.
|
|
1055
|
+
* @property {string} sessionId
|
|
1056
|
+
* A GUID identifying the current playback session. A playback session
|
|
1057
|
+
* typically ties together segments belonging to a single media asset.
|
|
1058
|
+
* Maximum length is 64 characters. It is RECOMMENDED to conform to the UUID
|
|
1059
|
+
* specification. By default the sessionId is automatically generated on each
|
|
1060
|
+
* <code>load()</code> call.
|
|
1061
|
+
* @property {string} contentId
|
|
1062
|
+
* A unique string identifying the current content. Maximum length is 64
|
|
1063
|
+
* characters. This value is consistent across multiple different sessions and
|
|
1064
|
+
* devices and is defined and updated at the discretion of the service
|
|
1065
|
+
* provider.
|
|
1066
|
+
* @exportDoc
|
|
1067
|
+
*/
|
|
1068
|
+
shaka.extern.CmcdConfiguration;
|
|
1069
|
+
|
|
1070
|
+
|
|
949
1071
|
/**
|
|
950
1072
|
* @typedef {{
|
|
951
1073
|
* trackSelectionCallback:
|
|
@@ -987,6 +1109,7 @@ shaka.extern.OfflineConfiguration;
|
|
|
987
1109
|
* streaming: shaka.extern.StreamingConfiguration,
|
|
988
1110
|
* abrFactory: shaka.extern.AbrManager.Factory,
|
|
989
1111
|
* abr: shaka.extern.AbrConfiguration,
|
|
1112
|
+
* cmcd: shaka.extern.CmcdConfiguration,
|
|
990
1113
|
* offline: shaka.extern.OfflineConfiguration,
|
|
991
1114
|
* preferredAudioLanguage: string,
|
|
992
1115
|
* preferredTextLanguage: string,
|
|
@@ -1013,6 +1136,8 @@ shaka.extern.OfflineConfiguration;
|
|
|
1013
1136
|
* A factory to construct an abr manager.
|
|
1014
1137
|
* @property {shaka.extern.AbrConfiguration} abr
|
|
1015
1138
|
* ABR configuration and settings.
|
|
1139
|
+
* @property {shaka.extern.CmcdConfiguration} cmcd
|
|
1140
|
+
* CMCD configuration and settings. (Common Media Client Data)
|
|
1016
1141
|
* @property {shaka.extern.OfflineConfiguration} offline
|
|
1017
1142
|
* Offline configuration and settings.
|
|
1018
1143
|
* @property {string} preferredAudioLanguage
|
package/externs/shaka/text.js
CHANGED
|
@@ -297,6 +297,20 @@ shaka.extern.Cue = class {
|
|
|
297
297
|
*/
|
|
298
298
|
this.fontFamily;
|
|
299
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Text stroke color as a CSS color, e.g. "#FFFFFF" or "white".
|
|
302
|
+
* @type {string}
|
|
303
|
+
* @exportDoc
|
|
304
|
+
*/
|
|
305
|
+
this.textStrokeColor;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Text stroke width as a CSS stroke-width value.
|
|
309
|
+
* @type {string}
|
|
310
|
+
* @exportDoc
|
|
311
|
+
*/
|
|
312
|
+
this.textStrokeWidth;
|
|
313
|
+
|
|
300
314
|
/**
|
|
301
315
|
* Text letter spacing as a CSS letter-spacing value.
|
|
302
316
|
* @type {string}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*! @license
|
|
2
|
+
* Shaka Player
|
|
3
|
+
* Copyright 2016 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview Externs for crypto properties not in the Closure compiler.
|
|
10
|
+
*
|
|
11
|
+
* @externs
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @return {string}
|
|
17
|
+
*/
|
|
18
|
+
webCrypto.Crypto.prototype.randomUUID = function() {};
|
package/lib/abr/ewma.js
CHANGED
|
@@ -35,6 +35,20 @@ shaka.abr.Ewma = class {
|
|
|
35
35
|
this.totalWeight_ = 0;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Update the alpha with a new halfLife value.
|
|
41
|
+
*
|
|
42
|
+
* @param {number} halfLife The quantity of prior samples (by weight) used
|
|
43
|
+
* when creating a new estimate. Those prior samples make up half of the
|
|
44
|
+
* new estimate.
|
|
45
|
+
*/
|
|
46
|
+
updateAlpha(halfLife) {
|
|
47
|
+
goog.asserts.assert(halfLife > 0, 'expected halfLife to be positive');
|
|
48
|
+
this.alpha_ = Math.exp(Math.log(0.5) / halfLife);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
38
52
|
/**
|
|
39
53
|
* Takes a sample.
|
|
40
54
|
*
|
|
@@ -47,7 +47,6 @@ shaka.abr.EwmaBandwidthEstimator = class {
|
|
|
47
47
|
* This specific value is based on experimentation.
|
|
48
48
|
*
|
|
49
49
|
* @private {number}
|
|
50
|
-
* @const
|
|
51
50
|
*/
|
|
52
51
|
this.minTotalBytes_ = 128e3; // 128kB
|
|
53
52
|
|
|
@@ -60,11 +59,26 @@ shaka.abr.EwmaBandwidthEstimator = class {
|
|
|
60
59
|
* This specific value is based on experimentation.
|
|
61
60
|
*
|
|
62
61
|
* @private {number}
|
|
63
|
-
* @const
|
|
64
62
|
*/
|
|
65
63
|
this.minBytes_ = 16e3; // 16kB
|
|
66
64
|
}
|
|
67
65
|
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Called by the Player to provide an updated configuration any time it
|
|
69
|
+
* changes.
|
|
70
|
+
* Must be called at least once before init().
|
|
71
|
+
*
|
|
72
|
+
* @param {shaka.extern.AdvancedAbrConfiguration} config
|
|
73
|
+
*/
|
|
74
|
+
configure(config) {
|
|
75
|
+
this.minTotalBytes_ = config.minTotalBytes;
|
|
76
|
+
this.minBytes_ = config.minBytes;
|
|
77
|
+
this.fast_.updateAlpha(config.fastHalfLife);
|
|
78
|
+
this.slow_.updateAlpha(config.slowHalfLife);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
68
82
|
/**
|
|
69
83
|
* Takes a bandwidth sample.
|
|
70
84
|
*
|
|
@@ -54,6 +54,9 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
54
54
|
navigator.connection.addEventListener('change', () => {
|
|
55
55
|
if (this.config_.useNetworkInformation && this.enabled_) {
|
|
56
56
|
this.bandwidthEstimator_ = new shaka.abr.EwmaBandwidthEstimator();
|
|
57
|
+
if (this.config_) {
|
|
58
|
+
this.bandwidthEstimator_.configure(this.config_.advanced);
|
|
59
|
+
}
|
|
57
60
|
const chosenVariant = this.chooseVariant();
|
|
58
61
|
if (chosenVariant) {
|
|
59
62
|
this.switch_(chosenVariant);
|
|
@@ -239,6 +242,9 @@ shaka.abr.SimpleAbrManager = class {
|
|
|
239
242
|
*/
|
|
240
243
|
configure(config) {
|
|
241
244
|
this.config_ = config;
|
|
245
|
+
if (this.bandwidthEstimator_ && this.config_) {
|
|
246
|
+
this.bandwidthEstimator_.configure(this.config_.advanced);
|
|
247
|
+
}
|
|
242
248
|
}
|
|
243
249
|
|
|
244
250
|
|
|
@@ -396,8 +396,10 @@ shaka.ads.ClientSideAdManager = class {
|
|
|
396
396
|
.set('originalEvent', e);
|
|
397
397
|
this.onEvent_(new shaka.util.FakeEvent(
|
|
398
398
|
shaka.ads.AdManager.AD_STARTED, data));
|
|
399
|
-
this.
|
|
400
|
-
|
|
399
|
+
if (this.ad_.isLinear()) {
|
|
400
|
+
this.adContainer_.setAttribute('ad-active', 'true');
|
|
401
|
+
this.video_.pause();
|
|
402
|
+
}
|
|
401
403
|
}
|
|
402
404
|
|
|
403
405
|
/**
|
|
@@ -407,7 +409,9 @@ shaka.ads.ClientSideAdManager = class {
|
|
|
407
409
|
onAdComplete_(e) {
|
|
408
410
|
this.onEvent_(new shaka.util.FakeEvent(shaka.ads.AdManager.AD_STOPPED,
|
|
409
411
|
(new Map()).set('originalEvent', e)));
|
|
410
|
-
this.
|
|
411
|
-
|
|
412
|
+
if (this.ad_.isLinear()) {
|
|
413
|
+
this.adContainer_.removeAttribute('ad-active');
|
|
414
|
+
this.video_.play();
|
|
415
|
+
}
|
|
412
416
|
}
|
|
413
417
|
};
|
package/lib/cast/cast_utils.js
CHANGED
package/lib/dash/dash_parser.js
CHANGED
|
@@ -19,6 +19,7 @@ goog.require('shaka.media.PresentationTimeline');
|
|
|
19
19
|
goog.require('shaka.media.SegmentIndex');
|
|
20
20
|
goog.require('shaka.net.NetworkingEngine');
|
|
21
21
|
goog.require('shaka.text.TextEngine');
|
|
22
|
+
goog.require('shaka.util.CmcdManager');
|
|
22
23
|
goog.require('shaka.util.Error');
|
|
23
24
|
goog.require('shaka.util.Functional');
|
|
24
25
|
goog.require('shaka.util.Iterables');
|
|
@@ -58,12 +59,12 @@ shaka.dash.DashParser = class {
|
|
|
58
59
|
this.globalId_ = 1;
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
|
-
* A map of IDs to
|
|
62
|
+
* A map of IDs to Stream objects.
|
|
62
63
|
* ID: Period@id,AdaptationSet@id,@Representation@id
|
|
63
64
|
* e.g.: '1,5,23'
|
|
64
|
-
* @private {!Object.<string, !shaka.
|
|
65
|
+
* @private {!Object.<string, !shaka.extern.Stream>}
|
|
65
66
|
*/
|
|
66
|
-
this.
|
|
67
|
+
this.streamMap_ = {};
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
70
|
* A map of period ids to their durations
|
|
@@ -164,8 +165,10 @@ shaka.dash.DashParser = class {
|
|
|
164
165
|
stop() {
|
|
165
166
|
// When the parser stops, release all segment indexes, which stops their
|
|
166
167
|
// timers, as well.
|
|
167
|
-
for (const
|
|
168
|
-
segmentIndex
|
|
168
|
+
for (const stream of Object.values(this.streamMap_)) {
|
|
169
|
+
if (stream.segmentIndex) {
|
|
170
|
+
stream.segmentIndex.release();
|
|
171
|
+
}
|
|
169
172
|
}
|
|
170
173
|
|
|
171
174
|
if (this.periodCombiner_) {
|
|
@@ -176,7 +179,7 @@ shaka.dash.DashParser = class {
|
|
|
176
179
|
this.config_ = null;
|
|
177
180
|
this.manifestUris_ = [];
|
|
178
181
|
this.manifest_ = null;
|
|
179
|
-
this.
|
|
182
|
+
this.streamMap_ = {};
|
|
180
183
|
this.periodCombiner_ = null;
|
|
181
184
|
|
|
182
185
|
if (this.updateTimer_ != null) {
|
|
@@ -224,6 +227,9 @@ shaka.dash.DashParser = class {
|
|
|
224
227
|
this.manifestUris_, this.config_.retryParameters);
|
|
225
228
|
const networkingEngine = this.playerInterface_.networkingEngine;
|
|
226
229
|
|
|
230
|
+
const format = shaka.util.CmcdManager.StreamingFormat.DASH;
|
|
231
|
+
this.playerInterface_.modifyManifestRequest(request, {format: format});
|
|
232
|
+
|
|
227
233
|
const startTime = Date.now();
|
|
228
234
|
const operation = networkingEngine.request(requestType, request);
|
|
229
235
|
this.operationManager_.manage(operation);
|
|
@@ -378,8 +384,11 @@ shaka.dash.DashParser = class {
|
|
|
378
384
|
// that the complex logic of multi-Period eviction and period-flattening
|
|
379
385
|
// is correct. See also:
|
|
380
386
|
// https://github.com/google/shaka-player/issues/3169#issuecomment-823580634
|
|
381
|
-
for (const
|
|
382
|
-
|
|
387
|
+
for (const stream of Object.values(this.streamMap_)) {
|
|
388
|
+
if (stream.segmentIndex) {
|
|
389
|
+
stream.segmentIndex.evict(
|
|
390
|
+
presentationTimeline.getSegmentAvailabilityStart());
|
|
391
|
+
}
|
|
383
392
|
}
|
|
384
393
|
} else {
|
|
385
394
|
// DASH IOP v3.0 suggests using a default delay between minBufferTime
|
|
@@ -1163,11 +1172,12 @@ shaka.dash.DashParser = class {
|
|
|
1163
1172
|
context, requestInitSegment);
|
|
1164
1173
|
} else if (context.representation.segmentList) {
|
|
1165
1174
|
streamInfo = shaka.dash.SegmentList.createStreamInfo(
|
|
1166
|
-
context, this.
|
|
1175
|
+
context, this.streamMap_);
|
|
1167
1176
|
} else if (context.representation.segmentTemplate) {
|
|
1168
1177
|
const hasManifest = !!this.manifest_;
|
|
1178
|
+
|
|
1169
1179
|
streamInfo = shaka.dash.SegmentTemplate.createStreamInfo(
|
|
1170
|
-
context, requestInitSegment, this.
|
|
1180
|
+
context, requestInitSegment, this.streamMap_, hasManifest,
|
|
1171
1181
|
this.config_.dash.initialSegmentLimit, this.periodDurations_);
|
|
1172
1182
|
} else {
|
|
1173
1183
|
goog.asserts.assert(isText,
|
|
@@ -1220,8 +1230,10 @@ shaka.dash.DashParser = class {
|
|
|
1220
1230
|
|
|
1221
1231
|
let forced = false;
|
|
1222
1232
|
if (isText) {
|
|
1223
|
-
// See: https://github.com/google/shaka-player/issues/2122
|
|
1224
|
-
|
|
1233
|
+
// See: https://github.com/google/shaka-player/issues/2122 and
|
|
1234
|
+
// https://github.com/Dash-Industry-Forum/DASH-IF-IOP/issues/165
|
|
1235
|
+
forced = roles.includes('forced_subtitle') ||
|
|
1236
|
+
roles.includes('forced-subtitle');
|
|
1225
1237
|
}
|
|
1226
1238
|
|
|
1227
1239
|
let tilesLayout;
|
|
@@ -1254,13 +1266,29 @@ shaka.dash.DashParser = class {
|
|
|
1254
1266
|
hdr = 'PQ';
|
|
1255
1267
|
}
|
|
1256
1268
|
|
|
1269
|
+
const contextId = context.representation.id ?
|
|
1270
|
+
context.period.id + ',' + context.representation.id : '';
|
|
1271
|
+
|
|
1257
1272
|
/** @type {shaka.extern.Stream} */
|
|
1258
1273
|
const stream = {
|
|
1259
1274
|
id: this.globalId_++,
|
|
1260
1275
|
originalId: context.representation.id,
|
|
1261
1276
|
createSegmentIndex: async () => {
|
|
1262
|
-
|
|
1263
|
-
|
|
1277
|
+
// If we have a stream with the same context id stored in the map
|
|
1278
|
+
// that has no segmentIndex, we should set the segmentIndex for it.
|
|
1279
|
+
const storedInMap = contextId && context.dynamic &&
|
|
1280
|
+
this.streamMap_[contextId];
|
|
1281
|
+
|
|
1282
|
+
const currentStream = storedInMap ? this.streamMap_[contextId] : stream;
|
|
1283
|
+
if (!currentStream.segmentIndex) {
|
|
1284
|
+
currentStream.segmentIndex = await streamInfo.generateSegmentIndex();
|
|
1285
|
+
}
|
|
1286
|
+
},
|
|
1287
|
+
|
|
1288
|
+
closeSegmentIndex: () => {
|
|
1289
|
+
if (stream.segmentIndex) {
|
|
1290
|
+
stream.segmentIndex.release();
|
|
1291
|
+
stream.segmentIndex = null;
|
|
1264
1292
|
}
|
|
1265
1293
|
},
|
|
1266
1294
|
segmentIndex: null,
|
|
@@ -1290,7 +1318,13 @@ shaka.dash.DashParser = class {
|
|
|
1290
1318
|
closedCaptions,
|
|
1291
1319
|
hdr,
|
|
1292
1320
|
tilesLayout,
|
|
1321
|
+
matchedStreams: [],
|
|
1293
1322
|
};
|
|
1323
|
+
|
|
1324
|
+
if (contextId && context.dynamic && !this.streamMap_[contextId]) {
|
|
1325
|
+
this.streamMap_[contextId] = stream;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1294
1328
|
return stream;
|
|
1295
1329
|
}
|
|
1296
1330
|
|
package/lib/dash/segment_base.js
CHANGED
|
@@ -61,7 +61,9 @@ shaka.dash.SegmentBase = class {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const getUris = () => resolvedUris;
|
|
64
|
-
|
|
64
|
+
const qualityInfo = shaka.dash.SegmentBase.createQualityInfo(context);
|
|
65
|
+
return new shaka.media.InitSegmentReference(
|
|
66
|
+
getUris, startByte, endByte, qualityInfo);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/**
|
|
@@ -346,4 +348,26 @@ shaka.dash.SegmentBase = class {
|
|
|
346
348
|
indexRange.start, indexRange.end,
|
|
347
349
|
scaledPresentationTimeOffset);
|
|
348
350
|
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Create a MediaQualityInfo object from a Context object.
|
|
354
|
+
*
|
|
355
|
+
* @param {!shaka.dash.DashParser.Context} context
|
|
356
|
+
* @return {!shaka.extern.MediaQualityInfo}
|
|
357
|
+
*/
|
|
358
|
+
static createQualityInfo(context) {
|
|
359
|
+
const representation = context.representation;
|
|
360
|
+
return {
|
|
361
|
+
bandwidth: context.bandwidth,
|
|
362
|
+
audioSamplingRate: representation.audioSamplingRate,
|
|
363
|
+
codecs: representation.codecs,
|
|
364
|
+
contentType: representation.contentType,
|
|
365
|
+
frameRate: representation.frameRate || null,
|
|
366
|
+
height: representation.height || null,
|
|
367
|
+
mimeType: representation.mimeType,
|
|
368
|
+
channelsCount: representation.numChannels,
|
|
369
|
+
pixelAspectRatio: representation.pixelAspectRatio || null,
|
|
370
|
+
width: representation.width || null,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
349
373
|
};
|
package/lib/dash/segment_list.js
CHANGED
|
@@ -30,10 +30,10 @@ shaka.dash.SegmentList = class {
|
|
|
30
30
|
* Updates the existing SegmentIndex, if any.
|
|
31
31
|
*
|
|
32
32
|
* @param {shaka.dash.DashParser.Context} context
|
|
33
|
-
* @param {!Object.<string, !shaka.
|
|
33
|
+
* @param {!Object.<string, !shaka.extern.Stream>} streamMap
|
|
34
34
|
* @return {shaka.dash.DashParser.StreamInfo}
|
|
35
35
|
*/
|
|
36
|
-
static createStreamInfo(context,
|
|
36
|
+
static createStreamInfo(context, streamMap) {
|
|
37
37
|
goog.asserts.assert(context.representation.segmentList,
|
|
38
38
|
'Should only be called with SegmentList');
|
|
39
39
|
const SegmentList = shaka.dash.SegmentList;
|
|
@@ -46,11 +46,14 @@ shaka.dash.SegmentList = class {
|
|
|
46
46
|
|
|
47
47
|
/** @type {shaka.media.SegmentIndex} */
|
|
48
48
|
let segmentIndex = null;
|
|
49
|
-
let
|
|
49
|
+
let stream = null;
|
|
50
50
|
if (context.period.id && context.representation.id) {
|
|
51
51
|
// Only check/store the index if period and representation IDs are set.
|
|
52
|
-
id = context.period.id + ',' + context.representation.id;
|
|
53
|
-
|
|
52
|
+
const id = context.period.id + ',' + context.representation.id;
|
|
53
|
+
stream = streamMap[id];
|
|
54
|
+
if (stream) {
|
|
55
|
+
segmentIndex = stream.segmentIndex;
|
|
56
|
+
}
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
const references = SegmentList.createSegmentReferences_(
|
|
@@ -64,9 +67,6 @@ shaka.dash.SegmentList = class {
|
|
|
64
67
|
segmentIndex.mergeAndEvict(references, start);
|
|
65
68
|
} else {
|
|
66
69
|
segmentIndex = new shaka.media.SegmentIndex(references);
|
|
67
|
-
if (id && context.dynamic) {
|
|
68
|
-
segmentIndexMap[id] = segmentIndex;
|
|
69
|
-
}
|
|
70
70
|
}
|
|
71
71
|
context.presentationTimeline.notifySegments(references);
|
|
72
72
|
|
|
@@ -77,8 +77,17 @@ shaka.dash.SegmentList = class {
|
|
|
77
77
|
segmentIndex.fit(periodStart, periodEnd, isNew);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
if (stream) {
|
|
81
|
+
stream.segmentIndex = segmentIndex;
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
return {
|
|
81
|
-
generateSegmentIndex: () =>
|
|
85
|
+
generateSegmentIndex: () => {
|
|
86
|
+
if (!segmentIndex || segmentIndex.isEmpty()) {
|
|
87
|
+
segmentIndex.merge(references);
|
|
88
|
+
}
|
|
89
|
+
return Promise.resolve(segmentIndex);
|
|
90
|
+
},
|
|
82
91
|
};
|
|
83
92
|
}
|
|
84
93
|
|