@volcengine/veplayer 2.6.2 → 2.7.0-rc.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.css +1 -2
- package/esm/veplayer.biz.live.development.js +953 -345
- package/esm/veplayer.biz.live.production.css +1 -1
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +285 -93
- package/esm/veplayer.development.css +1 -2
- package/esm/veplayer.development.js +912 -332
- package/esm/veplayer.live.d.ts +285 -93
- package/esm/veplayer.live.development.css +1 -2
- package/esm/veplayer.live.development.js +911 -331
- package/esm/veplayer.live.production.css +1 -1
- package/esm/veplayer.live.production.js +3 -3
- package/esm/veplayer.production.css +1 -1
- 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.css +1 -2
- package/umd/veplayer.biz.live.development.js +953 -345
- package/umd/veplayer.biz.live.production.css +1 -1
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +285 -93
- package/umd/veplayer.development.css +1 -2
- package/umd/veplayer.development.js +912 -332
- package/umd/veplayer.live.d.ts +285 -93
- package/umd/veplayer.live.development.css +1 -2
- package/umd/veplayer.live.development.js +911 -331
- package/umd/veplayer.live.production.css +1 -1
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.css +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 +285 -93
- package/veplayer.live.d.ts +285 -93
- package/veplayer.vod.d.ts +16 -19
|
@@ -11846,14 +11846,6 @@ var __publicField = (obj, key, value) => {
|
|
|
11846
11846
|
const sourceManager = args.player.config.sources.sourceManager;
|
|
11847
11847
|
args.config.list = sourceManager.sources;
|
|
11848
11848
|
}
|
|
11849
|
-
afterCreate() {
|
|
11850
|
-
super.afterCreate();
|
|
11851
|
-
if (this.config.sourceManager.sources.length < 2) {
|
|
11852
|
-
this.hide();
|
|
11853
|
-
} else {
|
|
11854
|
-
this.renderItemList();
|
|
11855
|
-
}
|
|
11856
|
-
}
|
|
11857
11849
|
registerIcons() {
|
|
11858
11850
|
return {
|
|
11859
11851
|
source: { icon: SourceIcon }
|
|
@@ -11862,6 +11854,10 @@ var __publicField = (obj, key, value) => {
|
|
|
11862
11854
|
renderItemList() {
|
|
11863
11855
|
const { sources, source } = this.config.sourceManager;
|
|
11864
11856
|
const i18nManager = this.player.config.i18nManager;
|
|
11857
|
+
if (sources.length < 2) {
|
|
11858
|
+
this.hide();
|
|
11859
|
+
return;
|
|
11860
|
+
}
|
|
11865
11861
|
const renderItems = sources.map((source2) => {
|
|
11866
11862
|
return {
|
|
11867
11863
|
...source2,
|
|
@@ -12543,6 +12539,10 @@ var __publicField = (obj, key, value) => {
|
|
|
12543
12539
|
var _a, _b;
|
|
12544
12540
|
const sourceManager = this.player.config.sourceManager;
|
|
12545
12541
|
const definitions = ((_a = sourceManager.source) == null ? void 0 : _a.definitions) ?? [];
|
|
12542
|
+
if (definitions.length < 2) {
|
|
12543
|
+
this.hide();
|
|
12544
|
+
return;
|
|
12545
|
+
}
|
|
12546
12546
|
const renderItems = definitions.map((definition) => {
|
|
12547
12547
|
const showItem = {
|
|
12548
12548
|
url: definition.url,
|
|
@@ -13463,7 +13463,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13463
13463
|
}
|
|
13464
13464
|
return "unknown";
|
|
13465
13465
|
}
|
|
13466
|
-
function isMseSupported$
|
|
13466
|
+
function isMseSupported$3(codec = Codec.H264) {
|
|
13467
13467
|
if (codec === Codec.H265) {
|
|
13468
13468
|
return sniffer$1.isHevcSupported();
|
|
13469
13469
|
}
|
|
@@ -13494,7 +13494,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13494
13494
|
...util$1,
|
|
13495
13495
|
...DomUtils,
|
|
13496
13496
|
getStreamType,
|
|
13497
|
-
isMseSupported: isMseSupported$
|
|
13497
|
+
isMseSupported: isMseSupported$3,
|
|
13498
13498
|
isSoftDecodeSupported: isSoftDecodeSupported$1,
|
|
13499
13499
|
isMMSSupported: isMMSSupported$2,
|
|
13500
13500
|
appendSearchParams: appendSearchParams$1,
|
|
@@ -14231,10 +14231,12 @@ var __publicField = (obj, key, value) => {
|
|
|
14231
14231
|
__publicField(this, "_events", {});
|
|
14232
14232
|
__publicField(this, "_customMedia");
|
|
14233
14233
|
__publicField(this, "_errorCallback");
|
|
14234
|
+
__publicField(this, "_beforeFallbackError");
|
|
14234
14235
|
var _a, _b, _c, _d, _e, _f;
|
|
14235
14236
|
this._sourceManager = options.sourceManager;
|
|
14236
14237
|
this._preparePlugins = options.preparePlugins;
|
|
14237
14238
|
this._previousPrepareResult = options.prepareResult;
|
|
14239
|
+
this._beforeFallbackError = options.beforeFallbackError;
|
|
14238
14240
|
this._i18nManager = options.i18nManager ?? new VeI18n({
|
|
14239
14241
|
i18n: options.i18n
|
|
14240
14242
|
});
|
|
@@ -14259,6 +14261,9 @@ var __publicField = (obj, key, value) => {
|
|
|
14259
14261
|
...DEFAULT_OPTIONS,
|
|
14260
14262
|
...xgOptions,
|
|
14261
14263
|
definition: {
|
|
14264
|
+
// TODO: ts
|
|
14265
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14266
|
+
// @ts-ignore
|
|
14262
14267
|
list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
|
|
14263
14268
|
defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
|
|
14264
14269
|
...options.definition ?? {}
|
|
@@ -14443,7 +14448,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14443
14448
|
* @brief Retrieve the player SDK version number.
|
|
14444
14449
|
*/
|
|
14445
14450
|
get playerVersion() {
|
|
14446
|
-
return "2.
|
|
14451
|
+
return "2.7.0-rc.0";
|
|
14447
14452
|
}
|
|
14448
14453
|
/** {zh}
|
|
14449
14454
|
* @brief 获取当前播放视频的清晰度唯一标识(definition)。
|
|
@@ -14929,13 +14934,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14929
14934
|
* @hidden
|
|
14930
14935
|
*/
|
|
14931
14936
|
async prepare(url) {
|
|
14932
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
14937
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
14933
14938
|
const result = await ((_a = this._preparePlugins) == null ? void 0 : _a.call(this, url));
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14939
|
+
let isSameProtocol;
|
|
14940
|
+
if ((result == null ? void 0 : result.protocol) && ((_b = this._previousPrepareResult) == null ? void 0 : _b.protocol)) {
|
|
14941
|
+
isSameProtocol = result.protocol === ((_c = this._previousPrepareResult) == null ? void 0 : _c.protocol);
|
|
14942
|
+
} else {
|
|
14943
|
+
const newUrl = ((_d = result == null ? void 0 : result.options) == null ? void 0 : _d.url) ?? url;
|
|
14944
|
+
const oldUrl = (_f = (_e = this._player) == null ? void 0 : _e.config) == null ? void 0 : _f.url;
|
|
14945
|
+
isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
|
|
14946
|
+
}
|
|
14937
14947
|
if (!isSameProtocol) {
|
|
14938
|
-
(
|
|
14948
|
+
(_h = (_g = this._previousPrepareResult) == null ? void 0 : _g.plugins) == null ? void 0 : _h.forEach((plugin) => {
|
|
14939
14949
|
this._player.unRegisterPlugin(plugin.pluginName);
|
|
14940
14950
|
});
|
|
14941
14951
|
}
|
|
@@ -14944,7 +14954,7 @@ var __publicField = (obj, key, value) => {
|
|
|
14944
14954
|
this._player.setConfig(result.options);
|
|
14945
14955
|
}
|
|
14946
14956
|
return {
|
|
14947
|
-
plugins: isSameProtocol ? [] : (
|
|
14957
|
+
plugins: isSameProtocol ? [] : (_i = result == null ? void 0 : result.plugins) == null ? void 0 : _i.map((plugin) => {
|
|
14948
14958
|
return this._player.registerPlugin(plugin);
|
|
14949
14959
|
}),
|
|
14950
14960
|
options: result == null ? void 0 : result.options,
|
|
@@ -14957,11 +14967,18 @@ var __publicField = (obj, key, value) => {
|
|
|
14957
14967
|
const preUrl = this._sourceManager.url;
|
|
14958
14968
|
const url = this._sourceManager.fallback();
|
|
14959
14969
|
if (!url) {
|
|
14970
|
+
const transformedError = transform$1(err, this._i18nManager);
|
|
14971
|
+
try {
|
|
14972
|
+
const { canEmitError } = await this._beforeFallbackError(
|
|
14973
|
+
transformedError
|
|
14974
|
+
);
|
|
14975
|
+
if (!canEmitError) {
|
|
14976
|
+
return;
|
|
14977
|
+
}
|
|
14978
|
+
} catch (error2) {
|
|
14979
|
+
}
|
|
14960
14980
|
this._player.removeClass(STATE_CLASS.ENTER);
|
|
14961
|
-
this.emit(
|
|
14962
|
-
Events$1.FALLBACK_ERROR,
|
|
14963
|
-
transform$1(err, this._i18nManager)
|
|
14964
|
-
);
|
|
14981
|
+
this.emit(Events$1.FALLBACK_ERROR, transformedError);
|
|
14965
14982
|
return;
|
|
14966
14983
|
}
|
|
14967
14984
|
this._player.once("canplay", () => {
|
|
@@ -15041,7 +15058,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15041
15058
|
return new Promise((resolve) => {
|
|
15042
15059
|
const curTime = this._player.currentTime;
|
|
15043
15060
|
const _canplay = () => {
|
|
15044
|
-
console.log("canplay canplay");
|
|
15045
15061
|
this._player.currentTime = curTime;
|
|
15046
15062
|
if (isPaused) {
|
|
15047
15063
|
this._player.once(CANPLAY, () => {
|
|
@@ -19592,44 +19608,6 @@ var __publicField = (obj, key, value) => {
|
|
|
19592
19608
|
return result;
|
|
19593
19609
|
}
|
|
19594
19610
|
}
|
|
19595
|
-
function enableHlsJs(options) {
|
|
19596
|
-
var _a, _b;
|
|
19597
|
-
if ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableHlsJs) {
|
|
19598
|
-
return true;
|
|
19599
|
-
}
|
|
19600
|
-
if (((_b = options == null ? void 0 : options.ad) == null ? void 0 : _b.adType) === "ssai") {
|
|
19601
|
-
return true;
|
|
19602
|
-
}
|
|
19603
|
-
return false;
|
|
19604
|
-
}
|
|
19605
|
-
const getHlsStrategy = async (options) => {
|
|
19606
|
-
var _a, _b;
|
|
19607
|
-
let mseStrategy;
|
|
19608
|
-
let softStrategy;
|
|
19609
|
-
const codec = await getCodec(options);
|
|
19610
|
-
const isSoftDecode$1 = await isSoftDecode(options, codec);
|
|
19611
|
-
const useHlsJs = enableHlsJs(options);
|
|
19612
|
-
if (isSoftDecode$1) {
|
|
19613
|
-
softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
|
|
19614
|
-
mseStrategy = createHlsMseStrategy(options, useHlsJs);
|
|
19615
|
-
}
|
|
19616
|
-
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))) {
|
|
19617
|
-
mseStrategy = createHlsMseStrategy(options, useHlsJs);
|
|
19618
|
-
}
|
|
19619
|
-
if (!mseStrategy && !softStrategy) {
|
|
19620
|
-
return {};
|
|
19621
|
-
}
|
|
19622
|
-
const [mseModule, softModule] = await Promise.all([
|
|
19623
|
-
(mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
|
|
19624
|
-
(softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
|
|
19625
|
-
]);
|
|
19626
|
-
(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));
|
|
19627
|
-
const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
|
|
19628
|
-
return {
|
|
19629
|
-
options: combineOptions$1,
|
|
19630
|
-
plugins: (mseModule == null ? void 0 : mseModule.HlsPlugin) ? [mseModule.HlsPlugin] : []
|
|
19631
|
-
};
|
|
19632
|
-
};
|
|
19633
19611
|
const getDefaultFlvOptions = (options) => {
|
|
19634
19612
|
var _a;
|
|
19635
19613
|
return {
|
|
@@ -19801,203 +19779,6 @@ var __publicField = (obj, key, value) => {
|
|
|
19801
19779
|
i18n
|
|
19802
19780
|
);
|
|
19803
19781
|
}
|
|
19804
|
-
async function isRTMSupported() {
|
|
19805
|
-
const { RtmPlugin } = await load(DynamicModule.PluginRtm);
|
|
19806
|
-
return RtmPlugin.isSupported();
|
|
19807
|
-
}
|
|
19808
|
-
async function isRTMSupportCodec(codec = RTMCodec.H264) {
|
|
19809
|
-
const { RtmPlugin } = await load(DynamicModule.PluginRtm);
|
|
19810
|
-
if (codec === RTMCodec.H264)
|
|
19811
|
-
return RtmPlugin.isSupportedH264();
|
|
19812
|
-
return false;
|
|
19813
|
-
}
|
|
19814
|
-
const rtmStrategy = {
|
|
19815
|
-
options: {},
|
|
19816
|
-
module: DynamicModule.PluginRtm
|
|
19817
|
-
};
|
|
19818
|
-
const generateFallbackUrl = (url) => {
|
|
19819
|
-
if (sniffer$1.device === "pc") {
|
|
19820
|
-
return url.replace(".sdp", ".flv");
|
|
19821
|
-
} else {
|
|
19822
|
-
return url.replace(".sdp", ".m3u8");
|
|
19823
|
-
}
|
|
19824
|
-
};
|
|
19825
|
-
const getRtmStrategy = async (options, player, i18n) => {
|
|
19826
|
-
var _a, _b;
|
|
19827
|
-
let backupStrategy;
|
|
19828
|
-
let actualFallbackUrl = "";
|
|
19829
|
-
const { url, playlist } = options;
|
|
19830
|
-
const { fallbackUrl, enableRTMAutoTranscode, ...ret } = options.rtm || {};
|
|
19831
|
-
let { enableFallback = true } = options.rtm || {};
|
|
19832
|
-
if (playlist == null ? void 0 : playlist.length) {
|
|
19833
|
-
enableFallback = false;
|
|
19834
|
-
}
|
|
19835
|
-
const isRTMAutoTranscode = enableRTMAutoTranscode || ((_a = getUrlObject(url)) == null ? void 0 : _a.searchParams.get("enableRTMAutoTranscode")) === "true";
|
|
19836
|
-
if (enableFallback) {
|
|
19837
|
-
if (fallbackUrl) {
|
|
19838
|
-
actualFallbackUrl = fallbackUrl;
|
|
19839
|
-
} else if (isRTMAutoTranscode && url) {
|
|
19840
|
-
actualFallbackUrl = generateFallbackUrl(url);
|
|
19841
|
-
} else {
|
|
19842
|
-
console.warn(
|
|
19843
|
-
create(ErrorCode.EMPTY_RTM_FALLBACK_PARAMETER, i18n).message
|
|
19844
|
-
);
|
|
19845
|
-
}
|
|
19846
|
-
}
|
|
19847
|
-
const backupType = actualFallbackUrl && util.getStreamType(actualFallbackUrl);
|
|
19848
|
-
if (backupType === "flv" && util.isMseSupported(Codec.H264)) {
|
|
19849
|
-
backupStrategy = createFlvMseStrategy(options);
|
|
19850
|
-
} else if (backupType === "hls" && (sniffer$1.device !== "mobile" || ((_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.enableMSE)) && util.isMseSupported(Codec.H264)) {
|
|
19851
|
-
backupStrategy = createHlsMseStrategy(options);
|
|
19852
|
-
}
|
|
19853
|
-
const [rtmCdn, backupCdn] = await Promise.all([
|
|
19854
|
-
load(rtmStrategy.module).then((module2) => {
|
|
19855
|
-
return module2.RtmPlugin;
|
|
19856
|
-
}).catch(() => void 0),
|
|
19857
|
-
backupStrategy && load(backupStrategy.module).then((module2) => {
|
|
19858
|
-
if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginFlv) {
|
|
19859
|
-
return module2.FlvPlugin;
|
|
19860
|
-
} else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginHls) {
|
|
19861
|
-
return module2.HlsPlugin;
|
|
19862
|
-
}
|
|
19863
|
-
}).catch(() => void 0)
|
|
19864
|
-
]);
|
|
19865
|
-
if (actualFallbackUrl) {
|
|
19866
|
-
const [RTMSupported, RTMSupportCodec] = await Promise.all([
|
|
19867
|
-
isRTMSupported(),
|
|
19868
|
-
isRTMSupportCodec()
|
|
19869
|
-
]);
|
|
19870
|
-
if (!RTMSupported || !RTMSupportCodec) {
|
|
19871
|
-
if (player) {
|
|
19872
|
-
player.emit("degrade", {
|
|
19873
|
-
url: actualFallbackUrl,
|
|
19874
|
-
originRtmUrl: url,
|
|
19875
|
-
code: "NOT_SUPPORT",
|
|
19876
|
-
message: "not support rtm or h264",
|
|
19877
|
-
isRTMSupported: RTMSupported,
|
|
19878
|
-
isRTMSupportCodec: RTMSupportCodec
|
|
19879
|
-
});
|
|
19880
|
-
}
|
|
19881
|
-
return {
|
|
19882
|
-
options: {
|
|
19883
|
-
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
19884
|
-
url: actualFallbackUrl,
|
|
19885
|
-
_RTMdegrade: {
|
|
19886
|
-
_originRtmUrl: url,
|
|
19887
|
-
_isRTMSupported: RTMSupported,
|
|
19888
|
-
_isRTMSupportCodec: RTMSupportCodec
|
|
19889
|
-
}
|
|
19890
|
-
},
|
|
19891
|
-
plugins: backupCdn ? [backupCdn] : []
|
|
19892
|
-
};
|
|
19893
|
-
}
|
|
19894
|
-
}
|
|
19895
|
-
return {
|
|
19896
|
-
options: {
|
|
19897
|
-
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
19898
|
-
url: enableRTMAutoTranscode ? util.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
|
|
19899
|
-
_RTMdegrade: void 0,
|
|
19900
|
-
rts: {
|
|
19901
|
-
retryCount: 0,
|
|
19902
|
-
...ret,
|
|
19903
|
-
backupURL: actualFallbackUrl,
|
|
19904
|
-
backupConstruct: backupCdn
|
|
19905
|
-
}
|
|
19906
|
-
},
|
|
19907
|
-
plugins: rtmCdn ? [rtmCdn] : []
|
|
19908
|
-
};
|
|
19909
|
-
};
|
|
19910
|
-
var DrmType = /* @__PURE__ */ ((DrmType2) => {
|
|
19911
|
-
DrmType2["Fairplay"] = "fairplay";
|
|
19912
|
-
return DrmType2;
|
|
19913
|
-
})(DrmType || {});
|
|
19914
|
-
function getDrmType(drm) {
|
|
19915
|
-
if ((drm == null ? void 0 : drm.fairplay) && (sniffer$1.browser === "safari" || sniffer$1.os.isIos)) {
|
|
19916
|
-
return "fairplay";
|
|
19917
|
-
}
|
|
19918
|
-
return;
|
|
19919
|
-
}
|
|
19920
|
-
function isMseSupportedWithDrm({
|
|
19921
|
-
drm,
|
|
19922
|
-
streamType
|
|
19923
|
-
}) {
|
|
19924
|
-
const drmType = getDrmType(drm);
|
|
19925
|
-
if (!drmType) {
|
|
19926
|
-
return true;
|
|
19927
|
-
}
|
|
19928
|
-
if (drmType === "fairplay" && streamType === "hls") {
|
|
19929
|
-
return false;
|
|
19930
|
-
}
|
|
19931
|
-
return true;
|
|
19932
|
-
}
|
|
19933
|
-
const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$1 } = util;
|
|
19934
|
-
function enableMMS() {
|
|
19935
|
-
return sniffer$1.os.isIos;
|
|
19936
|
-
}
|
|
19937
|
-
function isFLVSupported(codec = Codec.H264) {
|
|
19938
|
-
const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$1;
|
|
19939
|
-
return isMediaSourceSupported(codec);
|
|
19940
|
-
}
|
|
19941
|
-
const { appendSearchParams } = util;
|
|
19942
|
-
const getFlvStrategy = async (options) => {
|
|
19943
|
-
var _a, _b, _c, _d, _e, _f;
|
|
19944
|
-
let mseStrategy;
|
|
19945
|
-
let softStrategy;
|
|
19946
|
-
const enableLowLatency = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency;
|
|
19947
|
-
const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
|
|
19948
|
-
const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
|
|
19949
|
-
const codec = await getCodec(options);
|
|
19950
|
-
const isSoftDecode$1 = await isSoftDecode(options, codec);
|
|
19951
|
-
if (isSoftDecode$1) {
|
|
19952
|
-
softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
|
|
19953
|
-
mseStrategy = createFlvMseStrategy(options);
|
|
19954
|
-
}
|
|
19955
|
-
if (codec === "unknown" ? isFLVSupported(Codec.H264) : isFLVSupported(codec)) {
|
|
19956
|
-
mseStrategy = enableMMS() ? createFlvMssStrategy(options) : createFlvMseStrategy(options);
|
|
19957
|
-
}
|
|
19958
|
-
if (!mseStrategy && !softStrategy) {
|
|
19959
|
-
return {};
|
|
19960
|
-
}
|
|
19961
|
-
const [mseModule, softModule] = await Promise.all([
|
|
19962
|
-
(mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
|
|
19963
|
-
(softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
|
|
19964
|
-
]);
|
|
19965
|
-
(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));
|
|
19966
|
-
const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
|
|
19967
|
-
const plugins = [];
|
|
19968
|
-
if (enableLowLatency) {
|
|
19969
|
-
combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
|
|
19970
|
-
}
|
|
19971
|
-
if (mseModule) {
|
|
19972
|
-
plugins.push(mseModule.FlvPlugin);
|
|
19973
|
-
if (enableLowLatency && enableFrameChasing) {
|
|
19974
|
-
plugins.push(mseModule.Adaptive);
|
|
19975
|
-
}
|
|
19976
|
-
}
|
|
19977
|
-
return {
|
|
19978
|
-
options: combineOptions$1,
|
|
19979
|
-
plugins
|
|
19980
|
-
};
|
|
19981
|
-
};
|
|
19982
|
-
const getTypeStrategy = async (options, player, i18n) => {
|
|
19983
|
-
const type = options.url ? util.getStreamType(options.url) : "";
|
|
19984
|
-
if (!type || type === "unknown") {
|
|
19985
|
-
return { options: {}, plugins: [] };
|
|
19986
|
-
}
|
|
19987
|
-
if (type === "rtm") {
|
|
19988
|
-
return await getRtmStrategy(options, player, i18n);
|
|
19989
|
-
}
|
|
19990
|
-
if (type === "flv") {
|
|
19991
|
-
return await getFlvStrategy(options);
|
|
19992
|
-
}
|
|
19993
|
-
if (type === "hls") {
|
|
19994
|
-
if (!isMseSupportedWithDrm({ drm: options.drm, streamType: type })) {
|
|
19995
|
-
return { options: {}, plugins: [] };
|
|
19996
|
-
}
|
|
19997
|
-
return await getHlsStrategy(options);
|
|
19998
|
-
}
|
|
19999
|
-
return { options: {}, plugins: [] };
|
|
20000
|
-
};
|
|
20001
19782
|
var FUNC_ERROR_TEXT = "Expected a function";
|
|
20002
19783
|
var NAN = 0 / 0;
|
|
20003
19784
|
var symbolTag = "[object Symbol]";
|
|
@@ -22810,7 +22591,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22810
22591
|
device_id: this._deviceId,
|
|
22811
22592
|
error_report_stop: true,
|
|
22812
22593
|
ext: {
|
|
22813
|
-
veplayer_version: "2.
|
|
22594
|
+
veplayer_version: "2.7.0-rc.0",
|
|
22814
22595
|
flv_version: "3.0.21-rc.21",
|
|
22815
22596
|
hls_version: "3.0.21-rc.21",
|
|
22816
22597
|
rts_version: "0.2.1-alpha.14"
|
|
@@ -22824,7 +22605,6 @@ var __publicField = (obj, key, value) => {
|
|
|
22824
22605
|
return transform2 ? transform2(value) : value.toString();
|
|
22825
22606
|
}
|
|
22826
22607
|
function getDefaultRow(data) {
|
|
22827
|
-
var _a;
|
|
22828
22608
|
return {
|
|
22829
22609
|
rows: [
|
|
22830
22610
|
{
|
|
@@ -22840,10 +22620,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22840
22620
|
{
|
|
22841
22621
|
key: "bitrate",
|
|
22842
22622
|
labelTextKey: "BITRATE",
|
|
22843
|
-
value: normalizeNumber(
|
|
22844
|
-
data.bitrate,
|
|
22845
|
-
(value) => `${(value / 1e3).toFixed(2)} kbps`
|
|
22846
|
-
)
|
|
22623
|
+
value: normalizeNumber(data.bitrate, (value) => `${value / 1e3} kbps`)
|
|
22847
22624
|
},
|
|
22848
22625
|
{
|
|
22849
22626
|
key: "gop",
|
|
@@ -22853,7 +22630,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22853
22630
|
{
|
|
22854
22631
|
key: "resolution",
|
|
22855
22632
|
labelTextKey: "RESOLUTION",
|
|
22856
|
-
value: `${normalizeNumber(data.
|
|
22633
|
+
value: `${normalizeNumber(data.height)} * ${normalizeNumber(
|
|
22857
22634
|
data.height
|
|
22858
22635
|
)}`
|
|
22859
22636
|
},
|
|
@@ -22865,14 +22642,14 @@ var __publicField = (obj, key, value) => {
|
|
|
22865
22642
|
{
|
|
22866
22643
|
key: "bufferEnd",
|
|
22867
22644
|
labelTextKey: "BUFFER_END",
|
|
22868
|
-
value: normalizeNumber(
|
|
22645
|
+
value: normalizeNumber(data.bufferEnd)
|
|
22869
22646
|
},
|
|
22870
22647
|
{
|
|
22871
22648
|
key: "currentTime",
|
|
22872
22649
|
labelTextKey: "CURRENT_TIME",
|
|
22873
22650
|
value: normalizeNumber(
|
|
22874
22651
|
data.currentTime,
|
|
22875
|
-
(value) => value.toFixed(
|
|
22652
|
+
(value) => value.toFixed(6) + "s"
|
|
22876
22653
|
)
|
|
22877
22654
|
}
|
|
22878
22655
|
]
|
|
@@ -22885,7 +22662,7 @@ var __publicField = (obj, key, value) => {
|
|
|
22885
22662
|
{
|
|
22886
22663
|
key: "decodeEfficiency",
|
|
22887
22664
|
labelTextKey: "DECODE_EFFICIENCY",
|
|
22888
|
-
value: normalizeNumber(data.decodeFps, (value) => value + "
|
|
22665
|
+
value: normalizeNumber(data.decodeFps, (value) => value + "frames/s")
|
|
22889
22666
|
},
|
|
22890
22667
|
{
|
|
22891
22668
|
key: "decodeCost",
|
|
@@ -23089,13 +22866,323 @@ var __publicField = (obj, key, value) => {
|
|
|
23089
22866
|
DECODE_INFO: "软解信息",
|
|
23090
22867
|
REFRESH: "刷新"
|
|
23091
22868
|
};
|
|
23092
|
-
const
|
|
23093
|
-
|
|
23094
|
-
|
|
23095
|
-
|
|
23096
|
-
|
|
23097
|
-
|
|
23098
|
-
|
|
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([
|
|
23099
23186
|
load(DynamicModule.PluginDrm).then((module2) => module2.DrmPlugin).catch(() => void 0),
|
|
23100
23187
|
getDrmConfig == null ? void 0 : getDrmConfig({
|
|
23101
23188
|
url: options.url
|
|
@@ -23120,29 +23207,547 @@ var __publicField = (obj, key, value) => {
|
|
|
23120
23207
|
}
|
|
23121
23208
|
return {};
|
|
23122
23209
|
};
|
|
23123
|
-
|
|
23124
|
-
|
|
23125
|
-
|
|
23126
|
-
|
|
23210
|
+
class HlsProtocol extends BaseProtocol {
|
|
23211
|
+
static get suffix() {
|
|
23212
|
+
return ".m3u8";
|
|
23213
|
+
}
|
|
23214
|
+
get protocolType() {
|
|
23215
|
+
return LiveUrlType.Hls;
|
|
23216
|
+
}
|
|
23217
|
+
get defaultFallbackStrategy() {
|
|
23127
23218
|
return {};
|
|
23128
23219
|
}
|
|
23129
|
-
|
|
23130
|
-
|
|
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() {
|
|
23131
23278
|
return {};
|
|
23132
23279
|
}
|
|
23133
|
-
|
|
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((module2) => {
|
|
23353
|
+
return module2.RtmPlugin;
|
|
23354
|
+
}).catch(() => void 0),
|
|
23355
|
+
backupStrategy && load(backupStrategy.module).then((module2) => {
|
|
23356
|
+
if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginFlv) {
|
|
23357
|
+
return module2.FlvPlugin;
|
|
23358
|
+
} else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginHls) {
|
|
23359
|
+
return module2.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
|
+
}
|
|
23134
23393
|
return {
|
|
23135
23394
|
options: {
|
|
23136
|
-
|
|
23137
|
-
|
|
23138
|
-
|
|
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
|
|
23139
23403
|
}
|
|
23140
23404
|
},
|
|
23141
|
-
plugins: [
|
|
23142
|
-
streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
|
|
23143
|
-
]
|
|
23405
|
+
plugins: rtmCdn ? [rtmCdn] : []
|
|
23144
23406
|
};
|
|
23145
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();
|
|
23146
23751
|
VeI18n.extend([
|
|
23147
23752
|
{
|
|
23148
23753
|
LANG: "zh-cn",
|
|
@@ -23174,6 +23779,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23174
23779
|
*/
|
|
23175
23780
|
constructor(options) {
|
|
23176
23781
|
super(options);
|
|
23782
|
+
__publicField(this, "_protocolManager");
|
|
23177
23783
|
}
|
|
23178
23784
|
/** {zh}
|
|
23179
23785
|
* @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
|
|
@@ -23353,16 +23959,12 @@ var __publicField = (obj, key, value) => {
|
|
|
23353
23959
|
var _a, _b, _c;
|
|
23354
23960
|
return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
|
|
23355
23961
|
}
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
*/
|
|
23363
|
-
getHLSStats() {
|
|
23364
|
-
var _a, _b, _c;
|
|
23365
|
-
return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats();
|
|
23962
|
+
async updatePlaylist(playlist, target, needUpdateProtocol = true) {
|
|
23963
|
+
var _a;
|
|
23964
|
+
if (needUpdateProtocol) {
|
|
23965
|
+
await ((_a = this._protocolManager) == null ? void 0 : _a.update({ playlist }));
|
|
23966
|
+
}
|
|
23967
|
+
return super.updatePlaylist(playlist, target);
|
|
23366
23968
|
}
|
|
23367
23969
|
}
|
|
23368
23970
|
async function createLivePlayer(options) {
|
|
@@ -23382,10 +23984,16 @@ var __publicField = (obj, key, value) => {
|
|
|
23382
23984
|
...options,
|
|
23383
23985
|
plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
|
|
23384
23986
|
};
|
|
23987
|
+
const protocolManager = await ProtocolManager.create(finalOptions);
|
|
23988
|
+
if (!options.url && !(protocolManager == null ? void 0 : protocolManager.playlist)) {
|
|
23989
|
+
throw create(ErrorCode.INVALID_PARAMETER, i18n);
|
|
23990
|
+
}
|
|
23385
23991
|
player = await VePlayerBase.create(
|
|
23386
23992
|
{
|
|
23387
23993
|
...LIVE_DEFAULT_OPTIONS,
|
|
23388
23994
|
...finalOptions,
|
|
23995
|
+
playlist: protocolManager == null ? void 0 : protocolManager.playlist,
|
|
23996
|
+
beforeFallbackError: fallback.beforeFallbackError,
|
|
23389
23997
|
isLive: true,
|
|
23390
23998
|
i18nManager: i18n,
|
|
23391
23999
|
preProcessUrl: (url) => {
|
|
@@ -23397,44 +24005,16 @@ var __publicField = (obj, key, value) => {
|
|
|
23397
24005
|
};
|
|
23398
24006
|
},
|
|
23399
24007
|
async preparePlugins(url) {
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
...finalOptions,
|
|
23405
|
-
url
|
|
23406
|
-
},
|
|
23407
|
-
player,
|
|
23408
|
-
i18n
|
|
23409
|
-
),
|
|
23410
|
-
getDrmStrategy(
|
|
23411
|
-
{
|
|
23412
|
-
...finalOptions,
|
|
23413
|
-
url
|
|
23414
|
-
},
|
|
23415
|
-
player
|
|
23416
|
-
),
|
|
23417
|
-
getAbrStrategy({
|
|
23418
|
-
...finalOptions,
|
|
23419
|
-
url
|
|
23420
|
-
})
|
|
23421
|
-
]);
|
|
23422
|
-
const { options: options2, plugins } = typeStrategy ?? {};
|
|
23423
|
-
const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
|
|
23424
|
-
const { options: abrOptions, plugins: abrPlugins } = abrStrategy ?? {};
|
|
23425
|
-
return {
|
|
23426
|
-
options: Object.assign({}, options2, drmOptions, abrOptions),
|
|
23427
|
-
plugins: [
|
|
23428
|
-
...plugins ?? [],
|
|
23429
|
-
...drmPlugins ?? [],
|
|
23430
|
-
...abrPlugins ?? []
|
|
23431
|
-
],
|
|
23432
|
-
useSrc: !((_a2 = typeStrategy.plugins) == null ? void 0 : _a2.length)
|
|
23433
|
-
};
|
|
24008
|
+
if (!protocolManager.enableSelector) {
|
|
24009
|
+
await protocolManager.update({ url });
|
|
24010
|
+
}
|
|
24011
|
+
return protocolManager.getStrategy(player, i18n);
|
|
23434
24012
|
}
|
|
23435
24013
|
},
|
|
23436
24014
|
VePlayerLive
|
|
23437
24015
|
);
|
|
24016
|
+
player._protocolManager = protocolManager;
|
|
24017
|
+
fallback.initErrorFallback(player, protocolManager);
|
|
23438
24018
|
if (player) {
|
|
23439
24019
|
const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
|
|
23440
24020
|
if (RTMDegrade) {
|