Add CuesWithTiming.endTimeUs
In most cases this is more useful than `durationUs`. We will keep `durationUs`, and the constructor will continue to take `startTimeUs` and `durationUs`, to allow for use-cases where we don't know the start time but still want to indicate a duration (this will be used to implement CEA-608 timeout). #minor-release PiperOrigin-RevId: 570944449
This commit is contained in:
parent
89a1bb528d
commit
bf7b91e57e
@ -51,10 +51,29 @@ public class CuesWithTiming {
|
||||
*/
|
||||
public final long durationUs;
|
||||
|
||||
/**
|
||||
* The time at which {@link #cues} should stop being shown on screen, in microseconds, or {@link
|
||||
* C#TIME_UNSET} if not known.
|
||||
*
|
||||
* <p>The time base of this is the same as {@link #startTimeUs}.
|
||||
*
|
||||
* <p>If {@link Format#cueReplacementBehavior} is {@link Format#CUE_REPLACEMENT_BEHAVIOR_MERGE}
|
||||
* then cues from multiple instances will be shown on screen simultaneously if their start and
|
||||
* times overlap.
|
||||
*
|
||||
* <p>{@link C#TIME_UNSET} is only permitted if the {@link Format#cueReplacementBehavior} of the
|
||||
* current track is {@link Format#CUE_REPLACEMENT_BEHAVIOR_REPLACE}.
|
||||
*/
|
||||
public final long endTimeUs;
|
||||
|
||||
/** Creates an instance. */
|
||||
public CuesWithTiming(List<Cue> cues, long startTimeUs, long durationUs) {
|
||||
this.cues = ImmutableList.copyOf(cues);
|
||||
this.startTimeUs = startTimeUs;
|
||||
this.durationUs = durationUs;
|
||||
this.endTimeUs =
|
||||
startTimeUs == C.TIME_UNSET || durationUs == C.TIME_UNSET
|
||||
? C.TIME_UNSET
|
||||
: startTimeUs + durationUs;
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public class CueSerializationTest {
|
||||
|
||||
assertThat(cuesAfterDecoding.startTimeUs).isEqualTo(1000);
|
||||
assertThat(cuesAfterDecoding.durationUs).isEqualTo(2000);
|
||||
assertThat(cuesAfterDecoding.endTimeUs).isEqualTo(3000);
|
||||
|
||||
Cue cueAfterDecoding = cuesAfterDecoding.cues.get(0);
|
||||
assertThat(cueAfterDecoding.text.toString()).isEqualTo(cue.text.toString());
|
||||
@ -112,6 +113,7 @@ public class CueSerializationTest {
|
||||
|
||||
assertThat(cuesAfterDecoding.startTimeUs).isEqualTo(1000);
|
||||
assertThat(cuesAfterDecoding.durationUs).isEqualTo(2000);
|
||||
assertThat(cuesAfterDecoding.endTimeUs).isEqualTo(3000);
|
||||
|
||||
assertThat(cuesAfterDecoding.cues).hasSize(2);
|
||||
Cue textCueAfterDecoding = cuesAfterDecoding.cues.get(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user