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
4b776ffe
authored
Jul 10, 2019
by
Venkatarama NG. Avadhani
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Refactor FlacStreamInfo to FlacStreamMetadata
parent
fb1f91b2
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
72 deletions
extensions/flac/proguard-rules.txt
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeekerTest.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeeker.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java
extensions/flac/src/main/jni/flac_jni.cc
library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/FlacReader.java
library/core/src/main/java/com/google/android/exoplayer2/util/FlacStreamInfo.java → library/core/src/main/java/com/google/android/exoplayer2/util/FlacStreamMetadata.java
library/core/src/test/java/com/google/android/exoplayer2/metadata/vorbis/VorbisCommentDecoderTest.java
extensions/flac/proguard-rules.txt
View file @
4b776ffe
...
...
@@ -9,6 +9,6 @@
-keep class com.google.android.exoplayer2.ext.flac.FlacDecoderJni {
*;
}
-keep class com.google.android.exoplayer2.util.FlacStream
Info
{
-keep class com.google.android.exoplayer2.util.FlacStream
Metadata
{
*;
}
extensions/flac/src/androidTest/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeekerTest.java
View file @
4b776ffe
...
...
@@ -52,7 +52,7 @@ public final class FlacBinarySearchSeekerTest {
FlacBinarySearchSeeker
seeker
=
new
FlacBinarySearchSeeker
(
decoderJni
.
decodeStream
Info
(),
/* firstFramePosition= */
0
,
data
.
length
,
decoderJni
);
decoderJni
.
decodeStream
Metadata
(),
/* firstFramePosition= */
0
,
data
.
length
,
decoderJni
);
SeekMap
seekMap
=
seeker
.
getSeekMap
();
assertThat
(
seekMap
).
isNotNull
();
...
...
@@ -70,7 +70,7 @@ public final class FlacBinarySearchSeekerTest {
decoderJni
.
setData
(
input
);
FlacBinarySearchSeeker
seeker
=
new
FlacBinarySearchSeeker
(
decoderJni
.
decodeStream
Info
(),
/* firstFramePosition= */
0
,
data
.
length
,
decoderJni
);
decoderJni
.
decodeStream
Metadata
(),
/* firstFramePosition= */
0
,
data
.
length
,
decoderJni
);
seeker
.
setSeekTargetUs
(
/* timeUs= */
1000
);
assertThat
(
seeker
.
isSeeking
()).
isTrue
();
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacBinarySearchSeeker.java
View file @
4b776ffe
...
...
@@ -19,7 +19,7 @@ import com.google.android.exoplayer2.extractor.BinarySearchSeeker;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.FlacStream
Info
;
import
com.google.android.exoplayer2.util.FlacStream
Metadata
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
...
...
@@ -34,20 +34,20 @@ import java.nio.ByteBuffer;
private
final
FlacDecoderJni
decoderJni
;
public
FlacBinarySearchSeeker
(
FlacStream
Info
streamInfo
,
FlacStream
Metadata
streamMetadata
,
long
firstFramePosition
,
long
inputLength
,
FlacDecoderJni
decoderJni
)
{
super
(
new
FlacSeekTimestampConverter
(
stream
Info
),
new
FlacSeekTimestampConverter
(
stream
Metadata
),
new
FlacTimestampSeeker
(
decoderJni
),
stream
Info
.
durationUs
(),
stream
Metadata
.
durationUs
(),
/* floorTimePosition= */
0
,
/* ceilingTimePosition= */
stream
Info
.
totalSamples
,
/* ceilingTimePosition= */
stream
Metadata
.
totalSamples
,
/* floorBytePosition= */
firstFramePosition
,
/* ceilingBytePosition= */
inputLength
,
/* approxBytesPerFrame= */
stream
Info
.
getApproxBytesPerFrame
(),
/* minimumSearchRange= */
Math
.
max
(
1
,
stream
Info
.
minFrameSize
));
/* approxBytesPerFrame= */
stream
Metadata
.
getApproxBytesPerFrame
(),
/* minimumSearchRange= */
Math
.
max
(
1
,
stream
Metadata
.
minFrameSize
));
this
.
decoderJni
=
Assertions
.
checkNotNull
(
decoderJni
);
}
...
...
@@ -112,15 +112,15 @@ import java.nio.ByteBuffer;
* the timestamp for a stream seek time position.
*/
private
static
final
class
FlacSeekTimestampConverter
implements
SeekTimestampConverter
{
private
final
FlacStream
Info
streamInfo
;
private
final
FlacStream
Metadata
streamMetadata
;
public
FlacSeekTimestampConverter
(
FlacStream
Info
streamInfo
)
{
this
.
stream
Info
=
streamInfo
;
public
FlacSeekTimestampConverter
(
FlacStream
Metadata
streamMetadata
)
{
this
.
stream
Metadata
=
streamMetadata
;
}
@Override
public
long
timeUsToTargetTime
(
long
timeUs
)
{
return
Assertions
.
checkNotNull
(
stream
Info
).
getSampleIndex
(
timeUs
);
return
Assertions
.
checkNotNull
(
stream
Metadata
).
getSampleIndex
(
timeUs
);
}
}
}
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java
View file @
4b776ffe
...
...
@@ -21,7 +21,7 @@ import com.google.android.exoplayer2.ParserException;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.util.FlacStream
Info
;
import
com.google.android.exoplayer2.util.FlacStream
Metadata
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.util.List
;
...
...
@@ -58,9 +58,9 @@ import java.util.List;
}
decoderJni
=
new
FlacDecoderJni
();
decoderJni
.
setData
(
ByteBuffer
.
wrap
(
initializationData
.
get
(
0
)));
FlacStream
Info
streamInfo
;
FlacStream
Metadata
streamMetadata
;
try
{
stream
Info
=
decoderJni
.
decodeStreamInfo
();
stream
Metadata
=
decoderJni
.
decodeStreamMetadata
();
}
catch
(
ParserException
e
)
{
throw
new
FlacDecoderException
(
"Failed to decode StreamInfo"
,
e
);
}
catch
(
IOException
|
InterruptedException
e
)
{
...
...
@@ -69,9 +69,9 @@ import java.util.List;
}
int
initialInputBufferSize
=
maxInputBufferSize
!=
Format
.
NO_VALUE
?
maxInputBufferSize
:
stream
Info
.
maxFrameSize
;
maxInputBufferSize
!=
Format
.
NO_VALUE
?
maxInputBufferSize
:
stream
Metadata
.
maxFrameSize
;
setInitialInputBufferSize
(
initialInputBufferSize
);
maxOutputBufferSize
=
stream
Info
.
maxDecodedFrameSize
();
maxOutputBufferSize
=
stream
Metadata
.
maxDecodedFrameSize
();
}
@Override
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoderJni.java
View file @
4b776ffe
...
...
@@ -19,7 +19,7 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.util.FlacStream
Info
;
import
com.google.android.exoplayer2.util.FlacStream
Metadata
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
...
...
@@ -142,13 +142,13 @@ import java.nio.ByteBuffer;
return
byteCount
;
}
/** Decodes and consumes the
StreamInfo section
from the FLAC stream. */
public
FlacStream
Info
decodeStreamInfo
()
throws
IOException
,
InterruptedException
{
FlacStream
Info
streamInfo
=
flacDecodeMetadata
(
nativeDecoderContext
);
if
(
stream
Info
==
null
)
{
/** Decodes and consumes the
metadata
from the FLAC stream. */
public
FlacStream
Metadata
decodeStreamMetadata
()
throws
IOException
,
InterruptedException
{
FlacStream
Metadata
streamMetadata
=
flacDecodeMetadata
(
nativeDecoderContext
);
if
(
stream
Metadata
==
null
)
{
throw
new
ParserException
(
"Failed to decode StreamInfo"
);
}
return
stream
Info
;
return
stream
Metadata
;
}
/**
...
...
@@ -266,7 +266,7 @@ import java.nio.ByteBuffer;
private
native
long
flacInit
();
private
native
FlacStream
Info
flacDecodeMetadata
(
long
context
)
private
native
FlacStream
Metadata
flacDecodeMetadata
(
long
context
)
throws
IOException
,
InterruptedException
;
private
native
int
flacDecodeToBuffer
(
long
context
,
ByteBuffer
outputBuffer
)
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java
View file @
4b776ffe
...
...
@@ -34,7 +34,7 @@ import com.google.android.exoplayer2.extractor.TrackOutput;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.id3.Id3Decoder
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.FlacStream
Info
;
import
com.google.android.exoplayer2.util.FlacStream
Metadata
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
java.io.IOException
;
...
...
@@ -87,7 +87,7 @@ public final class FlacExtractor implements Extractor {
private
@MonotonicNonNull
TrackOutput
trackOutput
;
private
boolean
streamInfoDecoded
;
private
@MonotonicNonNull
FlacStream
Info
streamInfo
;
private
@MonotonicNonNull
FlacStream
Metadata
streamMetadata
;
private
@MonotonicNonNull
OutputFrameHolder
outputFrameHolder
;
@Nullable
private
Metadata
id3Metadata
;
...
...
@@ -207,16 +207,16 @@ public final class FlacExtractor implements Extractor {
}
@RequiresNonNull
({
"decoderJni"
,
"extractorOutput"
,
"trackOutput"
})
// Requires initialized.
@EnsuresNonNull
({
"stream
Info
"
,
"outputFrameHolder"
})
// Ensures StreamInfo decoded.
@EnsuresNonNull
({
"stream
Metadata
"
,
"outputFrameHolder"
})
// Ensures StreamInfo decoded.
@SuppressWarnings
({
"contracts.postcondition.not.satisfied"
})
private
void
decodeStreamInfo
(
ExtractorInput
input
)
throws
InterruptedException
,
IOException
{
if
(
streamInfoDecoded
)
{
return
;
}
FlacStream
Info
streamInfo
;
FlacStream
Metadata
streamMetadata
;
try
{
stream
Info
=
decoderJni
.
decodeStreamInfo
();
stream
Metadata
=
decoderJni
.
decodeStreamMetadata
();
}
catch
(
IOException
e
)
{
decoderJni
.
reset
(
/* newPosition= */
0
);
input
.
setRetryPosition
(
/* position= */
0
,
e
);
...
...
@@ -224,16 +224,16 @@ public final class FlacExtractor implements Extractor {
}
streamInfoDecoded
=
true
;
if
(
this
.
stream
Info
==
null
)
{
this
.
stream
Info
=
streamInfo
;
if
(
this
.
stream
Metadata
==
null
)
{
this
.
stream
Metadata
=
streamMetadata
;
binarySearchSeeker
=
outputSeekMap
(
decoderJni
,
stream
Info
,
input
.
getLength
(),
extractorOutput
);
outputSeekMap
(
decoderJni
,
stream
Metadata
,
input
.
getLength
(),
extractorOutput
);
Metadata
metadata
=
id3MetadataDisabled
?
null
:
id3Metadata
;
if
(
stream
Info
.
vorbisComments
!=
null
)
{
metadata
=
stream
Info
.
vorbisComments
.
copyWithAppendedEntriesFrom
(
metadata
);
if
(
stream
Metadata
.
vorbisComments
!=
null
)
{
metadata
=
stream
Metadata
.
vorbisComments
.
copyWithAppendedEntriesFrom
(
metadata
);
}
outputFormat
(
stream
Info
,
metadata
,
trackOutput
);
outputBuffer
.
reset
(
stream
Info
.
maxDecodedFrameSize
());
outputFormat
(
stream
Metadata
,
metadata
,
trackOutput
);
outputBuffer
.
reset
(
stream
Metadata
.
maxDecodedFrameSize
());
outputFrameHolder
=
new
OutputFrameHolder
(
ByteBuffer
.
wrap
(
outputBuffer
.
data
));
}
}
...
...
@@ -273,38 +273,38 @@ public final class FlacExtractor implements Extractor {
@Nullable
private
static
FlacBinarySearchSeeker
outputSeekMap
(
FlacDecoderJni
decoderJni
,
FlacStream
Info
streamInfo
,
FlacStream
Metadata
streamMetadata
,
long
streamLength
,
ExtractorOutput
output
)
{
boolean
hasSeekTable
=
decoderJni
.
getSeekPosition
(
/* timeUs= */
0
)
!=
-
1
;
FlacBinarySearchSeeker
binarySearchSeeker
=
null
;
SeekMap
seekMap
;
if
(
hasSeekTable
)
{
seekMap
=
new
FlacSeekMap
(
stream
Info
.
durationUs
(),
decoderJni
);
seekMap
=
new
FlacSeekMap
(
stream
Metadata
.
durationUs
(),
decoderJni
);
}
else
if
(
streamLength
!=
C
.
LENGTH_UNSET
)
{
long
firstFramePosition
=
decoderJni
.
getDecodePosition
();
binarySearchSeeker
=
new
FlacBinarySearchSeeker
(
stream
Info
,
firstFramePosition
,
streamLength
,
decoderJni
);
new
FlacBinarySearchSeeker
(
stream
Metadata
,
firstFramePosition
,
streamLength
,
decoderJni
);
seekMap
=
binarySearchSeeker
.
getSeekMap
();
}
else
{
seekMap
=
new
SeekMap
.
Unseekable
(
stream
Info
.
durationUs
());
seekMap
=
new
SeekMap
.
Unseekable
(
stream
Metadata
.
durationUs
());
}
output
.
seekMap
(
seekMap
);
return
binarySearchSeeker
;
}
private
static
void
outputFormat
(
FlacStream
Info
streamInfo
,
@Nullable
Metadata
metadata
,
TrackOutput
output
)
{
FlacStream
Metadata
streamMetadata
,
@Nullable
Metadata
metadata
,
TrackOutput
output
)
{
Format
mediaFormat
=
Format
.
createAudioSampleFormat
(
/* id= */
null
,
MimeTypes
.
AUDIO_RAW
,
/* codecs= */
null
,
stream
Info
.
bitRate
(),
stream
Info
.
maxDecodedFrameSize
(),
stream
Info
.
channels
,
stream
Info
.
sampleRate
,
getPcmEncoding
(
stream
Info
.
bitsPerSample
),
stream
Metadata
.
bitRate
(),
stream
Metadata
.
maxDecodedFrameSize
(),
stream
Metadata
.
channels
,
stream
Metadata
.
sampleRate
,
getPcmEncoding
(
stream
Metadata
.
bitsPerSample
),
/* encoderDelay= */
0
,
/* encoderPadding= */
0
,
/* initializationData= */
null
,
...
...
extensions/flac/src/main/jni/flac_jni.cc
View file @
4b776ffe
...
...
@@ -124,7 +124,7 @@ DECODER_FUNC(jobject, flacDecodeMetadata, jlong jContext) {
context
->
parser
->
getStreamInfo
();
jclass
cls
=
env
->
FindClass
(
"com/google/android/exoplayer2/util/"
"FlacStream
Info
"
);
"FlacStream
Metadata
"
);
jmethodID
constructor
=
env
->
GetMethodID
(
cls
,
"<init>"
,
"(IIIIIIIJLjava/util/ArrayList;)V"
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/ogg/FlacReader.java
View file @
4b776ffe
...
...
@@ -19,7 +19,7 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.extractor.ExtractorInput
;
import
com.google.android.exoplayer2.extractor.SeekMap
;
import
com.google.android.exoplayer2.extractor.SeekPoint
;
import
com.google.android.exoplayer2.util.FlacStream
Info
;
import
com.google.android.exoplayer2.util.FlacStream
Metadata
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.android.exoplayer2.util.Util
;
...
...
@@ -38,7 +38,7 @@ import java.util.List;
private
static
final
int
FRAME_HEADER_SAMPLE_NUMBER_OFFSET
=
4
;
private
FlacStream
Info
streamInfo
;
private
FlacStream
Metadata
streamMetadata
;
private
FlacOggSeeker
flacOggSeeker
;
public
static
boolean
verifyBitstreamType
(
ParsableByteArray
data
)
{
...
...
@@ -50,7 +50,7 @@ import java.util.List;
protected
void
reset
(
boolean
headerData
)
{
super
.
reset
(
headerData
);
if
(
headerData
)
{
stream
Info
=
null
;
stream
Metadata
=
null
;
flacOggSeeker
=
null
;
}
}
...
...
@@ -71,14 +71,24 @@ import java.util.List;
protected
boolean
readHeaders
(
ParsableByteArray
packet
,
long
position
,
SetupData
setupData
)
throws
IOException
,
InterruptedException
{
byte
[]
data
=
packet
.
data
;
if
(
stream
Info
==
null
)
{
stream
Info
=
new
FlacStreamInfo
(
data
,
17
);
if
(
stream
Metadata
==
null
)
{
stream
Metadata
=
new
FlacStreamMetadata
(
data
,
17
);
byte
[]
metadata
=
Arrays
.
copyOfRange
(
data
,
9
,
packet
.
limit
());
metadata
[
4
]
=
(
byte
)
0x80
;
// Set the last metadata block flag, ignore the other blocks
List
<
byte
[]>
initializationData
=
Collections
.
singletonList
(
metadata
);
setupData
.
format
=
Format
.
createAudioSampleFormat
(
null
,
MimeTypes
.
AUDIO_FLAC
,
null
,
Format
.
NO_VALUE
,
streamInfo
.
bitRate
(),
streamInfo
.
channels
,
streamInfo
.
sampleRate
,
initializationData
,
null
,
0
,
null
);
setupData
.
format
=
Format
.
createAudioSampleFormat
(
null
,
MimeTypes
.
AUDIO_FLAC
,
null
,
Format
.
NO_VALUE
,
streamMetadata
.
bitRate
(),
streamMetadata
.
channels
,
streamMetadata
.
sampleRate
,
initializationData
,
null
,
0
,
null
);
}
else
if
((
data
[
0
]
&
0x7F
)
==
SEEKTABLE_PACKET_TYPE
)
{
flacOggSeeker
=
new
FlacOggSeeker
();
flacOggSeeker
.
parseSeekTable
(
packet
);
...
...
@@ -211,7 +221,7 @@ import java.util.List;
@Override
public
long
getDurationUs
()
{
return
stream
Info
.
durationUs
();
return
stream
Metadata
.
durationUs
();
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/FlacStream
Info
.java
→
library/core/src/main/java/com/google/android/exoplayer2/util/FlacStream
Metadata
.java
View file @
4b776ffe
...
...
@@ -24,7 +24,7 @@ import java.util.ArrayList;
/**
* Holder for FLAC stream info.
*/
public
final
class
FlacStream
Info
{
public
final
class
FlacStream
Metadata
{
public
final
int
minBlockSize
;
public
final
int
maxBlockSize
;
...
...
@@ -40,14 +40,14 @@ public final class FlacStreamInfo {
private
static
final
String
SEPARATOR
=
"="
;
/**
* Constructs a FlacStream
Info
parsing the given binary FLAC stream info metadata structure.
* Constructs a FlacStream
Metadata
parsing the given binary FLAC stream info metadata structure.
*
* @param data An array holding FLAC stream info metadata structure
* @param offset Offset of the structure in the array
* @see <a href="https://xiph.org/flac/format.html#metadata_block_streaminfo">FLAC format
* METADATA_BLOCK_STREAMINFO</a>
*/
public
FlacStream
Info
(
byte
[]
data
,
int
offset
)
{
public
FlacStream
Metadata
(
byte
[]
data
,
int
offset
)
{
ParsableBitArray
scratch
=
new
ParsableBitArray
(
data
);
scratch
.
setPosition
(
offset
*
8
);
this
.
minBlockSize
=
scratch
.
readBits
(
16
);
...
...
@@ -64,7 +64,7 @@ public final class FlacStreamInfo {
}
/**
* Constructs a FlacStream
Info
given the parameters.
* Constructs a FlacStream
Metadata
given the parameters.
*
* @param minBlockSize Minimum block size of the FLAC stream.
* @param maxBlockSize Maximum block size of the FLAC stream.
...
...
@@ -77,7 +77,7 @@ public final class FlacStreamInfo {
* @see <a href="https://xiph.org/flac/format.html#metadata_block_streaminfo">FLAC format
* METADATA_BLOCK_STREAMINFO</a>
*/
public
FlacStream
Info
(
public
FlacStream
Metadata
(
int
minBlockSize
,
int
maxBlockSize
,
int
minFrameSize
,
...
...
@@ -98,7 +98,7 @@ public final class FlacStreamInfo {
}
/**
* Constructs a FlacStream
Info
given the parameters.
* Constructs a FlacStream
Metadata
given the parameters.
*
* @param minBlockSize Minimum block size of the FLAC stream.
* @param maxBlockSize Maximum block size of the FLAC stream.
...
...
@@ -109,11 +109,11 @@ public final class FlacStreamInfo {
* @param bitsPerSample Number of bits per sample of the FLAC stream.
* @param totalSamples Total samples of the FLAC stream.
* @param vorbisCommentList An {@link ArrayList<String>} that contains vorbis comments, which will
* be converted and stored as metadata in {@link FlacStream
Info
#vorbisComments}
* be converted and stored as metadata in {@link FlacStream
Metadata
#vorbisComments}
* @see <a href="https://xiph.org/flac/format.html#metadata_block_streaminfo">FLAC format
* METADATA_BLOCK_STREAMINFO</a>
*/
public
FlacStream
Info
(
public
FlacStream
Metadata
(
int
minBlockSize
,
int
maxBlockSize
,
int
minFrameSize
,
...
...
library/core/src/test/java/com/google/android/exoplayer2/metadata/vorbis/VorbisCommentDecoderTest.java
View file @
4b776ffe
...
...
@@ -19,12 +19,12 @@ import static com.google.common.truth.Truth.assertThat;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.util.FlacStream
Info
;
import
com.google.android.exoplayer2.util.FlacStream
Metadata
;
import
java.util.ArrayList
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
/** Test for {@link FlacStream
Info
}'s conversion of {@link ArrayList} to {@link Metadata}. */
/** Test for {@link FlacStream
Metadata
}'s conversion of {@link ArrayList} to {@link Metadata}. */
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
VorbisCommentDecoderTest
{
...
...
@@ -35,7 +35,7 @@ public final class VorbisCommentDecoderTest {
commentsList
.
add
(
"Title=Song"
);
commentsList
.
add
(
"Artist=Singer"
);
Metadata
metadata
=
new
FlacStream
Info
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
Metadata
metadata
=
new
FlacStream
Metadata
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
assertThat
(
metadata
.
length
()).
isEqualTo
(
2
);
VorbisCommentFrame
commentFrame
=
(
VorbisCommentFrame
)
metadata
.
get
(
0
);
...
...
@@ -50,7 +50,7 @@ public final class VorbisCommentDecoderTest {
public
void
decodeEmptyList
()
{
ArrayList
<
String
>
commentsList
=
new
ArrayList
<>();
Metadata
metadata
=
new
FlacStream
Info
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
Metadata
metadata
=
new
FlacStream
Metadata
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
assertThat
(
metadata
).
isNull
();
}
...
...
@@ -62,7 +62,7 @@ public final class VorbisCommentDecoderTest {
commentsList
.
add
(
"Title=Song"
);
commentsList
.
add
(
"Artist=Sing=er"
);
Metadata
metadata
=
new
FlacStream
Info
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
Metadata
metadata
=
new
FlacStream
Metadata
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
assertThat
(
metadata
.
length
()).
isEqualTo
(
2
);
VorbisCommentFrame
commentFrame
=
(
VorbisCommentFrame
)
metadata
.
get
(
0
);
...
...
@@ -80,7 +80,7 @@ public final class VorbisCommentDecoderTest {
commentsList
.
add
(
"TitleSong"
);
commentsList
.
add
(
"Artist=Singer"
);
Metadata
metadata
=
new
FlacStream
Info
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
Metadata
metadata
=
new
FlacStream
Metadata
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
commentsList
).
vorbisComments
;
assertThat
(
metadata
.
length
()).
isEqualTo
(
1
);
VorbisCommentFrame
commentFrame
=
(
VorbisCommentFrame
)
metadata
.
get
(
0
);
...
...
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