3f87ad97 by Tom Johnson

Document rendition selection logic in README and update code commentary for rend…

…ition sort by viewport logic
1 parent 441895be
...@@ -101,5 +101,22 @@ configured. Easy [instructions are ...@@ -101,5 +101,22 @@ configured. Easy [instructions are
101 available](http://enable-cors.org/server.html) for popular webservers 101 available](http://enable-cors.org/server.html) for popular webservers
102 and most CDNs should have no trouble turning CORS on for your account. 102 and most CDNs should have no trouble turning CORS on for your account.
103 103
104 ## MBR Rendition Selection Logic
105 In situations where manifests have multiple renditions, the player will
106 go through the following algorithm to determine the best rendition by
107 bandwidth and viewport dimensions.
108
109 - Start on index 0 as defined in the HLS Spec (link above)
110 - On a successful load complete per segment determine the following;
111 - player.hls.bandwidth set to value as segment byte size over download time
112 - Viewport width/height as determined by player.width()/player.height()
113 - Playlists mapped and sorted by BANDWIDTH less than or equal to 1.1x player.hls.bandwidth
114 - Best playlist variant by BANDWIDTH determined
115 - Subset of bandwidth appropriate renditions mapped
116 - Subset validated for RESOLUTION attributes less than or equal to player dimensions
117 - Best playlist variant by RESOLUTION determined
118 - Result is as follows;
119 - [Best RESOLUTION variant] OR [Best BANDWIDTH variant] OR [inital playlist in manifest]
120
104 ## Release History 121 ## Release History
105 _(Nothing yet)_ 122 _(Nothing yet)_
......
...@@ -85,6 +85,8 @@ var ...@@ -85,6 +85,8 @@ var
85 85
86 rightWidth = rightWidth || window.Number.MAX_VALUE; 86 rightWidth = rightWidth || window.Number.MAX_VALUE;
87 87
88 // NOTE - Fallback to bandwidth sort as appropriate in cases where multiple renditions
89 // have the same media dimensions/ resolution
88 if (leftWidth === rightWidth && left.attributes.BANDWIDTH && right.attributes.BANDWIDTH) { 90 if (leftWidth === rightWidth && left.attributes.BANDWIDTH && right.attributes.BANDWIDTH) {
89 return left.attributes.BANDWIDTH - right.attributes.BANDWIDTH; 91 return left.attributes.BANDWIDTH - right.attributes.BANDWIDTH;
90 } else { 92 } else {
......