-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wire up SSAI #73
Merged
Merged
Wire up SSAI #73
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5f70eb7
Add SSAI api to ConvivaAnalyticsIntegration
strangesource 7ea5924
Expose SSAI namespace on ConvivaAnalyticsIntegration
strangesource 8ca10ac
Reset SSAI state on internal session end
strangesource 1bd6baa
Report stream error as ad error in case of active SSAI ad
strangesource 77ab16e
Add first instrumentation test
strangesource aecc986
Add unit tests for SSAI in ConvivaAnalyticsIntegration
strangesource e1d45db
Merge branch 'develop' into wire-up-ssai
strangesource 2499557
Reset potential ads and ad break on reset
strangesource File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
ConvivaTestApp/src/androidTest/java/com/bitmovin/analytics/conviva/testapp/SsaiTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package com.bitmovin.analytics.conviva.testapp | ||
|
||
import android.os.Handler | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.bitmovin.analytics.conviva.ConvivaAnalyticsIntegration | ||
import com.bitmovin.analytics.conviva.ConvivaConfig | ||
import com.bitmovin.analytics.conviva.MetadataOverrides | ||
import com.bitmovin.analytics.conviva.ssai.SsaiApi | ||
import com.bitmovin.analytics.conviva.testapp.framework.BITMOVIN_PLAYER_LICENSE_KEY | ||
import com.bitmovin.analytics.conviva.testapp.framework.CONVIVA_CUSTOMER_KEY | ||
import com.bitmovin.analytics.conviva.testapp.framework.CONVIVA_GATEWAY_URL | ||
import com.bitmovin.analytics.conviva.testapp.framework.Sources | ||
import com.bitmovin.analytics.conviva.testapp.framework.expectEvent | ||
import com.bitmovin.analytics.conviva.testapp.framework.postWaiting | ||
import com.bitmovin.player.api.PlaybackConfig | ||
import com.bitmovin.player.api.Player | ||
import com.bitmovin.player.api.PlayerConfig | ||
import com.bitmovin.player.api.analytics.AnalyticsPlayerConfig | ||
import com.bitmovin.player.api.event.PlayerEvent | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
|
||
/** | ||
* This test class does not verify any specific behavior, but rather can be used to validate the | ||
* integration against the [Conviva Touchstone integration test tool](https://touchstone.conviva.com/). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class SsaiTests { | ||
/** | ||
* Plays a vod stream and fakes a SSAI ad break with a single 5 seconds ad and a 1 seconds slate. | ||
*/ | ||
@Test | ||
fun reports_ad_analytics_for_mid_roll_ad() { | ||
val adStart = 5.0 | ||
val adDuration = 5.0 | ||
val slateStart = adStart + adDuration | ||
val slateDuration = 1.0 | ||
|
||
|
||
val context = InstrumentationRegistry.getInstrumentation().targetContext | ||
val mainHandler = Handler(context.mainLooper) | ||
val player = mainHandler.postWaiting { | ||
Player( | ||
context, | ||
PlayerConfig( | ||
key = BITMOVIN_PLAYER_LICENSE_KEY, | ||
playbackConfig = PlaybackConfig( | ||
isAutoplayEnabled = true, | ||
), | ||
), | ||
analyticsConfig = AnalyticsPlayerConfig.Disabled, | ||
) | ||
} | ||
|
||
val integration = mainHandler.postWaiting { | ||
val convivaAnalyticsIntegration = ConvivaAnalyticsIntegration( | ||
player, | ||
CONVIVA_CUSTOMER_KEY, | ||
context, | ||
ConvivaConfig().apply { | ||
isDebugLoggingEnabled = true | ||
gatewayUrl = CONVIVA_GATEWAY_URL | ||
}, | ||
) | ||
|
||
convivaAnalyticsIntegration.updateContentMetadata( | ||
MetadataOverrides() | ||
.apply { | ||
applicationName = "Bitmovin Android Conviva integration example app" | ||
viewerId = "testViewerId" | ||
} | ||
) | ||
convivaAnalyticsIntegration | ||
} | ||
|
||
mainHandler.postWaiting { player.load(Sources.Dash.basic) } | ||
player.expectEvent<PlayerEvent.TimeChanged> { it.time > adStart } // play main content until ad start | ||
|
||
// fake ad break | ||
mainHandler.postWaiting { | ||
integration.ssai.reportAdBreakStarted() | ||
integration.ssai.reportAdStarted(SsaiApi.AdInfo().apply { | ||
duration = adDuration | ||
isSlate = false | ||
id = "testAdId" | ||
title = "testAdTitle" | ||
}) | ||
} | ||
|
||
player.expectEvent<PlayerEvent.TimeChanged> { it.time > adStart + adDuration } // wait unitl ad is over | ||
|
||
|
||
mainHandler.postWaiting { | ||
integration.ssai.reportAdFinished() | ||
integration.ssai.reportAdStarted( | ||
SsaiApi.AdInfo().apply { | ||
duration = slateDuration | ||
isSlate = true | ||
title = "testSlate" | ||
} | ||
) | ||
} | ||
|
||
player.expectEvent<PlayerEvent.TimeChanged> { it.time > slateStart + slateDuration } // wait for five more seconds of playback | ||
|
||
mainHandler.postWaiting { | ||
integration.ssai.reportAdFinished() | ||
integration.ssai.reportAdBreakFinished() | ||
} | ||
|
||
mainHandler.postWaiting { player.destroy() } | ||
runBlocking { delay(1000) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implicitly enables tracking of
on the
ConvivaAdAnalytics
as it is already tracked for client side ads.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When reporting the play head time, is the current format what the conviva backend expects or do we have to convert the time to a relative timestamp since the ad(break) started? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent question. I would assume no but let me double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately there is no documentation to be found about this. Let's leave it as-is for now as it makes the most sense for SSAI ads.