Swap inheritance hierarchy between vorbis types
Instead of having types in flac inherit types in vorbis, make types in vorbis inherit types in flac. This is a bit of a hack and somewhat messy, but it retains backwards compatibility.
This commit is contained in:
parent
9c1018679a
commit
f6bee303e7
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.metadata.flac;
|
||||
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.MediaMetadata;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
@ -25,7 +26,25 @@ import java.util.Arrays;
|
||||
|
||||
/** @deprecated Use {@link com.google.android.exoplayer2.metadata.vorbis.PictureFrame} instead. */
|
||||
@Deprecated
|
||||
public final class PictureFrame extends com.google.android.exoplayer2.metadata.vorbis.PictureFrame {
|
||||
public 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 PictureFrame(
|
||||
int pictureType,
|
||||
String mimeType,
|
||||
@ -35,6 +54,98 @@ public final class PictureFrame extends com.google.android.exoplayer2.metadata.v
|
||||
int depth,
|
||||
int colors,
|
||||
byte[] pictureData) {
|
||||
super(pictureType, mimeType, description, width, height, depth, colors, 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;
|
||||
}
|
||||
|
||||
/* 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 Parcelable.Creator<PictureFrame> CREATOR =
|
||||
new Parcelable.Creator<PictureFrame>() {
|
||||
|
||||
@Override
|
||||
public PictureFrame createFromParcel(Parcel in) {
|
||||
return new PictureFrame(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PictureFrame[] newArray(int size) {
|
||||
return new PictureFrame[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -18,18 +18,107 @@ package com.google.android.exoplayer2.metadata.flac;
|
||||
import static com.google.android.exoplayer2.util.Util.castNonNull;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.MediaMetadata;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
|
||||
/** @deprecated Use {@link com.google.android.exoplayer2.metadata.vorbis.VorbisComment} instead. */
|
||||
@Deprecated
|
||||
public final class VorbisComment extends com.google.android.exoplayer2.metadata.vorbis.VorbisComment {
|
||||
public class VorbisComment implements Metadata.Entry {
|
||||
|
||||
/** The key. */
|
||||
public final String key;
|
||||
|
||||
/** The value. */
|
||||
public final String value;
|
||||
|
||||
/**
|
||||
* @param key The key.
|
||||
* @param value The value.
|
||||
*/
|
||||
public VorbisComment(String key, String value) {
|
||||
super(key, value);
|
||||
this.key = key;
|
||||
this.value = 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 Parcelable.Creator<VorbisComment> CREATOR =
|
||||
new Parcelable.Creator<VorbisComment>() {
|
||||
|
||||
@Override
|
||||
public VorbisComment createFromParcel(Parcel in) {
|
||||
return new VorbisComment(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VorbisComment[] newArray(int size) {
|
||||
return new VorbisComment[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -25,25 +25,7 @@ import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import java.util.Arrays;
|
||||
|
||||
/** A picture parsed from a Vorbis Comment or a FLAC picture block. */
|
||||
public 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.flac.PictureFrame {
|
||||
public PictureFrame(
|
||||
int pictureType,
|
||||
String mimeType,
|
||||
@ -53,85 +35,22 @@ public 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;
|
||||
// Workaround to get parcel instantiation working while retaining backwards compatibility
|
||||
// with the old type.
|
||||
super(
|
||||
in.readInt(),
|
||||
castNonNull(in.readString()),
|
||||
castNonNull(in.readString()),
|
||||
in.readInt(),
|
||||
in.readInt(),
|
||||
in.readInt(),
|
||||
in.readInt(),
|
||||
castNonNull(in.createByteArray())
|
||||
);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<PictureFrame> CREATOR =
|
||||
@ -147,4 +66,4 @@ public class PictureFrame implements Metadata.Entry {
|
||||
return new PictureFrame[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -24,100 +24,32 @@ import com.google.android.exoplayer2.MediaMetadata;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
|
||||
/** A vorbis comment, extracted from a FLAC or OGG file. */
|
||||
public 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.flac.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;
|
||||
// Workaround to get parcel instantiation working while retaining backwards compatibility
|
||||
// with the old type.
|
||||
super(castNonNull(in.readString()), castNonNull(in.readString()));
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<VorbisComment> CREATOR =
|
||||
new Parcelable.Creator<VorbisComment>() {
|
||||
new Parcelable.Creator<VorbisComment>() {
|
||||
|
||||
@Override
|
||||
public VorbisComment createFromParcel(Parcel in) {
|
||||
return new VorbisComment(in);
|
||||
}
|
||||
@Override
|
||||
public VorbisComment createFromParcel(Parcel in) {
|
||||
return new VorbisComment(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VorbisComment[] newArray(int size) {
|
||||
return new VorbisComment[size];
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public VorbisComment[] newArray(int size) {
|
||||
return new VorbisComment[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user