-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #334 from THEOplayer/feature/ssai_custom_integration
Feature/ssai custom integration
- Loading branch information
Showing
19 changed files
with
133 additions
and
396 deletions.
There are no files selected for viewing
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
Binary file removed
BIN
-17.7 KB
android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/7.0.0/ads-wrapper-7.0.0.aar
Binary file not shown.
Binary file added
BIN
+17.7 KB
android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/7.6.0/ads-wrapper-7.6.0.aar
Binary file not shown.
4 changes: 2 additions & 2 deletions
4
...d/ads-wrapper/7.0.0/ads-wrapper-7.0.0.pom → ...d/ads-wrapper/7.6.0/ads-wrapper-7.6.0.pom
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>7.0.0</modelVersion> | ||
<modelVersion>7.6.0</modelVersion> | ||
<groupId>com.theoplayer.theoplayer-sdk-android</groupId> | ||
<artifactId>ads-wrapper</artifactId> | ||
<version>7.0.0</version> | ||
<version>7.6.0</version> | ||
<packaging>aar</packaging> | ||
</project> |
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
34 changes: 34 additions & 0 deletions
34
android/src/main/java/com/theoplayer/source/GoogleDaiSourceAdapter.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,34 @@ | ||
package com.theoplayer.source | ||
|
||
import com.google.gson.Gson | ||
import com.theoplayer.BuildConfig | ||
import com.theoplayer.android.api.error.ErrorCode | ||
import com.theoplayer.android.api.error.THEOplayerException | ||
import com.theoplayer.android.api.source.GoogleDaiTypedSource | ||
import com.theoplayer.android.api.source.TypedSource | ||
import com.theoplayer.android.api.source.ssai.dai.GoogleDaiLiveConfiguration | ||
import com.theoplayer.android.api.source.ssai.dai.GoogleDaiVodConfiguration | ||
import org.json.JSONObject | ||
|
||
private const val PROP_AVAILABILITY_TYPE = "availabilityType" | ||
private const val AVAILABILITY_TYPE_VOD = "vod" | ||
private const val ERROR_DAI_NOT_ENABLED = "Google DAI support not enabled." | ||
|
||
@Throws(THEOplayerException::class) | ||
fun googleDaiBuilderFromJson(builder: TypedSource.Builder, json: JSONObject): TypedSource.Builder { | ||
// Check whether the integration was enabled | ||
if (!BuildConfig.EXTENSION_GOOGLE_DAI) { | ||
throw THEOplayerException(ErrorCode.AD_ERROR, ERROR_DAI_NOT_ENABLED) | ||
} | ||
// We need to create a new builder as the player SDK checks for: | ||
// typedSource is GoogleDaiTypedSource | ||
return if (json.optString(PROP_AVAILABILITY_TYPE) == AVAILABILITY_TYPE_VOD) { | ||
GoogleDaiTypedSource.Builder( | ||
Gson().fromJson(json.toString(), GoogleDaiVodConfiguration::class.java) | ||
) | ||
} else { | ||
GoogleDaiTypedSource.Builder( | ||
Gson().fromJson(json.toString(), GoogleDaiLiveConfiguration::class.java) | ||
) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
android/src/main/java/com/theoplayer/source/SSAIAdapterRegistry.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,51 @@ | ||
package com.theoplayer.source | ||
|
||
import android.text.TextUtils | ||
import com.theoplayer.android.api.error.ErrorCode | ||
import com.theoplayer.android.api.error.THEOplayerException | ||
import com.theoplayer.android.api.source.SourceType | ||
import com.theoplayer.android.api.source.TypedSource | ||
import org.json.JSONObject | ||
|
||
typealias CustomSSAIAdapter = (json: JSONObject, currentBuilder: TypedSource.Builder) -> TypedSource.Builder | ||
|
||
private const val ERROR_UNSUPPORTED_SSAI_INTEGRATION = "Unsupported SSAI integration" | ||
private const val ERROR_MISSING_SSAI_INTEGRATION = "Missing SSAI integration" | ||
private const val PROP_INTEGRATION = "integration" | ||
|
||
object SSAIAdapterRegistry { | ||
private val _adapters: MutableMap<String, CustomSSAIAdapter> = HashMap() | ||
|
||
fun register(integration: String, adapter: CustomSSAIAdapter) { | ||
_adapters[integration] = adapter | ||
} | ||
|
||
fun hasIntegration(integration: String): Boolean { | ||
return _adapters[integration] != null | ||
} | ||
|
||
fun typedSourceBuilderFromJson(json: JSONObject, currentBuilder: TypedSource.Builder, sourceType: SourceType?): TypedSource.Builder { | ||
// Check for valid SsaiIntegration | ||
val ssaiIntegrationStr = json.optString(PROP_INTEGRATION) | ||
|
||
// Check for valid `integration` property, which is mandatory. | ||
if (TextUtils.isEmpty(ssaiIntegrationStr)) { | ||
throw THEOplayerException(ErrorCode.AD_ERROR, ERROR_MISSING_SSAI_INTEGRATION) | ||
} | ||
|
||
// Check for known SsaiIntegration | ||
if (!hasIntegration(ssaiIntegrationStr)) { | ||
throw THEOplayerException( | ||
ErrorCode.AD_ERROR, | ||
"$ERROR_UNSUPPORTED_SSAI_INTEGRATION: $ssaiIntegrationStr" | ||
) | ||
} | ||
|
||
// Prefer DASH if SSAI type not specified | ||
if (sourceType == null) { | ||
currentBuilder.type(SourceType.DASH) | ||
} | ||
|
||
return _adapters[ssaiIntegrationStr]?.invoke(json, currentBuilder) ?: currentBuilder | ||
} | ||
} |
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
Oops, something went wrong.