@volcengine/veplayer 2.6.2 → 2.7.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/esm/index.d.ts +16 -19
- package/esm/veplayer.biz.live.development.js +950 -327
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +255 -27
- package/esm/veplayer.development.js +911 -316
- package/esm/veplayer.live.d.ts +255 -27
- package/esm/veplayer.live.development.js +910 -315
- package/esm/veplayer.live.production.js +3 -3
- package/esm/veplayer.production.js +3 -3
- package/esm/veplayer.vod.d.ts +16 -19
- package/esm/veplayer.vod.development.js +36 -20
- package/esm/veplayer.vod.production.js +2 -2
- package/package.json +1 -1
- package/umd/index.d.ts +16 -19
- package/umd/veplayer.biz.live.development.js +950 -327
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +255 -27
- package/umd/veplayer.development.js +911 -316
- package/umd/veplayer.live.d.ts +255 -27
- package/umd/veplayer.live.development.js +910 -315
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.js +1 -1
- package/umd/veplayer.vod.d.ts +16 -19
- package/umd/veplayer.vod.development.js +36 -20
- package/umd/veplayer.vod.production.js +1 -1
- package/veplayer.d.ts +255 -27
- package/veplayer.live.d.ts +255 -27
- package/veplayer.vod.d.ts +16 -19
|
@@ -11842,14 +11842,6 @@ class Sources extends OptionsIcon {
|
|
|
11842
11842
|
const sourceManager = args.player.config.sources.sourceManager;
|
|
11843
11843
|
args.config.list = sourceManager.sources;
|
|
11844
11844
|
}
|
|
11845
|
-
afterCreate() {
|
|
11846
|
-
super.afterCreate();
|
|
11847
|
-
if (this.config.sourceManager.sources.length < 2) {
|
|
11848
|
-
this.hide();
|
|
11849
|
-
} else {
|
|
11850
|
-
this.renderItemList();
|
|
11851
|
-
}
|
|
11852
|
-
}
|
|
11853
11845
|
registerIcons() {
|
|
11854
11846
|
return {
|
|
11855
11847
|
source: { icon: SourceIcon }
|
|
@@ -11858,6 +11850,10 @@ class Sources extends OptionsIcon {
|
|
|
11858
11850
|
renderItemList() {
|
|
11859
11851
|
const { sources, source } = this.config.sourceManager;
|
|
11860
11852
|
const i18nManager = this.player.config.i18nManager;
|
|
11853
|
+
if (sources.length < 2) {
|
|
11854
|
+
this.hide();
|
|
11855
|
+
return;
|
|
11856
|
+
}
|
|
11861
11857
|
const renderItems = sources.map((source2) => {
|
|
11862
11858
|
return {
|
|
11863
11859
|
...source2,
|
|
@@ -12539,6 +12535,10 @@ class DefinitionPlugin extends OptionsIcon {
|
|
|
12539
12535
|
var _a, _b;
|
|
12540
12536
|
const sourceManager = this.player.config.sourceManager;
|
|
12541
12537
|
const definitions = ((_a = sourceManager.source) == null ? void 0 : _a.definitions) ?? [];
|
|
12538
|
+
if (definitions.length < 2) {
|
|
12539
|
+
this.hide();
|
|
12540
|
+
return;
|
|
12541
|
+
}
|
|
12542
12542
|
const renderItems = definitions.map((definition) => {
|
|
12543
12543
|
const showItem = {
|
|
12544
12544
|
url: definition.url,
|
|
@@ -13459,7 +13459,7 @@ function getStreamType(url) {
|
|
|
13459
13459
|
}
|
|
13460
13460
|
return "unknown";
|
|
13461
13461
|
}
|
|
13462
|
-
function isMseSupported$
|
|
13462
|
+
function isMseSupported$3(codec = Codec.H264) {
|
|
13463
13463
|
if (codec === Codec.H265) {
|
|
13464
13464
|
return sniffer$1.isHevcSupported();
|
|
13465
13465
|
}
|
|
@@ -13490,7 +13490,7 @@ const util = {
|
|
|
13490
13490
|
...util$1,
|
|
13491
13491
|
...DomUtils,
|
|
13492
13492
|
getStreamType,
|
|
13493
|
-
isMseSupported: isMseSupported$
|
|
13493
|
+
isMseSupported: isMseSupported$3,
|
|
13494
13494
|
isSoftDecodeSupported: isSoftDecodeSupported$1,
|
|
13495
13495
|
isMMSSupported: isMMSSupported$2,
|
|
13496
13496
|
appendSearchParams: appendSearchParams$1,
|
|
@@ -14227,10 +14227,12 @@ class VePlayerBase {
|
|
|
14227
14227
|
__publicField(this, "_events", {});
|
|
14228
14228
|
__publicField(this, "_customMedia");
|
|
14229
14229
|
__publicField(this, "_errorCallback");
|
|
14230
|
+
__publicField(this, "_beforeFallbackError");
|
|
14230
14231
|
var _a, _b, _c, _d, _e, _f;
|
|
14231
14232
|
this._sourceManager = options.sourceManager;
|
|
14232
14233
|
this._preparePlugins = options.preparePlugins;
|
|
14233
14234
|
this._previousPrepareResult = options.prepareResult;
|
|
14235
|
+
this._beforeFallbackError = options.beforeFallbackError;
|
|
14234
14236
|
this._i18nManager = options.i18nManager ?? new VeI18n({
|
|
14235
14237
|
i18n: options.i18n
|
|
14236
14238
|
});
|
|
@@ -14255,6 +14257,9 @@ class VePlayerBase {
|
|
|
14255
14257
|
...DEFAULT_OPTIONS,
|
|
14256
14258
|
...xgOptions,
|
|
14257
14259
|
definition: {
|
|
14260
|
+
// TODO: ts
|
|
14261
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14262
|
+
// @ts-ignore
|
|
14258
14263
|
list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
|
|
14259
14264
|
defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
|
|
14260
14265
|
...options.definition ?? {}
|
|
@@ -14439,7 +14444,7 @@ class VePlayerBase {
|
|
|
14439
14444
|
* @brief Retrieve the player SDK version number.
|
|
14440
14445
|
*/
|
|
14441
14446
|
get playerVersion() {
|
|
14442
|
-
return "2.
|
|
14447
|
+
return "2.7.0";
|
|
14443
14448
|
}
|
|
14444
14449
|
/** {zh}
|
|
14445
14450
|
* @brief 获取当前播放视频的清晰度唯一标识(definition)。
|
|
@@ -14925,13 +14930,18 @@ class VePlayerBase {
|
|
|
14925
14930
|
* @hidden
|
|
14926
14931
|
*/
|
|
14927
14932
|
async prepare(url) {
|
|
14928
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
14933
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
14929
14934
|
const result = await ((_a = this._preparePlugins) == null ? void 0 : _a.call(this, url));
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14935
|
+
let isSameProtocol;
|
|
14936
|
+
if ((result == null ? void 0 : result.protocol) && ((_b = this._previousPrepareResult) == null ? void 0 : _b.protocol)) {
|
|
14937
|
+
isSameProtocol = result.protocol === ((_c = this._previousPrepareResult) == null ? void 0 : _c.protocol);
|
|
14938
|
+
} else {
|
|
14939
|
+
const newUrl = ((_d = result == null ? void 0 : result.options) == null ? void 0 : _d.url) ?? url;
|
|
14940
|
+
const oldUrl = (_f = (_e = this._player) == null ? void 0 : _e.config) == null ? void 0 : _f.url;
|
|
14941
|
+
isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
|
|
14942
|
+
}
|
|
14933
14943
|
if (!isSameProtocol) {
|
|
14934
|
-
(
|
|
14944
|
+
(_h = (_g = this._previousPrepareResult) == null ? void 0 : _g.plugins) == null ? void 0 : _h.forEach((plugin) => {
|
|
14935
14945
|
this._player.unRegisterPlugin(plugin.pluginName);
|
|
14936
14946
|
});
|
|
14937
14947
|
}
|
|
@@ -14940,7 +14950,7 @@ class VePlayerBase {
|
|
|
14940
14950
|
this._player.setConfig(result.options);
|
|
14941
14951
|
}
|
|
14942
14952
|
return {
|
|
14943
|
-
plugins: isSameProtocol ? [] : (
|
|
14953
|
+
plugins: isSameProtocol ? [] : (_i = result == null ? void 0 : result.plugins) == null ? void 0 : _i.map((plugin) => {
|
|
14944
14954
|
return this._player.registerPlugin(plugin);
|
|
14945
14955
|
}),
|
|
14946
14956
|
options: result == null ? void 0 : result.options,
|
|
@@ -14953,11 +14963,18 @@ class VePlayerBase {
|
|
|
14953
14963
|
const preUrl = this._sourceManager.url;
|
|
14954
14964
|
const url = this._sourceManager.fallback();
|
|
14955
14965
|
if (!url) {
|
|
14966
|
+
const transformedError = transform$1(err, this._i18nManager);
|
|
14967
|
+
try {
|
|
14968
|
+
const { canEmitError } = await this._beforeFallbackError(
|
|
14969
|
+
transformedError
|
|
14970
|
+
);
|
|
14971
|
+
if (!canEmitError) {
|
|
14972
|
+
return;
|
|
14973
|
+
}
|
|
14974
|
+
} catch (error2) {
|
|
14975
|
+
}
|
|
14956
14976
|
this._player.removeClass(STATE_CLASS.ENTER);
|
|
14957
|
-
this.emit(
|
|
14958
|
-
Events$1.FALLBACK_ERROR,
|
|
14959
|
-
transform$1(err, this._i18nManager)
|
|
14960
|
-
);
|
|
14977
|
+
this.emit(Events$1.FALLBACK_ERROR, transformedError);
|
|
14961
14978
|
return;
|
|
14962
14979
|
}
|
|
14963
14980
|
this._player.once("canplay", () => {
|
|
@@ -15037,7 +15054,6 @@ class VePlayerBase {
|
|
|
15037
15054
|
return new Promise((resolve) => {
|
|
15038
15055
|
const curTime = this._player.currentTime;
|
|
15039
15056
|
const _canplay = () => {
|
|
15040
|
-
console.log("canplay canplay");
|
|
15041
15057
|
this._player.currentTime = curTime;
|
|
15042
15058
|
if (isPaused) {
|
|
15043
15059
|
this._player.once(CANPLAY, () => {
|
|
@@ -19588,44 +19604,6 @@ class Lite {
|
|
|
19588
19604
|
return result;
|
|
19589
19605
|
}
|
|
19590
19606
|
}
|
|
19591
|
-
function enableHlsJs(options) {
|
|
19592
|
-
var _a, _b;
|
|
19593
|
-
if ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableHlsJs) {
|
|
19594
|
-
return true;
|
|
19595
|
-
}
|
|
19596
|
-
if (((_b = options == null ? void 0 : options.ad) == null ? void 0 : _b.adType) === "ssai") {
|
|
19597
|
-
return true;
|
|
19598
|
-
}
|
|
19599
|
-
return false;
|
|
19600
|
-
}
|
|
19601
|
-
const getHlsStrategy = async (options) => {
|
|
19602
|
-
var _a, _b;
|
|
19603
|
-
let mseStrategy;
|
|
19604
|
-
let softStrategy;
|
|
19605
|
-
const codec = await getCodec(options);
|
|
19606
|
-
const isSoftDecode$1 = await isSoftDecode(options, codec);
|
|
19607
|
-
const useHlsJs = enableHlsJs(options);
|
|
19608
|
-
if (isSoftDecode$1) {
|
|
19609
|
-
softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
|
|
19610
|
-
mseStrategy = createHlsMseStrategy(options, useHlsJs);
|
|
19611
|
-
}
|
|
19612
|
-
if ((sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported$2(Codec.H264) : isMseSupported$2(codec))) {
|
|
19613
|
-
mseStrategy = createHlsMseStrategy(options, useHlsJs);
|
|
19614
|
-
}
|
|
19615
|
-
if (!mseStrategy && !softStrategy) {
|
|
19616
|
-
return {};
|
|
19617
|
-
}
|
|
19618
|
-
const [mseModule, softModule] = await Promise.all([
|
|
19619
|
-
(mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
|
|
19620
|
-
(softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
|
|
19621
|
-
]);
|
|
19622
|
-
(softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_b = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _b.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
|
|
19623
|
-
const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
|
|
19624
|
-
return {
|
|
19625
|
-
options: combineOptions$1,
|
|
19626
|
-
plugins: (mseModule == null ? void 0 : mseModule.HlsPlugin) ? [mseModule.HlsPlugin] : []
|
|
19627
|
-
};
|
|
19628
|
-
};
|
|
19629
19607
|
const getDefaultFlvOptions = (options) => {
|
|
19630
19608
|
var _a;
|
|
19631
19609
|
return {
|
|
@@ -19797,203 +19775,6 @@ function create(errorCode, i18n) {
|
|
|
19797
19775
|
i18n
|
|
19798
19776
|
);
|
|
19799
19777
|
}
|
|
19800
|
-
async function isRTMSupported() {
|
|
19801
|
-
const { RtmPlugin } = await load(DynamicModule.PluginRtm);
|
|
19802
|
-
return RtmPlugin.isSupported();
|
|
19803
|
-
}
|
|
19804
|
-
async function isRTMSupportCodec(codec = RTMCodec.H264) {
|
|
19805
|
-
const { RtmPlugin } = await load(DynamicModule.PluginRtm);
|
|
19806
|
-
if (codec === RTMCodec.H264)
|
|
19807
|
-
return RtmPlugin.isSupportedH264();
|
|
19808
|
-
return false;
|
|
19809
|
-
}
|
|
19810
|
-
const rtmStrategy = {
|
|
19811
|
-
options: {},
|
|
19812
|
-
module: DynamicModule.PluginRtm
|
|
19813
|
-
};
|
|
19814
|
-
const generateFallbackUrl = (url) => {
|
|
19815
|
-
if (sniffer$1.device === "pc") {
|
|
19816
|
-
return url.replace(".sdp", ".flv");
|
|
19817
|
-
} else {
|
|
19818
|
-
return url.replace(".sdp", ".m3u8");
|
|
19819
|
-
}
|
|
19820
|
-
};
|
|
19821
|
-
const getRtmStrategy = async (options, player, i18n) => {
|
|
19822
|
-
var _a, _b;
|
|
19823
|
-
let backupStrategy;
|
|
19824
|
-
let actualFallbackUrl = "";
|
|
19825
|
-
const { url, playlist } = options;
|
|
19826
|
-
const { fallbackUrl, enableRTMAutoTranscode, ...ret } = options.rtm || {};
|
|
19827
|
-
let { enableFallback = true } = options.rtm || {};
|
|
19828
|
-
if (playlist == null ? void 0 : playlist.length) {
|
|
19829
|
-
enableFallback = false;
|
|
19830
|
-
}
|
|
19831
|
-
const isRTMAutoTranscode = enableRTMAutoTranscode || ((_a = getUrlObject(url)) == null ? void 0 : _a.searchParams.get("enableRTMAutoTranscode")) === "true";
|
|
19832
|
-
if (enableFallback) {
|
|
19833
|
-
if (fallbackUrl) {
|
|
19834
|
-
actualFallbackUrl = fallbackUrl;
|
|
19835
|
-
} else if (isRTMAutoTranscode && url) {
|
|
19836
|
-
actualFallbackUrl = generateFallbackUrl(url);
|
|
19837
|
-
} else {
|
|
19838
|
-
console.warn(
|
|
19839
|
-
create(ErrorCode.EMPTY_RTM_FALLBACK_PARAMETER, i18n).message
|
|
19840
|
-
);
|
|
19841
|
-
}
|
|
19842
|
-
}
|
|
19843
|
-
const backupType = actualFallbackUrl && util.getStreamType(actualFallbackUrl);
|
|
19844
|
-
if (backupType === "flv" && util.isMseSupported(Codec.H264)) {
|
|
19845
|
-
backupStrategy = createFlvMseStrategy(options);
|
|
19846
|
-
} else if (backupType === "hls" && (sniffer$1.device !== "mobile" || ((_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.enableMSE)) && util.isMseSupported(Codec.H264)) {
|
|
19847
|
-
backupStrategy = createHlsMseStrategy(options);
|
|
19848
|
-
}
|
|
19849
|
-
const [rtmCdn, backupCdn] = await Promise.all([
|
|
19850
|
-
load(rtmStrategy.module).then((module) => {
|
|
19851
|
-
return module.RtmPlugin;
|
|
19852
|
-
}).catch(() => void 0),
|
|
19853
|
-
backupStrategy && load(backupStrategy.module).then((module) => {
|
|
19854
|
-
if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginFlv) {
|
|
19855
|
-
return module.FlvPlugin;
|
|
19856
|
-
} else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginHls) {
|
|
19857
|
-
return module.HlsPlugin;
|
|
19858
|
-
}
|
|
19859
|
-
}).catch(() => void 0)
|
|
19860
|
-
]);
|
|
19861
|
-
if (actualFallbackUrl) {
|
|
19862
|
-
const [RTMSupported, RTMSupportCodec] = await Promise.all([
|
|
19863
|
-
isRTMSupported(),
|
|
19864
|
-
isRTMSupportCodec()
|
|
19865
|
-
]);
|
|
19866
|
-
if (!RTMSupported || !RTMSupportCodec) {
|
|
19867
|
-
if (player) {
|
|
19868
|
-
player.emit("degrade", {
|
|
19869
|
-
url: actualFallbackUrl,
|
|
19870
|
-
originRtmUrl: url,
|
|
19871
|
-
code: "NOT_SUPPORT",
|
|
19872
|
-
message: "not support rtm or h264",
|
|
19873
|
-
isRTMSupported: RTMSupported,
|
|
19874
|
-
isRTMSupportCodec: RTMSupportCodec
|
|
19875
|
-
});
|
|
19876
|
-
}
|
|
19877
|
-
return {
|
|
19878
|
-
options: {
|
|
19879
|
-
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
19880
|
-
url: actualFallbackUrl,
|
|
19881
|
-
_RTMdegrade: {
|
|
19882
|
-
_originRtmUrl: url,
|
|
19883
|
-
_isRTMSupported: RTMSupported,
|
|
19884
|
-
_isRTMSupportCodec: RTMSupportCodec
|
|
19885
|
-
}
|
|
19886
|
-
},
|
|
19887
|
-
plugins: backupCdn ? [backupCdn] : []
|
|
19888
|
-
};
|
|
19889
|
-
}
|
|
19890
|
-
}
|
|
19891
|
-
return {
|
|
19892
|
-
options: {
|
|
19893
|
-
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
19894
|
-
url: enableRTMAutoTranscode ? util.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
|
|
19895
|
-
_RTMdegrade: void 0,
|
|
19896
|
-
rts: {
|
|
19897
|
-
retryCount: 0,
|
|
19898
|
-
...ret,
|
|
19899
|
-
backupURL: actualFallbackUrl,
|
|
19900
|
-
backupConstruct: backupCdn
|
|
19901
|
-
}
|
|
19902
|
-
},
|
|
19903
|
-
plugins: rtmCdn ? [rtmCdn] : []
|
|
19904
|
-
};
|
|
19905
|
-
};
|
|
19906
|
-
var DrmType = /* @__PURE__ */ ((DrmType2) => {
|
|
19907
|
-
DrmType2["Fairplay"] = "fairplay";
|
|
19908
|
-
return DrmType2;
|
|
19909
|
-
})(DrmType || {});
|
|
19910
|
-
function getDrmType(drm) {
|
|
19911
|
-
if ((drm == null ? void 0 : drm.fairplay) && (sniffer$1.browser === "safari" || sniffer$1.os.isIos)) {
|
|
19912
|
-
return "fairplay";
|
|
19913
|
-
}
|
|
19914
|
-
return;
|
|
19915
|
-
}
|
|
19916
|
-
function isMseSupportedWithDrm({
|
|
19917
|
-
drm,
|
|
19918
|
-
streamType
|
|
19919
|
-
}) {
|
|
19920
|
-
const drmType = getDrmType(drm);
|
|
19921
|
-
if (!drmType) {
|
|
19922
|
-
return true;
|
|
19923
|
-
}
|
|
19924
|
-
if (drmType === "fairplay" && streamType === "hls") {
|
|
19925
|
-
return false;
|
|
19926
|
-
}
|
|
19927
|
-
return true;
|
|
19928
|
-
}
|
|
19929
|
-
const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$1 } = util;
|
|
19930
|
-
function enableMMS() {
|
|
19931
|
-
return sniffer$1.os.isIos;
|
|
19932
|
-
}
|
|
19933
|
-
function isFLVSupported(codec = Codec.H264) {
|
|
19934
|
-
const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$1;
|
|
19935
|
-
return isMediaSourceSupported(codec);
|
|
19936
|
-
}
|
|
19937
|
-
const { appendSearchParams } = util;
|
|
19938
|
-
const getFlvStrategy = async (options) => {
|
|
19939
|
-
var _a, _b, _c, _d, _e, _f;
|
|
19940
|
-
let mseStrategy;
|
|
19941
|
-
let softStrategy;
|
|
19942
|
-
const enableLowLatency = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency;
|
|
19943
|
-
const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
|
|
19944
|
-
const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
|
|
19945
|
-
const codec = await getCodec(options);
|
|
19946
|
-
const isSoftDecode$1 = await isSoftDecode(options, codec);
|
|
19947
|
-
if (isSoftDecode$1) {
|
|
19948
|
-
softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
|
|
19949
|
-
mseStrategy = createFlvMseStrategy(options);
|
|
19950
|
-
}
|
|
19951
|
-
if (codec === "unknown" ? isFLVSupported(Codec.H264) : isFLVSupported(codec)) {
|
|
19952
|
-
mseStrategy = enableMMS() ? createFlvMssStrategy(options) : createFlvMseStrategy(options);
|
|
19953
|
-
}
|
|
19954
|
-
if (!mseStrategy && !softStrategy) {
|
|
19955
|
-
return {};
|
|
19956
|
-
}
|
|
19957
|
-
const [mseModule, softModule] = await Promise.all([
|
|
19958
|
-
(mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
|
|
19959
|
-
(softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
|
|
19960
|
-
]);
|
|
19961
|
-
(softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
|
|
19962
|
-
const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
|
|
19963
|
-
const plugins = [];
|
|
19964
|
-
if (enableLowLatency) {
|
|
19965
|
-
combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
|
|
19966
|
-
}
|
|
19967
|
-
if (mseModule) {
|
|
19968
|
-
plugins.push(mseModule.FlvPlugin);
|
|
19969
|
-
if (enableLowLatency && enableFrameChasing) {
|
|
19970
|
-
plugins.push(mseModule.Adaptive);
|
|
19971
|
-
}
|
|
19972
|
-
}
|
|
19973
|
-
return {
|
|
19974
|
-
options: combineOptions$1,
|
|
19975
|
-
plugins
|
|
19976
|
-
};
|
|
19977
|
-
};
|
|
19978
|
-
const getTypeStrategy = async (options, player, i18n) => {
|
|
19979
|
-
const type = options.url ? util.getStreamType(options.url) : "";
|
|
19980
|
-
if (!type || type === "unknown") {
|
|
19981
|
-
return { options: {}, plugins: [] };
|
|
19982
|
-
}
|
|
19983
|
-
if (type === "rtm") {
|
|
19984
|
-
return await getRtmStrategy(options, player, i18n);
|
|
19985
|
-
}
|
|
19986
|
-
if (type === "flv") {
|
|
19987
|
-
return await getFlvStrategy(options);
|
|
19988
|
-
}
|
|
19989
|
-
if (type === "hls") {
|
|
19990
|
-
if (!isMseSupportedWithDrm({ drm: options.drm, streamType: type })) {
|
|
19991
|
-
return { options: {}, plugins: [] };
|
|
19992
|
-
}
|
|
19993
|
-
return await getHlsStrategy(options);
|
|
19994
|
-
}
|
|
19995
|
-
return { options: {}, plugins: [] };
|
|
19996
|
-
};
|
|
19997
19778
|
var FUNC_ERROR_TEXT = "Expected a function";
|
|
19998
19779
|
var NAN = 0 / 0;
|
|
19999
19780
|
var symbolTag = "[object Symbol]";
|
|
@@ -22806,7 +22587,7 @@ class Logger extends Plugin {
|
|
|
22806
22587
|
device_id: this._deviceId,
|
|
22807
22588
|
error_report_stop: true,
|
|
22808
22589
|
ext: {
|
|
22809
|
-
veplayer_version: "2.
|
|
22590
|
+
veplayer_version: "2.7.0",
|
|
22810
22591
|
flv_version: "3.0.21-rc.21",
|
|
22811
22592
|
hls_version: "3.0.21-rc.21",
|
|
22812
22593
|
rts_version: "0.2.1-alpha.14"
|
|
@@ -23085,16 +22866,326 @@ const ZH_CN = {
|
|
|
23085
22866
|
DECODE_INFO: "软解信息",
|
|
23086
22867
|
REFRESH: "刷新"
|
|
23087
22868
|
};
|
|
23088
|
-
const
|
|
23089
|
-
|
|
23090
|
-
|
|
23091
|
-
|
|
23092
|
-
|
|
23093
|
-
|
|
23094
|
-
|
|
23095
|
-
|
|
23096
|
-
|
|
23097
|
-
|
|
22869
|
+
const LiveUrlType = {
|
|
22870
|
+
Hls: "hls",
|
|
22871
|
+
LLHls: "ll-hls",
|
|
22872
|
+
Flv: "flv",
|
|
22873
|
+
Rtm: "rtm",
|
|
22874
|
+
LLFlv: "ll-flv"
|
|
22875
|
+
};
|
|
22876
|
+
const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$2 } = util;
|
|
22877
|
+
function enableMMS() {
|
|
22878
|
+
return sniffer$1.os.isIos;
|
|
22879
|
+
}
|
|
22880
|
+
function isFLVSupported(codec = Codec.H264) {
|
|
22881
|
+
const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$2;
|
|
22882
|
+
return isMediaSourceSupported(codec);
|
|
22883
|
+
}
|
|
22884
|
+
var FallbackKind = /* @__PURE__ */ ((FallbackKind2) => {
|
|
22885
|
+
FallbackKind2["Error"] = "Error";
|
|
22886
|
+
FallbackKind2["Stall"] = "Stall";
|
|
22887
|
+
return FallbackKind2;
|
|
22888
|
+
})(FallbackKind || {});
|
|
22889
|
+
class BaseProtocol {
|
|
22890
|
+
constructor(options) {
|
|
22891
|
+
// 下一个 protocol 类
|
|
22892
|
+
__publicField(this, "nextProtocol");
|
|
22893
|
+
__publicField(this, "preProtocol");
|
|
22894
|
+
__publicField(this, "protocolStrategy");
|
|
22895
|
+
__publicField(this, "_fallback");
|
|
22896
|
+
this._fallback = options.fallback;
|
|
22897
|
+
}
|
|
22898
|
+
_getKindFallbackStrategy(kind) {
|
|
22899
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
22900
|
+
return ((_c = (_b = (_a = this._fallback) == null ? void 0 : _a.fallbackStrategy) == null ? void 0 : _b[this.protocolType]) == null ? void 0 : _c[kind]) ?? ((_f = (_e = (_d = this._fallback) == null ? void 0 : _d.fallbackStrategy) == null ? void 0 : _e["all"]) == null ? void 0 : _f[kind]) ?? ((_g = this.defaultFallbackStrategy) == null ? void 0 : _g[kind]);
|
|
22901
|
+
}
|
|
22902
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
22903
|
+
get errorFallbackStrategy() {
|
|
22904
|
+
return this._getKindFallbackStrategy(
|
|
22905
|
+
"Error"
|
|
22906
|
+
/* Error */
|
|
22907
|
+
);
|
|
22908
|
+
}
|
|
22909
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
22910
|
+
get stallFallbackStrategy() {
|
|
22911
|
+
return this._getKindFallbackStrategy(
|
|
22912
|
+
"Stall"
|
|
22913
|
+
/* Stall */
|
|
22914
|
+
);
|
|
22915
|
+
}
|
|
22916
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
22917
|
+
shouldFallbackWhenError(params) {
|
|
22918
|
+
var _a, _b, _c;
|
|
22919
|
+
if ((_a = this.errorFallbackStrategy) == null ? void 0 : _a.shouldFallback) {
|
|
22920
|
+
return (_b = this.errorFallbackStrategy) == null ? void 0 : _b.shouldFallback(
|
|
22921
|
+
this.protocolType,
|
|
22922
|
+
params
|
|
22923
|
+
);
|
|
22924
|
+
}
|
|
22925
|
+
if ((_c = this.errorFallbackStrategy) == null ? void 0 : _c.excludeList) {
|
|
22926
|
+
return !this.errorFallbackStrategy.excludeList.includes(
|
|
22927
|
+
params.error.errorCode
|
|
22928
|
+
);
|
|
22929
|
+
}
|
|
22930
|
+
return false;
|
|
22931
|
+
}
|
|
22932
|
+
}
|
|
22933
|
+
const { appendSearchParams } = util;
|
|
22934
|
+
const getFlvStrategy = async (options) => {
|
|
22935
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22936
|
+
let mseStrategy;
|
|
22937
|
+
let softStrategy;
|
|
22938
|
+
const enableLowLatency = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency;
|
|
22939
|
+
const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
|
|
22940
|
+
const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
|
|
22941
|
+
const codec = await getCodec(options);
|
|
22942
|
+
const isSoftDecode$1 = await isSoftDecode(options, codec);
|
|
22943
|
+
if (isSoftDecode$1) {
|
|
22944
|
+
softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
|
|
22945
|
+
mseStrategy = createFlvMseStrategy(options);
|
|
22946
|
+
}
|
|
22947
|
+
if (codec === "unknown" ? isFLVSupported(Codec.H264) : isFLVSupported(codec)) {
|
|
22948
|
+
mseStrategy = enableMMS() ? createFlvMssStrategy(options) : createFlvMseStrategy(options);
|
|
22949
|
+
}
|
|
22950
|
+
if (!mseStrategy && !softStrategy) {
|
|
22951
|
+
return {};
|
|
22952
|
+
}
|
|
22953
|
+
const [mseModule, softModule] = await Promise.all([
|
|
22954
|
+
(mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
|
|
22955
|
+
(softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
|
|
22956
|
+
]);
|
|
22957
|
+
(softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
|
|
22958
|
+
const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
|
|
22959
|
+
const plugins = [];
|
|
22960
|
+
if (enableLowLatency) {
|
|
22961
|
+
combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
|
|
22962
|
+
}
|
|
22963
|
+
if (mseModule) {
|
|
22964
|
+
plugins.push(mseModule.FlvPlugin);
|
|
22965
|
+
if (enableLowLatency && enableFrameChasing) {
|
|
22966
|
+
plugins.push(mseModule.Adaptive);
|
|
22967
|
+
}
|
|
22968
|
+
}
|
|
22969
|
+
return {
|
|
22970
|
+
options: combineOptions$1,
|
|
22971
|
+
plugins
|
|
22972
|
+
};
|
|
22973
|
+
};
|
|
22974
|
+
class FlvProtocol extends BaseProtocol {
|
|
22975
|
+
static get suffix() {
|
|
22976
|
+
return ".flv";
|
|
22977
|
+
}
|
|
22978
|
+
get protocolType() {
|
|
22979
|
+
return LiveUrlType.Flv;
|
|
22980
|
+
}
|
|
22981
|
+
get defaultFallbackStrategy() {
|
|
22982
|
+
return {};
|
|
22983
|
+
}
|
|
22984
|
+
static generateUrl(urls, {
|
|
22985
|
+
generateUrlFromOtherProtocol: generateUrlFromOtherProtocol2
|
|
22986
|
+
}) {
|
|
22987
|
+
return urls[LiveUrlType.Flv] ?? generateUrlFromOtherProtocol2();
|
|
22988
|
+
}
|
|
22989
|
+
static canGenerateOtherProtocol() {
|
|
22990
|
+
return true;
|
|
22991
|
+
}
|
|
22992
|
+
async canPlay() {
|
|
22993
|
+
return {
|
|
22994
|
+
canPlay: isFLVSupported()
|
|
22995
|
+
};
|
|
22996
|
+
}
|
|
22997
|
+
shouldFallbackWhenStall() {
|
|
22998
|
+
return false;
|
|
22999
|
+
}
|
|
23000
|
+
async getProtocolStrategy(options, {
|
|
23001
|
+
enableSelector
|
|
23002
|
+
}) {
|
|
23003
|
+
return getFlvStrategy(
|
|
23004
|
+
enableSelector ? {
|
|
23005
|
+
...options,
|
|
23006
|
+
flv: {
|
|
23007
|
+
...options.flv,
|
|
23008
|
+
enableLowLatency: false
|
|
23009
|
+
}
|
|
23010
|
+
} : options
|
|
23011
|
+
);
|
|
23012
|
+
}
|
|
23013
|
+
async getAbrStrategy(options) {
|
|
23014
|
+
var _a;
|
|
23015
|
+
const abrOptions = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.abr;
|
|
23016
|
+
if (!abrOptions) {
|
|
23017
|
+
return {};
|
|
23018
|
+
}
|
|
23019
|
+
const abrPlugin = await load(DynamicModule.PluginAbr).catch(
|
|
23020
|
+
() => void 0
|
|
23021
|
+
);
|
|
23022
|
+
return {
|
|
23023
|
+
options: {
|
|
23024
|
+
abr: {
|
|
23025
|
+
...abrOptions,
|
|
23026
|
+
open: abrOptions.enable ?? true
|
|
23027
|
+
}
|
|
23028
|
+
},
|
|
23029
|
+
plugins: [abrPlugin == null ? void 0 : abrPlugin.AbrPlugin]
|
|
23030
|
+
};
|
|
23031
|
+
}
|
|
23032
|
+
getDrmStrategy() {
|
|
23033
|
+
return void 0;
|
|
23034
|
+
}
|
|
23035
|
+
}
|
|
23036
|
+
class FlvLowLatencyProtocol extends FlvProtocol {
|
|
23037
|
+
get protocolType() {
|
|
23038
|
+
return LiveUrlType.LLFlv;
|
|
23039
|
+
}
|
|
23040
|
+
async getProtocolStrategy(options) {
|
|
23041
|
+
return getFlvStrategy({
|
|
23042
|
+
...options,
|
|
23043
|
+
flv: {
|
|
23044
|
+
...options.flv,
|
|
23045
|
+
enableLowLatency: true
|
|
23046
|
+
}
|
|
23047
|
+
});
|
|
23048
|
+
}
|
|
23049
|
+
}
|
|
23050
|
+
var DrmType = /* @__PURE__ */ ((DrmType2) => {
|
|
23051
|
+
DrmType2["Fairplay"] = "fairplay";
|
|
23052
|
+
return DrmType2;
|
|
23053
|
+
})(DrmType || {});
|
|
23054
|
+
function getDrmType(drm) {
|
|
23055
|
+
if ((drm == null ? void 0 : drm.fairplay) && (sniffer$1.browser === "safari" || sniffer$1.os.isIos)) {
|
|
23056
|
+
return "fairplay";
|
|
23057
|
+
}
|
|
23058
|
+
return;
|
|
23059
|
+
}
|
|
23060
|
+
function isMseSupportedWithDrm({
|
|
23061
|
+
drm,
|
|
23062
|
+
streamType
|
|
23063
|
+
}) {
|
|
23064
|
+
const drmType = getDrmType(drm);
|
|
23065
|
+
if (!drmType) {
|
|
23066
|
+
return true;
|
|
23067
|
+
}
|
|
23068
|
+
if (drmType === "fairplay" && streamType === "hls") {
|
|
23069
|
+
return false;
|
|
23070
|
+
}
|
|
23071
|
+
return true;
|
|
23072
|
+
}
|
|
23073
|
+
const { isMseSupported: isMseSupported$1 } = util;
|
|
23074
|
+
function enableHlsJs(options) {
|
|
23075
|
+
var _a, _b;
|
|
23076
|
+
if ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableHlsJs) {
|
|
23077
|
+
return true;
|
|
23078
|
+
}
|
|
23079
|
+
if (((_b = options == null ? void 0 : options.ad) == null ? void 0 : _b.adType) === "ssai") {
|
|
23080
|
+
return true;
|
|
23081
|
+
}
|
|
23082
|
+
return false;
|
|
23083
|
+
}
|
|
23084
|
+
const getHlsStrategy = async (options) => {
|
|
23085
|
+
var _a, _b;
|
|
23086
|
+
let mseStrategy;
|
|
23087
|
+
let softStrategy;
|
|
23088
|
+
if (!isMseSupportedWithDrm({ drm: options.drm, streamType: "hls" })) {
|
|
23089
|
+
return { options: {}, plugins: [] };
|
|
23090
|
+
}
|
|
23091
|
+
const codec = await getCodec(options);
|
|
23092
|
+
const isSoftDecode$1 = await isSoftDecode(options, codec);
|
|
23093
|
+
const useHlsJs = enableHlsJs(options);
|
|
23094
|
+
if (isSoftDecode$1) {
|
|
23095
|
+
softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
|
|
23096
|
+
mseStrategy = createHlsMseStrategy(options, useHlsJs);
|
|
23097
|
+
}
|
|
23098
|
+
if ((sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported$1(Codec.H264) : isMseSupported$1(codec))) {
|
|
23099
|
+
mseStrategy = createHlsMseStrategy(options, useHlsJs);
|
|
23100
|
+
}
|
|
23101
|
+
if (!mseStrategy && !softStrategy) {
|
|
23102
|
+
return {};
|
|
23103
|
+
}
|
|
23104
|
+
const [mseModule, softModule] = await Promise.all([
|
|
23105
|
+
(mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
|
|
23106
|
+
(softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
|
|
23107
|
+
]);
|
|
23108
|
+
(softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_b = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _b.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
|
|
23109
|
+
const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
|
|
23110
|
+
return {
|
|
23111
|
+
options: combineOptions$1,
|
|
23112
|
+
plugins: (mseModule == null ? void 0 : mseModule.HlsPlugin) ? [mseModule.HlsPlugin] : []
|
|
23113
|
+
};
|
|
23114
|
+
};
|
|
23115
|
+
function getType(definition) {
|
|
23116
|
+
if (typeof definition === "string") {
|
|
23117
|
+
return getStreamType(definition);
|
|
23118
|
+
}
|
|
23119
|
+
if (definition.type) {
|
|
23120
|
+
return definition.type;
|
|
23121
|
+
}
|
|
23122
|
+
return getStreamType(definition.url);
|
|
23123
|
+
}
|
|
23124
|
+
function pushToEmpty(obj, key, value) {
|
|
23125
|
+
if (!obj[key]) {
|
|
23126
|
+
obj[key] = [];
|
|
23127
|
+
}
|
|
23128
|
+
obj[key].push(value);
|
|
23129
|
+
}
|
|
23130
|
+
function splitPlaylist(playlist) {
|
|
23131
|
+
return playlist.reduce((pre, source) => {
|
|
23132
|
+
const definitionMap = source.definitions.reduce(
|
|
23133
|
+
(preDefinition, definition) => {
|
|
23134
|
+
const type = getType(definition);
|
|
23135
|
+
pushToEmpty(preDefinition, type, definition);
|
|
23136
|
+
return preDefinition;
|
|
23137
|
+
},
|
|
23138
|
+
{}
|
|
23139
|
+
);
|
|
23140
|
+
Object.keys(definitionMap).map((type) => {
|
|
23141
|
+
pushToEmpty(pre, type, {
|
|
23142
|
+
...source,
|
|
23143
|
+
definitions: definitionMap[type]
|
|
23144
|
+
});
|
|
23145
|
+
});
|
|
23146
|
+
return pre;
|
|
23147
|
+
}, {});
|
|
23148
|
+
}
|
|
23149
|
+
function generateUrlFromOtherProtocol(playlist, suffix, targetSuffix) {
|
|
23150
|
+
return modifyPlaylistUrl(playlist, (url) => {
|
|
23151
|
+
return url.replace(suffix, targetSuffix);
|
|
23152
|
+
});
|
|
23153
|
+
}
|
|
23154
|
+
function modifyPlaylistUrl(playlist, callback) {
|
|
23155
|
+
const newPlaylist = [];
|
|
23156
|
+
playlist == null ? void 0 : playlist.forEach((source) => {
|
|
23157
|
+
const definitions = [];
|
|
23158
|
+
source.definitions.forEach((definition) => {
|
|
23159
|
+
var _a;
|
|
23160
|
+
if (typeof definition === "string") {
|
|
23161
|
+
definitions.push(callback(definition));
|
|
23162
|
+
} else {
|
|
23163
|
+
definitions.push({
|
|
23164
|
+
...definition,
|
|
23165
|
+
url: callback(definition.url),
|
|
23166
|
+
fallbackUrls: (_a = definition.fallbackUrls) == null ? void 0 : _a.map(
|
|
23167
|
+
(fallbackUrl) => callback(fallbackUrl)
|
|
23168
|
+
)
|
|
23169
|
+
});
|
|
23170
|
+
}
|
|
23171
|
+
});
|
|
23172
|
+
newPlaylist.push({
|
|
23173
|
+
...source,
|
|
23174
|
+
definitions
|
|
23175
|
+
});
|
|
23176
|
+
});
|
|
23177
|
+
return newPlaylist;
|
|
23178
|
+
}
|
|
23179
|
+
const getDrmStrategy = async (options, player) => {
|
|
23180
|
+
var _a;
|
|
23181
|
+
const drmType = getDrmType(options.drm);
|
|
23182
|
+
if (options.url && drmType === DrmType.Fairplay) {
|
|
23183
|
+
try {
|
|
23184
|
+
const { getDrmConfig, ...originFairplayConfig } = ((_a = options == null ? void 0 : options.drm) == null ? void 0 : _a.fairplay) ?? {};
|
|
23185
|
+
const [drmPlugin, drmConfig] = await Promise.all([
|
|
23186
|
+
load(DynamicModule.PluginDrm).then((module) => module.DrmPlugin).catch(() => void 0),
|
|
23187
|
+
getDrmConfig == null ? void 0 : getDrmConfig({
|
|
23188
|
+
url: options.url
|
|
23098
23189
|
})
|
|
23099
23190
|
]);
|
|
23100
23191
|
const fairplayDrmConfig = Object.assign(
|
|
@@ -23116,29 +23207,547 @@ const getDrmStrategy = async (options, player) => {
|
|
|
23116
23207
|
}
|
|
23117
23208
|
return {};
|
|
23118
23209
|
};
|
|
23119
|
-
|
|
23120
|
-
|
|
23121
|
-
|
|
23122
|
-
|
|
23210
|
+
class HlsProtocol extends BaseProtocol {
|
|
23211
|
+
static get suffix() {
|
|
23212
|
+
return ".m3u8";
|
|
23213
|
+
}
|
|
23214
|
+
get protocolType() {
|
|
23215
|
+
return LiveUrlType.Hls;
|
|
23216
|
+
}
|
|
23217
|
+
get defaultFallbackStrategy() {
|
|
23123
23218
|
return {};
|
|
23124
23219
|
}
|
|
23125
|
-
|
|
23126
|
-
|
|
23220
|
+
static canGenerateOtherProtocol() {
|
|
23221
|
+
return true;
|
|
23222
|
+
}
|
|
23223
|
+
static generateUrl(urls, {
|
|
23224
|
+
generateUrlFromOtherProtocol: generateUrlFromOtherProtocol2
|
|
23225
|
+
}) {
|
|
23226
|
+
if (urls[LiveUrlType.Hls]) {
|
|
23227
|
+
return urls[LiveUrlType.Hls];
|
|
23228
|
+
}
|
|
23229
|
+
if (urls[LiveUrlType.LLHls]) {
|
|
23230
|
+
return modifyPlaylistUrl(urls[LiveUrlType.LLHls], (url) => {
|
|
23231
|
+
return util.appendSearchParams(url, {
|
|
23232
|
+
fpkey_normal_hls: "1"
|
|
23233
|
+
});
|
|
23234
|
+
});
|
|
23235
|
+
}
|
|
23236
|
+
return generateUrlFromOtherProtocol2();
|
|
23237
|
+
}
|
|
23238
|
+
async canPlay() {
|
|
23239
|
+
return { canPlay: true };
|
|
23240
|
+
}
|
|
23241
|
+
shouldFallbackWhenStall() {
|
|
23242
|
+
return false;
|
|
23243
|
+
}
|
|
23244
|
+
async getProtocolStrategy(options) {
|
|
23245
|
+
return getHlsStrategy(options);
|
|
23246
|
+
}
|
|
23247
|
+
async getAbrStrategy(options) {
|
|
23248
|
+
var _a;
|
|
23249
|
+
const abrOptions = (_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.abr;
|
|
23250
|
+
if (!abrOptions) {
|
|
23251
|
+
return {};
|
|
23252
|
+
}
|
|
23253
|
+
const abrPlugin = await load(DynamicModule.PluginAbr).catch(
|
|
23254
|
+
() => void 0
|
|
23255
|
+
);
|
|
23256
|
+
return {
|
|
23257
|
+
options: {
|
|
23258
|
+
hlsabr: {
|
|
23259
|
+
...abrOptions,
|
|
23260
|
+
open: abrOptions.enable ?? true
|
|
23261
|
+
}
|
|
23262
|
+
},
|
|
23263
|
+
plugins: [abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin]
|
|
23264
|
+
};
|
|
23265
|
+
}
|
|
23266
|
+
getDrmStrategy(options, player) {
|
|
23267
|
+
return getDrmStrategy(options, player);
|
|
23268
|
+
}
|
|
23269
|
+
}
|
|
23270
|
+
class HlsLowLatencyProtocol extends BaseProtocol {
|
|
23271
|
+
static get suffix() {
|
|
23272
|
+
return ".m3u8";
|
|
23273
|
+
}
|
|
23274
|
+
get protocolType() {
|
|
23275
|
+
return LiveUrlType.LLHls;
|
|
23276
|
+
}
|
|
23277
|
+
get defaultFallbackStrategy() {
|
|
23127
23278
|
return {};
|
|
23128
23279
|
}
|
|
23129
|
-
|
|
23280
|
+
static generateUrl(urls) {
|
|
23281
|
+
return urls[LiveUrlType.LLHls];
|
|
23282
|
+
}
|
|
23283
|
+
static canGenerateOtherProtocol() {
|
|
23284
|
+
return true;
|
|
23285
|
+
}
|
|
23286
|
+
async canPlay() {
|
|
23287
|
+
return { canPlay: true };
|
|
23288
|
+
}
|
|
23289
|
+
shouldFallbackWhenStall() {
|
|
23290
|
+
return false;
|
|
23291
|
+
}
|
|
23292
|
+
async getProtocolStrategy(options) {
|
|
23293
|
+
return getHlsStrategy(options);
|
|
23294
|
+
}
|
|
23295
|
+
getAbrStrategy() {
|
|
23296
|
+
return void 0;
|
|
23297
|
+
}
|
|
23298
|
+
getDrmStrategy() {
|
|
23299
|
+
return void 0;
|
|
23300
|
+
}
|
|
23301
|
+
}
|
|
23302
|
+
async function isRTMSupported() {
|
|
23303
|
+
const { RtmPlugin } = await load(DynamicModule.PluginRtm);
|
|
23304
|
+
return RtmPlugin.isSupported();
|
|
23305
|
+
}
|
|
23306
|
+
async function isRTMSupportCodec(codec = RTMCodec.H264) {
|
|
23307
|
+
const { RtmPlugin } = await load(DynamicModule.PluginRtm);
|
|
23308
|
+
if (codec === RTMCodec.H264)
|
|
23309
|
+
return RtmPlugin.isSupportedH264();
|
|
23310
|
+
return false;
|
|
23311
|
+
}
|
|
23312
|
+
const rtmStrategy = {
|
|
23313
|
+
options: {},
|
|
23314
|
+
module: DynamicModule.PluginRtm
|
|
23315
|
+
};
|
|
23316
|
+
const generateFallbackUrl = (url) => {
|
|
23317
|
+
if (sniffer$1.device === "pc") {
|
|
23318
|
+
return url.replace(".sdp", ".flv");
|
|
23319
|
+
} else {
|
|
23320
|
+
return url.replace(".sdp", ".m3u8");
|
|
23321
|
+
}
|
|
23322
|
+
};
|
|
23323
|
+
const getRtmStrategy = async (options, player, i18n) => {
|
|
23324
|
+
var _a, _b;
|
|
23325
|
+
let backupStrategy;
|
|
23326
|
+
let actualFallbackUrl = "";
|
|
23327
|
+
const { url, playlist } = options;
|
|
23328
|
+
const { fallbackUrl, enableRTMAutoTranscode, ...ret } = options.rtm || {};
|
|
23329
|
+
let { enableFallback = true } = options.rtm || {};
|
|
23330
|
+
if (playlist == null ? void 0 : playlist.length) {
|
|
23331
|
+
enableFallback = false;
|
|
23332
|
+
}
|
|
23333
|
+
const isRTMAutoTranscode = enableRTMAutoTranscode || ((_a = getUrlObject(url)) == null ? void 0 : _a.searchParams.get("enableRTMAutoTranscode")) === "true";
|
|
23334
|
+
if (enableFallback) {
|
|
23335
|
+
if (fallbackUrl) {
|
|
23336
|
+
actualFallbackUrl = fallbackUrl;
|
|
23337
|
+
} else if (isRTMAutoTranscode && url) {
|
|
23338
|
+
actualFallbackUrl = generateFallbackUrl(url);
|
|
23339
|
+
} else {
|
|
23340
|
+
console.warn(
|
|
23341
|
+
create(ErrorCode.EMPTY_RTM_FALLBACK_PARAMETER, i18n).message
|
|
23342
|
+
);
|
|
23343
|
+
}
|
|
23344
|
+
}
|
|
23345
|
+
const backupType = actualFallbackUrl && util.getStreamType(actualFallbackUrl);
|
|
23346
|
+
if (backupType === "flv" && util.isMseSupported(Codec.H264)) {
|
|
23347
|
+
backupStrategy = createFlvMseStrategy(options);
|
|
23348
|
+
} else if (backupType === "hls" && (sniffer$1.device !== "mobile" || ((_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.enableMSE)) && util.isMseSupported(Codec.H264)) {
|
|
23349
|
+
backupStrategy = createHlsMseStrategy(options);
|
|
23350
|
+
}
|
|
23351
|
+
const [rtmCdn, backupCdn] = await Promise.all([
|
|
23352
|
+
load(rtmStrategy.module).then((module) => {
|
|
23353
|
+
return module.RtmPlugin;
|
|
23354
|
+
}).catch(() => void 0),
|
|
23355
|
+
backupStrategy && load(backupStrategy.module).then((module) => {
|
|
23356
|
+
if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginFlv) {
|
|
23357
|
+
return module.FlvPlugin;
|
|
23358
|
+
} else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginHls) {
|
|
23359
|
+
return module.HlsPlugin;
|
|
23360
|
+
}
|
|
23361
|
+
}).catch(() => void 0)
|
|
23362
|
+
]);
|
|
23363
|
+
if (actualFallbackUrl) {
|
|
23364
|
+
const [RTMSupported, RTMSupportCodec] = await Promise.all([
|
|
23365
|
+
isRTMSupported(),
|
|
23366
|
+
isRTMSupportCodec()
|
|
23367
|
+
]);
|
|
23368
|
+
if (!RTMSupported || !RTMSupportCodec) {
|
|
23369
|
+
if (player) {
|
|
23370
|
+
player.emit("degrade", {
|
|
23371
|
+
url: actualFallbackUrl,
|
|
23372
|
+
originRtmUrl: url,
|
|
23373
|
+
code: "NOT_SUPPORT",
|
|
23374
|
+
message: "not support rtm or h264",
|
|
23375
|
+
isRTMSupported: RTMSupported,
|
|
23376
|
+
isRTMSupportCodec: RTMSupportCodec
|
|
23377
|
+
});
|
|
23378
|
+
}
|
|
23379
|
+
return {
|
|
23380
|
+
options: {
|
|
23381
|
+
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
23382
|
+
url: actualFallbackUrl,
|
|
23383
|
+
_RTMdegrade: {
|
|
23384
|
+
_originRtmUrl: url,
|
|
23385
|
+
_isRTMSupported: RTMSupported,
|
|
23386
|
+
_isRTMSupportCodec: RTMSupportCodec
|
|
23387
|
+
}
|
|
23388
|
+
},
|
|
23389
|
+
plugins: backupCdn ? [backupCdn] : []
|
|
23390
|
+
};
|
|
23391
|
+
}
|
|
23392
|
+
}
|
|
23130
23393
|
return {
|
|
23131
23394
|
options: {
|
|
23132
|
-
|
|
23133
|
-
|
|
23134
|
-
|
|
23395
|
+
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
23396
|
+
url: enableRTMAutoTranscode ? util.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
|
|
23397
|
+
_RTMdegrade: void 0,
|
|
23398
|
+
rts: {
|
|
23399
|
+
retryCount: 0,
|
|
23400
|
+
...ret,
|
|
23401
|
+
backupURL: actualFallbackUrl,
|
|
23402
|
+
backupConstruct: backupCdn
|
|
23135
23403
|
}
|
|
23136
23404
|
},
|
|
23137
|
-
plugins: [
|
|
23138
|
-
streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
|
|
23139
|
-
]
|
|
23405
|
+
plugins: rtmCdn ? [rtmCdn] : []
|
|
23140
23406
|
};
|
|
23141
23407
|
};
|
|
23408
|
+
class RtmProtocol extends BaseProtocol {
|
|
23409
|
+
static get suffix() {
|
|
23410
|
+
return ".sdp";
|
|
23411
|
+
}
|
|
23412
|
+
get protocolType() {
|
|
23413
|
+
return LiveUrlType.Rtm;
|
|
23414
|
+
}
|
|
23415
|
+
get defaultFallbackStrategy() {
|
|
23416
|
+
return { [FallbackKind.Error]: { shouldFallback: () => true } };
|
|
23417
|
+
}
|
|
23418
|
+
static canGenerateOtherProtocol(options) {
|
|
23419
|
+
var _a;
|
|
23420
|
+
return (_a = options.rtm) == null ? void 0 : _a.enableRTMAutoTranscode;
|
|
23421
|
+
}
|
|
23422
|
+
static generateUrl(urls, {
|
|
23423
|
+
generateUrlFromOtherProtocol: generateUrlFromOtherProtocol2,
|
|
23424
|
+
options
|
|
23425
|
+
}) {
|
|
23426
|
+
var _a;
|
|
23427
|
+
if (urls[LiveUrlType.Rtm]) {
|
|
23428
|
+
return urls[LiveUrlType.Rtm];
|
|
23429
|
+
}
|
|
23430
|
+
if ((_a = options.rtm) == null ? void 0 : _a.enableRTMAutoTranscode) {
|
|
23431
|
+
return generateUrlFromOtherProtocol2();
|
|
23432
|
+
}
|
|
23433
|
+
console.warn("生成 rtm 地址失败。请传入 rtm 播放地址,或开启自动转码");
|
|
23434
|
+
return;
|
|
23435
|
+
}
|
|
23436
|
+
async canPlay() {
|
|
23437
|
+
const [isSupported, isSupportCodec] = await Promise.all([
|
|
23438
|
+
isRTMSupported(),
|
|
23439
|
+
isRTMSupportCodec()
|
|
23440
|
+
]);
|
|
23441
|
+
return {
|
|
23442
|
+
canPlay: isSupported && isSupportCodec
|
|
23443
|
+
};
|
|
23444
|
+
}
|
|
23445
|
+
shouldFallbackWhenStall() {
|
|
23446
|
+
return false;
|
|
23447
|
+
}
|
|
23448
|
+
async getProtocolStrategy(options, {
|
|
23449
|
+
player,
|
|
23450
|
+
i18n,
|
|
23451
|
+
enableSelector
|
|
23452
|
+
}) {
|
|
23453
|
+
this.protocolStrategy = await getRtmStrategy(
|
|
23454
|
+
enableSelector ? {
|
|
23455
|
+
options,
|
|
23456
|
+
rtm: {
|
|
23457
|
+
...options.rtm,
|
|
23458
|
+
enableFallback: false
|
|
23459
|
+
}
|
|
23460
|
+
} : options,
|
|
23461
|
+
player,
|
|
23462
|
+
i18n
|
|
23463
|
+
);
|
|
23464
|
+
return this.protocolStrategy;
|
|
23465
|
+
}
|
|
23466
|
+
getAbrStrategy() {
|
|
23467
|
+
return void 0;
|
|
23468
|
+
}
|
|
23469
|
+
getDrmStrategy() {
|
|
23470
|
+
return void 0;
|
|
23471
|
+
}
|
|
23472
|
+
}
|
|
23473
|
+
class ProtocolSelector {
|
|
23474
|
+
constructor({ queue, streams, options }) {
|
|
23475
|
+
// 链开始的类
|
|
23476
|
+
// start?: AbstractProtocol;
|
|
23477
|
+
// 链结束的类,也是当前正在播放的类型
|
|
23478
|
+
__publicField(this, "current");
|
|
23479
|
+
// 降级顺序
|
|
23480
|
+
__publicField(this, "_queue");
|
|
23481
|
+
__publicField(this, "_streams");
|
|
23482
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
23483
|
+
// @ts-ignore
|
|
23484
|
+
__publicField(this, "_options");
|
|
23485
|
+
this._queue = queue;
|
|
23486
|
+
this._streams = streams;
|
|
23487
|
+
this._options = options;
|
|
23488
|
+
this.current = this._getStartProtocol();
|
|
23489
|
+
}
|
|
23490
|
+
// 获取最终返回的播放类型和参数。
|
|
23491
|
+
async getProtocol() {
|
|
23492
|
+
if (!this.current) {
|
|
23493
|
+
return;
|
|
23494
|
+
}
|
|
23495
|
+
const { canPlay } = await this.current.canPlay() ?? {};
|
|
23496
|
+
if (canPlay) {
|
|
23497
|
+
return this.current;
|
|
23498
|
+
}
|
|
23499
|
+
this.next();
|
|
23500
|
+
return this.getProtocol();
|
|
23501
|
+
}
|
|
23502
|
+
// 降级时,将指针指到上次结束的位置
|
|
23503
|
+
next() {
|
|
23504
|
+
var _a;
|
|
23505
|
+
this.current = (_a = this.current) == null ? void 0 : _a.nextProtocol;
|
|
23506
|
+
}
|
|
23507
|
+
// 生成责任链
|
|
23508
|
+
_getStartProtocol() {
|
|
23509
|
+
let nextProtocol;
|
|
23510
|
+
for (let index = this._queue.length - 1; index >= 0; index--) {
|
|
23511
|
+
const type = this._queue[index];
|
|
23512
|
+
const protocol = this._streams[type];
|
|
23513
|
+
if (protocol) {
|
|
23514
|
+
if (nextProtocol) {
|
|
23515
|
+
nextProtocol.preProtocol = protocol;
|
|
23516
|
+
protocol.nextProtocol = nextProtocol;
|
|
23517
|
+
}
|
|
23518
|
+
nextProtocol = protocol;
|
|
23519
|
+
}
|
|
23520
|
+
}
|
|
23521
|
+
return nextProtocol;
|
|
23522
|
+
}
|
|
23523
|
+
}
|
|
23524
|
+
const _LowLatencySelector = class extends ProtocolSelector {
|
|
23525
|
+
// 目前默认传入了默认的低延迟选择顺序,
|
|
23526
|
+
// 也可以支持自定义配置
|
|
23527
|
+
constructor({
|
|
23528
|
+
streams,
|
|
23529
|
+
options
|
|
23530
|
+
}) {
|
|
23531
|
+
super({
|
|
23532
|
+
queue: _LowLatencySelector.queue,
|
|
23533
|
+
streams,
|
|
23534
|
+
options
|
|
23535
|
+
});
|
|
23536
|
+
}
|
|
23537
|
+
};
|
|
23538
|
+
let LowLatencySelector = _LowLatencySelector;
|
|
23539
|
+
__publicField(LowLatencySelector, "queue", [
|
|
23540
|
+
LiveUrlType.Rtm,
|
|
23541
|
+
LiveUrlType.LLFlv,
|
|
23542
|
+
LiveUrlType.Flv,
|
|
23543
|
+
LiveUrlType.LLHls,
|
|
23544
|
+
LiveUrlType.Hls
|
|
23545
|
+
]);
|
|
23546
|
+
class CustomSelector extends ProtocolSelector {
|
|
23547
|
+
constructor({
|
|
23548
|
+
streams,
|
|
23549
|
+
options
|
|
23550
|
+
}) {
|
|
23551
|
+
var _a;
|
|
23552
|
+
super({
|
|
23553
|
+
queue: (_a = options.fallback) == null ? void 0 : _a.fallbackOrder,
|
|
23554
|
+
streams,
|
|
23555
|
+
options
|
|
23556
|
+
});
|
|
23557
|
+
}
|
|
23558
|
+
}
|
|
23559
|
+
__publicField(CustomSelector, "queue");
|
|
23560
|
+
const _ProtocolManager = class {
|
|
23561
|
+
constructor(options) {
|
|
23562
|
+
__publicField(this, "_options");
|
|
23563
|
+
__publicField(this, "_selector");
|
|
23564
|
+
__publicField(this, "_protocol");
|
|
23565
|
+
__publicField(this, "_playlistMap", {});
|
|
23566
|
+
this._options = options;
|
|
23567
|
+
this._init({
|
|
23568
|
+
url: options.url,
|
|
23569
|
+
playlist: options.playlist
|
|
23570
|
+
});
|
|
23571
|
+
}
|
|
23572
|
+
get enableSelector() {
|
|
23573
|
+
return !!this._selector;
|
|
23574
|
+
}
|
|
23575
|
+
get protocol() {
|
|
23576
|
+
return this._protocol;
|
|
23577
|
+
}
|
|
23578
|
+
get playlist() {
|
|
23579
|
+
var _a;
|
|
23580
|
+
return ((_a = this._protocol) == null ? void 0 : _a.protocolType) && this._playlistMap ? this._playlistMap[this._protocol.protocolType] : void 0;
|
|
23581
|
+
}
|
|
23582
|
+
static async create(options) {
|
|
23583
|
+
const protocolManager = new _ProtocolManager(options);
|
|
23584
|
+
await protocolManager.getProtocol();
|
|
23585
|
+
return protocolManager;
|
|
23586
|
+
}
|
|
23587
|
+
static _generateProtocolMap(queue, splittedPlaylist, options) {
|
|
23588
|
+
const protocolMap = {};
|
|
23589
|
+
const playlistMap = {};
|
|
23590
|
+
const baseGenerateProtocol = queue.find((type) => {
|
|
23591
|
+
return _ProtocolManager._protocolMap[type].canGenerateOtherProtocol(options) && splittedPlaylist[type];
|
|
23592
|
+
});
|
|
23593
|
+
queue.forEach((protocolType) => {
|
|
23594
|
+
var _a;
|
|
23595
|
+
const playlist = ((_a = _ProtocolManager._protocolMap[protocolType]) == null ? void 0 : _a.generateUrl(
|
|
23596
|
+
splittedPlaylist,
|
|
23597
|
+
{
|
|
23598
|
+
generateUrlFromOtherProtocol: () => {
|
|
23599
|
+
if (!baseGenerateProtocol) {
|
|
23600
|
+
return;
|
|
23601
|
+
}
|
|
23602
|
+
return generateUrlFromOtherProtocol(
|
|
23603
|
+
splittedPlaylist[baseGenerateProtocol],
|
|
23604
|
+
_ProtocolManager._protocolMap[baseGenerateProtocol].suffix,
|
|
23605
|
+
_ProtocolManager._protocolMap[protocolType].suffix
|
|
23606
|
+
);
|
|
23607
|
+
},
|
|
23608
|
+
options
|
|
23609
|
+
}
|
|
23610
|
+
)) ?? splittedPlaylist[protocolType];
|
|
23611
|
+
if (playlist) {
|
|
23612
|
+
playlistMap[protocolType] = playlist;
|
|
23613
|
+
protocolMap[protocolType] = new _ProtocolManager._protocolMap[protocolType](options);
|
|
23614
|
+
}
|
|
23615
|
+
});
|
|
23616
|
+
return { protocolMap, playlistMap };
|
|
23617
|
+
}
|
|
23618
|
+
async getProtocol() {
|
|
23619
|
+
if (this._selector) {
|
|
23620
|
+
this._protocol = await this._selector.getProtocol();
|
|
23621
|
+
}
|
|
23622
|
+
return this._protocol;
|
|
23623
|
+
}
|
|
23624
|
+
async update({
|
|
23625
|
+
url,
|
|
23626
|
+
playlist
|
|
23627
|
+
}) {
|
|
23628
|
+
this._options = { ...this._options, url, playlist };
|
|
23629
|
+
this._init({
|
|
23630
|
+
url,
|
|
23631
|
+
playlist
|
|
23632
|
+
});
|
|
23633
|
+
await this.getProtocol();
|
|
23634
|
+
}
|
|
23635
|
+
async next() {
|
|
23636
|
+
if (!this._selector) {
|
|
23637
|
+
return;
|
|
23638
|
+
}
|
|
23639
|
+
this._selector.next();
|
|
23640
|
+
await this.getProtocol();
|
|
23641
|
+
return this._protocol;
|
|
23642
|
+
}
|
|
23643
|
+
async getStrategy(player, i18n) {
|
|
23644
|
+
var _a, _b, _c;
|
|
23645
|
+
const protocol = this._protocol;
|
|
23646
|
+
const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
|
|
23647
|
+
protocol == null ? void 0 : protocol.getProtocolStrategy(this._options, {
|
|
23648
|
+
player,
|
|
23649
|
+
i18n,
|
|
23650
|
+
enableSelector: !!this._selector
|
|
23651
|
+
}),
|
|
23652
|
+
(_a = protocol == null ? void 0 : protocol.getDrmStrategy) == null ? void 0 : _a.call(protocol, this._options, player),
|
|
23653
|
+
(_b = protocol == null ? void 0 : protocol.getAbrStrategy) == null ? void 0 : _b.call(protocol, this._options)
|
|
23654
|
+
]);
|
|
23655
|
+
const { options, plugins } = typeStrategy ?? {};
|
|
23656
|
+
const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
|
|
23657
|
+
const { options: abrOptions, plugins: abrPlugins } = abrStrategy ?? {};
|
|
23658
|
+
return {
|
|
23659
|
+
options: Object.assign({}, options, drmOptions, abrOptions),
|
|
23660
|
+
plugins: [
|
|
23661
|
+
...plugins ?? [],
|
|
23662
|
+
...drmPlugins ?? [],
|
|
23663
|
+
...abrPlugins ?? []
|
|
23664
|
+
],
|
|
23665
|
+
useSrc: !((_c = typeStrategy == null ? void 0 : typeStrategy.plugins) == null ? void 0 : _c.length),
|
|
23666
|
+
protocol: protocol == null ? void 0 : protocol.protocolType
|
|
23667
|
+
};
|
|
23668
|
+
}
|
|
23669
|
+
_init({
|
|
23670
|
+
url,
|
|
23671
|
+
playlist
|
|
23672
|
+
}) {
|
|
23673
|
+
var _a;
|
|
23674
|
+
if (playlist) {
|
|
23675
|
+
const splittedPlaylist = splitPlaylist(playlist);
|
|
23676
|
+
const Selector = this._options.latencyMode === "low" ? LowLatencySelector : CustomSelector;
|
|
23677
|
+
const queue = (Selector == null ? void 0 : Selector.queue) ?? ((_a = this._options.fallback) == null ? void 0 : _a.fallbackOrder);
|
|
23678
|
+
if (queue == null ? void 0 : queue.length) {
|
|
23679
|
+
const { protocolMap, playlistMap } = _ProtocolManager._generateProtocolMap(
|
|
23680
|
+
queue,
|
|
23681
|
+
splittedPlaylist,
|
|
23682
|
+
this._options
|
|
23683
|
+
);
|
|
23684
|
+
this._playlistMap = playlistMap;
|
|
23685
|
+
this._selector = new Selector({
|
|
23686
|
+
streams: protocolMap,
|
|
23687
|
+
options: this._options
|
|
23688
|
+
});
|
|
23689
|
+
return;
|
|
23690
|
+
}
|
|
23691
|
+
this._playlistMap = splittedPlaylist;
|
|
23692
|
+
this._initSingleProtocol(Object.keys(splittedPlaylist)[0]);
|
|
23693
|
+
} else if (url) {
|
|
23694
|
+
this._initSingleProtocol(getStreamType(url));
|
|
23695
|
+
}
|
|
23696
|
+
}
|
|
23697
|
+
_initSingleProtocol(protocol) {
|
|
23698
|
+
if (protocol) {
|
|
23699
|
+
this._protocol = new _ProtocolManager._protocolMap[protocol](
|
|
23700
|
+
this._options
|
|
23701
|
+
);
|
|
23702
|
+
}
|
|
23703
|
+
}
|
|
23704
|
+
};
|
|
23705
|
+
let ProtocolManager = _ProtocolManager;
|
|
23706
|
+
__publicField(ProtocolManager, "_protocolMap", {
|
|
23707
|
+
[LiveUrlType.Flv]: FlvProtocol,
|
|
23708
|
+
[LiveUrlType.LLFlv]: FlvLowLatencyProtocol,
|
|
23709
|
+
[LiveUrlType.Hls]: HlsProtocol,
|
|
23710
|
+
[LiveUrlType.LLHls]: HlsLowLatencyProtocol,
|
|
23711
|
+
[LiveUrlType.Rtm]: RtmProtocol
|
|
23712
|
+
});
|
|
23713
|
+
class Fallback {
|
|
23714
|
+
constructor() {
|
|
23715
|
+
__publicField(this, "player");
|
|
23716
|
+
__publicField(this, "protocolManager");
|
|
23717
|
+
__publicField(this, "beforeFallbackError", async (error2) => {
|
|
23718
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23719
|
+
if (!((_b = (_a = this.protocolManager) == null ? void 0 : _a.protocol) == null ? void 0 : _b.shouldFallbackWhenError({ error: error2 })) || !((_d = (_c = this.protocolManager) == null ? void 0 : _c.protocol) == null ? void 0 : _d.nextProtocol)) {
|
|
23720
|
+
return { canEmitError: true };
|
|
23721
|
+
}
|
|
23722
|
+
const nextProtocol = await ((_e = this.protocolManager) == null ? void 0 : _e.next());
|
|
23723
|
+
if (!nextProtocol || !((_f = this.protocolManager) == null ? void 0 : _f.playlist)) {
|
|
23724
|
+
return { canEmitError: true };
|
|
23725
|
+
}
|
|
23726
|
+
this.fallback();
|
|
23727
|
+
return { canEmitError: false };
|
|
23728
|
+
});
|
|
23729
|
+
}
|
|
23730
|
+
initErrorFallback(player, protocolManager) {
|
|
23731
|
+
this.player = player;
|
|
23732
|
+
this.protocolManager = protocolManager;
|
|
23733
|
+
}
|
|
23734
|
+
async fallback() {
|
|
23735
|
+
var _a, _b, _c, _d;
|
|
23736
|
+
if (!((_a = this.protocolManager) == null ? void 0 : _a.playlist))
|
|
23737
|
+
return;
|
|
23738
|
+
const definition = (_b = this.player) == null ? void 0 : _b.definition;
|
|
23739
|
+
const source = (_c = this.player) == null ? void 0 : _c.source;
|
|
23740
|
+
(_d = this.player) == null ? void 0 : _d.updatePlaylist(
|
|
23741
|
+
this.protocolManager.playlist,
|
|
23742
|
+
{
|
|
23743
|
+
definition,
|
|
23744
|
+
source
|
|
23745
|
+
},
|
|
23746
|
+
false
|
|
23747
|
+
);
|
|
23748
|
+
}
|
|
23749
|
+
}
|
|
23750
|
+
const fallback = new Fallback();
|
|
23142
23751
|
VeI18n.extend([
|
|
23143
23752
|
{
|
|
23144
23753
|
LANG: "zh-cn",
|
|
@@ -23170,6 +23779,7 @@ class VePlayerLive extends VePlayerBase {
|
|
|
23170
23779
|
*/
|
|
23171
23780
|
constructor(options) {
|
|
23172
23781
|
super(options);
|
|
23782
|
+
__publicField(this, "_protocolManager");
|
|
23173
23783
|
}
|
|
23174
23784
|
/** {zh}
|
|
23175
23785
|
* @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
|
|
@@ -23360,6 +23970,13 @@ class VePlayerLive extends VePlayerBase {
|
|
|
23360
23970
|
var _a, _b, _c;
|
|
23361
23971
|
return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats();
|
|
23362
23972
|
}
|
|
23973
|
+
async updatePlaylist(playlist, target, needUpdateProtocol = true) {
|
|
23974
|
+
var _a;
|
|
23975
|
+
if (needUpdateProtocol) {
|
|
23976
|
+
await ((_a = this._protocolManager) == null ? void 0 : _a.update({ playlist }));
|
|
23977
|
+
}
|
|
23978
|
+
return super.updatePlaylist(playlist, target);
|
|
23979
|
+
}
|
|
23363
23980
|
}
|
|
23364
23981
|
async function createLivePlayer(options) {
|
|
23365
23982
|
var _a, _b, _c, _d;
|
|
@@ -23378,10 +23995,16 @@ async function createLivePlayer(options) {
|
|
|
23378
23995
|
...options,
|
|
23379
23996
|
plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
|
|
23380
23997
|
};
|
|
23998
|
+
const protocolManager = await ProtocolManager.create(finalOptions);
|
|
23999
|
+
if (!options.url && !(protocolManager == null ? void 0 : protocolManager.playlist)) {
|
|
24000
|
+
throw create(ErrorCode.INVALID_PARAMETER, i18n);
|
|
24001
|
+
}
|
|
23381
24002
|
player = await VePlayerBase.create(
|
|
23382
24003
|
{
|
|
23383
24004
|
...LIVE_DEFAULT_OPTIONS,
|
|
23384
24005
|
...finalOptions,
|
|
24006
|
+
playlist: protocolManager == null ? void 0 : protocolManager.playlist,
|
|
24007
|
+
beforeFallbackError: fallback.beforeFallbackError,
|
|
23385
24008
|
isLive: true,
|
|
23386
24009
|
i18nManager: i18n,
|
|
23387
24010
|
preProcessUrl: (url) => {
|
|
@@ -23393,44 +24016,16 @@ async function createLivePlayer(options) {
|
|
|
23393
24016
|
};
|
|
23394
24017
|
},
|
|
23395
24018
|
async preparePlugins(url) {
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
...finalOptions,
|
|
23401
|
-
url
|
|
23402
|
-
},
|
|
23403
|
-
player,
|
|
23404
|
-
i18n
|
|
23405
|
-
),
|
|
23406
|
-
getDrmStrategy(
|
|
23407
|
-
{
|
|
23408
|
-
...finalOptions,
|
|
23409
|
-
url
|
|
23410
|
-
},
|
|
23411
|
-
player
|
|
23412
|
-
),
|
|
23413
|
-
getAbrStrategy({
|
|
23414
|
-
...finalOptions,
|
|
23415
|
-
url
|
|
23416
|
-
})
|
|
23417
|
-
]);
|
|
23418
|
-
const { options: options2, plugins } = typeStrategy ?? {};
|
|
23419
|
-
const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
|
|
23420
|
-
const { options: abrOptions, plugins: abrPlugins } = abrStrategy ?? {};
|
|
23421
|
-
return {
|
|
23422
|
-
options: Object.assign({}, options2, drmOptions, abrOptions),
|
|
23423
|
-
plugins: [
|
|
23424
|
-
...plugins ?? [],
|
|
23425
|
-
...drmPlugins ?? [],
|
|
23426
|
-
...abrPlugins ?? []
|
|
23427
|
-
],
|
|
23428
|
-
useSrc: !((_a2 = typeStrategy.plugins) == null ? void 0 : _a2.length)
|
|
23429
|
-
};
|
|
24019
|
+
if (!protocolManager.enableSelector) {
|
|
24020
|
+
await protocolManager.update({ url });
|
|
24021
|
+
}
|
|
24022
|
+
return protocolManager.getStrategy(player, i18n);
|
|
23430
24023
|
}
|
|
23431
24024
|
},
|
|
23432
24025
|
VePlayerLive
|
|
23433
24026
|
);
|
|
24027
|
+
player._protocolManager = protocolManager;
|
|
24028
|
+
fallback.initErrorFallback(player, protocolManager);
|
|
23434
24029
|
if (player) {
|
|
23435
24030
|
const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
|
|
23436
24031
|
if (RTMDegrade) {
|