mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
Add manifestless captions support. This code fits into the pre-existing
captions fetcher architecture. 1. ManifestlessCaptionsMetadata Other captions fetchers must first fetch a manifest (HLS or manifest) to discover captions tracks. This process does not exist for manifestless. All we need to do is scan the FormatStream's for the right itag, so this is an all-static class. 2. ManifestlessSubtitleWindowProvider Once a captions track is selected, a subtitles provider is instantiated. This is the main interface used by the player to retrieve captions according to playback position. This class stores fetched captions in a tree index by time for efficient lookups. Background captions fetches are used to populate the tree. 3. ManifestlessCaptionsFetch Captions are fetched one segment at a time. One instance of this object is required per fetch. It performs a blocking fetch on call(), and is intended to be submitted to a background-thread executor. 4. ManifestlessCaptionsFetch.CaptionSegment This is the result of the caption fetch. These values are used to populate the captions tree. Manifestlessness The initial request is always a headm request. There is a separate tree of every segment indexed by start time. This tree is used to improve manifestless sequence number calculation. Once we have data for the current timestamp, we walk forward through the tree to find the next unfetched sequence number, and fetch that. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177385094
This commit is contained in:
parent
800cfeea3d
commit
f0f726dfa9
@ -31,10 +31,11 @@ import java.util.List;
|
||||
* @see <a href="https://w3c.github.io/webvtt/#applying-css-properties">W3C specification - Apply
|
||||
* CSS properties</a>
|
||||
*/
|
||||
/* package */ final class WebvttCssStyle {
|
||||
public final class WebvttCssStyle {
|
||||
|
||||
public static final int UNSPECIFIED = -1;
|
||||
|
||||
/** Style flag enum */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(flag = true, value = {UNSPECIFIED, STYLE_NORMAL, STYLE_BOLD, STYLE_ITALIC,
|
||||
STYLE_BOLD_ITALIC})
|
||||
@ -44,6 +45,7 @@ import java.util.List;
|
||||
public static final int STYLE_ITALIC = Typeface.ITALIC;
|
||||
public static final int STYLE_BOLD_ITALIC = Typeface.BOLD_ITALIC;
|
||||
|
||||
/** Font size unit enum */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({UNSPECIFIED, FONT_SIZE_UNIT_PIXEL, FONT_SIZE_UNIT_EM, FONT_SIZE_UNIT_PERCENT})
|
||||
public @interface FontSizeUnit {}
|
||||
|
@ -23,7 +23,7 @@ import com.google.android.exoplayer2.text.Cue;
|
||||
/**
|
||||
* A representation of a WebVTT cue.
|
||||
*/
|
||||
/* package */ final class WebvttCue extends Cue {
|
||||
public final class WebvttCue extends Cue {
|
||||
|
||||
public final long startTime;
|
||||
public final long endTime;
|
||||
@ -59,7 +59,7 @@ import com.google.android.exoplayer2.text.Cue;
|
||||
* Builder for WebVTT cues.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
public static final class Builder {
|
||||
public static class Builder {
|
||||
|
||||
private static final String TAG = "WebvttCueBuilder";
|
||||
|
||||
|
@ -45,7 +45,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* Parser for WebVTT cues. (https://w3c.github.io/webvtt/#cues)
|
||||
*/
|
||||
/* package */ final class WebvttCueParser {
|
||||
public final class WebvttCueParser {
|
||||
|
||||
public static final Pattern CUE_HEADER_PATTERN = Pattern
|
||||
.compile("^(\\S+)\\s+-->\\s+(\\S+)(.*)?$");
|
||||
@ -90,7 +90,7 @@ import java.util.regex.Pattern;
|
||||
* @param styles List of styles defined by the CSS style blocks preceeding the cues.
|
||||
* @return Whether a valid Cue was found.
|
||||
*/
|
||||
/* package */ boolean parseCue(ParsableByteArray webvttData, WebvttCue.Builder builder,
|
||||
public boolean parseCue(ParsableByteArray webvttData, WebvttCue.Builder builder,
|
||||
List<WebvttCssStyle> styles) {
|
||||
String firstLine = webvttData.readLine();
|
||||
if (firstLine == null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user