Commit 8caaf0b5 by Oliver Woodman

Big cleanup of mp4 metadata extraction

parent 1b39d21e
...@@ -154,6 +154,18 @@ import java.util.Locale; ...@@ -154,6 +154,18 @@ import java.util.Locale;
} }
Log.d(TAG, " ]"); Log.d(TAG, " ]");
} }
// Log metadata for at most one of the tracks selected for the renderer.
if (trackSelection != null) {
for (int selectionIndex = 0; selectionIndex < trackSelection.length(); selectionIndex++) {
Metadata metadata = trackSelection.getFormat(selectionIndex).metadata;
if (metadata != null) {
Log.d(TAG, " Metadata [");
printMetadata(metadata, " ");
Log.d(TAG, " ]");
break;
}
}
}
Log.d(TAG, " ]"); Log.d(TAG, " ]");
} }
} }
...@@ -184,7 +196,7 @@ import java.util.Locale; ...@@ -184,7 +196,7 @@ import java.util.Locale;
@Override @Override
public void onMetadata(Metadata metadata) { public void onMetadata(Metadata metadata) {
Log.d(TAG, "onMetadata ["); Log.d(TAG, "onMetadata [");
printMetadata(metadata); printMetadata(metadata, " ");
Log.d(TAG, "]"); Log.d(TAG, "]");
} }
...@@ -208,13 +220,8 @@ import java.util.Locale; ...@@ -208,13 +220,8 @@ import java.util.Locale;
@Override @Override
public void onAudioInputFormatChanged(Format format) { public void onAudioInputFormatChanged(Format format) {
boolean hasMetadata = format.metadata != null;
Log.d(TAG, "audioFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format) Log.d(TAG, "audioFormatChanged [" + getSessionTimeString() + ", " + getFormatString(format)
+ (hasMetadata ? "" : "]")); + "]");
if (hasMetadata) {
printMetadata(format.metadata);
Log.d(TAG, "]");
}
} }
@Override @Override
...@@ -335,35 +342,35 @@ import java.util.Locale; ...@@ -335,35 +342,35 @@ import java.util.Locale;
Log.e(TAG, "internalError [" + getSessionTimeString() + ", " + type + "]", e); Log.e(TAG, "internalError [" + getSessionTimeString() + ", " + type + "]", e);
} }
private void printMetadata(Metadata metadata) { private void printMetadata(Metadata metadata, String prefix) {
for (int i = 0; i < metadata.length(); i++) { for (int i = 0; i < metadata.length(); i++) {
Metadata.Entry entry = metadata.get(i); Metadata.Entry entry = metadata.get(i);
if (entry instanceof TxxxFrame) { if (entry instanceof TxxxFrame) {
TxxxFrame txxxFrame = (TxxxFrame) entry; TxxxFrame txxxFrame = (TxxxFrame) entry;
Log.d(TAG, String.format(" %s: description=%s, value=%s", txxxFrame.id, Log.d(TAG, prefix + String.format("%s: description=%s, value=%s", txxxFrame.id,
txxxFrame.description, txxxFrame.value)); txxxFrame.description, txxxFrame.value));
} else if (entry instanceof PrivFrame) { } else if (entry instanceof PrivFrame) {
PrivFrame privFrame = (PrivFrame) entry; PrivFrame privFrame = (PrivFrame) entry;
Log.d(TAG, String.format(" %s: owner=%s", privFrame.id, privFrame.owner)); Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
} else if (entry instanceof GeobFrame) { } else if (entry instanceof GeobFrame) {
GeobFrame geobFrame = (GeobFrame) entry; GeobFrame geobFrame = (GeobFrame) entry;
Log.d(TAG, String.format(" %s: mimeType=%s, filename=%s, description=%s", Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description)); geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
} else if (entry instanceof ApicFrame) { } else if (entry instanceof ApicFrame) {
ApicFrame apicFrame = (ApicFrame) entry; ApicFrame apicFrame = (ApicFrame) entry;
Log.d(TAG, String.format(" %s: mimeType=%s, description=%s", Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
apicFrame.id, apicFrame.mimeType, apicFrame.description)); apicFrame.id, apicFrame.mimeType, apicFrame.description));
} else if (entry instanceof TextInformationFrame) { } else if (entry instanceof TextInformationFrame) {
TextInformationFrame textInformationFrame = (TextInformationFrame) entry; TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
Log.d(TAG, String.format(" %s: description=%s", textInformationFrame.id, Log.d(TAG, prefix + String.format("%s: description=%s", textInformationFrame.id,
textInformationFrame.description)); textInformationFrame.description));
} else if (entry instanceof CommentFrame) { } else if (entry instanceof CommentFrame) {
CommentFrame commentFrame = (CommentFrame) entry; CommentFrame commentFrame = (CommentFrame) entry;
Log.d(TAG, String.format(" %s: language=%s description=%s", commentFrame.id, Log.d(TAG, prefix + String.format("%s: language=%s description=%s", commentFrame.id,
commentFrame.language, commentFrame.description)); commentFrame.language, commentFrame.description, commentFrame.text));
} else if (entry instanceof Id3Frame) { } else if (entry instanceof Id3Frame) {
Id3Frame id3Frame = (Id3Frame) entry; Id3Frame id3Frame = (Id3Frame) entry;
Log.d(TAG, String.format(" %s", id3Frame.id)); Log.d(TAG, prefix + String.format("%s", id3Frame.id));
} }
} }
} }
......
...@@ -132,7 +132,6 @@ import java.util.List; ...@@ -132,7 +132,6 @@ import java.util.List;
public static final int TYPE_vp08 = Util.getIntegerCodeForString("vp08"); public static final int TYPE_vp08 = Util.getIntegerCodeForString("vp08");
public static final int TYPE_vp09 = Util.getIntegerCodeForString("vp09"); public static final int TYPE_vp09 = Util.getIntegerCodeForString("vp09");
public static final int TYPE_vpcC = Util.getIntegerCodeForString("vpcC"); public static final int TYPE_vpcC = Util.getIntegerCodeForString("vpcC");
public static final int TYPE_DASHES = Util.getIntegerCodeForString("----");
public final int type; public final int type;
...@@ -299,7 +298,7 @@ import java.util.List; ...@@ -299,7 +298,7 @@ import java.util.List;
* @return The corresponding four character string. * @return The corresponding four character string.
*/ */
public static String getAtomTypeString(int type) { public static String getAtomTypeString(int type) {
return "" + (char) (type >> 24) return "" + (char) ((type >> 24) & 0xFF)
+ (char) ((type >> 16) & 0xFF) + (char) ((type >> 16) & 0xFF)
+ (char) ((type >> 8) & 0xFF) + (char) ((type >> 8) & 0xFF)
+ (char) (type & 0xFF); + (char) (type & 0xFF);
......
/*
* Copyright (C) 2016 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.metadata.id3;
/**
* ID3 utility methods.
*/
public final class Id3Util {
private static final String[] STANDARD_GENRES = new String[] {
// These are the official ID3v1 genres.
"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap",
"Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska",
"Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient",
"Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical",
"Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise",
"AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative",
"Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave",
"Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream",
"Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap",
"Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave",
"Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal",
"Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll",
"Hard Rock",
// These were made up by the authors of Winamp but backported into the ID3 spec.
"Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion",
"Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde",
"Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock",
"Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour",
"Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony",
"Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club",
"Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul",
"Freestyle", "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House",
"Dance Hall",
// These were also invented by the Winamp folks but ignored by the ID3 authors.
"Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie",
"BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta Rap",
"Heavy Metal", "Black Metal", "Crossover", "Contemporary Christian",
"Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "Jpop",
"Synthpop"
};
private Id3Util() {}
public static String decodeGenre(int code) {
return (0 < code && code <= STANDARD_GENRES.length) ? STANDARD_GENRES[code - 1] : null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment