Commit b9addf28 by Oliver Woodman

Formatting tweaks for enhanced ID3 support + support in demo app.

parent 0c6566bc
...@@ -26,6 +26,8 @@ import com.google.android.exoplayer.demo.player.DemoPlayer.RendererBuilder; ...@@ -26,6 +26,8 @@ import com.google.android.exoplayer.demo.player.DemoPlayer.RendererBuilder;
import com.google.android.exoplayer.demo.player.HlsRendererBuilder; import com.google.android.exoplayer.demo.player.HlsRendererBuilder;
import com.google.android.exoplayer.demo.player.SmoothStreamingRendererBuilder; import com.google.android.exoplayer.demo.player.SmoothStreamingRendererBuilder;
import com.google.android.exoplayer.demo.player.UnsupportedDrmException; import com.google.android.exoplayer.demo.player.UnsupportedDrmException;
import com.google.android.exoplayer.metadata.GeobMetadata;
import com.google.android.exoplayer.metadata.PrivMetadata;
import com.google.android.exoplayer.metadata.TxxxMetadata; import com.google.android.exoplayer.metadata.TxxxMetadata;
import com.google.android.exoplayer.text.CaptionStyleCompat; import com.google.android.exoplayer.text.CaptionStyleCompat;
import com.google.android.exoplayer.text.SubtitleView; import com.google.android.exoplayer.text.SubtitleView;
...@@ -446,11 +448,22 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, ...@@ -446,11 +448,22 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
@Override @Override
public void onId3Metadata(Map<String, Object> metadata) { public void onId3Metadata(Map<String, Object> metadata) {
for (int i = 0; i < metadata.size(); i++) { for (Map.Entry<String, Object> entry : metadata.entrySet()) {
if (metadata.containsKey(TxxxMetadata.TYPE)) { if (TxxxMetadata.TYPE.equals(entry.getKey())) {
TxxxMetadata txxxMetadata = (TxxxMetadata) metadata.get(TxxxMetadata.TYPE); TxxxMetadata txxxMetadata = (TxxxMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata: description=%s, value=%s", Log.i(TAG, String.format("ID3 TimedMetadata %s: description=%s, value=%s",
txxxMetadata.description, txxxMetadata.value)); TxxxMetadata.TYPE, txxxMetadata.description, txxxMetadata.value));
} else if (PrivMetadata.TYPE.equals(entry.getKey())) {
PrivMetadata privMetadata = (PrivMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: owner=%s",
PrivMetadata.TYPE, privMetadata.owner));
} else if (GeobMetadata.TYPE.equals(entry.getKey())) {
GeobMetadata geobMetadata = (GeobMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: mimeType=%s, filename=%s, description=%s",
GeobMetadata.TYPE, geobMetadata.mimeType, geobMetadata.filename,
geobMetadata.description));
} else {
Log.i(TAG, String.format("ID3 TimedMetadata %s", entry.getKey()));
} }
} }
} }
......
...@@ -123,9 +123,8 @@ import java.util.Locale; ...@@ -123,9 +123,8 @@ import java.util.Locale;
new Sample("Apple AAC media playlist", new Sample("Apple AAC media playlist",
"https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear0/" "https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear0/"
+ "prog_index.m3u8", DemoUtil.TYPE_HLS), + "prog_index.m3u8", DemoUtil.TYPE_HLS),
new Sample("Apple ID3 metadata", new Sample("Apple ID3 metadata", "http://devimages.apple.com/samplecode/adDemo/ad.m3u8",
"http://devimages.apple.com/samplecode/adDemo/" DemoUtil.TYPE_HLS),
+ "ad.m3u8", DemoUtil.TYPE_HLS),
}; };
public static final Sample[] MISC = new Sample[] { public static final Sample[] MISC = new Sample[] {
......
...@@ -100,8 +100,8 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> { ...@@ -100,8 +100,8 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
String description = new String(frame, descriptionStartIndex, String description = new String(frame, descriptionStartIndex,
descriptionEndIndex - descriptionStartIndex, charset); descriptionEndIndex - descriptionStartIndex, charset);
int objectDataSize = frameSize - 1 /* encoding byte */ - descriptionEndIndex - int objectDataSize = frameSize - 1 /* encoding byte */ - descriptionEndIndex
delimiterLength(encoding); - delimiterLength(encoding);
byte[] objectData = new byte[objectDataSize]; byte[] objectData = new byte[objectDataSize];
System.arraycopy(frame, descriptionEndIndex + delimiterLength(encoding), objectData, 0, System.arraycopy(frame, descriptionEndIndex + delimiterLength(encoding), objectData, 0,
objectDataSize); objectDataSize);
...@@ -133,13 +133,13 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> { ...@@ -133,13 +133,13 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
int terminationPos = indexOf(data, fromIndex, (byte) 0); int terminationPos = indexOf(data, fromIndex, (byte) 0);
// For single byte encoding charsets, we are done // For single byte encoding charsets, we are done
if(encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 || encodingByte == ID3_TEXT_ENCODING_UTF_8) { if (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 || encodingByte == ID3_TEXT_ENCODING_UTF_8) {
return terminationPos; return terminationPos;
} }
// Otherwise, look for a two zero bytes // Otherwise, look for a two zero bytes
while(terminationPos < data.length - 1) { while (terminationPos < data.length - 1) {
if(data[terminationPos + 1] == (byte) 0) { if (data[terminationPos + 1] == (byte) 0) {
return terminationPos; return terminationPos;
} }
terminationPos = indexOf(data, terminationPos + 1, (byte) 0); terminationPos = indexOf(data, terminationPos + 1, (byte) 0);
...@@ -149,8 +149,8 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> { ...@@ -149,8 +149,8 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
} }
private static int delimiterLength(int encodingByte) { private static int delimiterLength(int encodingByte) {
return (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 || return (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1
encodingByte == ID3_TEXT_ENCODING_UTF_8) ? 1 : 2; || encodingByte == ID3_TEXT_ENCODING_UTF_8) ? 1 : 2;
} }
/** /**
......
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