Add custom format comparator support to AdaptiveTrackSelection#3068
Add custom format comparator support to AdaptiveTrackSelection#3068AndyWangLYN wants to merge 3 commits intoandroidx:releasefrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
df1bdf0 to
d29702f
Compare
|
hey guys can I get some feedback on this PR? Any feedback can do. Very much appreciated! @tonihei @oceanjules |
|
Also raised a question regarding this: #3077 |
...exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java
Outdated
Show resolved
Hide resolved
...exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java
Outdated
Show resolved
Hide resolved
...exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelection.java
Outdated
Show resolved
Hide resolved
...layer/src/test/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelectionTest.java
Outdated
Show resolved
Hide resolved
...layer/src/test/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelectionTest.java
Show resolved
Hide resolved
|
Hey ready for another review whenever you have the time. Thank you @tonihei |
|
Mind sharing some more insights on this PR? I really believe this could be helpful, especially in mixed codec (bitrate != video quality) cases and could be beneficial (ran into this issue during my work). Thank you! @tonihei |
Summary
Adds optional custom format ordering for
AdaptiveTrackSelectionso apps can influenceABR selection priority beyond bitrate-only ordering. While default behavior remain unchanged
This PR is refined version of the PR: #3064 in which I received comments about track format sorting. Intend to close above PR if this one is deemed good eventually.
What changed
AdaptiveTrackSelection.Factory#setTrackFormatComparator(Comparator<Format>)to allow custom format ordering via the factory.
protected final getTrackFormatComparator()onFactoryso subclasses thatoverride
createAdaptiveTrackSelection()can access the configured comparator.protectedconstructor onAdaptiveTrackSelectionaccepting aComparator<Format>, enabling subclasses to pass a comparator directly.updateSelectedTrackto use indexcomparison instead of bitrate comparison, so it works correctly with any comparator
(lower index = higher priority).
DEFAULT_FORMAT_COMPARATORas a named constant inBaseTrackSelection.TrackSelectionand field Javadoc to say "selection order" instead of"decreasing bandwidth order".
Why
The current implementation always prioritizes higher bitrate. This makes it difficult to
express developer-defined rules (e.g. a quality score ranking) without subclassing and
duplicating ABR logic. These hooks allow custom ordering without touching core ABR
switching behavior.
Testing Done