From 0ea8567b6b2e8957290bafe910df49ebf54998d5 Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Mon, 17 Jan 2022 07:54:39 -0700 Subject: [PATCH] Superclass deprecated vorbis metadata types In the old `flac` module, superclass the deprecated types under the moved types in the `vorbis` module. This ensures backwards compat with existing library users. --- .../metadata/flac/PictureFrame.java | 114 +----------------- .../metadata/flac/VorbisComment.java | 92 +------------- .../metadata/vorbis/PictureFrame.java | 2 +- .../metadata/vorbis/VorbisComment.java | 2 +- 4 files changed, 6 insertions(+), 204 deletions(-) diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/PictureFrame.java b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/PictureFrame.java index 9d89bb1431..2061549ef7 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/PictureFrame.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/PictureFrame.java @@ -25,25 +25,7 @@ import java.util.Arrays; /** @deprecated Use {@link com.google.android.exoplayer2.metadata.vorbis.PictureFrame} instead. */ @Deprecated -public final class PictureFrame implements Metadata.Entry { - - /** The type of the picture. */ - public final int pictureType; - /** The mime type of the picture. */ - public final String mimeType; - /** A description of the picture. */ - public final String description; - /** The width of the picture in pixels. */ - public final int width; - /** The height of the picture in pixels. */ - public final int height; - /** The color depth of the picture in bits-per-pixel. */ - public final int depth; - /** For indexed-color pictures (e.g. GIF), the number of colors used. 0 otherwise. */ - public final int colors; - /** The encoded picture data. */ - public final byte[] pictureData; - +public final class PictureFrame extends com.google.android.exoplayer2.metadata.vorbis.PictureFrame { public PictureFrame( int pictureType, String mimeType, @@ -53,98 +35,6 @@ public final class PictureFrame implements Metadata.Entry { int depth, int colors, byte[] pictureData) { - this.pictureType = pictureType; - this.mimeType = mimeType; - this.description = description; - this.width = width; - this.height = height; - this.depth = depth; - this.colors = colors; - this.pictureData = pictureData; + super(pictureType, mimeType, description, width, height, depth, colors, pictureData); } - - /* package */ PictureFrame(Parcel in) { - this.pictureType = in.readInt(); - this.mimeType = castNonNull(in.readString()); - this.description = castNonNull(in.readString()); - this.width = in.readInt(); - this.height = in.readInt(); - this.depth = in.readInt(); - this.colors = in.readInt(); - this.pictureData = castNonNull(in.createByteArray()); - } - - @Override - public void populateMediaMetadata(MediaMetadata.Builder builder) { - builder.maybeSetArtworkData(pictureData, pictureType); - } - - @Override - public String toString() { - return "Picture: mimeType=" + mimeType + ", description=" + description; - } - - @Override - public boolean equals(@Nullable Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - PictureFrame other = (PictureFrame) obj; - return (pictureType == other.pictureType) - && mimeType.equals(other.mimeType) - && description.equals(other.description) - && (width == other.width) - && (height == other.height) - && (depth == other.depth) - && (colors == other.colors) - && Arrays.equals(pictureData, other.pictureData); - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + pictureType; - result = 31 * result + mimeType.hashCode(); - result = 31 * result + description.hashCode(); - result = 31 * result + width; - result = 31 * result + height; - result = 31 * result + depth; - result = 31 * result + colors; - result = 31 * result + Arrays.hashCode(pictureData); - return result; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(pictureType); - dest.writeString(mimeType); - dest.writeString(description); - dest.writeInt(width); - dest.writeInt(height); - dest.writeInt(depth); - dest.writeInt(colors); - dest.writeByteArray(pictureData); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Creator CREATOR = - new Creator() { - - @Override - public PictureFrame createFromParcel(Parcel in) { - return new PictureFrame(in); - } - - @Override - public PictureFrame[] newArray(int size) { - return new PictureFrame[size]; - } - }; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/VorbisComment.java b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/VorbisComment.java index d56c9dc6fb..4aec15d970 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/VorbisComment.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/flac/VorbisComment.java @@ -24,100 +24,12 @@ import com.google.android.exoplayer2.metadata.Metadata; /** @deprecated Use {@link com.google.android.exoplayer2.metadata.vorbis.VorbisComment} instead. */ @Deprecated -public final class VorbisComment implements Metadata.Entry { - - /** The key. */ - public final String key; - - /** The value. */ - public final String value; - +public final class VorbisComment extends com.google.android.exoplayer2.metadata.vorbis.VorbisComment { /** * @param key The key. * @param value The value. */ public VorbisComment(String key, String value) { - this.key = key; - this.value = value; + super(key, value); } - - /* package */ VorbisComment(Parcel in) { - this.key = castNonNull(in.readString()); - this.value = castNonNull(in.readString()); - } - - @Override - public void populateMediaMetadata(MediaMetadata.Builder builder) { - switch (key) { - case "TITLE": - builder.setTitle(value); - break; - case "ARTIST": - builder.setArtist(value); - break; - case "ALBUM": - builder.setAlbumTitle(value); - break; - case "ALBUMARTIST": - builder.setAlbumArtist(value); - break; - case "DESCRIPTION": - builder.setDescription(value); - break; - default: - break; - } - } - - @Override - public String toString() { - return "VC: " + key + "=" + value; - } - - @Override - public boolean equals(@Nullable Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - VorbisComment other = (VorbisComment) obj; - return key.equals(other.key) && value.equals(other.value); - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + key.hashCode(); - result = 31 * result + value.hashCode(); - return result; - } - - // Parcelable implementation. - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(key); - dest.writeString(value); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Creator CREATOR = - new Creator() { - - @Override - public VorbisComment createFromParcel(Parcel in) { - return new VorbisComment(in); - } - - @Override - public VorbisComment[] newArray(int size) { - return new VorbisComment[size]; - } - }; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/PictureFrame.java b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/PictureFrame.java index aa950996e6..5b656ff50b 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/PictureFrame.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/PictureFrame.java @@ -25,7 +25,7 @@ import com.google.android.exoplayer2.metadata.Metadata; import java.util.Arrays; /** A picture parsed from a FLAC file. */ -public final class PictureFrame implements Metadata.Entry { +public class PictureFrame implements Metadata.Entry { /** The type of the picture. */ public final int pictureType; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/VorbisComment.java b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/VorbisComment.java index 019992c10b..7a135ec608 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/VorbisComment.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/metadata/vorbis/VorbisComment.java @@ -24,7 +24,7 @@ import com.google.android.exoplayer2.MediaMetadata; import com.google.android.exoplayer2.metadata.Metadata; /** A vorbis comment, extracted from a FLAC or OGG file. */ -public final class VorbisComment implements Metadata.Entry { +public class VorbisComment implements Metadata.Entry { /** The key. */ public final String key;