Commit 06e63918 by ibaker Committed by marcbaechinger

Fix CEA-708 priority

According to the spec (section 8.4.2), high numeric values represent low
priorities, so we need to flip this sort.

Issue: #8704
#minor-release
PiperOrigin-RevId: 362558370
parent 3bdfb76c
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
continuing to be displayed over mid-roll ads continuing to be displayed over mid-roll ads
([#5317](https://github.com/google/ExoPlayer/issues/5317), ([#5317](https://github.com/google/ExoPlayer/issues/5317),
[#8456](https://github.com/google/ExoPlayer/issues/8456)). [#8456](https://github.com/google/ExoPlayer/issues/8456)).
* Fix CEA-708 priority handling to sort cues in the order defined by the
spec ([#8704](https://github.com/google/ExoPlayer/issues/8704)).
* MediaSession extension: Remove dependency to core module and rely on common * MediaSession extension: Remove dependency to core module and rely on common
only. The `TimelineQueueEditor` uses a new `MediaDescriptionConverter` for only. The `TimelineQueueEditor` uses a new `MediaDescriptionConverter` for
this purpose and does not rely on the `ConcatenatingMediaSource` anymore. this purpose and does not rely on the `ConcatenatingMediaSource` anymore.
......
...@@ -41,6 +41,7 @@ import com.google.android.exoplayer2.util.ParsableByteArray; ...@@ -41,6 +41,7 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull;
...@@ -798,9 +799,7 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -798,9 +799,7 @@ public final class Cea708Decoder extends CeaDecoder {
} }
} }
} }
Collections.sort( Collections.sort(displayCueInfos, Cea708CueInfo.LEAST_IMPORTANT_FIRST);
displayCueInfos,
(thisInfo, thatInfo) -> Integer.compare(thisInfo.priority, thatInfo.priority));
List<Cue> displayCues = new ArrayList<>(displayCueInfos.size()); List<Cue> displayCues = new ArrayList<>(displayCueInfos.size());
for (int i = 0; i < displayCueInfos.size(); i++) { for (int i = 0; i < displayCueInfos.size(); i++) {
displayCues.add(displayCueInfos.get(i).cue); displayCues.add(displayCueInfos.get(i).cue);
...@@ -1321,9 +1320,22 @@ public final class Cea708Decoder extends CeaDecoder { ...@@ -1321,9 +1320,22 @@ public final class Cea708Decoder extends CeaDecoder {
/** A {@link Cue} for CEA-708. */ /** A {@link Cue} for CEA-708. */
private static final class Cea708CueInfo { private static final class Cea708CueInfo {
/**
* Sorts cue infos in order of ascending {@link Cea708CueInfo#priority} (which is descending by
* numeric value).
*/
private static final Comparator<Cea708CueInfo> LEAST_IMPORTANT_FIRST =
(thisInfo, thatInfo) -> Integer.compare(thatInfo.priority, thisInfo.priority);
public final Cue cue; public final Cue cue;
/** The priority of the cue box. */ /**
* The priority of the cue box. Low values are higher priority.
*
* <p>If cue boxes overlap, higher priority cue boxes are drawn on top.
*
* <p>See 8.4.2 of the CEA-708B spec.
*/
public final int priority; public final int priority;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment