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 6 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 @@

## [0.32.0] - 2024-11-14

### 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 `ForceReuseVideoCodecReason` enum value.
*/
private fun String.toForceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {
"ColorInfoMismatch" -> ForceReuseVideoCodecReason.ColorInfoMismatch
"MaxInputSizeExceeded" -> ForceReuseVideoCodecReason.MaxInputSizeExceeded
"MaxResolutionExceeded" -> ForceReuseVideoCodecReason.MaxResolutionExceeded
else -> null
}

/**
* Converts any JS object into a `TweaksConfig` object.
*/
Expand All @@ -189,6 +200,12 @@ fun ReadableMap.toTweaksConfig(): TweaksConfig = TweaksConfig().apply {
withBoolean("useDrmSessionForClearSources") { useDrmSessionForClearSources = it }
withBoolean("useFiletypeExtractorFallbackForHls") { useFiletypeExtractorFallbackForHls = it }
withBoolean("preferSoftwareDecodingForAds") { preferSoftwareDecodingForAds = it }
withStringArray("forceReuseVideoCodecReasons") {
forceReuseVideoCodecReasons = it
.filterNotNull()
.mapNotNull(String::toForceReuseVideoCodecReason)
.toSet()
}
}

/**
Expand Down
39 changes: 39 additions & 0 deletions src/tweaksConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/**
* When switching the video quality, the video decoder's configuration might change
* as the player can't always know if the codec supports such configuration change, it destroys and recreates it.
* This behaviour can cause brief black screens when switching between video qualities as codec recreation can be slow.
*
* If a codec is know to support a given configuration change without issues,
* the configuration can be added to the `TweaksConfig.forceReuseVideoCodecReasons`
* to always reuse the video codec and avoid the black screen.
*/
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',
}

/**
* 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 +194,19 @@ 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.
*
* 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

@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
*/
forceReuseVideoCodecReasons?: Array<ForceReuseVideoCodecReason>;
}
Loading