Skip to content

Commit

Permalink
Use quality.peakBitrate for BITRATE metric
Browse files Browse the repository at this point in the history
Add additional test
  • Loading branch information
testcenter committed Aug 13, 2024
1 parent 7353551 commit 886ee97
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public HashMap<String, Object[]> getPlaybackVideoData() {
VideoQuality playbackVideoData = player.getPlaybackVideoData();
if (playbackVideoData != null) {
videoData.put(ConvivaSdkConstants.PLAYBACK.RESOLUTION, new Object[]{playbackVideoData.getWidth(), playbackVideoData.getHeight()});
videoData.put(ConvivaSdkConstants.PLAYBACK.BITRATE, new Object[]{playbackVideoData.getBitrate() / 1000});
int averageBitrate = playbackVideoData.getAverageBitrate();
final int peakBitrate = playbackVideoData.getPeakBitrate();
if (peakBitrate != VideoQuality.BITRATE_NO_VALUE) {
videoData.put(ConvivaSdkConstants.PLAYBACK.BITRATE, new Object[]{peakBitrate / 1000});
}
final int averageBitrate = playbackVideoData.getAverageBitrate();
if (averageBitrate != VideoQuality.BITRATE_NO_VALUE) {
videoData.put(ConvivaSdkConstants.PLAYBACK.AVG_BITRATE, new Object[]{averageBitrate / 1000});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.bitmovin.player.api.event.Event
import com.bitmovin.player.api.event.EventListener
import com.bitmovin.player.api.event.PlayerEvent
import com.bitmovin.player.api.event.SourceEvent
import com.bitmovin.player.api.media.Quality
import com.bitmovin.player.api.media.video.quality.VideoQuality
import com.conviva.sdk.ConvivaAdAnalytics
import com.conviva.sdk.ConvivaSdkConstants
Expand Down Expand Up @@ -130,6 +131,35 @@ class ConvivaAnalyticsIntegrationTest {
verify { adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE, 10) }
}

@Test
fun `does not report bitrate, if not available`() {
every { ssaiApi.isAdBreakActive } returns true
Quality.Companion.BITRATE_NO_VALUE
val newVideoQuality = VideoQuality(
id = "id",
label = "label",
bitrate = Quality.Companion.BITRATE_NO_VALUE,
averageBitrate = Quality.Companion.BITRATE_NO_VALUE,
peakBitrate = Quality.Companion.BITRATE_NO_VALUE,
codec = "codec",
frameRate = 10.3F,
width = 400,
height = 300,
)
every { mockedPlayer.playbackVideoData } returns newVideoQuality

player.listeners[PlayerEvent.VideoPlaybackQualityChanged::class]?.forEach { onEvent ->
onEvent(PlayerEvent.VideoPlaybackQualityChanged(null, newVideoQuality))
}

verify(exactly = 0) {
adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.BITRATE, any())
adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.AVG_BITRATE, any())
}
verify { adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.RESOLUTION, 400, 300) }
verify { adAnalytics.reportAdMetric(ConvivaSdkConstants.PLAYBACK.RENDERED_FRAMERATE, 10) }
}

companion object {
@JvmStatic
@BeforeClass
Expand Down

0 comments on commit 886ee97

Please sign in to comment.