From ab64ba18a1f549f6076ce14d3f403d12db3cc0ab Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Tue, 5 Apr 2022 14:26:07 +0200 Subject: [PATCH 1/9] Initial commit; Added functionality to copyQueryUrl that reduces the exported string to 'externalSettings' + actually changed settings --- samples/dash-if-reference-player/app/main.js | 26 ++- .../app/src/defaultSettings.js | 186 ++++++++++++++++++ samples/dash-if-reference-player/index.html | 2 + 3 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 samples/dash-if-reference-player/app/src/defaultSettings.js diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 6a382cda4d..48ee6341c4 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -1438,11 +1438,15 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } } var currentSetting = $scope.player.getSettings(); + currentSetting = $scope.makeSettingDifferencesObject(currentSetting, defaultSettings); + var url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?'; var queryString = externalSettingsString + $scope.toQueryString(currentSetting); var urlString = url + queryString; + if(urlString.slice(-1) === '&') urlString = urlString.slice(0,- 1); + $scope.checkQueryLength(urlString); const element = document.createElement('textarea'); @@ -1453,6 +1457,26 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' document.body.removeChild(element); } + $scope.makeSettingDifferencesObject = function(settings, defaultSettings, isRecursionEnd = true){ + var settingDifferencesObject = {}; + + if (Array.isArray(settings)){ + return settings; + } + + for(var setting in settings){ + console.log(defaultSettings[setting]); + if(typeof defaultSettings[setting] === "object" && defaultSettings[setting] !== null){ + settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); + } + else if(settings[setting] !== defaultSettings[setting]){ + settingDifferencesObject[setting] = settings[setting]; + } + } + + return settingDifferencesObject; + } + /** Transform the current Settings into a nested query-string format */ $scope.toQueryString = function(settings, prefix){ var urlString = []; @@ -1466,7 +1490,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } } // Make the string, then remove all cases of && caused by empty settings - return urlString.join("&").split('&&').join('&'); + return urlString.join("&").split(/&&*/).join('&'); } /** Resolve nested query parameters */ diff --git a/samples/dash-if-reference-player/app/src/defaultSettings.js b/samples/dash-if-reference-player/app/src/defaultSettings.js new file mode 100644 index 0000000000..15068c5915 --- /dev/null +++ b/samples/dash-if-reference-player/app/src/defaultSettings.js @@ -0,0 +1,186 @@ +const defaultSettings = { + debug: { + logLevel: 3, + dispatchEvent: false + }, + streaming: { + abandonLoadTimeout: 10000, + wallclockTimeUpdateInterval: 100, + lowLatencyEnabled: false, + lowLatencyEnabledByManifest: true, + manifestUpdateRetryInterval: 100, + cacheInitSegments: false, + eventControllerRefreshDelay: 150, + capabilities: { + filterUnsupportedEssentialProperties: true, + useMediaCapabilitiesApi: false + }, + timeShiftBuffer: { + calcFromSegmentTimeline: false, + fallbackToSegmentTimeline: true + }, + metrics: { + maxListDepth: 100 + }, + delay: { + liveDelayFragmentCount: NaN, + liveDelay: NaN, + useSuggestedPresentationDelay: true, + applyServiceDescription: true + }, + protection: { + keepProtectionMediaKeys: false, + ignoreEmeEncryptedEvent: false + }, + buffer: { + enableSeekDecorrelationFix: false, + fastSwitchEnabled: true, + flushBufferAtTrackSwitch: false, + reuseExistingSourceBuffers: true, + bufferPruningInterval: 10, + bufferToKeep: 20, + bufferTimeAtTopQuality: 30, + bufferTimeAtTopQualityLongForm: 60, + initialBufferLevel: NaN, + stableBufferTime: 12, + longFormContentDurationThreshold: 600, + stallThreshold: 0.3, + useAppendWindow: true, + setStallState: true + }, + gaps: { + jumpGaps: true, + jumpLargeGaps: true, + smallGapLimit: 1.5, + threshold: 0.3, + enableSeekFix: true + }, + utcSynchronization: { + enabled: true, + useManifestDateHeaderTimeSource: true, + backgroundAttempts: 2, + timeBetweenSyncAttempts: 30, + maximumTimeBetweenSyncAttempts: 600, + minimumTimeBetweenSyncAttempts: 2, + timeBetweenSyncAttemptsAdjustmentFactor: 2, + maximumAllowedDrift: 100, + enableBackgroundSyncAfterSegmentDownloadError: true, + defaultTimingSource: { + scheme: 'urn:mpeg:dash:utc:http-xsdate:2014', + value: 'https://time.akamai.com/?iso&ms' + } + }, + scheduling: { + defaultTimeout: 500, + lowLatencyTimeout: 0, + scheduleWhilePaused: true + }, + text: { + defaultEnabled: true + }, + liveCatchup: { + minDrift: 0.02, + maxDrift: 12, + playbackRate: 0.5, + latencyThreshold: 60, + playbackBufferMin: 0.5, + enabled: false, + mode: 'liveCatchupModeDefault' + }, + lastBitrateCachingInfo: { + enabled: true, + ttl: 360000 + }, + lastMediaSettingsCachingInfo: { + enabled: true, + ttl: 360000 + }, + cacheLoadThresholds: { + video: 50, + audio: 5 + }, + trackSwitchMode: { + audio: 'alwaysReplace', + video: 'neverReplace' + }, + selectionModeForInitialTrack: 'highestSelectionPriority', + fragmentRequestTimeout: 10000, + retryIntervals: { + 'MPD': 500, + 'XLinkExpansion': 500, + 'MediaSegment': 1000, + 'InitializationSegment': 1000, + 'BitstreamSwitchingSegment': 1000, + 'IndexSegment': 1000, + 'FragmentInfoSegment': 1000, + 'license': 1000, + 'other': 1000, + lowLatencyReductionFactor: 10 + }, + retryAttempts: { + 'MPD': 3, + 'XLinkExpansion': 1, + 'MediaSegment': 3, + 'InitializationSegment': 3, + 'BitstreamSwitchingSegment': 3, + 'IndexSegment': 3, + 'FragmentInfoSegment': 3, + 'license': 3, + 'other': 3, + lowLatencyMultiplyFactor: 5 + }, + abr: { + movingAverageMethod: 'slidingWindow', + ABRStrategy: 'abrDynamic', + additionalAbrRules: { + insufficientBufferRule: true, + switchHistoryRule: true, + droppedFramesRule: true, + abandonRequestsRule: false + }, + bandwidthSafetyFactor: 0.9, + useDefaultABRRules: true, + useDeadTimeLatency: true, + limitBitrateByPortal: false, + usePixelRatioInLimitBitrateByPortal: false, + maxBitrate: { + audio: -1, + video: -1 + }, + minBitrate: { + audio: -1, + video: -1 + }, + maxRepresentationRatio: { + audio: 1, + video: 1 + }, + initialBitrate: { + audio: -1, + video: -1 + }, + initialRepresentationRatio: { + audio: -1, + video: -1 + }, + autoSwitchBitrate: { + audio: true, + video: true + }, + fetchThroughputCalculationMode: 'abrFetchThroughputCalculationMoofParsing' + }, + cmcd: { + enabled: false, + sid: null, + cid: null, + rtp: null, + rtpSafetyFactor: 5, + mode: 'query' + } + }, + errors: { + recoverAttempts: { + mediaErrorDecode: 5 + } + } +}; \ No newline at end of file diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index 994f691905..bc8481c8a5 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -26,6 +26,8 @@ + + From 4b84e10589f295307951e3ed0b51e53812e87f77 Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Tue, 5 Apr 2022 15:22:31 +0200 Subject: [PATCH 2/9] Removed hardcoded defaultSettings.js, replaced with dynamic method --- samples/dash-if-reference-player/app/main.js | 5 +- .../app/src/defaultSettings.js | 186 ------------------ samples/dash-if-reference-player/index.html | 2 - 3 files changed, 3 insertions(+), 190 deletions(-) delete mode 100644 samples/dash-if-reference-player/app/src/defaultSettings.js diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 48ee6341c4..52734a9244 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -308,6 +308,8 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' // store a ref in window.player to provide an easy way to play with dash.js API window.player = $scope.player = dashjs.MediaPlayer().create(); /* jshint ignore:line */ + const defaultSettings = JSON.parse(JSON.stringify($scope.player.getSettings())); + $scope.player.on(dashjs.MediaPlayer.events.ERROR, function (e) { /* jshint ignore:line */ console.log(e); if (!e.event) { @@ -1457,7 +1459,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' document.body.removeChild(element); } - $scope.makeSettingDifferencesObject = function(settings, defaultSettings, isRecursionEnd = true){ + $scope.makeSettingDifferencesObject = function(settings, defaultSettings){ var settingDifferencesObject = {}; if (Array.isArray(settings)){ @@ -1465,7 +1467,6 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } for(var setting in settings){ - console.log(defaultSettings[setting]); if(typeof defaultSettings[setting] === "object" && defaultSettings[setting] !== null){ settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); } diff --git a/samples/dash-if-reference-player/app/src/defaultSettings.js b/samples/dash-if-reference-player/app/src/defaultSettings.js deleted file mode 100644 index 15068c5915..0000000000 --- a/samples/dash-if-reference-player/app/src/defaultSettings.js +++ /dev/null @@ -1,186 +0,0 @@ -const defaultSettings = { - debug: { - logLevel: 3, - dispatchEvent: false - }, - streaming: { - abandonLoadTimeout: 10000, - wallclockTimeUpdateInterval: 100, - lowLatencyEnabled: false, - lowLatencyEnabledByManifest: true, - manifestUpdateRetryInterval: 100, - cacheInitSegments: false, - eventControllerRefreshDelay: 150, - capabilities: { - filterUnsupportedEssentialProperties: true, - useMediaCapabilitiesApi: false - }, - timeShiftBuffer: { - calcFromSegmentTimeline: false, - fallbackToSegmentTimeline: true - }, - metrics: { - maxListDepth: 100 - }, - delay: { - liveDelayFragmentCount: NaN, - liveDelay: NaN, - useSuggestedPresentationDelay: true, - applyServiceDescription: true - }, - protection: { - keepProtectionMediaKeys: false, - ignoreEmeEncryptedEvent: false - }, - buffer: { - enableSeekDecorrelationFix: false, - fastSwitchEnabled: true, - flushBufferAtTrackSwitch: false, - reuseExistingSourceBuffers: true, - bufferPruningInterval: 10, - bufferToKeep: 20, - bufferTimeAtTopQuality: 30, - bufferTimeAtTopQualityLongForm: 60, - initialBufferLevel: NaN, - stableBufferTime: 12, - longFormContentDurationThreshold: 600, - stallThreshold: 0.3, - useAppendWindow: true, - setStallState: true - }, - gaps: { - jumpGaps: true, - jumpLargeGaps: true, - smallGapLimit: 1.5, - threshold: 0.3, - enableSeekFix: true - }, - utcSynchronization: { - enabled: true, - useManifestDateHeaderTimeSource: true, - backgroundAttempts: 2, - timeBetweenSyncAttempts: 30, - maximumTimeBetweenSyncAttempts: 600, - minimumTimeBetweenSyncAttempts: 2, - timeBetweenSyncAttemptsAdjustmentFactor: 2, - maximumAllowedDrift: 100, - enableBackgroundSyncAfterSegmentDownloadError: true, - defaultTimingSource: { - scheme: 'urn:mpeg:dash:utc:http-xsdate:2014', - value: 'https://time.akamai.com/?iso&ms' - } - }, - scheduling: { - defaultTimeout: 500, - lowLatencyTimeout: 0, - scheduleWhilePaused: true - }, - text: { - defaultEnabled: true - }, - liveCatchup: { - minDrift: 0.02, - maxDrift: 12, - playbackRate: 0.5, - latencyThreshold: 60, - playbackBufferMin: 0.5, - enabled: false, - mode: 'liveCatchupModeDefault' - }, - lastBitrateCachingInfo: { - enabled: true, - ttl: 360000 - }, - lastMediaSettingsCachingInfo: { - enabled: true, - ttl: 360000 - }, - cacheLoadThresholds: { - video: 50, - audio: 5 - }, - trackSwitchMode: { - audio: 'alwaysReplace', - video: 'neverReplace' - }, - selectionModeForInitialTrack: 'highestSelectionPriority', - fragmentRequestTimeout: 10000, - retryIntervals: { - 'MPD': 500, - 'XLinkExpansion': 500, - 'MediaSegment': 1000, - 'InitializationSegment': 1000, - 'BitstreamSwitchingSegment': 1000, - 'IndexSegment': 1000, - 'FragmentInfoSegment': 1000, - 'license': 1000, - 'other': 1000, - lowLatencyReductionFactor: 10 - }, - retryAttempts: { - 'MPD': 3, - 'XLinkExpansion': 1, - 'MediaSegment': 3, - 'InitializationSegment': 3, - 'BitstreamSwitchingSegment': 3, - 'IndexSegment': 3, - 'FragmentInfoSegment': 3, - 'license': 3, - 'other': 3, - lowLatencyMultiplyFactor: 5 - }, - abr: { - movingAverageMethod: 'slidingWindow', - ABRStrategy: 'abrDynamic', - additionalAbrRules: { - insufficientBufferRule: true, - switchHistoryRule: true, - droppedFramesRule: true, - abandonRequestsRule: false - }, - bandwidthSafetyFactor: 0.9, - useDefaultABRRules: true, - useDeadTimeLatency: true, - limitBitrateByPortal: false, - usePixelRatioInLimitBitrateByPortal: false, - maxBitrate: { - audio: -1, - video: -1 - }, - minBitrate: { - audio: -1, - video: -1 - }, - maxRepresentationRatio: { - audio: 1, - video: 1 - }, - initialBitrate: { - audio: -1, - video: -1 - }, - initialRepresentationRatio: { - audio: -1, - video: -1 - }, - autoSwitchBitrate: { - audio: true, - video: true - }, - fetchThroughputCalculationMode: 'abrFetchThroughputCalculationMoofParsing' - }, - cmcd: { - enabled: false, - sid: null, - cid: null, - rtp: null, - rtpSafetyFactor: 5, - mode: 'query' - } - }, - errors: { - recoverAttempts: { - mediaErrorDecode: 5 - } - } -}; \ No newline at end of file diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index bc8481c8a5..994f691905 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -26,8 +26,6 @@ - - From c4bdebcb12e4d6a9f7f748802e9fd255557bf40b Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Mon, 11 Apr 2022 10:35:43 +0200 Subject: [PATCH 3/9] Changed externalSettings to also only reflect changed settings; Switched from using 'debug' as the delimiter between external and internal settigns to '+' as debug is no longer guaranteed in the string --- samples/dash-if-reference-player/app/main.js | 50 +++++++++++++------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 52734a9244..263a680ee6 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -231,6 +231,20 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.conformanceViolations = []; + var defaultExternalSettings = { + mpd: encodeURIComponent('https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd'), + loop: true, + autoPlay: true, + drmToday: false, + forceQualitySwitchSelected: false, + drmPrioritiesEnabled: false, + languageAudio: null, + roleVideo: null, + languageText: null, + roleText: undefined, + forceTextStreaming: false + } + // metrics $scope.videoBitrate = 0; $scope.videoIndex = 0; @@ -1404,18 +1418,21 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' /** Copy a URL containing the current settings as query Parameters to the Clipboard */ $scope.copyQueryUrl = function(){ - var externalSettingsString = 'mpd=' + encodeURIComponent(decodeURIComponent($scope.selectedItem.url)) - + '&loop=' + $scope.loopSelected - + '&autoPlay=' + $scope.autoPlaySelected - + '&drmToday=' + $scope.drmToday - + '&forceQualitySwitchSelected=' + $scope.forceQualitySwitchSelected - + '&drmPrioritiesEnabled=' + $scope.prioritiesEnabled - + '&languageAudio=' + $scope.initialSettings.audio - + '&roleVideo=' + $scope.initialSettings.video - + '&languageText=' + $scope.initialSettings.text - + '&roleText=' + $scope.initialSettings.textRole - + '&forceTextStreaming=' + $scope.initialSettings.forceTextStreaming - + '&'; + var currentExternalSettings = { + mpd: encodeURIComponent(decodeURIComponent($scope.selectedItem.url)), + loop: $scope.loopSelected, + autoPlay: $scope.autoPlaySelected, + drmToday: $scope.drmToday, + forceQualitySwitchSelected: $scope.forceQualitySwitchSelected, + drmPrioritiesEnabled: $scope.prioritiesEnabled, + languageAudio: $scope.initialSettings.audio, + roleVideo: $scope.initialSettings.video, + languageText: $scope.initialSettings.text, + roleText: $scope.textRole, + forceTextStreaming: $scope.initialSettings.forceTextStreaming + } + + var externalSettingsString = $scope.toQueryString($scope.makeSettingDifferencesObject(currentExternalSettings, defaultExternalSettings)); $scope.handleRequestHeaders(); $scope.handleClearkeys(); @@ -1443,7 +1460,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' currentSetting = $scope.makeSettingDifferencesObject(currentSetting, defaultSettings); var url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?'; - var queryString = externalSettingsString + $scope.toQueryString(currentSetting); + var queryString = externalSettingsString + '+&' + $scope.toQueryString(currentSetting); var urlString = url + queryString; @@ -1640,9 +1657,10 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' var [key, value] = handleExternalSettings[index].split('=') || ''; switch(key){ case 'mpd': - $scope.selectedItem.url = decodeURIComponent(value); + $scope.selectedItem.url = decodeURIComponent(value).slice(0, -1); + break; case 'loop': - $scope.loopSelected = $scope.parseBoolean(value); + $scope.loopSelected = this.parseBoolean(value); break; case 'autoPlay': $scope.autoPlaySelected = this.parseBoolean(value); @@ -1692,7 +1710,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' if(!currentQuery.includes('&')){ return; } - var passedSettings = currentQuery.slice(currentQuery.indexOf('debug')); + var passedSettings = currentQuery.slice(currentQuery.indexOf('+')).substring(1); passedSettings = $scope.toSettingsObject(passedSettings)[0]; $scope.protectionData = $scope.toSettingsObject(currentQuery)[1]; $scope.player.updateSettings(passedSettings); From 2a02958dbbe98ed5ccbab38d2d760ee27f95f8c5 Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Mon, 11 Apr 2022 11:00:56 +0200 Subject: [PATCH 4/9] Fixed settings who are NaN by default not being filtered out of the URL --- samples/dash-if-reference-player/app/main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 05d06ddc9b..ca29939973 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -1469,7 +1469,13 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); } else if(settings[setting] !== defaultSettings[setting]){ - settingDifferencesObject[setting] = settings[setting]; + if(isNaN(settings[setting])){ + // do nothing + } + else { + settingDifferencesObject[setting] = settings[setting]; + } + } } From e84c82ddec2a383ca9c6c63feb331c28edcb166f Mon Sep 17 00:00:00 2001 From: dsilhavy Date: Thu, 14 Apr 2022 13:55:38 +0200 Subject: [PATCH 5/9] Only copy array values in "copy settings url" functionality if an entry has changed --- samples/dash-if-reference-player/app/main.js | 52 +++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 4906e57b3b..815620bc2e 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -1429,7 +1429,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } /** Copy a URL containing the current settings as query Parameters to the Clipboard */ - $scope.copyQueryUrl = function(){ + $scope.copyQueryUrl = function () { var currentExternalSettings = { mpd: encodeURIComponent(decodeURIComponent($scope.selectedItem.url)), loop: $scope.loopSelected, @@ -1476,7 +1476,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' var urlString = url + queryString; - if(urlString.slice(-1) === '&') urlString = urlString.slice(0,- 1); + if (urlString.slice(-1) === '&') urlString = urlString.slice(0, -1); $scope.checkQueryLength(urlString); @@ -1488,22 +1488,25 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' document.body.removeChild(element); } - $scope.makeSettingDifferencesObject = function(settings, defaultSettings){ + $scope.makeSettingDifferencesObject = function (settings, defaultSettings) { var settingDifferencesObject = {}; - if (Array.isArray(settings)){ + if (Array.isArray(settings)) { return settings; } - for(var setting in settings){ - if(typeof defaultSettings[setting] === "object" && defaultSettings[setting] !== null){ + for (var setting in settings) { + if (typeof defaultSettings[setting] === 'object' && defaultSettings[setting] !== null && !(defaultSettings[setting] instanceof Array)) { settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); - } - else if(settings[setting] !== defaultSettings[setting]){ - if(isNaN(settings[setting])){ - // do nothing + } else if (settings[setting] instanceof Array) { + // Check if there is any difference in the array. If so, copy whole array + if (!_arraysEqual(settings[setting], defaultSettings[setting])) { + settingDifferencesObject[setting] = settings[setting]; } - else { + } else if (settings[setting] !== defaultSettings[setting]) { + if (isNaN(settings[setting])) { + // do nothing + } else { settingDifferencesObject[setting] = settings[setting]; } @@ -1513,6 +1516,31 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' return settingDifferencesObject; } + function _arraysEqual(a, b) { + if (a === b) { + return true; + } + if (a == null || b == null) { + return false; + } + if (a.length !== b.length) { + return false; + } + + // If you don't care about the order of the elements inside + // the array, you should sort both arrays here. + // Please note that calling sort on an array will modify that array. + // you might want to clone your array first. + + for (var i = 0; i < a.length; ++i) { + if (a[i] !== b[i]) { + return false; + } + } + + return true; + } + /** Transform the current Settings into a nested query-string format */ $scope.toQueryString = function (settings, prefix) { var urlString = []; @@ -1526,7 +1554,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } } // Make the string, then remove all cases of && caused by empty settings - return urlString.join("&").split(/&&*/).join('&'); + return urlString.join('&').split(/&&*/).join('&'); } /** Resolve nested query parameters */ From 4a947f9423e28838f6251ed5cf42e0caf5622333 Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Thu, 14 Apr 2022 15:01:25 +0200 Subject: [PATCH 6/9] Removed NaN check --- samples/dash-if-reference-player/app/main.js | 34 +++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 815620bc2e..b4020a9a41 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -1455,15 +1455,15 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' switch (drm.drmKeySystem) { case 'com.microsoft.playready': currentDrm = { 'playready': drm }; - externalSettingsString += $scope.toQueryString(currentDrm) + '&'; + externalSettingsString += '&' + $scope.toQueryString(currentDrm); break; case 'com.widevine.alpha': currentDrm = { 'widevine': drm }; - externalSettingsString += $scope.toQueryString(currentDrm) + '&'; + externalSettingsString += '&' + $scope.toQueryString(currentDrm); break; case 'org.w3.clearkey': currentDrm = { 'clearkey': drm }; - externalSettingsString += $scope.toQueryString(currentDrm) + '&'; + externalSettingsString += '&' + $scope.toQueryString(currentDrm); break; } } @@ -1488,28 +1488,30 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' document.body.removeChild(element); } + $scope.compareArrays = function(array1, array2) { + if(array1.length !== array2.length) return false; + + for(var index in array1) { + if(array1[index] !== array2[index]) return false; + } + + return true; + } + $scope.makeSettingDifferencesObject = function (settings, defaultSettings) { var settingDifferencesObject = {}; if (Array.isArray(settings)) { - return settings; + // return compareArrays(settings, defaultSettings) ? settings : {}; + return settings; } for (var setting in settings) { if (typeof defaultSettings[setting] === 'object' && defaultSettings[setting] !== null && !(defaultSettings[setting] instanceof Array)) { settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); - } else if (settings[setting] instanceof Array) { - // Check if there is any difference in the array. If so, copy whole array - if (!_arraysEqual(settings[setting], defaultSettings[setting])) { - settingDifferencesObject[setting] = settings[setting]; - } - } else if (settings[setting] !== defaultSettings[setting]) { - if (isNaN(settings[setting])) { - // do nothing - } else { - settingDifferencesObject[setting] = settings[setting]; - } - + } + else if(settings[setting] !== defaultSettings[setting]){ + settingDifferencesObject[setting] = settings[setting]; } } From dfd5603e6b84f28bce966a48a53648ca31b40322 Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Thu, 14 Apr 2022 16:10:58 +0200 Subject: [PATCH 7/9] Added code to prevent cmcd array being part of the url if default was not changed --- samples/dash-if-reference-player/app/main.js | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index b4020a9a41..eb5ac0b01a 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -1488,22 +1488,12 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' document.body.removeChild(element); } - $scope.compareArrays = function(array1, array2) { - if(array1.length !== array2.length) return false; - - for(var index in array1) { - if(array1[index] !== array2[index]) return false; - } - - return true; - } - $scope.makeSettingDifferencesObject = function (settings, defaultSettings) { var settingDifferencesObject = {}; if (Array.isArray(settings)) { - // return compareArrays(settings, defaultSettings) ? settings : {}; - return settings; + console.log(settings) + return _arraysEqual(settings, defaultSettings) ? settings : {}; } for (var setting in settings) { @@ -1511,7 +1501,13 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); } else if(settings[setting] !== defaultSettings[setting]){ - settingDifferencesObject[setting] = settings[setting]; + if(Array.isArray(settings[setting])){ + _arraysEqual(settings[setting], defaultSettings[setting]) ? settingDifferencesObject[setting] = {} : settingDifferencesObject[setting] = settings[setting]; + } + else { + settingDifferencesObject[setting] = settings[setting]; + } + } } From 91c300b34f0db7ddbdf4dd4d0c804fd388924c55 Mon Sep 17 00:00:00 2001 From: ShikiSeiren Date: Thu, 14 Apr 2022 16:18:21 +0200 Subject: [PATCH 8/9] Fixed error in function order, shortened array handling line --- samples/dash-if-reference-player/app/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index eb5ac0b01a..22e4f6a30c 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -1493,7 +1493,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' if (Array.isArray(settings)) { console.log(settings) - return _arraysEqual(settings, defaultSettings) ? settings : {}; + return _arraysEqual(settings, defaultSettings) ? {} : settings; } for (var setting in settings) { @@ -1502,7 +1502,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } else if(settings[setting] !== defaultSettings[setting]){ if(Array.isArray(settings[setting])){ - _arraysEqual(settings[setting], defaultSettings[setting]) ? settingDifferencesObject[setting] = {} : settingDifferencesObject[setting] = settings[setting]; + settingDifferencesObject[setting] = _arraysEqual(settings[setting], defaultSettings[setting]) ? {} : settings[setting]; } else { settingDifferencesObject[setting] = settings[setting]; From d95cda55cb10b8b548eb67b4f48e21126e0504a8 Mon Sep 17 00:00:00 2001 From: dsilhavy Date: Fri, 22 Apr 2022 08:39:48 +0200 Subject: [PATCH 9/9] Adjust description text for export settings --- .../dash-if-reference-player/app/css/main.css | 4 + samples/dash-if-reference-player/index.html | 149 +++++++++++------- 2 files changed, 100 insertions(+), 53 deletions(-) diff --git a/samples/dash-if-reference-player/app/css/main.css b/samples/dash-if-reference-player/app/css/main.css index 913e5fdcb1..e021400bb4 100644 --- a/samples/dash-if-reference-player/app/css/main.css +++ b/samples/dash-if-reference-player/app/css/main.css @@ -689,6 +689,10 @@ BS Information border-left-color: #5cb85c ; } +.bs-callout-warning { + border-left-color: #f0ad4e ; +} + .bs-callout-danger { border-left-color: #CA0B00; } diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index 9c0dcb05b2..2a521e71ed 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -131,12 +131,12 @@ ng-cloak>{{getOptionsButtonLabel()}} - +
-
URL Copied!
+
URL Copied!
@@ -199,14 +199,16 @@
@@ -247,19 +249,22 @@
@@ -295,13 +300,15 @@
@@ -312,24 +319,29 @@
@@ -600,12 +612,14 @@
@@ -615,7 +629,8 @@
@@ -626,9 +641,11 @@
Live delay
- + - +
- + - + - + @@ -665,12 +685,14 @@ ng-model="initialSettings.textRole" ng-change="updateInitialRoleText()"> @@ -682,26 +704,32 @@ @@ -713,37 +741,43 @@ @@ -759,32 +793,40 @@ Enable CMCD Reporting - + - + - + - + - - + +
@@ -848,12 +890,13 @@
-
-
NewExport settings
- Try out our new "export settings" feature and share your current dash.js settings and DRM parameters easily via URL query parameters. - Click on "Copy Settings URL" on the top right and paste the URL in the address bar of your browser. +
+
UpdatedExport settings
+ Our export settings feature creates smaller URLs now. + Click on "Copy Settings URL" on the top right and paste the URL in the address bar of your browser. The + current settings are compared to the default settings and the difference is stored using query parameters.