Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5153e9e9
authored
Jan 17, 2017
by
Philip Simpson
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Improved ID3 chapter parsing code from feedback given.
parent
f2f10580
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
76 deletions
library/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java → library/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapFrame.java
library/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterTOCFrame.java → library/src/main/java/com/google/android/exoplayer2/metadata/id3/CtocFrame.java
library/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java
library/src/main/java/com/google/android/exoplayer2/metadata/id3/UrlLinkFrame.java → library/src/main/java/com/google/android/exoplayer2/metadata/id3/WxxxFrame.java
library/src/main/java/com/google/android/exoplayer2/metadata/id3/Chap
ter
Frame.java
→
library/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapFrame.java
View file @
5153e9e9
/*
/*
* Copyright (C) 201
6
The Android Open Source Project
* Copyright (C) 201
7
The Android Open Source Project
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -22,7 +22,7 @@ import com.google.android.exoplayer2.util.Util;
/**
/**
* Chapter information "CHAP" ID3 frame.
* Chapter information "CHAP" ID3 frame.
*/
*/
public
final
class
Chap
ter
Frame
extends
Id3Frame
{
public
final
class
ChapFrame
extends
Id3Frame
{
public
static
final
String
ID
=
"CHAP"
;
public
static
final
String
ID
=
"CHAP"
;
...
@@ -35,8 +35,8 @@ public final class ChapterFrame extends Id3Frame {
...
@@ -35,8 +35,8 @@ public final class ChapterFrame extends Id3Frame {
public
final
String
url
;
public
final
String
url
;
public
final
ApicFrame
image
;
public
final
ApicFrame
image
;
public
Chap
ter
Frame
(
String
chapterId
,
int
startTime
,
int
endTime
,
int
startOffset
,
int
endOffset
,
public
ChapFrame
(
String
chapterId
,
int
startTime
,
int
endTime
,
int
startOffset
,
int
endOffset
,
String
title
,
String
url
,
ApicFrame
image
)
{
String
title
,
String
url
,
ApicFrame
image
)
{
super
(
ID
);
super
(
ID
);
this
.
chapterId
=
chapterId
;
this
.
chapterId
=
chapterId
;
this
.
startTime
=
startTime
;
this
.
startTime
=
startTime
;
...
@@ -48,7 +48,7 @@ public final class ChapterFrame extends Id3Frame {
...
@@ -48,7 +48,7 @@ public final class ChapterFrame extends Id3Frame {
this
.
image
=
image
;
this
.
image
=
image
;
}
}
/* package */
Chap
ter
Frame
(
Parcel
in
)
{
/* package */
ChapFrame
(
Parcel
in
)
{
super
(
ID
);
super
(
ID
);
this
.
chapterId
=
in
.
readString
();
this
.
chapterId
=
in
.
readString
();
this
.
startTime
=
in
.
readInt
();
this
.
startTime
=
in
.
readInt
();
...
@@ -68,15 +68,15 @@ public final class ChapterFrame extends Id3Frame {
...
@@ -68,15 +68,15 @@ public final class ChapterFrame extends Id3Frame {
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
return
false
;
}
}
ChapterFrame
other
=
(
ChapterFrame
)
obj
;
ChapFrame
other
=
(
ChapFrame
)
obj
;
return
Util
.
areEqual
(
chapterId
,
other
.
chapterId
)
return
startTime
==
other
.
startTime
&&
startTime
==
other
.
startTime
&&
endTime
==
other
.
endTime
&&
endTime
==
other
.
endTime
&&
startOffset
==
other
.
startOffset
&&
startOffset
==
other
.
startOffset
&&
endOffset
==
other
.
endOffset
&&
endOffset
==
other
.
endOffset
&&
title
!=
null
?
title
.
equals
(
other
.
title
)
:
other
.
title
==
null
&&
Util
.
areEqual
(
chapterId
,
other
.
chapterId
)
&&
url
!=
null
?
url
.
equals
(
other
.
url
)
:
other
.
url
==
null
&&
Util
.
areEqual
(
title
,
other
.
title
)
&&
image
!=
null
?
image
.
equals
(
other
.
image
)
:
other
.
image
==
null
;
&&
Util
.
areEqual
(
url
,
other
.
url
)
&&
Util
.
areEqual
(
image
,
other
.
image
);
}
}
@Override
@Override
...
@@ -103,7 +103,7 @@ public final class ChapterFrame extends Id3Frame {
...
@@ -103,7 +103,7 @@ public final class ChapterFrame extends Id3Frame {
dest
.
writeString
(
title
);
dest
.
writeString
(
title
);
dest
.
writeString
(
url
);
dest
.
writeString
(
url
);
dest
.
writeString
(
title
);
dest
.
writeString
(
title
);
dest
.
writeParcelable
(
this
.
image
,
flags
);
dest
.
writeParcelable
(
image
,
flags
);
}
}
@Override
@Override
...
@@ -111,15 +111,15 @@ public final class ChapterFrame extends Id3Frame {
...
@@ -111,15 +111,15 @@ public final class ChapterFrame extends Id3Frame {
return
0
;
return
0
;
}
}
public
static
final
Creator
<
Chap
terFrame
>
CREATOR
=
new
Creator
<
Chapter
Frame
>()
{
public
static
final
Creator
<
Chap
Frame
>
CREATOR
=
new
Creator
<
Chap
Frame
>()
{
@Override
@Override
public
Chap
ter
Frame
createFromParcel
(
Parcel
in
)
{
public
ChapFrame
createFromParcel
(
Parcel
in
)
{
return
new
Chap
ter
Frame
(
in
);
return
new
ChapFrame
(
in
);
}
}
@Override
@Override
public
Chap
ter
Frame
[]
newArray
(
int
size
)
{
public
ChapFrame
[]
newArray
(
int
size
)
{
return
new
Chap
ter
Frame
[
size
];
return
new
ChapFrame
[
size
];
}
}
};
};
}
}
library/src/main/java/com/google/android/exoplayer2/metadata/id3/C
hapterTOC
Frame.java
→
library/src/main/java/com/google/android/exoplayer2/metadata/id3/C
toc
Frame.java
View file @
5153e9e9
/*
/*
* Copyright (C) 201
6
The Android Open Source Project
* Copyright (C) 201
7
The Android Open Source Project
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,12 +17,14 @@ package com.google.android.exoplayer2.metadata.id3;
...
@@ -17,12 +17,14 @@ package com.google.android.exoplayer2.metadata.id3;
import
android.os.Parcel
;
import
android.os.Parcel
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.Arrays
;
import
java.util.Arrays
;
/**
/**
* Chapter table of contents information "CTOC" ID3 frame.
* Chapter table of contents information "CTOC" ID3 frame.
*/
*/
public
class
ChapterTOC
Frame
extends
Id3Frame
{
public
final
class
Ctoc
Frame
extends
Id3Frame
{
public
static
final
String
ID
=
"CTOC"
;
public
static
final
String
ID
=
"CTOC"
;
...
@@ -32,7 +34,7 @@ public class ChapterTOCFrame extends Id3Frame {
...
@@ -32,7 +34,7 @@ public class ChapterTOCFrame extends Id3Frame {
public
final
String
[]
children
;
public
final
String
[]
children
;
public
final
String
title
;
public
final
String
title
;
public
C
hapterTOC
Frame
(
String
elementId
,
boolean
isRoot
,
boolean
isOrdered
,
String
[]
children
,
String
title
)
{
public
C
toc
Frame
(
String
elementId
,
boolean
isRoot
,
boolean
isOrdered
,
String
[]
children
,
String
title
)
{
super
(
ID
);
super
(
ID
);
this
.
elementId
=
elementId
;
this
.
elementId
=
elementId
;
this
.
isRoot
=
isRoot
;
this
.
isRoot
=
isRoot
;
...
@@ -41,7 +43,7 @@ public class ChapterTOCFrame extends Id3Frame {
...
@@ -41,7 +43,7 @@ public class ChapterTOCFrame extends Id3Frame {
this
.
title
=
title
;
this
.
title
=
title
;
}
}
/* package */
C
hapterTOC
Frame
(
Parcel
in
)
{
/* package */
C
toc
Frame
(
Parcel
in
)
{
super
(
ID
);
super
(
ID
);
this
.
elementId
=
in
.
readString
();
this
.
elementId
=
in
.
readString
();
this
.
isRoot
=
in
.
readByte
()
!=
0
;
this
.
isRoot
=
in
.
readByte
()
!=
0
;
...
@@ -58,12 +60,12 @@ public class ChapterTOCFrame extends Id3Frame {
...
@@ -58,12 +60,12 @@ public class ChapterTOCFrame extends Id3Frame {
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
return
false
;
}
}
ChapterTOCFrame
other
=
(
ChapterTOCFrame
)
obj
;
CtocFrame
other
=
(
CtocFrame
)
obj
;
return
elementId
!=
null
?
elementId
.
equals
(
other
.
elementId
)
:
other
.
elementId
==
null
return
isRoot
==
other
.
isRoot
&&
isRoot
==
other
.
isRoot
&&
isOrdered
==
other
.
isOrdered
&&
isOrdered
==
other
.
isOrdered
&&
Arrays
.
equals
(
children
,
other
.
children
)
&&
Util
.
areEqual
(
elementId
,
other
.
elementId
)
&&
title
!=
null
?
title
.
equals
(
other
.
title
)
:
other
.
title
==
null
;
&&
Util
.
areEqual
(
title
,
other
.
title
)
&&
Arrays
.
equals
(
children
,
other
.
children
);
}
}
@Override
@Override
...
@@ -79,22 +81,22 @@ public class ChapterTOCFrame extends Id3Frame {
...
@@ -79,22 +81,22 @@ public class ChapterTOCFrame extends Id3Frame {
@Override
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
this
.
elementId
);
dest
.
writeString
(
elementId
);
dest
.
writeByte
((
byte
)(
this
.
isRoot
?
1
:
0
));
dest
.
writeByte
((
byte
)(
isRoot
?
1
:
0
));
dest
.
writeByte
((
byte
)(
this
.
isOrdered
?
1
:
0
));
dest
.
writeByte
((
byte
)(
isOrdered
?
1
:
0
));
dest
.
writeStringArray
(
this
.
children
);
dest
.
writeStringArray
(
children
);
dest
.
writeString
(
t
his
.
t
itle
);
dest
.
writeString
(
title
);
}
}
public
static
final
Creator
<
C
hapterTOCFrame
>
CREATOR
=
new
Creator
<
ChapterTOC
Frame
>()
{
public
static
final
Creator
<
C
tocFrame
>
CREATOR
=
new
Creator
<
Ctoc
Frame
>()
{
@Override
@Override
public
C
hapterTOC
Frame
createFromParcel
(
Parcel
in
)
{
public
C
toc
Frame
createFromParcel
(
Parcel
in
)
{
return
new
C
hapterTOC
Frame
(
in
);
return
new
C
toc
Frame
(
in
);
}
}
@Override
@Override
public
C
hapterTOC
Frame
[]
newArray
(
int
size
)
{
public
C
toc
Frame
[]
newArray
(
int
size
)
{
return
new
C
hapterTOC
Frame
[
size
];
return
new
C
toc
Frame
[
size
];
}
}
};
};
}
}
library/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java
View file @
5153e9e9
...
@@ -84,7 +84,7 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -84,7 +84,7 @@ public final class Id3Decoder implements MetadataDecoder {
int
frameHeaderSize
=
id3Header
.
majorVersion
==
2
?
6
:
10
;
int
frameHeaderSize
=
id3Header
.
majorVersion
==
2
?
6
:
10
;
while
(
id3Data
.
bytesLeft
()
>=
frameHeaderSize
)
{
while
(
id3Data
.
bytesLeft
()
>=
frameHeaderSize
)
{
Id3Frame
frame
=
decodeFrame
(
id3Header
.
majorVersion
,
id3Data
,
unsignedIntFrameSizeHack
);
Id3Frame
frame
=
decodeFrame
(
id3Header
.
majorVersion
,
id3Data
,
unsignedIntFrameSizeHack
,
frameHeaderSize
);
if
(
frame
!=
null
)
{
if
(
frame
!=
null
)
{
id3Frames
.
add
(
frame
);
id3Frames
.
add
(
frame
);
}
}
...
@@ -190,7 +190,7 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -190,7 +190,7 @@ public final class Id3Decoder implements MetadataDecoder {
}
}
private
static
Id3Frame
decodeFrame
(
int
majorVersion
,
ParsableByteArray
id3Data
,
private
static
Id3Frame
decodeFrame
(
int
majorVersion
,
ParsableByteArray
id3Data
,
boolean
unsignedIntFrameSizeHack
)
{
boolean
unsignedIntFrameSizeHack
,
int
frameHeaderSize
)
{
int
frameId0
=
id3Data
.
readUnsignedByte
();
int
frameId0
=
id3Data
.
readUnsignedByte
();
int
frameId1
=
id3Data
.
readUnsignedByte
();
int
frameId1
=
id3Data
.
readUnsignedByte
();
int
frameId2
=
id3Data
.
readUnsignedByte
();
int
frameId2
=
id3Data
.
readUnsignedByte
();
...
@@ -282,12 +282,15 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -282,12 +282,15 @@ public final class Id3Decoder implements MetadataDecoder {
}
else
if
(
frameId0
==
'C'
&&
frameId1
==
'O'
&&
frameId2
==
'M'
}
else
if
(
frameId0
==
'C'
&&
frameId1
==
'O'
&&
frameId2
==
'M'
&&
(
frameId3
==
'M'
||
majorVersion
==
2
))
{
&&
(
frameId3
==
'M'
||
majorVersion
==
2
))
{
frame
=
decodeCommentFrame
(
id3Data
,
frameSize
);
frame
=
decodeCommentFrame
(
id3Data
,
frameSize
);
}
else
if
(
frameId0
==
'W'
&&
frameId1
==
'X'
&&
frameId2
==
'X'
&&
frameId3
==
'X'
)
{
}
else
if
(
majorVersion
==
2
?
(
frameId0
==
'W'
&&
frameId1
==
'X'
&&
frameId2
==
'X'
)
frame
=
decodeUrlLinkFrame
(
id3Data
,
frameSize
);
:
(
frameId0
==
'W'
&&
frameId1
==
'X'
&&
frameId2
==
'X'
&&
frameId3
==
'X'
))
{
frame
=
decodeWxxxFrame
(
id3Data
,
frameSize
);
}
else
if
(
frameId0
==
'C'
&&
frameId1
==
'H'
&&
frameId2
==
'A'
&&
frameId3
==
'P'
)
{
}
else
if
(
frameId0
==
'C'
&&
frameId1
==
'H'
&&
frameId2
==
'A'
&&
frameId3
==
'P'
)
{
frame
=
decodeChapterFrame
(
id3Data
,
frameSize
,
majorVersion
,
unsignedIntFrameSizeHack
);
frame
=
decodeChapFrame
(
id3Data
,
frameSize
,
majorVersion
,
unsignedIntFrameSizeHack
,
frameHeaderSize
);
}
else
if
(
frameId0
==
'C'
&&
frameId1
==
'T'
&&
frameId2
==
'O'
&&
frameId3
==
'C'
)
{
}
else
if
(
frameId0
==
'C'
&&
frameId1
==
'T'
&&
frameId2
==
'O'
&&
frameId3
==
'C'
)
{
frame
=
decodeChapterTOCFrame
(
id3Data
,
frameSize
,
majorVersion
,
unsignedIntFrameSizeHack
);
frame
=
decodeCtocFrame
(
id3Data
,
frameSize
,
majorVersion
,
unsignedIntFrameSizeHack
,
frameHeaderSize
);
}
else
{
}
else
{
String
id
=
majorVersion
==
2
String
id
=
majorVersion
==
2
?
String
.
format
(
Locale
.
US
,
"%c%c%c"
,
frameId0
,
frameId1
,
frameId2
)
?
String
.
format
(
Locale
.
US
,
"%c%c%c"
,
frameId0
,
frameId1
,
frameId2
)
...
@@ -450,7 +453,7 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -450,7 +453,7 @@ public final class Id3Decoder implements MetadataDecoder {
return
new
TextInformationFrame
(
id
,
description
);
return
new
TextInformationFrame
(
id
,
description
);
}
}
private
static
UrlLinkFrame
decodeUrlLink
Frame
(
ParsableByteArray
id3Data
,
private
static
WxxxFrame
decodeWxxx
Frame
(
ParsableByteArray
id3Data
,
int
frameSize
)
throws
UnsupportedEncodingException
{
int
frameSize
)
throws
UnsupportedEncodingException
{
int
encoding
=
id3Data
.
readUnsignedByte
();
int
encoding
=
id3Data
.
readUnsignedByte
();
String
charset
=
getCharsetName
(
encoding
);
String
charset
=
getCharsetName
(
encoding
);
...
@@ -461,16 +464,21 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -461,16 +464,21 @@ public final class Id3Decoder implements MetadataDecoder {
int
descriptionEndIndex
=
indexOfEos
(
data
,
0
,
encoding
);
int
descriptionEndIndex
=
indexOfEos
(
data
,
0
,
encoding
);
String
description
=
new
String
(
data
,
0
,
descriptionEndIndex
,
charset
);
String
description
=
new
String
(
data
,
0
,
descriptionEndIndex
,
charset
);
int
urlStartIndex
=
descriptionEndIndex
+
1
;
String
url
;
int
urlEndIndex
=
indexOfEos
(
data
,
urlStartIndex
,
encoding
);
int
urlStartIndex
=
descriptionEndIndex
+
delimiterLength
(
encoding
);
int
urlLength
=
urlEndIndex
-
urlStartIndex
;
if
(
urlStartIndex
<
data
.
length
)
{
String
url
=
new
String
(
data
,
urlStartIndex
,
urlLength
,
charset
);
int
urlEndIndex
=
indexOfEos
(
data
,
urlStartIndex
,
encoding
);
url
=
new
String
(
data
,
urlStartIndex
,
urlEndIndex
-
urlStartIndex
,
charset
);
}
else
{
url
=
""
;
}
return
new
UrlLink
Frame
(
description
,
url
);
return
new
Wxxx
Frame
(
description
,
url
);
}
}
private
static
ChapterFrame
decodeChapterFrame
(
ParsableByteArray
id3Data
,
int
frameSize
,
private
static
ChapFrame
decodeChapFrame
(
ParsableByteArray
id3Data
,
int
frameSize
,
int
majorVersion
,
boolean
unsignedIntFrameSizeHack
)
throws
UnsupportedEncodingException
{
int
majorVersion
,
boolean
unsignedIntFrameSizeHack
,
int
frameHeaderSize
)
throws
UnsupportedEncodingException
{
byte
[]
frameBytes
=
new
byte
[
frameSize
];
byte
[]
frameBytes
=
new
byte
[
frameSize
];
id3Data
.
readBytes
(
frameBytes
,
0
,
frameSize
-
1
);
id3Data
.
readBytes
(
frameBytes
,
0
,
frameSize
-
1
);
...
@@ -489,9 +497,9 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -489,9 +497,9 @@ public final class Id3Decoder implements MetadataDecoder {
String
url
=
null
;
String
url
=
null
;
ApicFrame
image
=
null
;
ApicFrame
image
=
null
;
int
frameHeaderSize
=
majorVersion
==
2
?
6
:
10
;
while
(
chapterData
.
bytesLeft
()
>=
frameHeaderSize
)
{
while
(
chapterData
.
bytesLeft
()
>=
frameHeaderSize
)
{
Id3Frame
frame
=
decodeFrame
(
majorVersion
,
chapterData
,
unsignedIntFrameSizeHack
);
Id3Frame
frame
=
decodeFrame
(
majorVersion
,
chapterData
,
unsignedIntFrameSizeHack
,
frameHeaderSize
);
if
(
frame
==
null
)
{
if
(
frame
==
null
)
{
continue
;
continue
;
}
}
...
@@ -501,8 +509,8 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -501,8 +509,8 @@ public final class Id3Decoder implements MetadataDecoder {
title
=
textFrame
.
description
;
title
=
textFrame
.
description
;
}
}
}
}
else
if
(
frame
instanceof
UrlLink
Frame
)
{
else
if
(
frame
instanceof
Wxxx
Frame
)
{
UrlLinkFrame
linkFrame
=
(
UrlLink
Frame
)
frame
;
WxxxFrame
linkFrame
=
(
Wxxx
Frame
)
frame
;
url
=
linkFrame
.
url
;
url
=
linkFrame
.
url
;
}
}
else
if
(
frame
instanceof
ApicFrame
)
{
else
if
(
frame
instanceof
ApicFrame
)
{
...
@@ -510,11 +518,12 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -510,11 +518,12 @@ public final class Id3Decoder implements MetadataDecoder {
}
}
}
}
return
new
Chap
ter
Frame
(
chapterId
,
startTime
,
endTime
,
startOffset
,
endOffset
,
title
,
url
,
image
);
return
new
ChapFrame
(
chapterId
,
startTime
,
endTime
,
startOffset
,
endOffset
,
title
,
url
,
image
);
}
}
private
static
ChapterTOCFrame
decodeChapterTOCFrame
(
ParsableByteArray
id3Data
,
int
frameSize
,
private
static
CtocFrame
decodeCtocFrame
(
ParsableByteArray
id3Data
,
int
frameSize
,
int
majorVersion
,
boolean
unsignedIntFrameSizeHack
)
throws
UnsupportedEncodingException
{
int
majorVersion
,
boolean
unsignedIntFrameSizeHack
,
int
frameHeaderSize
)
throws
UnsupportedEncodingException
{
byte
[]
frameBytes
=
new
byte
[
frameSize
];
byte
[]
frameBytes
=
new
byte
[
frameSize
];
id3Data
.
readBytes
(
frameBytes
,
0
,
frameSize
-
1
);
id3Data
.
readBytes
(
frameBytes
,
0
,
frameSize
-
1
);
...
@@ -530,7 +539,7 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -530,7 +539,7 @@ public final class Id3Decoder implements MetadataDecoder {
int
entryCount
=
tocData
.
readUnsignedByte
();
int
entryCount
=
tocData
.
readUnsignedByte
();
String
[]
children
=
new
String
[
entryCount
];
String
[]
children
=
new
String
[
entryCount
];
for
(
int
i
=
0
;
i
<
entryCount
&&
tocData
.
bytesLeft
()
>
0
;
i
++)
{
for
(
int
i
=
0
;
i
<
entryCount
;
i
++)
{
int
startIndex
=
tocData
.
getPosition
();
int
startIndex
=
tocData
.
getPosition
();
int
endIndex
=
indexOfZeroByte
(
frameBytes
,
startIndex
)
+
1
;
int
endIndex
=
indexOfZeroByte
(
frameBytes
,
startIndex
)
+
1
;
int
stringLength
=
endIndex
-
startIndex
;
int
stringLength
=
endIndex
-
startIndex
;
...
@@ -539,21 +548,18 @@ public final class Id3Decoder implements MetadataDecoder {
...
@@ -539,21 +548,18 @@ public final class Id3Decoder implements MetadataDecoder {
}
}
String
title
=
null
;
String
title
=
null
;
int
frameHeaderSize
=
majorVersion
==
2
?
6
:
10
;
while
(
tocData
.
bytesLeft
()
>=
frameHeaderSize
)
{
while
(
tocData
.
bytesLeft
()
>=
frameHeaderSize
)
{
Id3Frame
frame
=
decodeFrame
(
majorVersion
,
tocData
,
unsignedIntFrameSizeHack
);
Id3Frame
frame
=
decodeFrame
(
majorVersion
,
tocData
,
unsignedIntFrameSizeHack
,
if
(
frame
==
null
)
{
frameHeaderSize
);
continue
;
}
if
(
frame
instanceof
TextInformationFrame
)
{
if
(
frame
instanceof
TextInformationFrame
)
{
TextInformationFrame
textFrame
=
(
TextInformationFrame
)
frame
;
TextInformationFrame
textFrame
=
(
TextInformationFrame
)
frame
;
if
(
textFrame
.
id
!=
null
&&
textFrame
.
id
.
equals
(
"TIT2"
))
{
if
(
"TIT2"
.
equals
(
textFrame
.
id
))
{
title
=
textFrame
.
description
;
title
=
textFrame
.
description
;
}
}
}
}
}
}
return
new
C
hapterTOC
Frame
(
id
,
isRoot
,
isOrdered
,
children
,
title
);
return
new
C
toc
Frame
(
id
,
isRoot
,
isOrdered
,
children
,
title
);
}
}
private
static
BinaryFrame
decodeBinaryFrame
(
ParsableByteArray
id3Data
,
int
frameSize
,
private
static
BinaryFrame
decodeBinaryFrame
(
ParsableByteArray
id3Data
,
int
frameSize
,
...
...
library/src/main/java/com/google/android/exoplayer2/metadata/id3/
UrlLink
Frame.java
→
library/src/main/java/com/google/android/exoplayer2/metadata/id3/
Wxxx
Frame.java
View file @
5153e9e9
/*
/*
* Copyright (C) 201
6
The Android Open Source Project
* Copyright (C) 201
7
The Android Open Source Project
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -23,20 +23,20 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -23,20 +23,20 @@ import com.google.android.exoplayer2.util.Util;
/**
/**
* Url Frame "WXX" ID3 frame.
* Url Frame "WXX" ID3 frame.
*/
*/
public
class
UrlLink
Frame
extends
Id3Frame
{
public
final
class
Wxxx
Frame
extends
Id3Frame
{
public
static
final
String
ID
=
"WXXX"
;
public
static
final
String
ID
=
"WXXX"
;
public
final
String
description
;
public
final
String
description
;
public
final
String
url
;
public
final
String
url
;
public
UrlLink
Frame
(
String
description
,
String
url
)
{
public
Wxxx
Frame
(
String
description
,
String
url
)
{
super
(
ID
);
super
(
ID
);
this
.
description
=
description
;
this
.
description
=
description
;
this
.
url
=
url
;
this
.
url
=
url
;
}
}
/* package */
UrlLink
Frame
(
Parcel
in
)
{
/* package */
Wxxx
Frame
(
Parcel
in
)
{
super
(
ID
);
super
(
ID
);
description
=
in
.
readString
();
description
=
in
.
readString
();
url
=
in
.
readString
();
url
=
in
.
readString
();
...
@@ -50,7 +50,7 @@ public class UrlLinkFrame extends Id3Frame {
...
@@ -50,7 +50,7 @@ public class UrlLinkFrame extends Id3Frame {
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
if
(
obj
==
null
||
getClass
()
!=
obj
.
getClass
())
{
return
false
;
return
false
;
}
}
UrlLinkFrame
other
=
(
UrlLink
Frame
)
obj
;
WxxxFrame
other
=
(
Wxxx
Frame
)
obj
;
return
Util
.
areEqual
(
description
,
other
.
description
)
return
Util
.
areEqual
(
description
,
other
.
description
)
&&
Util
.
areEqual
(
url
,
other
.
url
);
&&
Util
.
areEqual
(
url
,
other
.
url
);
}
}
...
@@ -69,17 +69,17 @@ public class UrlLinkFrame extends Id3Frame {
...
@@ -69,17 +69,17 @@ public class UrlLinkFrame extends Id3Frame {
dest
.
writeString
(
url
);
dest
.
writeString
(
url
);
}
}
public
static
final
Parcelable
.
Creator
<
UrlLink
Frame
>
CREATOR
=
public
static
final
Parcelable
.
Creator
<
Wxxx
Frame
>
CREATOR
=
new
Parcelable
.
Creator
<
UrlLink
Frame
>()
{
new
Parcelable
.
Creator
<
Wxxx
Frame
>()
{
@Override
@Override
public
UrlLink
Frame
createFromParcel
(
Parcel
in
)
{
public
Wxxx
Frame
createFromParcel
(
Parcel
in
)
{
return
new
UrlLink
Frame
(
in
);
return
new
Wxxx
Frame
(
in
);
}
}
@Override
@Override
public
UrlLink
Frame
[]
newArray
(
int
size
)
{
public
Wxxx
Frame
[]
newArray
(
int
size
)
{
return
new
UrlLink
Frame
[
size
];
return
new
Wxxx
Frame
[
size
];
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment