Skip to content

Commit 3806cfe

Browse files
author
Kirk Shoop (MS OPEN TECH)
committed
change abr switch constants to be more conservative
reduce log
1 parent 6506f01 commit 3806cfe

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

app/js/streaming/rules/DownloadRatioRule.js

+24-31
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,31 @@ MediaPlayer.rules.DownloadRatioRule = function () {
6262
len,
6363
DOWNLOAD_RATIO_SAFETY_FACTOR = 0.75;
6464

65-
self.debug.log("Checking download ratio rule...");
65+
//self.debug.log("Checking download ratio rule...");
6666

6767
if (!metrics) {
68-
self.debug.log("No metrics, bailing.");
68+
//self.debug.log("No metrics, bailing.");
6969
return Q.when(new MediaPlayer.rules.SwitchRequest());
7070
}
7171

7272
if (lastRequest === null) {
73-
self.debug.log("No requests made for this stream yet, bailing.");
73+
//self.debug.log("No requests made for this stream yet, bailing.");
7474
return Q.when(new MediaPlayer.rules.SwitchRequest());
7575
}
7676

7777
totalTime = (lastRequest.tfinish.getTime() - lastRequest.trequest.getTime()) / 1000;
7878
downloadTime = (lastRequest.tfinish.getTime() - lastRequest.tresponse.getTime()) / 1000;
7979

8080
if (totalTime <= 0) {
81-
self.debug.log("Don't know how long the download of the last fragment took, bailing.");
81+
//self.debug.log("Don't know how long the download of the last fragment took, bailing.");
8282
return Q.when(new MediaPlayer.rules.SwitchRequest());
8383
}
8484

8585
if (lastRequest.mediaduration === null ||
8686
lastRequest.mediaduration === undefined ||
87-
lastRequest.mediaduration <= 0) {
88-
self.debug.log("Don't know the duration of the last media fragment, bailing.");
87+
lastRequest.mediaduration <= 0 ||
88+
isNaN(lastRequest.mediaduration)) {
89+
//self.debug.log("Don't know the duration of the last media fragment, bailing.");
8990
return Q.when(new MediaPlayer.rules.SwitchRequest());
9091
}
9192

@@ -97,28 +98,20 @@ MediaPlayer.rules.DownloadRatioRule = function () {
9798
downloadRatio = (lastRequest.mediaduration / downloadTime) * DOWNLOAD_RATIO_SAFETY_FACTOR;
9899

99100
if (isNaN(downloadRatio) || isNaN(totalRatio)) {
100-
self.debug.log("Total time: " + totalTime + "s");
101-
self.debug.log("Download time: " + downloadTime + "s");
101+
//self.debug.log("Total time: " + totalTime + "s");
102+
//self.debug.log("Download time: " + downloadTime + "s");
102103
self.debug.log("The ratios are NaN, bailing.");
103104
return Q.when(new MediaPlayer.rules.SwitchRequest());
104105
}
105106

106-
self.debug.log("Total ratio: " + totalRatio);
107-
self.debug.log("Download ratio: " + downloadRatio);
108-
109-
// if (totalRatio * 2 < downloadRatio) {
110-
// don't let data buffering or caching hide the time it
111-
// took to down load the data in the latency bucket
112-
//downloadRatio = (totalRatio * DOWNLOAD_RATIO_SAFETY_FACTOR);
113-
// }
114-
115-
self.debug.log("Download ratio: " + downloadRatio);
107+
//self.debug.log("Total ratio: " + totalRatio);
108+
//self.debug.log("Download ratio: " + downloadRatio);
116109

117110
if (isNaN(downloadRatio)) {
118-
self.debug.log("Invalid ratio, bailing.");
111+
//self.debug.log("Invalid ratio, bailing.");
119112
deferred.resolve(new MediaPlayer.rules.SwitchRequest());
120-
} else if (downloadRatio < 1.0) {
121-
self.debug.log("Download ratio is poor.");
113+
} else if (downloadRatio < 4.0) {
114+
//self.debug.log("Download ratio is poor.");
122115
if (current > 0) {
123116
self.debug.log("We are not at the lowest bitrate, so switch down.");
124117
self.manifestExt.getRepresentationFor(current - 1, data).then(
@@ -130,7 +123,7 @@ MediaPlayer.rules.DownloadRatioRule = function () {
130123
self.manifestExt.getBandwidth(representation2).then(
131124
function (currentBandwidth) {
132125
switchRatio = oneDownBandwidth / currentBandwidth;
133-
self.debug.log("Switch ratio: " + switchRatio);
126+
//self.debug.log("Switch ratio: " + switchRatio);
134127

135128
if (downloadRatio < switchRatio) {
136129
self.debug.log("Things must be going pretty bad, switch all the way down.");
@@ -148,16 +141,16 @@ MediaPlayer.rules.DownloadRatioRule = function () {
148141
}
149142
);
150143
} else {
151-
self.debug.log("We are at the lowest bitrate and cannot switch down, use current.");
144+
//self.debug.log("We are at the lowest bitrate and cannot switch down, use current.");
152145
deferred.resolve(new MediaPlayer.rules.SwitchRequest(current));
153146
}
154147
} else {
155-
self.debug.log("Download ratio is good.");
148+
//self.debug.log("Download ratio is good.");
156149
self.manifestExt.getRepresentationCount(data).then(
157150
function (max) {
158151
max -= 1; // 0 based
159152
if (current < max) {
160-
self.debug.log("We are not at the highest bitrate, so switch up.");
153+
//self.debug.log("We are not at the highest bitrate, so switch up.");
161154
self.manifestExt.getRepresentationFor(current + 1, data).then(
162155
function (representation1) {
163156
self.manifestExt.getBandwidth(representation1).then(
@@ -167,19 +160,19 @@ MediaPlayer.rules.DownloadRatioRule = function () {
167160
self.manifestExt.getBandwidth(representation2).then(
168161
function (currentBandwidth) {
169162
switchRatio = oneUpBandwidth / currentBandwidth;
170-
self.debug.log("Switch ratio: " + switchRatio);
163+
//self.debug.log("Switch ratio: " + switchRatio);
171164

172165
if (downloadRatio >= switchRatio) {
173-
if (downloadRatio > 1000.0) {
166+
if (downloadRatio > 100.0) {
174167
self.debug.log("Tons of bandwidth available, go all the way up.");
175168
deferred.resolve(new MediaPlayer.rules.SwitchRequest(max - 1));
176169
}
177-
else if (downloadRatio > 100.0) {
170+
else if (downloadRatio > 10.0) {
178171
self.debug.log("Just enough bandwidth available, switch up one.");
179172
deferred.resolve(new MediaPlayer.rules.SwitchRequest(current + 1));
180173
}
181174
else {
182-
self.debug.log("Not exactly sure where to go, so do some math.");
175+
//self.debug.log("Not exactly sure where to go, so do some math.");
183176
i = -1;
184177
funcs = [];
185178
while ((i += 1) < max) {
@@ -199,7 +192,7 @@ MediaPlayer.rules.DownloadRatioRule = function () {
199192
);
200193
}
201194
} else {
202-
self.debug.log("Not enough bandwidth to switch up.");
195+
//self.debug.log("Not enough bandwidth to switch up.");
203196
deferred.resolve(new MediaPlayer.rules.SwitchRequest());
204197
}
205198
}
@@ -211,7 +204,7 @@ MediaPlayer.rules.DownloadRatioRule = function () {
211204
}
212205
);
213206
} else {
214-
self.debug.log("We are at the highest bitrate and cannot switch up, use current.");
207+
//self.debug.log("We are at the highest bitrate and cannot switch up, use current.");
215208
deferred.resolve(new MediaPlayer.rules.SwitchRequest(max));
216209
}
217210
}

0 commit comments

Comments
 (0)