Skip to content

Commit

Permalink
Update TextRenderer to handle CuesWithTiming instances directly
Browse files Browse the repository at this point in the history
The existing `Subtitle` handling code is left intact to support the
legacy post-`SampleQueue` decoding path for now.

This also includes full support for merging overlapping `CuesWithTiming`
instances, which explains the test dump file changes, and which should
resolve the following issues (if used with the
decoder-before-`SampleQueue` subtitle logic added in
5d453fc):

* Issue: google/ExoPlayer#10295
* Issue: google/ExoPlayer#4794

It should also help resolve Issue: #288, but that will also require
some changes in the DASH module to enable pre-`SampleQueue` subtitle
parsing (which should happen soon).

PiperOrigin-RevId: 571021417
(cherry picked from commit 002ee05)
  • Loading branch information
icbaker authored and rohitjoins committed Oct 23, 2023
1 parent c16accb commit 6ad54d7
Show file tree
Hide file tree
Showing 15 changed files with 1,057 additions and 447 deletions.
9 changes: 9 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release notes

### Unreleased changes

* Video:
* Text:
* Remove `ExoplayerCuesDecoder`. Text tracks with `sampleMimeType =
application/x-media3-cues` are now directly handled by `TextRenderer`
without needing a `SubtitleDecoder` instance.


## 1.2

### 1.2.0-beta01 (2023-10-18)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.media3.exoplayer.text;

import androidx.media3.common.C;
import androidx.media3.common.text.Cue;
import androidx.media3.common.text.CueGroup;
import androidx.media3.extractor.text.CuesWithTiming;
import com.google.common.collect.ImmutableList;

/**
* A {@code CuesResolver} maps from time to the subtitle cues that should be shown.
*
* <p>It also exposes methods for querying when the next and previous change in subtitles is.
*
* <p>Different implementations may provide different resolution algorithms.
*/
/* package */ interface CuesResolver {

/** Adds cues to this instance. */
void addCues(CuesWithTiming cues);

/**
* Returns the {@linkplain Cue cues} that should be shown at time {@code timeUs}.
*
* @param timeUs The time to query, in microseconds.
* @return The cues that should be shown, ordered by ascending priority for compatibility with
* {@link CueGroup#cues}.
*/
ImmutableList<Cue> getCuesAtTimeUs(long timeUs);

/**
* Discards all cues that won't be shown at or after {@code timeUs}.
*
* @param timeUs The time to discard cues before, in microseconds.
*/
void discardCuesBeforeTimeUs(long timeUs);

/**
* Returns the time, in microseconds, of the change in {@linkplain #getCuesAtTimeUs(long) cue
* output} at or before {@code timeUs}.
*
* <p>If there's no change before {@code timeUs}, returns {@link C#TIME_UNSET}.
*/
long getPreviousCueChangeTimeUs(long timeUs);

/**
* Returns the time, in microseconds, of the next change in {@linkplain #getCuesAtTimeUs(long) cue
* output} after {@code timeUs} (exclusive).
*
* <p>If there's no change after {@code timeUs}, returns {@link C#TIME_END_OF_SOURCE}.
*/
long getNextCueChangeTimeUs(long timeUs);

/** Clears all cues that have been added to this instance. */
void clear();
}

This file was deleted.

0 comments on commit 6ad54d7

Please sign in to comment.