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
37ebec6e
authored
Aug 17, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Skip more than one ID3 header.
Issue: 713
parent
90f9f731
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java
library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java
View file @
37ebec6e
...
...
@@ -74,17 +74,21 @@ public final class Mp3Extractor implements Extractor {
public
boolean
sniff
(
ExtractorInput
input
)
throws
IOException
,
InterruptedException
{
ParsableByteArray
scratch
=
new
ParsableByteArray
(
4
);
int
startPosition
=
0
;
input
.
peekFully
(
scratch
.
data
,
0
,
3
);
if
(
scratch
.
readUnsignedInt24
()
==
ID3_TAG
)
{
while
(
true
)
{
input
.
peekFully
(
scratch
.
data
,
0
,
3
);
scratch
.
setPosition
(
0
);
if
(
scratch
.
readUnsignedInt24
()
!=
ID3_TAG
)
{
break
;
}
input
.
advancePeekPosition
(
3
);
input
.
peekFully
(
scratch
.
data
,
0
,
4
);
int
headerLength
=
((
scratch
.
data
[
0
]
&
0x7F
)
<<
21
)
|
((
scratch
.
data
[
1
]
&
0x7F
)
<<
14
)
|
((
scratch
.
data
[
2
]
&
0x7F
)
<<
7
)
|
(
scratch
.
data
[
3
]
&
0x7F
);
input
.
advancePeekPosition
(
headerLength
);
startPosition
=
3
+
3
+
4
+
headerLength
;
}
else
{
input
.
resetPeekPosition
();
startPosition
+=
3
+
3
+
4
+
headerLength
;
}
input
.
resetPeekPosition
();
input
.
advancePeekPosition
(
startPosition
);
// Try to find four consecutive valid MPEG audio frames.
int
headerPosition
=
startPosition
;
...
...
@@ -238,9 +242,12 @@ public final class Mp3Extractor implements Extractor {
// Skip any ID3 header at the start of the file.
if
(
startPosition
==
0
)
{
inputBuffer
.
read
(
extractorInput
,
scratch
.
data
,
0
,
3
);
scratch
.
setPosition
(
0
);
if
(
scratch
.
readUnsignedInt24
()
==
ID3_TAG
)
{
while
(
true
)
{
inputBuffer
.
read
(
extractorInput
,
scratch
.
data
,
0
,
3
);
scratch
.
setPosition
(
0
);
if
(
scratch
.
readUnsignedInt24
()
!=
ID3_TAG
)
{
break
;
}
extractorInput
.
skipFully
(
3
);
extractorInput
.
readFully
(
scratch
.
data
,
0
,
4
);
int
headerLength
=
((
scratch
.
data
[
0
]
&
0x7F
)
<<
21
)
|
((
scratch
.
data
[
1
]
&
0x7F
)
<<
14
)
...
...
@@ -248,9 +255,8 @@ public final class Mp3Extractor implements Extractor {
extractorInput
.
skipFully
(
headerLength
);
inputBuffer
.
reset
();
startPosition
=
getPosition
(
extractorInput
,
inputBuffer
);
}
else
{
inputBuffer
.
returnToMark
();
}
inputBuffer
.
returnToMark
();
}
// Try to find four consecutive valid MPEG audio frames.
...
...
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