Use Metadata.Entry.toString in PlaybackOutput test logging if possible

Add an allowlist of Metadata.Entry implementations with stable toString
overrides.

PiperOrigin-RevId: 366037505
This commit is contained in:
ibaker 2021-03-31 16:20:06 +01:00 committed by Oliver Woodman
parent f5a4f3e609
commit 056ef5c914
4 changed files with 50 additions and 13 deletions

View File

@ -19,6 +19,18 @@ import android.graphics.Bitmap;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.dvbsi.AppInfoTable;
import com.google.android.exoplayer2.metadata.emsg.EventMessage;
import com.google.android.exoplayer2.metadata.flac.PictureFrame;
import com.google.android.exoplayer2.metadata.flac.VorbisComment;
import com.google.android.exoplayer2.metadata.icy.IcyHeaders;
import com.google.android.exoplayer2.metadata.icy.IcyInfo;
import com.google.android.exoplayer2.metadata.id3.Id3Frame;
import com.google.android.exoplayer2.metadata.mp4.MdtaMetadataEntry;
import com.google.android.exoplayer2.metadata.mp4.MotionPhotoMetadata;
import com.google.android.exoplayer2.metadata.mp4.SlowMotionData;
import com.google.android.exoplayer2.metadata.mp4.SmtaMetadataEntry;
import com.google.android.exoplayer2.metadata.scte35.SpliceCommand;
import com.google.android.exoplayer2.testutil.CapturingRenderersFactory;
import com.google.android.exoplayer2.testutil.Dumper;
import com.google.android.exoplayer2.text.Cue;
@ -89,13 +101,38 @@ public final class PlaybackOutput implements Dumper.Dumpable {
dumper.startBlock("Metadata[" + i + "]");
Metadata metadata = metadatas.get(i);
for (int j = 0; j < metadata.length(); j++) {
dumper.add("entry[" + j + "]", metadata.get(j).getClass().getSimpleName());
dumper.add("entry[" + j + "]", getEntryAsString(metadata.get(j)));
}
dumper.endBlock();
}
dumper.endBlock();
}
/**
* Returns {@code entry.toString()} if we know the implementation overrides it, otherwise returns
* the simple class name.
*/
private static String getEntryAsString(Metadata.Entry entry) {
if (entry instanceof EventMessage
|| entry instanceof PictureFrame
|| entry instanceof VorbisComment
|| entry instanceof Id3Frame
|| entry instanceof MdtaMetadataEntry
|| entry instanceof MotionPhotoMetadata
|| entry instanceof SlowMotionData
|| entry instanceof SmtaMetadataEntry
|| entry instanceof AppInfoTable
|| entry instanceof IcyHeaders
|| entry instanceof IcyInfo
|| entry instanceof SpliceCommand
|| "com.google.android.exoplayer2.hls.HlsTrackMetadataEntry"
.equals(entry.getClass().getCanonicalName())) {
return entry.toString();
} else {
return entry.getClass().getSimpleName();
}
}
private void dumpSubtitles(Dumper dumper) {
if (subtitles.isEmpty()) {
return;

View File

@ -22,11 +22,11 @@ MediaCodecAdapter (exotest.audio.eac3):
buffers[19] = length 0, hash 1
MetadataOutput:
Metadata[0]:
entry[0] = AppInfoTable
entry[1] = AppInfoTable
entry[0] = Ait(controlCode=1,url=http://static-cdn.arte.tv/redbutton/index_fr.html)
entry[1] = Ait(controlCode=2,url=http://www.arte.tv/hbbtvv2/index.html?lang=fr_FR&page=PLUS7)
Metadata[1]:
entry[0] = AppInfoTable
entry[1] = AppInfoTable
entry[0] = Ait(controlCode=1,url=http://static-cdn.arte.tv/redbutton/index_fr.html)
entry[1] = Ait(controlCode=2,url=http://www.arte.tv/hbbtvv2/index.html?lang=fr_FR&page=PLUS7)
Metadata[2]:
entry[0] = AppInfoTable
entry[1] = AppInfoTable
entry[0] = Ait(controlCode=1,url=http://static-cdn.arte.tv/redbutton/index_fr.html)
entry[1] = Ait(controlCode=2,url=http://www.arte.tv/hbbtvv2/index.html?lang=fr_FR&page=PLUS7)

View File

@ -12,8 +12,8 @@ MediaCodecAdapter (exotest.video.mpeg2):
buffers[2] = length 0, hash 1
MetadataOutput:
Metadata[0]:
entry[0] = SpliceInsertCommand
entry[0] = SCTE-35 splice command: type=SpliceInsertCommand
Metadata[1]:
entry[0] = SpliceInsertCommand
entry[0] = SCTE-35 splice command: type=SpliceInsertCommand
Metadata[2]:
entry[0] = SpliceInsertCommand
entry[0] = SCTE-35 splice command: type=SpliceInsertCommand

View File

@ -147,7 +147,7 @@ MediaCodecAdapter (exotest.audio.aac):
buffers[144] = length 0, hash 1
MetadataOutput:
Metadata[0]:
entry[0] = ApicFrame
entry[0] = APIC: mimeType=image/jpeg, description=Hello World
Metadata[1]:
entry[0] = CommentFrame
entry[1] = ApicFrame
entry[0] = COMM: language=eng, description=description
entry[1] = APIC: mimeType=image/jpeg, description=Hello World