@@ -62,30 +62,31 @@ MediaPlayer.rules.DownloadRatioRule = function () {
62
62
len ,
63
63
DOWNLOAD_RATIO_SAFETY_FACTOR = 0.75 ;
64
64
65
- self . debug . log ( "Checking download ratio rule..." ) ;
65
+ // self.debug.log("Checking download ratio rule...");
66
66
67
67
if ( ! metrics ) {
68
- self . debug . log ( "No metrics, bailing." ) ;
68
+ // self.debug.log("No metrics, bailing.");
69
69
return Q . when ( new MediaPlayer . rules . SwitchRequest ( ) ) ;
70
70
}
71
71
72
72
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.");
74
74
return Q . when ( new MediaPlayer . rules . SwitchRequest ( ) ) ;
75
75
}
76
76
77
77
totalTime = ( lastRequest . tfinish . getTime ( ) - lastRequest . trequest . getTime ( ) ) / 1000 ;
78
78
downloadTime = ( lastRequest . tfinish . getTime ( ) - lastRequest . tresponse . getTime ( ) ) / 1000 ;
79
79
80
80
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.");
82
82
return Q . when ( new MediaPlayer . rules . SwitchRequest ( ) ) ;
83
83
}
84
84
85
85
if ( lastRequest . mediaduration === null ||
86
86
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.");
89
90
return Q . when ( new MediaPlayer . rules . SwitchRequest ( ) ) ;
90
91
}
91
92
@@ -97,28 +98,20 @@ MediaPlayer.rules.DownloadRatioRule = function () {
97
98
downloadRatio = ( lastRequest . mediaduration / downloadTime ) * DOWNLOAD_RATIO_SAFETY_FACTOR ;
98
99
99
100
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");
102
103
self . debug . log ( "The ratios are NaN, bailing." ) ;
103
104
return Q . when ( new MediaPlayer . rules . SwitchRequest ( ) ) ;
104
105
}
105
106
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);
116
109
117
110
if ( isNaN ( downloadRatio ) ) {
118
- self . debug . log ( "Invalid ratio, bailing." ) ;
111
+ // self.debug.log("Invalid ratio, bailing.");
119
112
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.");
122
115
if ( current > 0 ) {
123
116
self . debug . log ( "We are not at the lowest bitrate, so switch down." ) ;
124
117
self . manifestExt . getRepresentationFor ( current - 1 , data ) . then (
@@ -130,7 +123,7 @@ MediaPlayer.rules.DownloadRatioRule = function () {
130
123
self . manifestExt . getBandwidth ( representation2 ) . then (
131
124
function ( currentBandwidth ) {
132
125
switchRatio = oneDownBandwidth / currentBandwidth ;
133
- self . debug . log ( "Switch ratio: " + switchRatio ) ;
126
+ // self.debug.log("Switch ratio: " + switchRatio);
134
127
135
128
if ( downloadRatio < switchRatio ) {
136
129
self . debug . log ( "Things must be going pretty bad, switch all the way down." ) ;
@@ -148,16 +141,16 @@ MediaPlayer.rules.DownloadRatioRule = function () {
148
141
}
149
142
) ;
150
143
} 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.");
152
145
deferred . resolve ( new MediaPlayer . rules . SwitchRequest ( current ) ) ;
153
146
}
154
147
} else {
155
- self . debug . log ( "Download ratio is good." ) ;
148
+ // self.debug.log("Download ratio is good.");
156
149
self . manifestExt . getRepresentationCount ( data ) . then (
157
150
function ( max ) {
158
151
max -= 1 ; // 0 based
159
152
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.");
161
154
self . manifestExt . getRepresentationFor ( current + 1 , data ) . then (
162
155
function ( representation1 ) {
163
156
self . manifestExt . getBandwidth ( representation1 ) . then (
@@ -167,19 +160,19 @@ MediaPlayer.rules.DownloadRatioRule = function () {
167
160
self . manifestExt . getBandwidth ( representation2 ) . then (
168
161
function ( currentBandwidth ) {
169
162
switchRatio = oneUpBandwidth / currentBandwidth ;
170
- self . debug . log ( "Switch ratio: " + switchRatio ) ;
163
+ // self.debug.log("Switch ratio: " + switchRatio);
171
164
172
165
if ( downloadRatio >= switchRatio ) {
173
- if ( downloadRatio > 1000 .0) {
166
+ if ( downloadRatio > 100 .0) {
174
167
self . debug . log ( "Tons of bandwidth available, go all the way up." ) ;
175
168
deferred . resolve ( new MediaPlayer . rules . SwitchRequest ( max - 1 ) ) ;
176
169
}
177
- else if ( downloadRatio > 100 .0) {
170
+ else if ( downloadRatio > 10 .0) {
178
171
self . debug . log ( "Just enough bandwidth available, switch up one." ) ;
179
172
deferred . resolve ( new MediaPlayer . rules . SwitchRequest ( current + 1 ) ) ;
180
173
}
181
174
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.");
183
176
i = - 1 ;
184
177
funcs = [ ] ;
185
178
while ( ( i += 1 ) < max ) {
@@ -199,7 +192,7 @@ MediaPlayer.rules.DownloadRatioRule = function () {
199
192
) ;
200
193
}
201
194
} else {
202
- self . debug . log ( "Not enough bandwidth to switch up." ) ;
195
+ // self.debug.log("Not enough bandwidth to switch up.");
203
196
deferred . resolve ( new MediaPlayer . rules . SwitchRequest ( ) ) ;
204
197
}
205
198
}
@@ -211,7 +204,7 @@ MediaPlayer.rules.DownloadRatioRule = function () {
211
204
}
212
205
) ;
213
206
} 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.");
215
208
deferred . resolve ( new MediaPlayer . rules . SwitchRequest ( max ) ) ;
216
209
}
217
210
}
0 commit comments