Skip to content

Commit

Permalink
Pull out logging function
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiningTrapez committed Oct 14, 2024
1 parent 929f84e commit 7ad8f25
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/playbackstrategy/msestrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,21 +355,17 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
return parseInt(bitrateInfoList[index].bitrate / 1000)
}

function onQualityChangeRequested(event) {
function logBitrate(event) {
const { mediaType, oldQuality, newQuality } = event
function logBitrate({ mediaType, oldQuality, newQuality }) {
const oldBitrate = isNaN(oldQuality) ? "--" : playbackBitrateForRepresentationIndex(oldQuality, mediaType)
const newBitrate = isNaN(newQuality) ? "--" : playbackBitrateForRepresentationIndex(newQuality, mediaType)

const oldBitrate = isNaN(oldQuality) ? "--" : playbackBitrateForRepresentationIndex(oldQuality, mediaType)
const newBitrate = isNaN(newQuality) ? "--" : playbackBitrateForRepresentationIndex(newQuality, mediaType)
const oldRepresentation = isNaN(oldQuality) ? "Start" : `${oldQuality} (${oldBitrate} kbps)`
const newRepresentation = `${newQuality} (${newBitrate} kbps)`

const oldRepresentation = isNaN(oldQuality) ? "Start" : `${oldQuality} (${oldBitrate} kbps)`
const newRepresentation = `${newQuality} (${newBitrate} kbps)`

DebugTool.info(
`${mediaType} ABR Change Requested From Representation ${oldRepresentation} to ${newRepresentation}`
)
}
DebugTool.info(`${mediaType} ABR Change Requested From Representation ${oldRepresentation} to ${newRepresentation}`)
}

function onQualityChangeRequested(event) {
if (event.newQuality !== undefined) {
logBitrate(event)
}
Expand Down

0 comments on commit 7ad8f25

Please sign in to comment.