Nullness fixes for emsg and id3 metadata classes

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205972857
This commit is contained in:
olly 2018-07-25 04:08:18 -07:00 committed by Oliver Woodman
parent 3d55bc78f7
commit 14216ef53b
19 changed files with 84 additions and 108 deletions

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata; package com.google.android.exoplayer2.metadata;
import android.support.annotation.Nullable;
/** /**
* Decodes metadata from binary data. * Decodes metadata from binary data.
*/ */
@ -24,9 +26,8 @@ public interface MetadataDecoder {
* Decodes a {@link Metadata} element from the provided input buffer. * Decodes a {@link Metadata} element from the provided input buffer.
* *
* @param inputBuffer The input buffer to decode. * @param inputBuffer The input buffer to decode.
* @return The decoded metadata object. * @return The decoded metadata object, or null if the metadata could not be decoded.
* @throws MetadataDecoderException If a problem occurred decoding the data.
*/ */
Metadata decode(MetadataInputBuffer inputBuffer) throws MetadataDecoderException; @Nullable
Metadata decode(MetadataInputBuffer inputBuffer);
} }

View File

@ -1,38 +0,0 @@
/*
* Copyright (C) 2016 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
*
* http://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 com.google.android.exoplayer2.metadata;
/**
* Thrown when an error occurs decoding metadata.
*/
public class MetadataDecoderException extends Exception {
/**
* @param message The detail message for this exception.
*/
public MetadataDecoderException(String message) {
super(message);
}
/**
* @param message The detail message for this exception.
* @param cause The cause of this exception.
*/
public MetadataDecoderException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -128,14 +128,10 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
} else { } else {
buffer.subsampleOffsetUs = formatHolder.format.subsampleOffsetUs; buffer.subsampleOffsetUs = formatHolder.format.subsampleOffsetUs;
buffer.flip(); buffer.flip();
try {
int index = (pendingMetadataIndex + pendingMetadataCount) % MAX_PENDING_METADATA_COUNT; int index = (pendingMetadataIndex + pendingMetadataCount) % MAX_PENDING_METADATA_COUNT;
pendingMetadata[index] = decoder.decode(buffer); pendingMetadata[index] = decoder.decode(buffer);
pendingMetadataTimestamps[index] = buffer.timeUs; pendingMetadataTimestamps[index] = buffer.timeUs;
pendingMetadataCount++; pendingMetadataCount++;
} catch (MetadataDecoderException e) {
throw ExoPlaybackException.createForRenderer(e, getIndex());
}
} }
} }
} }

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.emsg; package com.google.android.exoplayer2.metadata.emsg;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -81,12 +83,12 @@ public final class EventMessage implements Metadata.Entry {
} }
/* package */ EventMessage(Parcel in) { /* package */ EventMessage(Parcel in) {
schemeIdUri = in.readString(); schemeIdUri = castNonNull(in.readString());
value = in.readString(); value = castNonNull(in.readString());
presentationTimeUs = in.readLong(); presentationTimeUs = in.readLong();
durationMs = in.readLong(); durationMs = in.readLong();
id = in.readLong(); id = in.readLong();
messageData = in.createByteArray(); messageData = castNonNull(in.createByteArray());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -44,10 +46,10 @@ public final class ApicFrame extends Id3Frame {
/* package */ ApicFrame(Parcel in) { /* package */ ApicFrame(Parcel in) {
super(ID); super(ID);
mimeType = in.readString(); mimeType = castNonNull(in.readString());
description = in.readString(); description = castNonNull(in.readString());
pictureType = in.readInt(); pictureType = in.readInt();
pictureData = in.createByteArray(); pictureData = castNonNull(in.createByteArray());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -33,8 +35,8 @@ public final class BinaryFrame extends Id3Frame {
} }
/* package */ BinaryFrame(Parcel in) { /* package */ BinaryFrame(Parcel in) {
super(in.readString()); super(castNonNull(in.readString()));
data = in.createByteArray(); data = castNonNull(in.createByteArray());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
@ -54,7 +56,7 @@ public final class ChapterFrame extends Id3Frame {
/* package */ ChapterFrame(Parcel in) { /* package */ ChapterFrame(Parcel in) {
super(ID); super(ID);
this.chapterId = in.readString(); this.chapterId = castNonNull(in.readString());
this.startTimeMs = in.readInt(); this.startTimeMs = in.readInt();
this.endTimeMs = in.readInt(); this.endTimeMs = in.readInt();
this.startOffset = in.readLong(); this.startOffset = in.readLong();

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
@ -45,7 +47,7 @@ public final class ChapterTocFrame extends Id3Frame {
/* package */ ChapterTocFrame(Parcel in) { /* package */ ChapterTocFrame(Parcel in) {
super(ID); super(ID);
this.elementId = in.readString(); this.elementId = castNonNull(in.readString());
this.isRoot = in.readByte() != 0; this.isRoot = in.readByte() != 0;
this.isOrdered = in.readByte() != 0; this.isOrdered = in.readByte() != 0;
this.children = in.createStringArray(); this.children = in.createStringArray();

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -40,9 +42,9 @@ public final class CommentFrame extends Id3Frame {
/* package */ CommentFrame(Parcel in) { /* package */ CommentFrame(Parcel in) {
super(ID); super(ID);
language = in.readString(); language = castNonNull(in.readString());
description = in.readString(); description = castNonNull(in.readString());
text = in.readString(); text = castNonNull(in.readString());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -43,10 +45,10 @@ public final class GeobFrame extends Id3Frame {
/* package */ GeobFrame(Parcel in) { /* package */ GeobFrame(Parcel in) {
super(ID); super(ID);
mimeType = in.readString(); mimeType = castNonNull(in.readString());
filename = in.readString(); filename = castNonNull(in.readString());
description = in.readString(); description = castNonNull(in.readString());
data = in.createByteArray(); data = castNonNull(in.createByteArray());
} }
@Override @Override

View File

@ -103,7 +103,7 @@ public final class Id3Decoder implements MetadataDecoder {
} }
@Override @Override
public Metadata decode(MetadataInputBuffer inputBuffer) { public @Nullable Metadata decode(MetadataInputBuffer inputBuffer) {
ByteBuffer buffer = inputBuffer.data; ByteBuffer buffer = inputBuffer.data;
return decode(buffer.array(), buffer.limit()); return decode(buffer.array(), buffer.limit());
} }
@ -113,9 +113,10 @@ public final class Id3Decoder implements MetadataDecoder {
* *
* @param data The bytes to decode ID3 tags from. * @param data The bytes to decode ID3 tags from.
* @param size Amount of bytes in {@code data} to read. * @param size Amount of bytes in {@code data} to read.
* @return A {@link Metadata} object containing the decoded ID3 tags. * @return A {@link Metadata} object containing the decoded ID3 tags, or null if the data could
* not be decoded.
*/ */
public Metadata decode(byte[] data, int size) { public @Nullable Metadata decode(byte[] data, int size) {
List<Id3Frame> id3Frames = new ArrayList<>(); List<Id3Frame> id3Frames = new ArrayList<>();
ParsableByteArray id3Data = new ParsableByteArray(data, size); ParsableByteArray id3Data = new ParsableByteArray(data, size);
@ -157,7 +158,7 @@ public final class Id3Decoder implements MetadataDecoder {
* @param data A {@link ParsableByteArray} from which the header should be read. * @param data A {@link ParsableByteArray} from which the header should be read.
* @return The parsed header, or null if the ID3 tag is unsupported. * @return The parsed header, or null if the ID3 tag is unsupported.
*/ */
private static Id3Header decodeHeader(ParsableByteArray data) { private static @Nullable Id3Header decodeHeader(ParsableByteArray data) {
if (data.bytesLeft() < ID3_HEADER_LENGTH) { if (data.bytesLeft() < ID3_HEADER_LENGTH) {
Log.w(TAG, "Data too short to be an ID3 tag"); Log.w(TAG, "Data too short to be an ID3 tag");
return null; return null;
@ -271,7 +272,7 @@ public final class Id3Decoder implements MetadataDecoder {
} }
} }
private static Id3Frame decodeFrame( private static @Nullable Id3Frame decodeFrame(
int majorVersion, int majorVersion,
ParsableByteArray id3Data, ParsableByteArray id3Data,
boolean unsignedIntFrameSizeHack, boolean unsignedIntFrameSizeHack,
@ -404,8 +405,8 @@ public final class Id3Decoder implements MetadataDecoder {
} }
} }
private static TextInformationFrame decodeTxxxFrame(ParsableByteArray id3Data, int frameSize) private static @Nullable TextInformationFrame decodeTxxxFrame(
throws UnsupportedEncodingException { ParsableByteArray id3Data, int frameSize) throws UnsupportedEncodingException {
if (frameSize < 1) { if (frameSize < 1) {
// Frame is malformed. // Frame is malformed.
return null; return null;
@ -427,8 +428,8 @@ public final class Id3Decoder implements MetadataDecoder {
return new TextInformationFrame("TXXX", description, value); return new TextInformationFrame("TXXX", description, value);
} }
private static TextInformationFrame decodeTextInformationFrame(ParsableByteArray id3Data, private static @Nullable TextInformationFrame decodeTextInformationFrame(
int frameSize, String id) throws UnsupportedEncodingException { ParsableByteArray id3Data, int frameSize, String id) throws UnsupportedEncodingException {
if (frameSize < 1) { if (frameSize < 1) {
// Frame is malformed. // Frame is malformed.
return null; return null;
@ -446,7 +447,7 @@ public final class Id3Decoder implements MetadataDecoder {
return new TextInformationFrame(id, null, value); return new TextInformationFrame(id, null, value);
} }
private static UrlLinkFrame decodeWxxxFrame(ParsableByteArray id3Data, int frameSize) private static @Nullable UrlLinkFrame decodeWxxxFrame(ParsableByteArray id3Data, int frameSize)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
if (frameSize < 1) { if (frameSize < 1) {
// Frame is malformed. // Frame is malformed.
@ -557,7 +558,7 @@ public final class Id3Decoder implements MetadataDecoder {
return new ApicFrame(mimeType, description, pictureType, pictureData); return new ApicFrame(mimeType, description, pictureType, pictureData);
} }
private static CommentFrame decodeCommentFrame(ParsableByteArray id3Data, int frameSize) private static @Nullable CommentFrame decodeCommentFrame(ParsableByteArray id3Data, int frameSize)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
if (frameSize < 4) { if (frameSize < 4) {
// Frame is malformed. // Frame is malformed.

View File

@ -16,7 +16,6 @@
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.util.Assertions;
/** /**
* Base class for ID3 frames. * Base class for ID3 frames.
@ -29,7 +28,7 @@ public abstract class Id3Frame implements Metadata.Entry {
public final String id; public final String id;
public Id3Frame(String id) { public Id3Frame(String id) {
this.id = Assertions.checkNotNull(id); this.id = id;
} }
@Override @Override

View File

@ -15,9 +15,10 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
/** Internal ID3 frame that is intended for use by the player. */ /** Internal ID3 frame that is intended for use by the player. */
@ -38,9 +39,9 @@ public final class InternalFrame extends Id3Frame {
/* package */ InternalFrame(Parcel in) { /* package */ InternalFrame(Parcel in) {
super(ID); super(ID);
domain = Assertions.checkNotNull(in.readString()); domain = castNonNull(in.readString());
description = Assertions.checkNotNull(in.readString()); description = castNonNull(in.readString());
text = Assertions.checkNotNull(in.readString()); text = castNonNull(in.readString());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -39,8 +41,8 @@ public final class PrivFrame extends Id3Frame {
/* package */ PrivFrame(Parcel in) { /* package */ PrivFrame(Parcel in) {
super(ID); super(ID);
owner = in.readString(); owner = castNonNull(in.readString());
privateData = in.createByteArray(); privateData = castNonNull(in.createByteArray());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -35,9 +37,9 @@ public final class TextInformationFrame extends Id3Frame {
} }
/* package */ TextInformationFrame(Parcel in) { /* package */ TextInformationFrame(Parcel in) {
super(in.readString()); super(castNonNull(in.readString()));
description = in.readString(); description = in.readString();
value = in.readString(); value = castNonNull(in.readString());
} }
@Override @Override

View File

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.metadata.id3; package com.google.android.exoplayer2.metadata.id3;
import static org.checkerframework.checker.nullness.NullnessUtil.castNonNull;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -25,19 +27,19 @@ import com.google.android.exoplayer2.util.Util;
*/ */
public final class UrlLinkFrame extends Id3Frame { public final class UrlLinkFrame extends Id3Frame {
public final String description; public final @Nullable String description;
public final String url; public final String url;
public UrlLinkFrame(String id, String description, String url) { public UrlLinkFrame(String id, @Nullable String description, String url) {
super(id); super(id);
this.description = description; this.description = description;
this.url = url; this.url = url;
} }
/* package */ UrlLinkFrame(Parcel in) { /* package */ UrlLinkFrame(Parcel in) {
super(in.readString()); super(castNonNull(in.readString()));
description = in.readString(); description = in.readString();
url = in.readString(); url = castNonNull(in.readString());
} }
@Override @Override

View File

@ -17,7 +17,6 @@ package com.google.android.exoplayer2.metadata.scte35;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataDecoder; import com.google.android.exoplayer2.metadata.MetadataDecoder;
import com.google.android.exoplayer2.metadata.MetadataDecoderException;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer; import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import com.google.android.exoplayer2.util.ParsableBitArray; import com.google.android.exoplayer2.util.ParsableBitArray;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
@ -46,7 +45,7 @@ public final class SpliceInfoDecoder implements MetadataDecoder {
} }
@Override @Override
public Metadata decode(MetadataInputBuffer inputBuffer) throws MetadataDecoderException { public Metadata decode(MetadataInputBuffer inputBuffer) {
// Internal timestamps adjustment. // Internal timestamps adjustment.
if (timestampAdjuster == null if (timestampAdjuster == null
|| inputBuffer.subsampleOffsetUs != timestampAdjuster.getTimestampOffsetUs()) { || inputBuffer.subsampleOffsetUs != timestampAdjuster.getTimestampOffsetUs()) {

View File

@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataDecoderException;
import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Assertions;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Arrays; import java.util.Arrays;
@ -38,7 +37,7 @@ public final class Id3DecoderTest {
private static final int ID3_TEXT_ENCODING_UTF_8 = 3; private static final int ID3_TEXT_ENCODING_UTF_8 = 3;
@Test @Test
public void testDecodeTxxxFrame() throws MetadataDecoderException { public void testDecodeTxxxFrame() {
byte[] rawId3 = buildSingleFrameTag("TXXX", new byte[] {3, 0, 109, 100, 105, 97, 108, 111, 103, byte[] rawId3 = buildSingleFrameTag("TXXX", new byte[] {3, 0, 109, 100, 105, 97, 108, 111, 103,
95, 86, 73, 78, 68, 73, 67, 79, 49, 53, 50, 55, 54, 54, 52, 95, 115, 116, 97, 114, 116, 0}); 95, 86, 73, 78, 68, 73, 67, 79, 49, 53, 50, 55, 54, 54, 52, 95, 115, 116, 97, 114, 116, 0});
Id3Decoder decoder = new Id3Decoder(); Id3Decoder decoder = new Id3Decoder();
@ -65,7 +64,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodeTextInformationFrame() throws MetadataDecoderException { public void testDecodeTextInformationFrame() {
byte[] rawId3 = buildSingleFrameTag("TIT2", new byte[] {3, 72, 101, 108, 108, 111, 32, 87, 111, byte[] rawId3 = buildSingleFrameTag("TIT2", new byte[] {3, 72, 101, 108, 108, 111, 32, 87, 111,
114, 108, 100, 0}); 114, 108, 100, 0});
Id3Decoder decoder = new Id3Decoder(); Id3Decoder decoder = new Id3Decoder();
@ -92,7 +91,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodeWxxxFrame() throws MetadataDecoderException { public void testDecodeWxxxFrame() {
byte[] rawId3 = buildSingleFrameTag("WXXX", new byte[] {ID3_TEXT_ENCODING_UTF_8, 116, 101, 115, byte[] rawId3 = buildSingleFrameTag("WXXX", new byte[] {ID3_TEXT_ENCODING_UTF_8, 116, 101, 115,
116, 0, 104, 116, 116, 112, 115, 58, 47, 47, 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 116, 0, 104, 116, 116, 112, 115, 58, 47, 47, 116, 101, 115, 116, 46, 99, 111, 109, 47, 97,
98, 99, 63, 100, 101, 102}); 98, 99, 63, 100, 101, 102});
@ -120,7 +119,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodeUrlLinkFrame() throws MetadataDecoderException { public void testDecodeUrlLinkFrame() {
byte[] rawId3 = buildSingleFrameTag("WCOM", new byte[] {104, 116, 116, 112, 115, 58, 47, 47, byte[] rawId3 = buildSingleFrameTag("WCOM", new byte[] {104, 116, 116, 112, 115, 58, 47, 47,
116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 98, 99, 63, 100, 101, 102}); 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 98, 99, 63, 100, 101, 102});
Id3Decoder decoder = new Id3Decoder(); Id3Decoder decoder = new Id3Decoder();
@ -142,7 +141,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodePrivFrame() throws MetadataDecoderException { public void testDecodePrivFrame() {
byte[] rawId3 = buildSingleFrameTag("PRIV", new byte[] {116, 101, 115, 116, 0, 1, 2, 3, 4}); byte[] rawId3 = buildSingleFrameTag("PRIV", new byte[] {116, 101, 115, 116, 0, 1, 2, 3, 4});
Id3Decoder decoder = new Id3Decoder(); Id3Decoder decoder = new Id3Decoder();
Metadata metadata = decoder.decode(rawId3, rawId3.length); Metadata metadata = decoder.decode(rawId3, rawId3.length);
@ -161,7 +160,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodeApicFrame() throws MetadataDecoderException { public void testDecodeApicFrame() {
byte[] rawId3 = buildSingleFrameTag("APIC", new byte[] {3, 105, 109, 97, 103, 101, 47, 106, 112, byte[] rawId3 = buildSingleFrameTag("APIC", new byte[] {3, 105, 109, 97, 103, 101, 47, 106, 112,
101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 0}); 8, 9, 0});
@ -177,7 +176,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodeCommentFrame() throws MetadataDecoderException { public void testDecodeCommentFrame() {
byte[] rawId3 = buildSingleFrameTag("COMM", new byte[] {ID3_TEXT_ENCODING_UTF_8, 101, 110, 103, byte[] rawId3 = buildSingleFrameTag("COMM", new byte[] {ID3_TEXT_ENCODING_UTF_8, 101, 110, 103,
100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 116, 101, 120, 116, 0}); 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 116, 101, 120, 116, 0});
Id3Decoder decoder = new Id3Decoder(); Id3Decoder decoder = new Id3Decoder();
@ -204,7 +203,7 @@ public final class Id3DecoderTest {
} }
@Test @Test
public void testDecodeMultiFrames() throws MetadataDecoderException { public void testDecodeMultiFrames() {
byte[] rawId3 = byte[] rawId3 =
buildMultiFramesTag( buildMultiFramesTag(
new FrameSpec( new FrameSpec(

View File

@ -19,7 +19,6 @@ import static com.google.android.exoplayer2.C.TIME_UNSET;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataDecoderException;
import com.google.android.exoplayer2.metadata.MetadataInputBuffer; import com.google.android.exoplayer2.metadata.MetadataInputBuffer;
import com.google.android.exoplayer2.util.TimestampAdjuster; import com.google.android.exoplayer2.util.TimestampAdjuster;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -45,7 +44,7 @@ public final class SpliceInfoDecoderTest {
} }
@Test @Test
public void testWrappedAroundTimeSignalCommand() throws MetadataDecoderException { public void testWrappedAroundTimeSignalCommand() {
byte[] rawTimeSignalSection = new byte[] { byte[] rawTimeSignalSection = new byte[] {
0, // table_id. 0, // table_id.
(byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4).
@ -72,7 +71,7 @@ public final class SpliceInfoDecoderTest {
} }
@Test @Test
public void test2SpliceInsertCommands() throws MetadataDecoderException { public void test2SpliceInsertCommands() {
byte[] rawSpliceInsertCommand1 = new byte[] { byte[] rawSpliceInsertCommand1 = new byte[] {
0, // table_id. 0, // table_id.
(byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4).
@ -165,8 +164,7 @@ public final class SpliceInfoDecoderTest {
assertThat(command.availsExpected).isEqualTo(2); assertThat(command.availsExpected).isEqualTo(2);
} }
private Metadata feedInputBuffer(byte[] data, long timeUs, long subsampleOffset) private Metadata feedInputBuffer(byte[] data, long timeUs, long subsampleOffset) {
throws MetadataDecoderException{
inputBuffer.clear(); inputBuffer.clear();
inputBuffer.data = ByteBuffer.allocate(data.length).put(data); inputBuffer.data = ByteBuffer.allocate(data.length).put(data);
inputBuffer.timeUs = timeUs; inputBuffer.timeUs = timeUs;