Skip to content

Commit

Permalink
Compare mediaInfo objects in DashAdapter (#3406)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy authored Sep 11, 2020
1 parent 5a5956e commit 23cf580
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
23 changes: 22 additions & 1 deletion src/dash/DashAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function DashAdapter() {

if (currentMediaInfo[streamInfo.id] && currentMediaInfo[streamInfo.id][type]) {
for (let i = 0, ln = adaptations.length; i < ln; i++) {
if (currentMediaInfo[streamInfo.id][type].isMediaInfoEqual(allMediaInfoForType[i])) {
if (areMediaInfosEqual(currentMediaInfo[streamInfo.id][type], allMediaInfoForType[i])) {
return adaptations[i];
}
}
Expand All @@ -192,6 +192,27 @@ function DashAdapter() {
return adaptations[0];
}

/**
* Compares two mediaInfo objects
* @param {MediaInfo} mInfoOne
* @param {MediaInfo} mInfoTwo
* @returns {boolean}
*/
function areMediaInfosEqual(mInfoOne, mInfoTwo) {
if (!mInfoOne || !mInfoTwo) {
return false;
}

const sameId = mInfoOne.id === mInfoTwo.id;
const sameViewpoint = mInfoOne.viewpoint === mInfoTwo.viewpoint;
const sameLang = mInfoOne.lang === mInfoTwo.lang;
const sameRoles = mInfoOne.roles.toString() === mInfoTwo.roles.toString();
const sameAccessibility = mInfoOne.accessibility.toString() === mInfoTwo.accessibility.toString();
const sameAudioChannelConfiguration = mInfoOne.audioChannelConfiguration.toString() === mInfoTwo.audioChannelConfiguration.toString();

return (sameId && sameViewpoint && sameLang && sameRoles && sameAccessibility && sameAudioChannelConfiguration);
}

/**
* Returns the mediaInfo for a given mediaType
* @param {object} streamInfo
Expand Down
16 changes: 1 addition & 15 deletions src/dash/vo/MediaInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ class MediaInfo {
this.bitrateList = null;
}

isMediaInfoEqual(mediaInfo) {
if (!mediaInfo) {
return false;
}

const sameId = this.id === mediaInfo.id;
const sameViewpoint = this.viewpoint === mediaInfo.viewpoint;
const sameLang = this.lang === mediaInfo.lang;
const sameRoles = this.roles.toString() === mediaInfo.roles.toString();
const sameAccessibility = this.accessibility.toString() === mediaInfo.accessibility.toString();
const sameAudioChannelConfiguration = this.audioChannelConfiguration.toString() === mediaInfo.audioChannelConfiguration.toString();

return (sameId && sameViewpoint && sameLang && sameRoles && sameAccessibility && sameAudioChannelConfiguration);
}
}

export default MediaInfo;
export default MediaInfo;

0 comments on commit 23cf580

Please sign in to comment.