From c79cb1bfe0b0c40eaf88fc27ed650ab5f49e7b50 Mon Sep 17 00:00:00 2001 From: tonihei Date: Mon, 20 Jan 2020 12:15:27 +0000 Subject: [PATCH] Add ID3 genres added in Wimamp 5.6 (2010). All these genres are currently causing a warning and are not added to the Metadata.Entry. PiperOrigin-RevId: 290594810 --- RELEASENOTES.md | 3 + .../extractor/mp4/MetadataUtil.java | 55 +++++++++++++++++-- .../extractor/mp4/MetadataUtilTest.java | 33 +++++++++++ 3 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtilTest.java diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7e77ce2a62..cdb313edc6 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -50,6 +50,9 @@ This issue caused FLAC streams with other bit depths to sound like white noise on earlier releases, but only when embedded in a non-FLAC container such as Matroska or MP4. +* Select multiple metadata tracks if multiple metadata renderers are available + ([#6676](https://github.com/google/ExoPlayer/issues/6676)). +* Add support for ID3 genres added in Wimamp 5.6 (2010). ### 2.11.1 (2019-12-20) ### diff --git a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java index 62d88426e0..732a69cecd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java @@ -16,6 +16,7 @@ package com.google.android.exoplayer2.extractor.mp4; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.extractor.GaplessInfoHolder; @@ -74,7 +75,8 @@ import java.nio.ByteBuffer; private static final int PICTURE_TYPE_FRONT_COVER = 3; // Standard genres. - private static final String[] STANDARD_GENRES = + @VisibleForTesting + /* package */ static final String[] STANDARD_GENRES = new String[] { // These are the official ID3v1 genres. "Blues", @@ -157,7 +159,7 @@ import java.nio.ByteBuffer; "Musical", "Rock & Roll", "Hard Rock", - // These were made up by the authors of Winamp and later added to the ID3 spec. + // Genres made up by the authors of Winamp (v1.91) and later added to the ID3 spec. "Folk", "Folk-Rock", "National Folk", @@ -204,7 +206,7 @@ import java.nio.ByteBuffer; "A capella", "Euro-House", "Dance Hall", - // These were made up by the authors of Winamp but have not been added to the ID3 spec. + // Genres made up by the authors of Winamp (v1.91) but have not been added to the ID3 spec. "Goa", "Drum & Bass", "Club-House", @@ -226,7 +228,52 @@ import java.nio.ByteBuffer; "Thrash Metal", "Anime", "Jpop", - "Synthpop" + "Synthpop", + // Genres made up by the authors of Winamp (v5.6) but have not been added to the ID3 spec. + "Abstract", + "Art Rock", + "Baroque", + "Bhangra", + "Big beat", + "Breakbeat", + "Chillout", + "Downtempo", + "Dub", + "EBM", + "Eclectic", + "Electro", + "Electroclash", + "Emo", + "Experimental", + "Garage", + "Global", + "IDM", + "Illbient", + "Industro-Goth", + "Jam Band", + "Krautrock", + "Leftfield", + "Lounge", + "Math Rock", + "New Romantic", + "Nu-Breakz", + "Post-Punk", + "Post-Rock", + "Psytrance", + "Shoegaze", + "Space Rock", + "Trop Rock", + "World Music", + "Neoclassical", + "Audiobook", + "Audio theatre", + "Neue Deutsche Welle", + "Podcast", + "Indie-Rock", + "G-Funk", + "Dubstep", + "Garage Rock", + "Psybient" }; private static final String LANGUAGE_UNDEFINED = "und"; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtilTest.java new file mode 100644 index 0000000000..2466c46d8a --- /dev/null +++ b/library/core/src/test/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtilTest.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.extractor.mp4; + +import static com.google.common.truth.Truth.assertThat; + +import androidx.test.ext.junit.runners.AndroidJUnit4; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** Test for {@link MetadataUtil}. */ +@RunWith(AndroidJUnit4.class) +public final class MetadataUtilTest { + + @Test + public void standardGenre_length_matchesNumberOfId3Genres() { + // Sanity check that we haven't forgotten a genre in the list. + assertThat(MetadataUtil.STANDARD_GENRES).hasLength(192); + } +}