Skip to content
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

Expose TweaksConfig.forceReuseVideoCodecReasons from Android #561

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- exposed `TweaksConfig.forceReuseVideoCodecReasons`
strangesource marked this conversation as resolved.
Show resolved Hide resolved

### Changed

- Update Bitmovin's native Android SDK version to `3.92.0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.bitmovin.analytics.api.CustomData
import com.bitmovin.analytics.api.DefaultMetadata
import com.bitmovin.analytics.api.SourceMetadata
import com.bitmovin.player.api.DeviceDescription.DeviceName
import com.bitmovin.player.api.ForceReuseVideoCodecReason
import com.bitmovin.player.api.PlaybackConfig
import com.bitmovin.player.api.PlayerConfig
import com.bitmovin.player.api.TweaksConfig
Expand Down Expand Up @@ -167,6 +168,16 @@ fun ReadableMap.toStyleConfig(): StyleConfig = StyleConfig().apply {
withString("scalingMode") { scalingMode = ScalingMode.valueOf(it) }
}

/**
* Converts any JS string into an `AdSourceType` enum value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Converts any JS string into an `AdSourceType` enum value.
* Converts any JS string into an `ForceReuseVideoCodecReason` enum value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
private fun String.forceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {
matamegger marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@krocard krocard Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion function are prefixed by to:

Suggested change
private fun String.forceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {
private fun String.toForceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ColorInfoMismatch" -> ForceReuseVideoCodecReason.ColorInfoMismatch
"MaxInputSizeExceeded" -> ForceReuseVideoCodecReason.MaxInputSizeExceeded
"MaxResolutionExceeded" -> ForceReuseVideoCodecReason.MaxResolutionExceeded
else -> null
}

/**
* Converts any JS object into a `TweaksConfig` object.
*/
Expand All @@ -189,6 +200,16 @@ fun ReadableMap.toTweaksConfig(): TweaksConfig = TweaksConfig().apply {
withBoolean("useDrmSessionForClearSources") { useDrmSessionForClearSources = it }
withBoolean("useFiletypeExtractorFallbackForHls") { useFiletypeExtractorFallbackForHls = it }
withBoolean("preferSoftwareDecodingForAds") { preferSoftwareDecodingForAds = it }
withStringArray("forceReuseVideoCodecReasons") {
val mutableSet = mutableSetOf<ForceReuseVideoCodecReason>()
for (item in it) {
val reason = item?.forceReuseVideoCodecReason()
if (reason != null) {
mutableSet.add(reason)
}
}
forceReuseVideoCodecReasons = mutableSet
}
Copy link
Contributor

@krocard krocard Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val mutableSet = mutableSetOf<ForceReuseVideoCodecReason>()
for (item in it) {
val reason = item?.forceReuseVideoCodecReason()
if (reason != null) {
mutableSet.add(reason)
}
}
forceReuseVideoCodecReasons = mutableSet
}
forceReuseVideoCodecReasons = it.mapNotNull(String::toForceReuseVideoCodecReason).toSet()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also a toSet() needs to be added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

/**
Expand Down
28 changes: 28 additions & 0 deletions src/tweaksConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* The different reasons when the video codec should be reused.
*/
export enum ForceReuseVideoCodecReason {
/**
* The new video quality color information is not compatible.
*/
ColorInfoMismatch = 'ColorInfoMismatch',
/**
* The new video quality exceed the decoder's configured maximum sample size.
*/
MaxInputSizeExceeded = 'MaxInputSizeExceeded',
/**
* The new video quality exceed the decoder's configured maximum resolution.
*/
MaxResolutionExceeded = 'MaxResolutionExceeded',
}

matamegger marked this conversation as resolved.
Show resolved Hide resolved
/**
* This configuration is used as an incubator for experimental features. Tweaks are not officially
* supported and are not guaranteed to be stable, i.e. their naming, functionality and API can
Expand Down Expand Up @@ -170,4 +188,14 @@ export interface TweaksConfig {
* @platform iOS
*/
updatesNowPlayingInfoCenter?: boolean;

/**
* When switching between video formats (eg: adapting between video qualities) the codec might be recreated due to several reasons.
* This behaviour can cause brief black screens when switching between video qualities as codec recreation can be slow.
*
Copy link
Contributor

@krocard krocard Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation was incomplete.

Suggested change
*
*
* If a device is know to support video format changes and keep the current decoder without issues,
* this set can be filled with multiple `ForceReuseVideoCodecReason` and avoid the black screen.
*

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* Default is `null` i.e not set
*
* @platform Android
*/
matamegger marked this conversation as resolved.
Show resolved Hide resolved
forceReuseVideoCodecReasons?: Array<ForceReuseVideoCodecReason>;
}
Loading