Commit 244c202c by andrewlewis Committed by Oliver Woodman

Fix hidden API warnings from Metalava

PiperOrigin-RevId: 255442455
parent 2a765f6b
...@@ -45,7 +45,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -45,7 +45,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
/** A {@link DrmSession} that supports playbacks using {@link ExoMediaDrm}. */ /** A {@link DrmSession} that supports playbacks using {@link ExoMediaDrm}. */
@TargetApi(18) @TargetApi(18)
/* package */ class DefaultDrmSession<T extends ExoMediaCrypto> implements DrmSession<T> { public class DefaultDrmSession<T extends ExoMediaCrypto> implements DrmSession<T> {
/** Manages provisioning requests. */ /** Manages provisioning requests. */
public interface ProvisioningManager<T extends ExoMediaCrypto> { public interface ProvisioningManager<T extends ExoMediaCrypto> {
......
...@@ -72,7 +72,7 @@ public final class H262Reader implements ElementaryStreamReader { ...@@ -72,7 +72,7 @@ public final class H262Reader implements ElementaryStreamReader {
this(null); this(null);
} }
public H262Reader(UserDataReader userDataReader) { /* package */ H262Reader(UserDataReader userDataReader) {
this.userDataReader = userDataReader; this.userDataReader = userDataReader;
prefixFlags = new boolean[4]; prefixFlags = new boolean[4];
csdBuffer = new CsdBuffer(128); csdBuffer = new CsdBuffer(128);
......
...@@ -26,10 +26,8 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -26,10 +26,8 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import java.util.List; import java.util.List;
/** /** Consumes SEI buffers, outputting contained CEA-608 messages to a {@link TrackOutput}. */
* Consumes SEI buffers, outputting contained CEA-608 messages to a {@link TrackOutput}. public final class SeiReader {
*/
/* package */ final class SeiReader {
private final List<Format> closedCaptionFormats; private final List<Format> closedCaptionFormats;
private final TrackOutput[] outputs; private final TrackOutput[] outputs;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.text.dvb; package com.google.android.exoplayer2.text.dvb;
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder; import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import java.util.List; import java.util.List;
...@@ -38,7 +39,7 @@ public final class DvbDecoder extends SimpleSubtitleDecoder { ...@@ -38,7 +39,7 @@ public final class DvbDecoder extends SimpleSubtitleDecoder {
} }
@Override @Override
protected DvbSubtitle decode(byte[] data, int length, boolean reset) { protected Subtitle decode(byte[] data, int length, boolean reset) {
if (reset) { if (reset) {
parser.reset(); parser.reset();
} }
......
...@@ -19,6 +19,7 @@ import android.text.TextUtils; ...@@ -19,6 +19,7 @@ import android.text.TextUtils;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder; import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.LongArray; import com.google.android.exoplayer2.util.LongArray;
...@@ -72,7 +73,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder { ...@@ -72,7 +73,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
} }
@Override @Override
protected SsaSubtitle decode(byte[] bytes, int length, boolean reset) { protected Subtitle decode(byte[] bytes, int length, boolean reset) {
ArrayList<Cue> cues = new ArrayList<>(); ArrayList<Cue> cues = new ArrayList<>();
LongArray cueTimesUs = new LongArray(); LongArray cueTimesUs = new LongArray();
......
...@@ -21,6 +21,7 @@ import android.text.Spanned; ...@@ -21,6 +21,7 @@ import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder; import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.LongArray; import com.google.android.exoplayer2.util.LongArray;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
...@@ -34,9 +35,9 @@ import java.util.regex.Pattern; ...@@ -34,9 +35,9 @@ import java.util.regex.Pattern;
public final class SubripDecoder extends SimpleSubtitleDecoder { public final class SubripDecoder extends SimpleSubtitleDecoder {
// Fractional positions for use when alignment tags are present. // Fractional positions for use when alignment tags are present.
/* package */ static final float START_FRACTION = 0.08f; private static final float START_FRACTION = 0.08f;
/* package */ static final float END_FRACTION = 1 - START_FRACTION; private static final float END_FRACTION = 1 - START_FRACTION;
/* package */ static final float MID_FRACTION = 0.5f; private static final float MID_FRACTION = 0.5f;
private static final String TAG = "SubripDecoder"; private static final String TAG = "SubripDecoder";
...@@ -68,7 +69,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { ...@@ -68,7 +69,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
} }
@Override @Override
protected SubripSubtitle decode(byte[] bytes, int length, boolean reset) { protected Subtitle decode(byte[] bytes, int length, boolean reset) {
ArrayList<Cue> cues = new ArrayList<>(); ArrayList<Cue> cues = new ArrayList<>();
LongArray cueTimesUs = new LongArray(); LongArray cueTimesUs = new LongArray();
ParsableByteArray subripData = new ParsableByteArray(bytes, length); ParsableByteArray subripData = new ParsableByteArray(bytes, length);
......
...@@ -19,6 +19,7 @@ import android.text.Layout; ...@@ -19,6 +19,7 @@ import android.text.Layout;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder; import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.text.SubtitleDecoderException; import com.google.android.exoplayer2.text.SubtitleDecoderException;
import com.google.android.exoplayer2.util.ColorParser; import com.google.android.exoplayer2.util.ColorParser;
import com.google.android.exoplayer2.util.Log; import com.google.android.exoplayer2.util.Log;
...@@ -102,7 +103,7 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { ...@@ -102,7 +103,7 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder {
} }
@Override @Override
protected TtmlSubtitle decode(byte[] bytes, int length, boolean reset) protected Subtitle decode(byte[] bytes, int length, boolean reset)
throws SubtitleDecoderException { throws SubtitleDecoderException {
try { try {
XmlPullParser xmlParser = xmlParserFactory.newPullParser(); XmlPullParser xmlParser = xmlParserFactory.newPullParser();
......
...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.text.webvtt; ...@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.text.webvtt;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder; import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.text.SubtitleDecoderException; import com.google.android.exoplayer2.text.SubtitleDecoderException;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
...@@ -49,7 +50,7 @@ public final class Mp4WebvttDecoder extends SimpleSubtitleDecoder { ...@@ -49,7 +50,7 @@ public final class Mp4WebvttDecoder extends SimpleSubtitleDecoder {
} }
@Override @Override
protected Mp4WebvttSubtitle decode(byte[] bytes, int length, boolean reset) protected Subtitle decode(byte[] bytes, int length, boolean reset)
throws SubtitleDecoderException { throws SubtitleDecoderException {
// Webvtt in Mp4 samples have boxes inside of them, so we have to do a traditional box parsing: // Webvtt in Mp4 samples have boxes inside of them, so we have to do a traditional box parsing:
// first 4 bytes size and then 4 bytes type. // first 4 bytes size and then 4 bytes type.
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.text.webvtt; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.text.webvtt;
import android.text.TextUtils; import android.text.TextUtils;
import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.text.SimpleSubtitleDecoder; import com.google.android.exoplayer2.text.SimpleSubtitleDecoder;
import com.google.android.exoplayer2.text.Subtitle;
import com.google.android.exoplayer2.text.SubtitleDecoderException; import com.google.android.exoplayer2.text.SubtitleDecoderException;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -55,7 +56,7 @@ public final class WebvttDecoder extends SimpleSubtitleDecoder { ...@@ -55,7 +56,7 @@ public final class WebvttDecoder extends SimpleSubtitleDecoder {
} }
@Override @Override
protected WebvttSubtitle decode(byte[] bytes, int length, boolean reset) protected Subtitle decode(byte[] bytes, int length, boolean reset)
throws SubtitleDecoderException { throws SubtitleDecoderException {
parsableWebvttData.reset(bytes, length); parsableWebvttData.reset(bytes, length);
// Initialization for consistent starting state. // Initialization for consistent starting state.
......
...@@ -380,13 +380,13 @@ public final class SimpleCache implements Cache { ...@@ -380,13 +380,13 @@ public final class SimpleCache implements Cache {
} }
@Override @Override
public synchronized SimpleCacheSpan startReadWrite(String key, long position) public synchronized CacheSpan startReadWrite(String key, long position)
throws InterruptedException, CacheException { throws InterruptedException, CacheException {
Assertions.checkState(!released); Assertions.checkState(!released);
checkInitialization(); checkInitialization();
while (true) { while (true) {
SimpleCacheSpan span = startReadWriteNonBlocking(key, position); CacheSpan span = startReadWriteNonBlocking(key, position);
if (span != null) { if (span != null) {
return span; return span;
} else { } else {
...@@ -402,7 +402,7 @@ public final class SimpleCache implements Cache { ...@@ -402,7 +402,7 @@ public final class SimpleCache implements Cache {
@Override @Override
@Nullable @Nullable
public synchronized SimpleCacheSpan startReadWriteNonBlocking(String key, long position) public synchronized CacheSpan startReadWriteNonBlocking(String key, long position)
throws CacheException { throws CacheException {
Assertions.checkState(!released); Assertions.checkState(!released);
checkInitialization(); checkInitialization();
......
...@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat; ...@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.text.Subtitle;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import org.junit.Test; import org.junit.Test;
...@@ -41,7 +42,7 @@ public final class SsaDecoderTest { ...@@ -41,7 +42,7 @@ public final class SsaDecoderTest {
public void testDecodeEmpty() throws IOException { public void testDecodeEmpty() throws IOException {
SsaDecoder decoder = new SsaDecoder(); SsaDecoder decoder = new SsaDecoder();
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY); byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(0); assertThat(subtitle.getEventTimeCount()).isEqualTo(0);
assertThat(subtitle.getCues(0).isEmpty()).isTrue(); assertThat(subtitle.getCues(0).isEmpty()).isTrue();
...@@ -51,7 +52,7 @@ public final class SsaDecoderTest { ...@@ -51,7 +52,7 @@ public final class SsaDecoderTest {
public void testDecodeTypical() throws IOException { public void testDecodeTypical() throws IOException {
SsaDecoder decoder = new SsaDecoder(); SsaDecoder decoder = new SsaDecoder();
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL); byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6); assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -71,7 +72,7 @@ public final class SsaDecoderTest { ...@@ -71,7 +72,7 @@ public final class SsaDecoderTest {
SsaDecoder decoder = new SsaDecoder(initializationData); SsaDecoder decoder = new SsaDecoder(initializationData);
byte[] bytes = byte[] bytes =
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_DIALOGUE_ONLY); TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_DIALOGUE_ONLY);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6); assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -85,7 +86,7 @@ public final class SsaDecoderTest { ...@@ -85,7 +86,7 @@ public final class SsaDecoderTest {
SsaDecoder decoder = new SsaDecoder(); SsaDecoder decoder = new SsaDecoder();
byte[] bytes = byte[] bytes =
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), INVALID_TIMECODES); TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), INVALID_TIMECODES);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(2); assertThat(subtitle.getEventTimeCount()).isEqualTo(2);
assertTypicalCue3(subtitle, 0); assertTypicalCue3(subtitle, 0);
...@@ -96,7 +97,7 @@ public final class SsaDecoderTest { ...@@ -96,7 +97,7 @@ public final class SsaDecoderTest {
SsaDecoder decoder = new SsaDecoder(); SsaDecoder decoder = new SsaDecoder();
byte[] bytes = byte[] bytes =
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_END_TIMECODES); TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_END_TIMECODES);
SsaSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(3); assertThat(subtitle.getEventTimeCount()).isEqualTo(3);
...@@ -113,21 +114,21 @@ public final class SsaDecoderTest { ...@@ -113,21 +114,21 @@ public final class SsaDecoderTest {
.isEqualTo("This is the third subtitle, with a comma."); .isEqualTo("This is the third subtitle, with a comma.");
} }
private static void assertTypicalCue1(SsaSubtitle subtitle, int eventIndex) { private static void assertTypicalCue1(Subtitle subtitle, int eventIndex) {
assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(0); assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(0);
assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString()) assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString())
.isEqualTo("This is the first subtitle."); .isEqualTo("This is the first subtitle.");
assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(1230000); assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(1230000);
} }
private static void assertTypicalCue2(SsaSubtitle subtitle, int eventIndex) { private static void assertTypicalCue2(Subtitle subtitle, int eventIndex) {
assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(2340000); assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(2340000);
assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString()) assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString())
.isEqualTo("This is the second subtitle \nwith a newline \nand another."); .isEqualTo("This is the second subtitle \nwith a newline \nand another.");
assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(3450000); assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(3450000);
} }
private static void assertTypicalCue3(SsaSubtitle subtitle, int eventIndex) { private static void assertTypicalCue3(Subtitle subtitle, int eventIndex) {
assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(4560000); assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(4560000);
assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString()) assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString())
.isEqualTo("This is the third subtitle, with a comma."); .isEqualTo("This is the third subtitle, with a comma.");
......
...@@ -21,6 +21,7 @@ import androidx.test.core.app.ApplicationProvider; ...@@ -21,6 +21,7 @@ import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.Subtitle;
import java.io.IOException; import java.io.IOException;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -44,7 +45,7 @@ public final class SubripDecoderTest { ...@@ -44,7 +45,7 @@ public final class SubripDecoderTest {
public void testDecodeEmpty() throws IOException { public void testDecodeEmpty() throws IOException {
SubripDecoder decoder = new SubripDecoder(); SubripDecoder decoder = new SubripDecoder();
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY_FILE); byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY_FILE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(0); assertThat(subtitle.getEventTimeCount()).isEqualTo(0);
assertThat(subtitle.getCues(0).isEmpty()).isTrue(); assertThat(subtitle.getCues(0).isEmpty()).isTrue();
...@@ -54,7 +55,7 @@ public final class SubripDecoderTest { ...@@ -54,7 +55,7 @@ public final class SubripDecoderTest {
public void testDecodeTypical() throws IOException { public void testDecodeTypical() throws IOException {
SubripDecoder decoder = new SubripDecoder(); SubripDecoder decoder = new SubripDecoder();
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_FILE); byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_FILE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6); assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -68,7 +69,7 @@ public final class SubripDecoderTest { ...@@ -68,7 +69,7 @@ public final class SubripDecoderTest {
byte[] bytes = byte[] bytes =
TestUtil.getByteArray( TestUtil.getByteArray(
ApplicationProvider.getApplicationContext(), TYPICAL_WITH_BYTE_ORDER_MARK); ApplicationProvider.getApplicationContext(), TYPICAL_WITH_BYTE_ORDER_MARK);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6); assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -82,7 +83,7 @@ public final class SubripDecoderTest { ...@@ -82,7 +83,7 @@ public final class SubripDecoderTest {
byte[] bytes = byte[] bytes =
TestUtil.getByteArray( TestUtil.getByteArray(
ApplicationProvider.getApplicationContext(), TYPICAL_EXTRA_BLANK_LINE); ApplicationProvider.getApplicationContext(), TYPICAL_EXTRA_BLANK_LINE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6); assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -97,7 +98,7 @@ public final class SubripDecoderTest { ...@@ -97,7 +98,7 @@ public final class SubripDecoderTest {
byte[] bytes = byte[] bytes =
TestUtil.getByteArray( TestUtil.getByteArray(
ApplicationProvider.getApplicationContext(), TYPICAL_MISSING_TIMECODE); ApplicationProvider.getApplicationContext(), TYPICAL_MISSING_TIMECODE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4); assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -111,7 +112,7 @@ public final class SubripDecoderTest { ...@@ -111,7 +112,7 @@ public final class SubripDecoderTest {
byte[] bytes = byte[] bytes =
TestUtil.getByteArray( TestUtil.getByteArray(
ApplicationProvider.getApplicationContext(), TYPICAL_MISSING_SEQUENCE); ApplicationProvider.getApplicationContext(), TYPICAL_MISSING_SEQUENCE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4); assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -125,7 +126,7 @@ public final class SubripDecoderTest { ...@@ -125,7 +126,7 @@ public final class SubripDecoderTest {
byte[] bytes = byte[] bytes =
TestUtil.getByteArray( TestUtil.getByteArray(
ApplicationProvider.getApplicationContext(), TYPICAL_NEGATIVE_TIMESTAMPS); ApplicationProvider.getApplicationContext(), TYPICAL_NEGATIVE_TIMESTAMPS);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(2); assertThat(subtitle.getEventTimeCount()).isEqualTo(2);
assertTypicalCue3(subtitle, 0); assertTypicalCue3(subtitle, 0);
...@@ -137,7 +138,7 @@ public final class SubripDecoderTest { ...@@ -137,7 +138,7 @@ public final class SubripDecoderTest {
SubripDecoder decoder = new SubripDecoder(); SubripDecoder decoder = new SubripDecoder();
byte[] bytes = byte[] bytes =
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_UNEXPECTED_END); TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_UNEXPECTED_END);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4); assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
...@@ -149,7 +150,7 @@ public final class SubripDecoderTest { ...@@ -149,7 +150,7 @@ public final class SubripDecoderTest {
SubripDecoder decoder = new SubripDecoder(); SubripDecoder decoder = new SubripDecoder();
byte[] bytes = byte[] bytes =
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_END_TIMECODES_FILE); TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), NO_END_TIMECODES_FILE);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertThat(subtitle.getEventTimeCount()).isEqualTo(3); assertThat(subtitle.getEventTimeCount()).isEqualTo(3);
...@@ -171,7 +172,7 @@ public final class SubripDecoderTest { ...@@ -171,7 +172,7 @@ public final class SubripDecoderTest {
SubripDecoder decoder = new SubripDecoder(); SubripDecoder decoder = new SubripDecoder();
byte[] bytes = byte[] bytes =
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_WITH_TAGS); TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), TYPICAL_WITH_TAGS);
SubripSubtitle subtitle = decoder.decode(bytes, bytes.length, false); Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
assertTypicalCue1(subtitle, 0); assertTypicalCue1(subtitle, 0);
assertTypicalCue2(subtitle, 2); assertTypicalCue2(subtitle, 2);
...@@ -194,21 +195,21 @@ public final class SubripDecoderTest { ...@@ -194,21 +195,21 @@ public final class SubripDecoderTest {
assertAlignmentCue(subtitle, 26, Cue.ANCHOR_TYPE_START, Cue.ANCHOR_TYPE_END); // {/an9} assertAlignmentCue(subtitle, 26, Cue.ANCHOR_TYPE_START, Cue.ANCHOR_TYPE_END); // {/an9}
} }
private static void assertTypicalCue1(SubripSubtitle subtitle, int eventIndex) { private static void assertTypicalCue1(Subtitle subtitle, int eventIndex) {
assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(0); assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(0);
assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString()) assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString())
.isEqualTo("This is the first subtitle."); .isEqualTo("This is the first subtitle.");
assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(1234000); assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(1234000);
} }
private static void assertTypicalCue2(SubripSubtitle subtitle, int eventIndex) { private static void assertTypicalCue2(Subtitle subtitle, int eventIndex) {
assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(2345000); assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(2345000);
assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString()) assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString())
.isEqualTo("This is the second subtitle.\nSecond subtitle with second line."); .isEqualTo("This is the second subtitle.\nSecond subtitle with second line.");
assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(3456000); assertThat(subtitle.getEventTime(eventIndex + 1)).isEqualTo(3456000);
} }
private static void assertTypicalCue3(SubripSubtitle subtitle, int eventIndex) { private static void assertTypicalCue3(Subtitle subtitle, int eventIndex) {
assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(4567000); assertThat(subtitle.getEventTime(eventIndex)).isEqualTo(4567000);
assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString()) assertThat(subtitle.getCues(subtitle.getEventTime(eventIndex)).get(0).text.toString())
.isEqualTo("This is the third subtitle."); .isEqualTo("This is the third subtitle.");
...@@ -216,7 +217,7 @@ public final class SubripDecoderTest { ...@@ -216,7 +217,7 @@ public final class SubripDecoderTest {
} }
private static void assertAlignmentCue( private static void assertAlignmentCue(
SubripSubtitle subtitle, Subtitle subtitle,
int eventIndex, int eventIndex,
@Cue.AnchorType int lineAnchor, @Cue.AnchorType int lineAnchor,
@Cue.AnchorType int positionAnchor) { @Cue.AnchorType int positionAnchor) {
......
...@@ -701,6 +701,6 @@ public final class TtmlDecoderTest { ...@@ -701,6 +701,6 @@ public final class TtmlDecoderTest {
private TtmlSubtitle getSubtitle(String file) throws IOException, SubtitleDecoderException { private TtmlSubtitle getSubtitle(String file) throws IOException, SubtitleDecoderException {
TtmlDecoder ttmlDecoder = new TtmlDecoder(); TtmlDecoder ttmlDecoder = new TtmlDecoder();
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), file); byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), file);
return ttmlDecoder.decode(bytes, bytes.length, false); return (TtmlSubtitle) ttmlDecoder.decode(bytes, bytes.length, false);
} }
} }
...@@ -395,7 +395,7 @@ public class WebvttDecoderTest { ...@@ -395,7 +395,7 @@ public class WebvttDecoderTest {
throws IOException, SubtitleDecoderException { throws IOException, SubtitleDecoderException {
WebvttDecoder decoder = new WebvttDecoder(); WebvttDecoder decoder = new WebvttDecoder();
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), asset); byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), asset);
return decoder.decode(bytes, bytes.length, /* reset= */ false); return (WebvttSubtitle) decoder.decode(bytes, bytes.length, /* reset= */ false);
} }
private Spanned getUniqueSpanTextAt(WebvttSubtitle sub, long timeUs) { private Spanned getUniqueSpanTextAt(WebvttSubtitle sub, long timeUs) {
......
...@@ -363,7 +363,7 @@ public final class CacheDataSourceTest { ...@@ -363,7 +363,7 @@ public final class CacheDataSourceTest {
.appendReadData(1); .appendReadData(1);
// Lock the content on the cache. // Lock the content on the cache.
SimpleCacheSpan cacheSpan = cache.startReadWriteNonBlocking(defaultCacheKey, 0); CacheSpan cacheSpan = cache.startReadWriteNonBlocking(defaultCacheKey, 0);
assertThat(cacheSpan).isNotNull(); assertThat(cacheSpan).isNotNull();
assertThat(cacheSpan.isHoleSpan()).isTrue(); assertThat(cacheSpan.isHoleSpan()).isTrue();
......
...@@ -164,7 +164,7 @@ public class SimpleCacheTest { ...@@ -164,7 +164,7 @@ public class SimpleCacheTest {
.isEqualTo(150); .isEqualTo(150);
// Removing the last span shouldn't cause the length be change next time cache loaded // Removing the last span shouldn't cause the length be change next time cache loaded
SimpleCacheSpan lastSpan = simpleCache2.startReadWrite(KEY_1, 145); CacheSpan lastSpan = simpleCache2.startReadWrite(KEY_1, 145);
simpleCache2.removeSpan(lastSpan); simpleCache2.removeSpan(lastSpan);
simpleCache2.release(); simpleCache2.release();
simpleCache2 = getSimpleCache(); simpleCache2 = getSimpleCache();
......
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