Add a default no-op implementation for SubtitleParser.reset

Most implementations were already no-ops.

PiperOrigin-RevId: 557503628
This commit is contained in:
ibaker 2023-08-16 17:02:05 +01:00 committed by oceanjules
parent d42c58f152
commit d3894e6691
8 changed files with 3 additions and 22 deletions

View File

@ -91,6 +91,8 @@ public interface SubtitleParser {
* Clears any data stored inside this parser from previous {@link #parse(byte[])} calls.
*
* <p>This must be called after a seek or other similar discontinuity in the source data.
*
* <p>The default implementation is a no-op.
*/
void reset();
default void reset() {}
}

View File

@ -53,9 +53,6 @@ public final class PgsParser implements SubtitleParser {
cueBuilder = new CueBuilder();
}
@Override
public void reset() {}
@Override
public ImmutableList<CuesWithTiming> parse(byte[] data, int offset, int length) {
buffer.reset(data, /* limit= */ offset + length);

View File

@ -117,9 +117,6 @@ public final class SsaParser implements SubtitleParser {
}
}
@Override
public void reset() {}
@Nullable
@Override
public ImmutableList<CuesWithTiming> parse(byte[] data, int offset, int length) {

View File

@ -151,9 +151,6 @@ public final class SubripParser implements SubtitleParser {
return cues.build();
}
@Override
public void reset() {}
/**
* Determine UTF encoding of the byte array from a byte order mark (BOM), defaulting to UTF-8 if
* no BOM is found.

View File

@ -191,9 +191,6 @@ public final class TtmlParser implements SubtitleParser {
}
}
@Override
public void reset() {}
private static FrameAndTickRate parseFrameAndTickRates(XmlPullParser xmlParser) {
int frameRate = DEFAULT_FRAME_RATE;
String frameRateString = xmlParser.getAttributeValue(TTP, "frameRate");

View File

@ -122,9 +122,6 @@ public final class Tx3gParser implements SubtitleParser {
}
}
@Override
public void reset() {}
@Override
public ImmutableList<CuesWithTiming> parse(byte[] data, int offset, int length) {
parsableByteArray.reset(data, /* limit= */ offset + length);

View File

@ -76,9 +76,6 @@ public final class Mp4WebvttParser implements SubtitleParser {
new CuesWithTiming(cues, /* startTimeUs= */ C.TIME_UNSET, /* durationUs= */ C.TIME_UNSET));
}
@Override
public void reset() {}
private static Cue parseVttCueBox(ParsableByteArray sampleData, int remainingCueBoxBytes) {
@Nullable Cue.Builder cueBuilder = null;
@Nullable CharSequence cueText = null;

View File

@ -88,9 +88,6 @@ public final class WebvttParser implements SubtitleParser {
return subtitle.toCuesWithTimingList();
}
@Override
public void reset() {}
/**
* Positions the input right before the next event, and returns the kind of event found. Does not
* consume any data from such event, if any.