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
9597ecbb
authored
Jan 17, 2022
by
OxygenCobalt
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clean up VorbisUtil
Try to eliminate some nitpicks regarding VorbisUtil.
parent
0ea8567b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacStreamMetadata.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisUtil.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacStreamMetadata.java
View file @
9597ecbb
...
...
@@ -269,7 +269,7 @@ public final class FlacStreamMetadata {
@Nullable
Metadata
appendedMetadata
=
getMetadataCopyWithAppendedEntriesFrom
(
VorbisUtil
.
buildMetadata
(
vorbisComments
,
Collections
.
emptyList
()
));
VorbisUtil
.
buildMetadata
(
vorbisComments
));
return
new
FlacStreamMetadata
(
minBlockSizeSamples
,
maxBlockSizeSamples
,
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisUtil.java
View file @
9597ecbb
...
...
@@ -270,7 +270,8 @@ public final class VorbisUtil {
* All others will be transformed into vorbis comments.
*
* @param vorbisComments The raw input of comments, as a key-value pair KEY=VAL.
* @return A metadata instance containing the processed tags.
* @return A Metadata instance containing the parsed metadata entries. Null if there are no
* valid metadata entries that can be parsed.
*/
@Nullable
public
static
Metadata
buildMetadata
(
List
<
String
>
vorbisComments
)
{
...
...
@@ -285,7 +286,8 @@ public final class VorbisUtil {
*
* @param vorbisComments The raw input of comments, as a key-value pair KEY=VAL.
* @param pictureFrames Any picture frames that were parsed beforehand.
* @return A metadata instance containing the processed tags.
* @return A Metadata instance containing the parsed metadata entries. Null if there are no
* valid metadata entries that can be parsed.
*/
@Nullable
public
static
Metadata
buildMetadata
(
List
<
String
>
vorbisComments
,
List
<
PictureFrame
>
pictureFrames
)
{
...
...
@@ -300,21 +302,22 @@ public final class VorbisUtil {
if
(
keyAndValue
.
length
!=
2
)
{
Log
.
w
(
TAG
,
"Failed to parse Vorbis comment: "
+
vorbisComment
);
}
else
{
if
(
keyAndValue
[
0
].
equals
(
"METADATA_BLOCK_PICTURE"
))
{
// This tag is a special cover art tag, outlined by
// https://wiki.xiph.org/index.php/VorbisComment#Cover_art.
// Decode it from Base64 and transform it into a PictureFrame.
try
{
byte
[]
decoded
=
Base64
.
decode
(
keyAndValue
[
1
],
Base64
.
DEFAULT
);
metadataEntries
.
add
(
buildPictureFrame
(
new
ParsableByteArray
(
decoded
)));
}
catch
(
Exception
e
)
{
Log
.
w
(
TAG
,
"Failed to parse vorbis picture"
);
}
}
else
{
VorbisComment
entry
=
new
VorbisComment
(
keyAndValue
[
0
],
keyAndValue
[
1
]);
metadataEntries
.
add
(
entry
);
continue
;
}
if
(
keyAndValue
[
0
].
equals
(
"METADATA_BLOCK_PICTURE"
))
{
// This tag is a special cover art tag, outlined by
// https://wiki.xiph.org/index.php/VorbisComment#Cover_art.
// Decode it from Base64 and transform it into a PictureFrame.
try
{
byte
[]
decoded
=
Base64
.
decode
(
keyAndValue
[
1
],
Base64
.
DEFAULT
);
metadataEntries
.
add
(
buildPictureFrame
(
new
ParsableByteArray
(
decoded
)));
}
catch
(
Exception
e
)
{
Log
.
w
(
TAG
,
"Failed to parse vorbis picture"
);
}
}
else
{
VorbisComment
entry
=
new
VorbisComment
(
keyAndValue
[
0
],
keyAndValue
[
1
]);
metadataEntries
.
add
(
entry
);
}
}
metadataEntries
.
addAll
(
pictureFrames
);
...
...
@@ -328,7 +331,7 @@ public final class VorbisUtil {
* @param scratch The bytes of the picture.
* @return A picture frame from the scratch data.
*/
static
PictureFrame
buildPictureFrame
(
ParsableByteArray
scratch
)
{
public
static
PictureFrame
buildPictureFrame
(
ParsableByteArray
scratch
)
{
int
pictureType
=
scratch
.
readInt
();
int
mimeTypeLength
=
scratch
.
readInt
();
String
mimeType
=
scratch
.
readString
(
mimeTypeLength
,
Charsets
.
US_ASCII
);
...
...
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