[go: nahoru, domu]

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: #876

#minor-release

PiperOrigin-RevId: 590215918
(cherry picked from commit 5580b78)
  • Loading branch information
icbaker authored and microkatz committed Jan 9, 2024
1 parent 504bcd8 commit 5001f70
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 24 deletions.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
([#693](https://github.com/androidx/media/issues/693)).
* Text:
* Metadata:
* Fix bug where `MediaMetadata` was only populated from Vorbis comments
with upper-case keys
([#876](https://github.com/androidx/media/issues/876)).
* DRM:
* Extend workaround for spurious ClearKey `https://default.url` license
URL to API 33+ (previously the workaround only applied on API 33
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import androidx.media3.common.MediaMetadata;
import androidx.media3.common.Metadata;
import androidx.media3.common.util.UnstableApi;
import com.google.common.base.Ascii;

/**
* @deprecated Use {@link androidx.media3.extractor.metadata.vorbis.VorbisComment} instead.
Expand All @@ -31,18 +32,21 @@
@UnstableApi
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 5001f70

Please sign in to comment.