@@ -2,6 +2,23 @@ import window from 'global/window';
2
2
import Config from './config' ;
3
3
import Playlist from './playlist' ;
4
4
import { codecsForPlaylist } from './util/codecs.js' ;
5
+ import logger from './util/logger' ;
6
+
7
+ const logFn = logger ( 'PlaylistSelector' ) ;
8
+ const representationToString = function ( representation ) {
9
+ if ( ! representation || ! representation . playlist ) {
10
+ return ;
11
+ }
12
+ const playlist = representation . playlist ;
13
+
14
+ return JSON . stringify ( {
15
+ id : playlist . id ,
16
+ bandwidth : representation . bandwidth ,
17
+ width : representation . width ,
18
+ height : representation . height ,
19
+ codecs : playlist . attributes && playlist . attributes . CODECS || ''
20
+ } ) ;
21
+ } ;
5
22
6
23
// Utilities
7
24
@@ -137,6 +154,13 @@ export const simpleSelector = function(
137
154
playerHeight ,
138
155
limitRenditionByPlayerDimensions
139
156
) {
157
+
158
+ const options = {
159
+ bandwidth : playerBandwidth ,
160
+ width : playerWidth ,
161
+ height : playerHeight ,
162
+ limitRenditionByPlayerDimensions
163
+ } ;
140
164
// convert the playlists to an intermediary representation to make comparisons easier
141
165
let sortedPlaylistReps = master . playlists . map ( ( playlist ) => {
142
166
let bandwidth ;
@@ -191,7 +215,22 @@ export const simpleSelector = function(
191
215
sortedPlaylistReps [ 0 ]
192
216
) ;
193
217
194
- return chosenRep ? chosenRep . playlist : null ;
218
+ if ( chosenRep && chosenRep . playlist ) {
219
+ let type = 'sortedPlaylistReps' ;
220
+
221
+ if ( bandwidthBestRep ) {
222
+ type = 'bandwidthBestRep' ;
223
+ }
224
+ if ( enabledPlaylistReps [ 0 ] ) {
225
+ type = 'enabledPlaylistReps' ;
226
+ }
227
+ logFn ( `choosing ${ representationToString ( chosenRep ) } using ${ type } with options` , options ) ;
228
+
229
+ return chosenRep . playlist ;
230
+ }
231
+
232
+ logFn ( 'could not choose a playlist with options' , options ) ;
233
+ return null ;
195
234
}
196
235
197
236
// filter out playlists without resolution information
@@ -236,7 +275,24 @@ export const simpleSelector = function(
236
275
sortedPlaylistReps [ 0 ]
237
276
) ;
238
277
239
- return chosenRep ? chosenRep . playlist : null ;
278
+ if ( chosenRep && chosenRep . playlist ) {
279
+ let type = 'sortedPlaylistReps' ;
280
+
281
+ if ( resolutionPlusOneRep ) {
282
+ type = 'resolutionPlusOneRep' ;
283
+ } else if ( resolutionBestRep ) {
284
+ type = 'resolutionBestRep' ;
285
+ } else if ( bandwidthBestRep ) {
286
+ type = 'bandwidthBestRep' ;
287
+ } else if ( enabledPlaylistReps [ 0 ] ) {
288
+ type = 'enabledPlaylistReps' ;
289
+ }
290
+
291
+ logFn ( `choosing ${ representationToString ( chosenRep ) } using ${ type } with options` , options ) ;
292
+ return chosenRep . playlist ;
293
+ }
294
+ logFn ( 'could not choose a playlist with options' , options ) ;
295
+ return null ;
240
296
} ;
241
297
242
298
// Playlist Selectors
0 commit comments