Skip to content

Commit

Permalink
Fix VorbisComment.populateMediaMetadata key comparison to ignore case
Browse files Browse the repository at this point in the history
Issue: androidx/media#876

#minor-release

PiperOrigin-RevId: 590215918
  • Loading branch information
icbaker authored and Copybara-Service committed Dec 12, 2023
1 parent 894954b commit 1cd4cdf
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,29 @@
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.MediaMetadata;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.common.base.Ascii;

/**
* @deprecated Use {@link com.google.android.exoplayer2.metadata.vorbis.VorbisComment} instead.
*/
@Deprecated
public class VorbisComment implements Metadata.Entry {

/** The key. */
/** The key in upper case, to ease case-insensitive comparisons. */
public final String key;

/** The value. */
public final String value;

/**
* @param key The key.
* Constructs an instance.
*
* @param key The key. Must be an ASCII string containing only characters between 0x20 and 0x7D
* (inclusive), excluding 0x3D ('=').
* @param value The value.
*/
public VorbisComment(String key, String value) {
this.key = key;
this.key = Ascii.toUpperCase(key);
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public void parseVorbisComments() {

assertThat(metadata.length()).isEqualTo(2);
VorbisComment commentFrame = (VorbisComment) metadata.get(0);
assertThat(commentFrame.key).isEqualTo("Title");
assertThat(commentFrame.key).isEqualTo("TITLE");
assertThat(commentFrame.value).isEqualTo("Song");
commentFrame = (VorbisComment) metadata.get(1);
assertThat(commentFrame.key).isEqualTo("Artist");
assertThat(commentFrame.key).isEqualTo("ARTIST");
assertThat(commentFrame.value).isEqualTo("Singer");
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public void parseVorbisCommentWithEqualsInValue() {

assertThat(metadata.length()).isEqualTo(1);
VorbisComment commentFrame = (VorbisComment) metadata.get(0);
assertThat(commentFrame.key).isEqualTo("Title");
assertThat(commentFrame.key).isEqualTo("TITLE");
assertThat(commentFrame.value).isEqualTo("So=ng");
}

Expand All @@ -150,7 +150,7 @@ public void parseInvalidVorbisComment() {

assertThat(metadata.length()).isEqualTo(1);
VorbisComment commentFrame = (VorbisComment) metadata.get(0);
assertThat(commentFrame.key).isEqualTo("Artist");
assertThat(commentFrame.key).isEqualTo("ARTIST");
assertThat(commentFrame.value).isEqualTo("Singer");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public void populateMediaMetadata_setsMediaMetadataValues() {
List<Metadata.Entry> entries =
ImmutableList.of(
new VorbisComment("TITLE", title),
new VorbisComment("ARTIST", artist),
new VorbisComment("ArTisT", artist),
new VorbisComment("ALBUM", albumTitle),
new VorbisComment("ALBUMARTIST", albumArtist),
new VorbisComment("albumartist", albumArtist),
new VorbisComment("DESCRIPTION", description));
MediaMetadata.Builder builder = MediaMetadata.EMPTY.buildUpon();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ track 0:
sampleMimeType = audio/opus
channelCount = 2
sampleRate = 48000
metadata = entries=[VC: encoder=Lavf54.20.4]
metadata = entries=[VC: ENCODER=Lavf54.20.4]
initializationData:
data = length 19, hash BFE794DB
data = length 8, hash CA22068C
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 1cd4cdf

Please sign in to comment.