diff --git a/src/utils/CountryMaps/de.json b/src/utils/CountryMaps/de.json index 7e83bfa4..f01f1d52 100644 --- a/src/utils/CountryMaps/de.json +++ b/src/utils/CountryMaps/de.json @@ -58,6 +58,7 @@ { "code": "GY", "name": "Guyana" }, { "code": "HT", "name": "Haiti" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hongkong" }, { "code": "IN", "name": "Indien" }, { "code": "ID", "name": "Indonesien" }, { "code": "IQ", "name": "Irak" }, @@ -168,6 +169,7 @@ { "code": "SR", "name": "Suriname" }, { "code": "SY", "name": "Syrien" }, { "code": "TJ", "name": "Tadschikistan" }, + { "code": "TW", "name": "Taiwan" }, { "code": "TZ", "name": "Tansania" }, { "code": "TH", "name": "Thailand" }, { "code": "TG", "name": "Togo" }, diff --git a/src/utils/CountryMaps/el.json b/src/utils/CountryMaps/el.json index 87deece6..1aa31b20 100644 --- a/src/utils/CountryMaps/el.json +++ b/src/utils/CountryMaps/el.json @@ -176,6 +176,7 @@ { "code": "TH", "name": "Ταϊλάνδη" }, { "code": "TZ", "name": "Τανζανία" }, { "code": "TJ", "name": "Τατζικιστάν" }, + { "code": "TW", "name": "Ταϊβάν" }, { "code": "JM", "name": "Τζαμάικα" }, { "code": "DJ", "name": "Τζιμπουτί" }, { "code": "TO", "name": "Τόγκα" }, @@ -191,5 +192,6 @@ { "code": "PH", "name": "Φιλιππίνες" }, { "code": "FI", "name": "Φινλανδία" }, { "code": "FJ", "name": "Φίτζι" }, - { "code": "CL", "name": "Χιλή" } + { "code": "CL", "name": "Χιλή" }, + { "code": "HK", "name": "Χονγκ Κονγκ" } ] diff --git a/src/utils/CountryMaps/en.json b/src/utils/CountryMaps/en.json index 9eb09598..c4c61584 100644 --- a/src/utils/CountryMaps/en.json +++ b/src/utils/CountryMaps/en.json @@ -73,6 +73,7 @@ { "code": "GY", "name": "Guyana" }, { "code": "HT", "name": "Haiti" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hong Kong" }, { "code": "HU", "name": "Hungary" }, { "code": "IS", "name": "Iceland" }, { "code": "IN", "name": "India" }, @@ -168,6 +169,7 @@ { "code": "SE", "name": "Sweden" }, { "code": "CH", "name": "Switzerland" }, { "code": "SY", "name": "Syrian Arab Republic" }, + { "code": "TW", "name": "Taiwan" }, { "code": "TJ", "name": "Tajikistan" }, { "code": "TZ", "name": "Tanzania, United Republic of" }, { "code": "TH", "name": "Thailand" }, diff --git a/src/utils/CountryMaps/es.json b/src/utils/CountryMaps/es.json index d97d5213..f2e74d5e 100644 --- a/src/utils/CountryMaps/es.json +++ b/src/utils/CountryMaps/es.json @@ -76,6 +76,7 @@ { "code": "GY", "name": "Guyana" }, { "code": "HT", "name": "Haití" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hong Kong" }, { "code": "HU", "name": "Hungría" }, { "code": "IN", "name": "India" }, { "code": "ID", "name": "Indonesia" }, @@ -171,6 +172,7 @@ { "code": "CH", "name": "Suiza" }, { "code": "SR", "name": "Surinam" }, { "code": "TH", "name": "Tailandia" }, + { "code": "TW", "name": "Taiwán" }, { "code": "TZ", "name": "Tanzania" }, { "code": "TJ", "name": "Tayikistán" }, { "code": "TL", "name": "Timor Oriental" }, diff --git a/src/utils/CountryMaps/fr.json b/src/utils/CountryMaps/fr.json index a60db656..051dc4eb 100644 --- a/src/utils/CountryMaps/fr.json +++ b/src/utils/CountryMaps/fr.json @@ -77,6 +77,7 @@ { "code": "GY", "name": "Guyana" }, { "code": "HT", "name": "Haïti" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hong Kong" }, { "code": "HU", "name": "Hongrie" }, { "code": "IN", "name": "Inde" }, { "code": "ID", "name": "Indonésie" }, @@ -173,6 +174,7 @@ { "code": "SY", "name": "Syrie" }, { "code": "TJ", "name": "Tadjikistan" }, { "code": "TZ", "name": "Tanzanie" }, + { "code": "TW", "name": "Taïwan" }, { "code": "TD", "name": "Tchad" }, { "code": "CZ", "name": "Tchéquie" }, { "code": "TH", "name": "Thaïlande" }, diff --git a/src/utils/CountryMaps/it.json b/src/utils/CountryMaps/it.json index 01891b86..4607ae99 100644 --- a/src/utils/CountryMaps/it.json +++ b/src/utils/CountryMaps/it.json @@ -76,6 +76,7 @@ { "code": "GY", "name": "Guyana" }, { "code": "HT", "name": "Haiti" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hong Kong" }, { "code": "IN", "name": "India" }, { "code": "ID", "name": "Indonesia" }, { "code": "IR", "name": "Iran" }, @@ -171,6 +172,7 @@ { "code": "CH", "name": "Svizzera" }, { "code": "SZ", "name": "eSwatini" }, { "code": "TJ", "name": "Tagikistan" }, + { "code": "TW", "name": "Taiwan" }, { "code": "TZ", "name": "Tanzania" }, { "code": "TH", "name": "Thailandia" }, { "code": "TL", "name": "Timor Est" }, diff --git a/src/utils/CountryMaps/lt.json b/src/utils/CountryMaps/lt.json index b1047592..da8d2541 100644 --- a/src/utils/CountryMaps/lt.json +++ b/src/utils/CountryMaps/lt.json @@ -54,6 +54,7 @@ { "code": "GY", "name": "Gajana" }, { "code": "HT", "name": "Haitis" }, { "code": "HN", "name": "Hondūras" }, + { "code": "HK", "name": "Honkongas" }, { "code": "HU", "name": "Vengrija" }, { "code": "IS", "name": "Islandija" }, { "code": "IN", "name": "Indija" }, @@ -169,6 +170,7 @@ { "code": "TJ", "name": "Tadžikija" }, { "code": "TZ", "name": "Tanzanija" }, { "code": "TH", "name": "Tailandas" }, + { "code": "TW", "name": "Taivanas" }, { "code": "TL", "name": "Rytų Timoras" }, { "code": "TG", "name": "Togas" }, { "code": "TO", "name": "Tonga" }, diff --git a/src/utils/CountryMaps/pl.json b/src/utils/CountryMaps/pl.json index 1f8303aa..ef2808fc 100644 --- a/src/utils/CountryMaps/pl.json +++ b/src/utils/CountryMaps/pl.json @@ -65,6 +65,7 @@ { "code": "ES", "name": "Hiszpania" }, { "code": "NL", "name": "Holandia" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hongkong" }, { "code": "IN", "name": "Indie" }, { "code": "ID", "name": "Indonezja" }, { "code": "IQ", "name": "Irak" }, @@ -166,6 +167,7 @@ { "code": "SE", "name": "Szwecja" }, { "code": "TJ", "name": "Tadżykistan" }, { "code": "TH", "name": "Tajlandia" }, + { "code": "TW", "name": "Tajwan" }, { "code": "TZ", "name": "Tanzania" }, { "code": "TL", "name": "Timor Wschodni" }, { "code": "TG", "name": "Togo" }, diff --git a/src/utils/CountryMaps/sk.json b/src/utils/CountryMaps/sk.json index a4530640..541084e7 100644 --- a/src/utils/CountryMaps/sk.json +++ b/src/utils/CountryMaps/sk.json @@ -58,6 +58,7 @@ { "code": "HT", "name": "Haiti" }, { "code": "NL", "name": "Holandsko" }, { "code": "HN", "name": "Honduras" }, + { "code": "HK", "name": "Hongkong" }, { "code": "HR", "name": "Chorvátsko" }, { "code": "IN", "name": "India" }, { "code": "ID", "name": "Indonézia" }, @@ -172,6 +173,7 @@ { "code": "CH", "name": "Švajčiarsko" }, { "code": "SE", "name": "Švédsko" }, { "code": "TJ", "name": "Tadžikistan" }, + { "code": "TW", "name": "Taiwan" }, { "code": "IT", "name": "Taliansko" }, { "code": "TZ", "name": "Tanzánia" }, { "code": "TH", "name": "Thajsko" }, diff --git a/src/utils/CountryMaps/sr.json b/src/utils/CountryMaps/sr.json index ab8eeab2..ee94ad0c 100644 --- a/src/utils/CountryMaps/sr.json +++ b/src/utils/CountryMaps/sr.json @@ -73,6 +73,7 @@ { "code": "GY", "name": "Гајана" }, { "code": "HT", "name": "Хаити" }, { "code": "HN", "name": "Хондурас" }, + { "code": "HK", "name": "Хонгконг" }, { "code": "HU", "name": "Мађарска" }, { "code": "IS", "name": "Исланд" }, { "code": "IN", "name": "Индија" }, @@ -170,6 +171,7 @@ { "code": "SY", "name": "Сиријска Арапска Република" }, { "code": "TJ", "name": "Таџикистан" }, { "code": "TZ", "name": "Танзанија" }, + { "code": "TW", "name": "Тајван" }, { "code": "TH", "name": "Тајланд" }, { "code": "TL", "name": "Тимор-Лесте" }, { "code": "TG", "name": "Того" }, diff --git a/src/utils/CountryMaps/zh_Hant.json b/src/utils/CountryMaps/zh_Hant.json index ae031616..057919c9 100644 --- a/src/utils/CountryMaps/zh_Hant.json +++ b/src/utils/CountryMaps/zh_Hant.json @@ -73,6 +73,7 @@ { "code": "GY", "name": "蓋亞那" }, { "code": "HT", "name": "海地" }, { "code": "HN", "name": "宏都拉斯" }, + { "code": "HK", "name": "香港" }, { "code": "HU", "name": "匈牙利" }, { "code": "IS", "name": "冰島" }, { "code": "IN", "name": "印度" }, @@ -179,6 +180,7 @@ { "code": "TR", "name": "土耳其" }, { "code": "TM", "name": "土庫曼" }, { "code": "TV", "name": "吐瓦魯" }, + { "code": "TW", "name": "台灣" }, { "code": "UG", "name": "烏干達" }, { "code": "UA", "name": "烏克蘭" }, { "code": "AE", "name": "阿聯" }, diff --git a/src/utils/DashUtils.js b/src/utils/DashUtils.js index 5b8fdd64..0cba5885 100644 --- a/src/utils/DashUtils.js +++ b/src/utils/DashUtils.js @@ -42,55 +42,69 @@ const DashUtils = { }, generate_adaptation_set(VideoFormatArray) { const adaptationSets = []; - const mimeTypes = []; - const mimeObjects = [[]]; - // sort the formats by mime types + + let mimeAudioObjs = []; + VideoFormatArray.forEach(videoFormat => { // the dual formats should not be used if (videoFormat.mimeType.indexOf("video") != -1 && !videoFormat.videoOnly) { return; } - // if these properties are not available, then we skip it because we cannot set these properties - //if (!(videoFormat.hasOwnProperty('initRange') && videoFormat.hasOwnProperty('indexRange'))) { - // return - //} + + const audioTrackId = videoFormat.audioTrackId; const mimeType = videoFormat.mimeType; - const mimeTypeIndex = mimeTypes.indexOf(mimeType); - if (mimeTypeIndex > -1) { - mimeObjects[mimeTypeIndex].push(videoFormat); - } else { - mimeTypes.push(mimeType); - mimeObjects.push([]); - mimeObjects[mimeTypes.length - 1].push(videoFormat); + + for (let i = 0; i < mimeAudioObjs.length; i++) { + const mimeAudioObj = mimeAudioObjs[i]; + + if (mimeAudioObj.audioTrackId == audioTrackId && mimeAudioObj.mimeType == mimeType) { + mimeAudioObj.videoFormats.push(videoFormat); + return; + } } + + mimeAudioObjs.push({ + audioTrackId, + mimeType, + videoFormats: [videoFormat], + }); }); - // for each MimeType generate a new Adaptation set with Representations as sub elements - for (let i = 0; i < mimeTypes.length; i++) { - let isVideoFormat = false; + + mimeAudioObjs.forEach(mimeAudioObj => { const adapSet = { type: "element", name: "AdaptationSet", attributes: { - id: i, - mimeType: mimeTypes[i], + id: mimeAudioObj.audioTrackId, + lang: mimeAudioObj.audioTrackId?.substr(0, 2), + mimeType: mimeAudioObj.mimeType, startWithSAP: "1", subsegmentAlignment: "true", }, elements: [], }; - if (!mimeTypes[i].includes("audio")) { - adapSet.attributes.scanType = "progressive"; + + let isVideoFormat = false; + + if (mimeAudioObj.mimeType.includes("video")) { isVideoFormat = true; } - mimeObjects[i].forEach(format => { + + if (isVideoFormat) { + adapSet.attributes.scanType = "progressive"; + } + + for (var i = 0; i < mimeAudioObj.videoFormats.length; i++) { + const videoFormat = mimeAudioObj.videoFormats[i]; if (isVideoFormat) { - adapSet.elements.push(this.generate_representation_video(format)); + adapSet.elements.push(this.generate_representation_video(videoFormat)); } else { - adapSet.elements.push(this.generate_representation_audio(format)); + adapSet.elements.push(this.generate_representation_audio(videoFormat)); } - }); + } + adaptationSets.push(adapSet); - } + }); return adaptationSets; }, generate_representation_audio(Format) {