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
10badcc4
authored
Sep 01, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Support multi-track in MKV/WebM extractor.
Issue: #514
parent
e07c3581
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
160 deletions
library/src/androidTest/java/com/google/android/exoplayer/extractor/webm/StreamBuilder.java
library/src/androidTest/java/com/google/android/exoplayer/extractor/webm/WebmExtractorTest.java
library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java
library/src/androidTest/java/com/google/android/exoplayer/extractor/webm/StreamBuilder.java
View file @
10badcc4
...
@@ -91,41 +91,44 @@ import java.util.List;
...
@@ -91,41 +91,44 @@ import java.util.List;
return
this
;
return
this
;
}
}
public
StreamBuilder
addVp9Track
(
int
width
,
int
height
,
public
StreamBuilder
addVp9Track
(
byte
trackNumber
,
int
width
,
int
height
,
ContentEncodingSettings
contentEncodingSettings
)
{
ContentEncodingSettings
contentEncodingSettings
)
{
trackEntries
.
add
(
createVideoTrackEntry
(
"V_VP9"
,
width
,
height
,
contentEncodingSettings
,
null
));
trackEntries
.
add
(
createVideoTrackEntry
(
trackNumber
,
"V_VP9"
,
width
,
height
,
contentEncodingSettings
,
null
));
return
this
;
return
this
;
}
}
public
StreamBuilder
addH264Track
(
int
width
,
int
height
,
byte
[]
codecPrivate
)
{
public
StreamBuilder
addH264Track
(
byte
trackNumber
,
int
width
,
int
height
,
byte
[]
codecPrivate
)
{
trackEntries
.
add
(
createVideoTrackEntry
(
"V_MPEG4/ISO/AVC"
,
width
,
height
,
null
,
codecPrivate
));
trackEntries
.
add
(
createVideoTrackEntry
(
trackNumber
,
"V_MPEG4/ISO/AVC"
,
width
,
height
,
null
,
codecPrivate
));
return
this
;
return
this
;
}
}
public
StreamBuilder
addOpusTrack
(
int
channelCount
,
int
sampleRate
,
int
codecDelay
,
public
StreamBuilder
addOpusTrack
(
byte
trackNumber
,
int
channelCount
,
int
sampleRate
,
int
seekPreRoll
,
byte
[]
codecPrivate
)
{
int
codecDelay
,
int
seekPreRoll
,
byte
[]
codecPrivate
)
{
trackEntries
.
add
(
createAudioTrackEntry
(
"A_OPUS"
,
channelCount
,
sampleRate
,
codecPriv
ate
,
trackEntries
.
add
(
createAudioTrackEntry
(
trackNumber
,
"A_OPUS"
,
channelCount
,
sampleR
ate
,
codecDelay
,
seekPreRoll
,
NO_VALUE
));
codec
Private
,
codec
Delay
,
seekPreRoll
,
NO_VALUE
));
return
this
;
return
this
;
}
}
public
StreamBuilder
addOpusTrack
(
int
channelCount
,
int
sampleRate
,
int
codecDelay
,
public
StreamBuilder
addOpusTrack
(
byte
trackNumber
,
int
channelCount
,
int
sampleRate
,
int
seekPreRoll
,
byte
[]
codecPrivate
,
int
defaultDurationNs
)
{
int
codecDelay
,
int
seekPreRoll
,
byte
[]
codecPrivate
,
int
defaultDurationNs
)
{
trackEntries
.
add
(
createAudioTrackEntry
(
"A_OPUS"
,
channelCount
,
sampleRate
,
codecPriv
ate
,
trackEntries
.
add
(
createAudioTrackEntry
(
trackNumber
,
"A_OPUS"
,
channelCount
,
sampleR
ate
,
codecDelay
,
seekPreRoll
,
defaultDurationNs
));
codec
Private
,
codec
Delay
,
seekPreRoll
,
defaultDurationNs
));
return
this
;
return
this
;
}
}
public
StreamBuilder
addVorbisTrack
(
int
channelCount
,
int
sampleRate
,
byte
[]
codecPrivate
)
{
public
StreamBuilder
addVorbisTrack
(
byte
trackNumber
,
int
channelCount
,
int
sampleRate
,
trackEntries
.
add
(
createAudioTrackEntry
(
"A_VORBIS"
,
channelCount
,
sampleRate
,
codecPrivate
,
byte
[]
codecPrivate
)
{
NO_VALUE
,
NO_VALUE
,
NO_VALUE
));
trackEntries
.
add
(
createAudioTrackEntry
(
trackNumber
,
"A_VORBIS"
,
channelCount
,
sampleRate
,
codecPrivate
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
));
return
this
;
return
this
;
}
}
public
StreamBuilder
addUnsupportedTrack
()
{
public
StreamBuilder
addUnsupportedTrack
(
byte
trackNumber
)
{
trackEntries
.
add
(
element
(
0xAE
,
// TrackEntry
trackEntries
.
add
(
element
(
0xAE
,
// TrackEntry
element
(
0x86
,
"D_WEBVTT/metadata"
.
getBytes
()),
// CodecID
element
(
0x86
,
"D_WEBVTT/metadata"
.
getBytes
()),
// CodecID
element
(
0xD7
,
(
byte
)
0x03
),
// TrackNumber
element
(
0xD7
,
trackNumber
),
// TrackNumber
element
(
0x83
,
(
byte
)
0x11
)));
// TrackType
element
(
0x83
,
(
byte
)
0x11
)));
// TrackType
return
this
;
return
this
;
}
}
...
@@ -252,8 +255,8 @@ import java.util.List;
...
@@ -252,8 +255,8 @@ import java.util.List;
durationFirst
?
timescaleElement
:
durationElement
);
durationFirst
?
timescaleElement
:
durationElement
);
}
}
private
static
EbmlElement
createVideoTrackEntry
(
String
codecId
,
int
pixelWidth
,
int
pixelHeight
,
private
static
EbmlElement
createVideoTrackEntry
(
byte
trackNumber
,
String
codecId
,
int
pixelWidth
,
ContentEncodingSettings
contentEncodingSettings
,
byte
[]
codecPrivate
)
{
int
pixelHeight
,
ContentEncodingSettings
contentEncodingSettings
,
byte
[]
codecPrivate
)
{
byte
[]
widthBytes
=
getIntegerBytes
(
pixelWidth
);
byte
[]
widthBytes
=
getIntegerBytes
(
pixelWidth
);
byte
[]
heightBytes
=
getIntegerBytes
(
pixelHeight
);
byte
[]
heightBytes
=
getIntegerBytes
(
pixelHeight
);
EbmlElement
contentEncodingSettingsElement
;
EbmlElement
contentEncodingSettingsElement
;
...
@@ -297,7 +300,7 @@ import java.util.List;
...
@@ -297,7 +300,7 @@ import java.util.List;
return
element
(
0xAE
,
// TrackEntry
return
element
(
0xAE
,
// TrackEntry
element
(
0x86
,
codecId
.
getBytes
()),
// CodecID
element
(
0x86
,
codecId
.
getBytes
()),
// CodecID
element
(
0xD7
,
(
byte
)
0x01
),
// TrackNumber
element
(
0xD7
,
trackNumber
),
// TrackNumber
element
(
0x83
,
(
byte
)
0x01
),
// TrackType
element
(
0x83
,
(
byte
)
0x01
),
// TrackType
contentEncodingSettingsElement
,
contentEncodingSettingsElement
,
element
(
0xE0
,
// Video
element
(
0xE0
,
// Video
...
@@ -306,13 +309,14 @@ import java.util.List;
...
@@ -306,13 +309,14 @@ import java.util.List;
codecPrivateElement
);
codecPrivateElement
);
}
}
private
static
EbmlElement
createAudioTrackEntry
(
String
codecId
,
int
channelCount
,
int
sampleRate
,
private
static
EbmlElement
createAudioTrackEntry
(
byte
trackNumber
,
String
codecId
,
byte
[]
codecPrivate
,
int
codecDelay
,
int
seekPreRoll
,
int
defaultDurationNs
)
{
int
channelCount
,
int
sampleRate
,
byte
[]
codecPrivate
,
int
codecDelay
,
int
seekPreRoll
,
int
defaultDurationNs
)
{
byte
channelCountByte
=
(
byte
)
(
channelCount
&
0xFF
);
byte
channelCountByte
=
(
byte
)
(
channelCount
&
0xFF
);
byte
[]
sampleRateDoubleBytes
=
getLongBytes
(
Double
.
doubleToLongBits
(
sampleRate
));
byte
[]
sampleRateDoubleBytes
=
getLongBytes
(
Double
.
doubleToLongBits
(
sampleRate
));
return
element
(
0xAE
,
// TrackEntry
return
element
(
0xAE
,
// TrackEntry
element
(
0x86
,
codecId
.
getBytes
()),
// CodecID
element
(
0x86
,
codecId
.
getBytes
()),
// CodecID
element
(
0xD7
,
(
byte
)
0x02
),
// TrackNumber
element
(
0xD7
,
trackNumber
),
// TrackNumber
element
(
0x83
,
(
byte
)
0x02
),
// TrackType
element
(
0x83
,
(
byte
)
0x02
),
// TrackType
// CodecDelay
// CodecDelay
codecDelay
!=
NO_VALUE
?
element
(
0x56AA
,
getIntegerBytes
(
codecDelay
))
:
empty
(),
codecDelay
!=
NO_VALUE
?
element
(
0x56AA
,
getIntegerBytes
(
codecDelay
))
:
empty
(),
...
...
library/src/androidTest/java/com/google/android/exoplayer/extractor/webm/WebmExtractorTest.java
View file @
10badcc4
...
@@ -60,6 +60,11 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -60,6 +60,11 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
0x40
,
0x1E
,
0xFF
,
0xE1
,
0x00
,
0x17
,
0x67
,
0x4D
,
0x40
,
0x1E
,
0xE8
,
0x80
,
0x50
,
0x17
,
0xFC
,
0x40
,
0x1E
,
0xFF
,
0xE1
,
0x00
,
0x17
,
0x67
,
0x4D
,
0x40
,
0x1E
,
0xE8
,
0x80
,
0x50
,
0x17
,
0xFC
,
0xB8
,
0x08
,
0x80
,
0x00
,
0x01
,
0xF4
,
0x80
,
0x00
,
0x75
,
0x30
,
0x07
,
0x8B
,
0x16
,
0x89
,
0x01
,
0xB8
,
0x08
,
0x80
,
0x00
,
0x01
,
0xF4
,
0x80
,
0x00
,
0x75
,
0x30
,
0x07
,
0x8B
,
0x16
,
0x89
,
0x01
,
0x00
,
0x04
,
0x68
,
0xEB
,
0xEF
,
0x20
);
0x00
,
0x04
,
0x68
,
0xEB
,
0xEF
,
0x20
);
private
static
final
byte
VIDEO_TRACK_NUMBER
=
0x01
;
private
static
final
byte
AUDIO_TRACK_NUMBER
=
0x02
;
private
static
final
byte
UNSUPPORTED_TRACK_NUMBER
=
0x03
;
private
static
final
byte
SECOND_VIDEO_TRACK_NUMBER
=
0x04
;
private
static
final
byte
SECOND_AUDIO_TRACK_NUMBER
=
0x05
;
private
static
final
UUID
WIDEVINE_UUID
=
new
UUID
(
0xEDEF8BA979D64ACE
L
,
0xA3C827DCD51D21ED
L
);
private
static
final
UUID
WIDEVINE_UUID
=
new
UUID
(
0xEDEF8BA979D64ACE
L
,
0xA3C827DCD51D21ED
L
);
private
static
final
UUID
ZERO_UUID
=
new
UUID
(
0
,
0
);
private
static
final
UUID
ZERO_UUID
=
new
UUID
(
0
,
0
);
...
@@ -86,13 +91,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -86,13 +91,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -100,7 +105,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -100,7 +105,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -108,7 +113,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -108,7 +113,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -116,14 +121,14 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -116,14 +121,14 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -131,13 +136,14 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -131,13 +136,14 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVorbisTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
getVorbisCodecPrivate
())
.
addVorbisTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
getVorbisCodecPrivate
())
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_VORBIS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_VORBIS
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -145,13 +151,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -145,13 +151,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
MATROSKA_DOC_TYPE
)
.
setHeader
(
MATROSKA_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addH264Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
TEST_H264_CODEC_PRIVATE
)
.
addH264Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
TEST_H264_CODEC_PRIVATE
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertH264VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertH264VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -159,8 +165,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -159,8 +165,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
build
(
1
);
.
build
(
1
);
...
@@ -168,8 +174,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -168,8 +174,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
assertTracksEnded
();
assertTracksEnded
();
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -177,9 +183,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -177,9 +183,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addUnsupportedTrack
()
.
addUnsupportedTrack
(
UNSUPPORTED_TRACK_NUMBER
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
build
(
1
);
.
build
(
1
);
...
@@ -188,8 +194,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -188,8 +194,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
assertTracksEnded
();
assertTracksEnded
();
// Even though the input stream has 3 tracks, only 2 of them are supported and will be reported.
// Even though the input stream has 3 tracks, only 2 of them are supported and will be reported.
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -197,21 +203,22 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -197,21 +203,22 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVorbisTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
getVorbisCodecPrivate
())
.
addVorbisTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
getVorbisCodecPrivate
())
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addVp9Track
(
SECOND_VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
addOpusTrack
(
SECOND_AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
// Even though the input stream has 4 supported tracks, only the first video and audio track
assertEquals
(
4
,
extractorOutput
.
numberOfTracks
);
// will be reported.
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assert
Equals
(
2
,
extractorOutput
.
numberOfTracks
);
assert
AudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_VORBIS
);
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
SECOND_VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_VORBI
S
);
assertAudioFormat
(
SECOND_AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPU
S
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
}
}
...
@@ -220,13 +227,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -220,13 +227,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
1
);
DrmInitData
drmInitData
=
extractorOutput
.
drmInitData
;
DrmInitData
drmInitData
=
extractorOutput
.
drmInitData
;
assertNotNull
(
drmInitData
);
assertNotNull
(
drmInitData
);
...
@@ -238,13 +245,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -238,13 +245,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
3
);
.
build
(
3
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
3
);
assertIndex
(
DEFAULT_TIMECODE_SCALE
,
3
);
}
}
...
@@ -268,13 +275,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -268,13 +275,13 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
timecodeScale
,
TEST_DURATION_TIMECODE
,
omitTimecodeScaleIfDefault
,
afterDuration
)
.
setInfo
(
timecodeScale
,
TEST_DURATION_TIMECODE
,
omitTimecodeScaleIfDefault
,
afterDuration
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
3
);
.
build
(
3
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
timecodeScale
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
timecodeScale
);
assertIndex
(
timecodeScale
,
3
);
assertIndex
(
timecodeScale
,
3
);
}
}
...
@@ -283,7 +290,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -283,7 +290,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
media
)
true
/* keyframe */
,
false
/* invisible */
,
media
)
.
build
(
0
);
.
build
(
0
);
...
@@ -298,7 +305,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -298,7 +305,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -310,7 +317,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -310,7 +317,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
MATROSKA_DOC_TYPE
)
.
setHeader
(
MATROSKA_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
1
);
.
build
(
1
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -322,7 +329,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -322,7 +329,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
"webB"
)
.
setHeader
(
"webB"
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
build
(
1
);
.
build
(
1
);
try
{
try
{
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -337,7 +344,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -337,7 +344,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
build
(
1
);
.
build
(
1
);
try
{
try
{
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -352,7 +359,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -352,7 +359,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
build
(
1
);
.
build
(
1
);
try
{
try
{
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -368,7 +375,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -368,7 +375,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
build
(
1
);
.
build
(
1
);
try
{
try
{
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -383,7 +390,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -383,7 +390,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
build
(
1
);
.
build
(
1
);
try
{
try
{
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -398,7 +405,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -398,7 +405,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
build
(
1
);
.
build
(
1
);
try
{
try
{
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
...
@@ -413,7 +420,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -413,7 +420,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
media
)
true
/* keyframe */
,
false
/* invisible */
,
media
)
.
build
(
1
);
.
build
(
1
);
...
@@ -421,8 +428,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -421,8 +428,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadSampleKeyframeStripped
()
throws
IOException
,
InterruptedException
{
public
void
testReadSampleKeyframeStripped
()
throws
IOException
,
InterruptedException
{
...
@@ -433,7 +440,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -433,7 +440,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
sampleBytes
)
true
/* keyframe */
,
false
/* invisible */
,
sampleBytes
)
.
build
(
1
);
.
build
(
1
);
...
@@ -441,8 +448,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -441,8 +448,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
unstrippedSampleBytes
,
0
,
true
,
false
,
null
,
getVideoOutput
());
assertSample
(
0
,
unstrippedSampleBytes
,
0
,
true
,
false
,
null
,
getTrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadSampleKeyframeManyBytesStripped
()
throws
IOException
,
InterruptedException
{
public
void
testReadSampleKeyframeManyBytesStripped
()
throws
IOException
,
InterruptedException
{
...
@@ -453,7 +461,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -453,7 +461,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
sampleBytes
)
true
/* keyframe */
,
false
/* invisible */
,
sampleBytes
)
.
build
(
1
);
.
build
(
1
);
...
@@ -461,8 +469,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -461,8 +469,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
unstrippedSampleBytes
,
0
,
true
,
false
,
null
,
getVideoOutput
());
assertSample
(
0
,
unstrippedSampleBytes
,
0
,
true
,
false
,
null
,
getTrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadTwoTrackSamples
()
throws
IOException
,
InterruptedException
{
public
void
testReadTwoTrackSamples
()
throws
IOException
,
InterruptedException
{
...
@@ -470,8 +479,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -470,8 +479,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
media
)
true
/* keyframe */
,
false
/* invisible */
,
media
)
...
@@ -483,10 +492,10 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -483,10 +492,10 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
assertTracksEnded
();
assertTracksEnded
();
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
AudioOutput
(
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
TrackOutput
(
AUDIO_TRACK_NUMBER
));
}
}
public
void
testReadTwoTrackSamplesWithSkippedTrack
()
throws
IOException
,
InterruptedException
{
public
void
testReadTwoTrackSamplesWithSkippedTrack
()
throws
IOException
,
InterruptedException
{
...
@@ -494,9 +503,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -494,9 +503,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addUnsupportedTrack
()
.
addUnsupportedTrack
(
UNSUPPORTED_TRACK_NUMBER
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
media
)
true
/* keyframe */
,
false
/* invisible */
,
media
)
...
@@ -510,10 +519,10 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -510,10 +519,10 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
assertTracksEnded
();
assertTracksEnded
();
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertEquals
(
2
,
extractorOutput
.
numberOfTracks
);
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
AudioOutput
(
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
TrackOutput
(
AUDIO_TRACK_NUMBER
));
}
}
public
void
testReadBlock
()
throws
IOException
,
InterruptedException
{
public
void
testReadBlock
()
throws
IOException
,
InterruptedException
{
...
@@ -521,7 +530,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -521,7 +530,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
TEST_SEEK_PRE_ROLL
,
TEST_OPUS_CODEC_PRIVATE
)
.
addBlockMedia
(
2
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addBlockMedia
(
2
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
media
)
true
/* keyframe */
,
false
/* invisible */
,
media
)
...
@@ -530,8 +539,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -530,8 +539,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
AudioOutput
(
));
assertSample
(
0
,
media
,
0
,
true
,
false
,
null
,
get
TrackOutput
(
AUDIO_TRACK_NUMBER
));
}
}
public
void
testReadBlockNonKeyframe
()
throws
IOException
,
InterruptedException
{
public
void
testReadBlockNonKeyframe
()
throws
IOException
,
InterruptedException
{
...
@@ -539,7 +548,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -539,7 +548,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
.
addBlockMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
false
/* keyframe */
,
false
/* invisible */
,
media
)
false
/* keyframe */
,
false
/* invisible */
,
media
)
.
build
(
1
);
.
build
(
1
);
...
@@ -547,8 +556,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -547,8 +556,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
media
,
0
,
false
,
false
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
0
,
false
,
false
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadEncryptedFrame
()
throws
IOException
,
InterruptedException
{
public
void
testReadEncryptedFrame
()
throws
IOException
,
InterruptedException
{
...
@@ -557,7 +566,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -557,7 +566,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addSimpleBlockEncryptedMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
.
addSimpleBlockEncryptedMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
true
/* validSignalByte */
,
media
)
true
/* validSignalByte */
,
media
)
...
@@ -566,8 +575,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -566,8 +575,9 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
media
,
0
,
true
,
false
,
TEST_ENCRYPTION_KEY_ID
,
getVideoOutput
());
assertSample
(
0
,
media
,
0
,
true
,
false
,
TEST_ENCRYPTION_KEY_ID
,
getTrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadEncryptedFrameWithInvalidSignalByte
()
public
void
testReadEncryptedFrameWithInvalidSignalByte
()
...
@@ -577,7 +587,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -577,7 +587,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
settings
)
.
addSimpleBlockEncryptedMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
.
addSimpleBlockEncryptedMedia
(
1
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
0
/* blockTimecode */
,
true
/* keyframe */
,
false
/* invisible */
,
false
/* validSignalByte */
,
media
)
false
/* validSignalByte */
,
media
)
...
@@ -597,7 +607,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -597,7 +607,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
12
/* clusterTimecode */
,
13
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
12
/* clusterTimecode */
,
13
/* blockTimecode */
,
false
/* keyframe */
,
true
/* invisible */
,
media
)
false
/* keyframe */
,
true
/* invisible */
,
media
)
.
build
(
1
);
.
build
(
1
);
...
@@ -605,8 +615,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -605,8 +615,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
media
,
25000
,
false
,
true
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
25000
,
false
,
true
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadSampleCustomTimecodeScale
()
throws
IOException
,
InterruptedException
{
public
void
testReadSampleCustomTimecodeScale
()
throws
IOException
,
InterruptedException
{
...
@@ -615,7 +625,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -615,7 +625,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
timecodeScale
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
timecodeScale
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
12
/* clusterTimecode */
,
13
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
12
/* clusterTimecode */
,
13
/* blockTimecode */
,
false
/* keyframe */
,
false
/* invisible */
,
media
)
false
/* keyframe */
,
false
/* invisible */
,
media
)
.
build
(
1
);
.
build
(
1
);
...
@@ -623,8 +633,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -623,8 +633,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
timecodeScale
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
timecodeScale
);
assertSample
(
0
,
media
,
25
,
false
,
false
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
25
,
false
,
false
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadSampleNegativeSimpleBlockTimecode
()
throws
IOException
,
InterruptedException
{
public
void
testReadSampleNegativeSimpleBlockTimecode
()
throws
IOException
,
InterruptedException
{
...
@@ -632,7 +642,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -632,7 +642,7 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addVp9Track
(
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addVp9Track
(
VIDEO_TRACK_NUMBER
,
TEST_WIDTH
,
TEST_HEIGHT
,
null
)
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
13
/* clusterTimecode */
,
-
12
/* blockTimecode */
,
.
addSimpleBlockMedia
(
1
/* trackNumber */
,
13
/* clusterTimecode */
,
-
12
/* blockTimecode */
,
true
/* keyframe */
,
true
/* invisible */
,
media
)
true
/* keyframe */
,
true
/* invisible */
,
media
)
.
build
(
1
);
.
build
(
1
);
...
@@ -640,8 +650,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -640,8 +650,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertVp9VideoFormat
(
DEFAULT_TIMECODE_SCALE
);
assertVp9VideoFormat
(
VIDEO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
);
assertSample
(
0
,
media
,
1000
,
true
,
true
,
null
,
get
VideoOutput
(
));
assertSample
(
0
,
media
,
1000
,
true
,
true
,
null
,
get
TrackOutput
(
VIDEO_TRACK_NUMBER
));
}
}
public
void
testReadSampleWithFixedSizeLacing
()
throws
IOException
,
InterruptedException
{
public
void
testReadSampleWithFixedSizeLacing
()
throws
IOException
,
InterruptedException
{
...
@@ -649,8 +659,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -649,8 +659,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_OPUS_CODEC_PRIVATE
,
TEST_DEFAULT_DURATION_NS
)
TEST_
SEEK_PRE_ROLL
,
TEST_
OPUS_CODEC_PRIVATE
,
TEST_DEFAULT_DURATION_NS
)
.
addSimpleBlockMediaWithFixedSizeLacing
(
2
/* trackNumber */
,
0
/* clusterTimecode */
,
.
addSimpleBlockMediaWithFixedSizeLacing
(
2
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
20
,
media
)
0
/* blockTimecode */
,
20
,
media
)
.
build
(
1
);
.
build
(
1
);
...
@@ -658,11 +668,11 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -658,11 +668,11 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
long
expectedTimeUs
=
i
*
TEST_DEFAULT_DURATION_NS
/
1000
;
long
expectedTimeUs
=
i
*
TEST_DEFAULT_DURATION_NS
/
1000
;
assertSample
(
i
,
Arrays
.
copyOfRange
(
media
,
i
*
5
,
i
*
5
+
5
),
expectedTimeUs
,
true
,
false
,
assertSample
(
i
,
Arrays
.
copyOfRange
(
media
,
i
*
5
,
i
*
5
+
5
),
expectedTimeUs
,
true
,
false
,
null
,
get
AudioOutput
(
));
null
,
get
TrackOutput
(
AUDIO_TRACK_NUMBER
));
}
}
}
}
...
@@ -671,8 +681,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -671,8 +681,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
byte
[]
data
=
new
StreamBuilder
()
byte
[]
data
=
new
StreamBuilder
()
.
setHeader
(
WEBM_DOC_TYPE
)
.
setHeader
(
WEBM_DOC_TYPE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
setInfo
(
DEFAULT_TIMECODE_SCALE
,
TEST_DURATION_TIMECODE
)
.
addOpusTrack
(
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_SEEK_PRE_ROLL
,
.
addOpusTrack
(
AUDIO_TRACK_NUMBER
,
TEST_CHANNEL_COUNT
,
TEST_SAMPLE_RATE
,
TEST_CODEC_DELAY
,
TEST_OPUS_CODEC_PRIVATE
,
TEST_DEFAULT_DURATION_NS
)
TEST_
SEEK_PRE_ROLL
,
TEST_
OPUS_CODEC_PRIVATE
,
TEST_DEFAULT_DURATION_NS
)
.
addSimpleBlockMediaWithXiphLacing
(
2
/* trackNumber */
,
0
/* clusterTimecode */
,
.
addSimpleBlockMediaWithXiphLacing
(
2
/* trackNumber */
,
0
/* clusterTimecode */
,
0
/* blockTimecode */
,
media
,
256
,
1
,
243
)
0
/* blockTimecode */
,
media
,
256
,
1
,
243
)
.
build
(
1
);
.
build
(
1
);
...
@@ -680,31 +690,25 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -680,31 +690,25 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
TestUtil
.
consumeTestData
(
extractor
,
data
);
TestUtil
.
consumeTestData
(
extractor
,
data
);
assertTracksEnded
();
assertTracksEnded
();
assertAudioFormat
(
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertAudioFormat
(
AUDIO_TRACK_NUMBER
,
DEFAULT_TIMECODE_SCALE
,
MimeTypes
.
AUDIO_OPUS
);
assertSample
(
0
,
Arrays
.
copyOfRange
(
media
,
0
,
256
),
0
*
TEST_DEFAULT_DURATION_NS
/
1000
,
true
,
assertSample
(
0
,
Arrays
.
copyOfRange
(
media
,
0
,
256
),
0
*
TEST_DEFAULT_DURATION_NS
/
1000
,
true
,
false
,
null
,
get
AudioOutput
(
));
false
,
null
,
get
TrackOutput
(
AUDIO_TRACK_NUMBER
));
assertSample
(
1
,
Arrays
.
copyOfRange
(
media
,
256
,
257
),
1
*
TEST_DEFAULT_DURATION_NS
/
1000
,
true
,
assertSample
(
1
,
Arrays
.
copyOfRange
(
media
,
256
,
257
),
1
*
TEST_DEFAULT_DURATION_NS
/
1000
,
true
,
false
,
null
,
get
AudioOutput
(
));
false
,
null
,
get
TrackOutput
(
AUDIO_TRACK_NUMBER
));
assertSample
(
2
,
Arrays
.
copyOfRange
(
media
,
257
,
300
),
2
*
TEST_DEFAULT_DURATION_NS
/
1000
,
true
,
assertSample
(
2
,
Arrays
.
copyOfRange
(
media
,
257
,
300
),
2
*
TEST_DEFAULT_DURATION_NS
/
1000
,
true
,
false
,
null
,
getAudioOutput
());
false
,
null
,
getTrackOutput
(
AUDIO_TRACK_NUMBER
));
}
private
FakeTrackOutput
getVideoOutput
()
{
// In the sample data the video track has id 1.
return
extractorOutput
.
trackOutputs
.
get
(
1
);
}
}
private
FakeTrackOutput
getAudioOutput
()
{
private
FakeTrackOutput
getTrackOutput
(
int
trackNumber
)
{
// In the sample data the video track has id 2.
return
extractorOutput
.
trackOutputs
.
get
(
trackNumber
);
return
extractorOutput
.
trackOutputs
.
get
(
2
);
}
}
private
void
assertTracksEnded
()
{
private
void
assertTracksEnded
()
{
assertTrue
(
extractorOutput
.
tracksEnded
);
assertTrue
(
extractorOutput
.
tracksEnded
);
}
}
private
void
assertVp9VideoFormat
(
int
timecodeScale
)
{
private
void
assertVp9VideoFormat
(
int
t
rackNumber
,
int
t
imecodeScale
)
{
MediaFormat
format
=
get
VideoOutput
(
).
format
;
MediaFormat
format
=
get
TrackOutput
(
trackNumber
).
format
;
assertEquals
(
Util
.
scaleLargeTimestamp
(
TEST_DURATION_TIMECODE
,
timecodeScale
,
1000
),
assertEquals
(
Util
.
scaleLargeTimestamp
(
TEST_DURATION_TIMECODE
,
timecodeScale
,
1000
),
format
.
durationUs
);
format
.
durationUs
);
assertEquals
(
TEST_WIDTH
,
format
.
width
);
assertEquals
(
TEST_WIDTH
,
format
.
width
);
...
@@ -712,8 +716,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -712,8 +716,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
assertEquals
(
MimeTypes
.
VIDEO_VP9
,
format
.
mimeType
);
assertEquals
(
MimeTypes
.
VIDEO_VP9
,
format
.
mimeType
);
}
}
private
void
assertH264VideoFormat
(
int
timecodeScale
)
{
private
void
assertH264VideoFormat
(
int
t
rackNumber
,
int
t
imecodeScale
)
{
MediaFormat
format
=
get
VideoOutput
(
).
format
;
MediaFormat
format
=
get
TrackOutput
(
trackNumber
).
format
;
assertEquals
(
Util
.
scaleLargeTimestamp
(
TEST_DURATION_TIMECODE
,
timecodeScale
,
1000
),
assertEquals
(
Util
.
scaleLargeTimestamp
(
TEST_DURATION_TIMECODE
,
timecodeScale
,
1000
),
format
.
durationUs
);
format
.
durationUs
);
assertEquals
(
TEST_WIDTH
,
format
.
width
);
assertEquals
(
TEST_WIDTH
,
format
.
width
);
...
@@ -721,8 +725,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
...
@@ -721,8 +725,8 @@ public final class WebmExtractorTest extends InstrumentationTestCase {
assertEquals
(
MimeTypes
.
VIDEO_H264
,
format
.
mimeType
);
assertEquals
(
MimeTypes
.
VIDEO_H264
,
format
.
mimeType
);
}
}
private
void
assertAudioFormat
(
int
timecodeScale
,
String
expectedMimeType
)
{
private
void
assertAudioFormat
(
int
t
rackNumber
,
int
t
imecodeScale
,
String
expectedMimeType
)
{
MediaFormat
format
=
get
AudioOutput
(
).
format
;
MediaFormat
format
=
get
TrackOutput
(
trackNumber
).
format
;
assertEquals
(
Util
.
scaleLargeTimestamp
(
TEST_DURATION_TIMECODE
,
timecodeScale
,
1000
),
assertEquals
(
Util
.
scaleLargeTimestamp
(
TEST_DURATION_TIMECODE
,
timecodeScale
,
1000
),
format
.
durationUs
);
format
.
durationUs
);
assertEquals
(
TEST_CHANNEL_COUNT
,
format
.
channelCount
);
assertEquals
(
TEST_CHANNEL_COUNT
,
format
.
channelCount
);
...
...
library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java
View file @
10badcc4
...
@@ -34,6 +34,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
...
@@ -34,6 +34,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
import
com.google.android.exoplayer.util.Util
;
import
com.google.android.exoplayer.util.Util
;
import
android.util.Pair
;
import
android.util.Pair
;
import
android.util.SparseArray
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
...
@@ -81,7 +82,6 @@ public final class WebmExtractor implements Extractor {
...
@@ -81,7 +82,6 @@ public final class WebmExtractor implements Extractor {
private
static
final
int
MP3_MAX_INPUT_SIZE
=
4096
;
private
static
final
int
MP3_MAX_INPUT_SIZE
=
4096
;
private
static
final
int
ENCRYPTION_IV_SIZE
=
8
;
private
static
final
int
ENCRYPTION_IV_SIZE
=
8
;
private
static
final
int
TRACK_TYPE_AUDIO
=
2
;
private
static
final
int
TRACK_TYPE_AUDIO
=
2
;
private
static
final
int
TRACK_TYPE_VIDEO
=
1
;
private
static
final
int
UNKNOWN
=
-
1
;
private
static
final
int
UNKNOWN
=
-
1
;
private
static
final
int
ID_EBML
=
0x1A45DFA3
;
private
static
final
int
ID_EBML
=
0x1A45DFA3
;
...
@@ -143,6 +143,7 @@ public final class WebmExtractor implements Extractor {
...
@@ -143,6 +143,7 @@ public final class WebmExtractor implements Extractor {
private
final
EbmlReader
reader
;
private
final
EbmlReader
reader
;
private
final
VarintReader
varintReader
;
private
final
VarintReader
varintReader
;
private
final
SparseArray
<
Track
>
tracks
;
// Temporary arrays.
// Temporary arrays.
private
final
ParsableByteArray
nalStartCode
;
private
final
ParsableByteArray
nalStartCode
;
...
@@ -158,10 +159,10 @@ public final class WebmExtractor implements Extractor {
...
@@ -158,10 +159,10 @@ public final class WebmExtractor implements Extractor {
private
long
durationTimecode
=
C
.
UNKNOWN_TIME_US
;
private
long
durationTimecode
=
C
.
UNKNOWN_TIME_US
;
private
long
durationUs
=
C
.
UNKNOWN_TIME_US
;
private
long
durationUs
=
C
.
UNKNOWN_TIME_US
;
// The track corresponding to the current TrackEntry element, or null.
private
Track
currentTrack
;
private
Track
currentTrack
;
private
Track
audioTrack
;
private
Track
videoTrack
;
// Whether drm init data has been sent to the output.
private
boolean
sentDrmInitData
;
private
boolean
sentDrmInitData
;
// Master seek entry related elements.
// Master seek entry related elements.
...
@@ -208,6 +209,7 @@ public final class WebmExtractor implements Extractor {
...
@@ -208,6 +209,7 @@ public final class WebmExtractor implements Extractor {
this
.
reader
=
reader
;
this
.
reader
=
reader
;
this
.
reader
.
init
(
new
InnerEbmlReaderOutput
());
this
.
reader
.
init
(
new
InnerEbmlReaderOutput
());
varintReader
=
new
VarintReader
();
varintReader
=
new
VarintReader
();
tracks
=
new
SparseArray
<>();
scratch
=
new
ParsableByteArray
(
4
);
scratch
=
new
ParsableByteArray
(
4
);
vorbisNumPageSamples
=
new
ParsableByteArray
(
ByteBuffer
.
allocate
(
4
).
putInt
(-
1
).
array
());
vorbisNumPageSamples
=
new
ParsableByteArray
(
ByteBuffer
.
allocate
(
4
).
putInt
(-
1
).
array
());
seekEntryIdBytes
=
new
ParsableByteArray
(
4
);
seekEntryIdBytes
=
new
ParsableByteArray
(
4
);
...
@@ -399,8 +401,7 @@ public final class WebmExtractor implements Extractor {
...
@@ -399,8 +401,7 @@ public final class WebmExtractor implements Extractor {
if
(!
sampleSeenReferenceBlock
)
{
if
(!
sampleSeenReferenceBlock
)
{
blockFlags
|=
C
.
SAMPLE_FLAG_SYNC
;
blockFlags
|=
C
.
SAMPLE_FLAG_SYNC
;
}
}
outputSampleMetadata
((
audioTrack
!=
null
&&
blockTrackNumber
==
audioTrack
.
number
)
outputSampleMetadata
(
tracks
.
get
(
blockTrackNumber
),
blockTimeUs
);
?
audioTrack
.
output
:
videoTrack
.
output
,
blockTimeUs
);
blockState
=
BLOCK_STATE_START
;
blockState
=
BLOCK_STATE_START
;
return
;
return
;
case
ID_CONTENT_ENCODING:
case
ID_CONTENT_ENCODING:
...
@@ -421,26 +422,16 @@ public final class WebmExtractor implements Extractor {
...
@@ -421,26 +422,16 @@ public final class WebmExtractor implements Extractor {
}
}
return
;
return
;
case
ID_TRACK_ENTRY:
case
ID_TRACK_ENTRY:
if
((
currentTrack
.
type
==
TRACK_TYPE_AUDIO
&&
audioTrack
!=
null
)
if
(
tracks
.
get
(
currentTrack
.
number
)
==
null
&&
isCodecSupported
(
currentTrack
.
codecId
))
{
||
(
currentTrack
.
type
==
TRACK_TYPE_VIDEO
&&
videoTrack
!=
null
))
{
currentTrack
.
initializeOutput
(
extractorOutput
,
durationUs
);
// There is more than 1 audio/video track. Ignore everything but the first.
tracks
.
put
(
currentTrack
.
number
,
currentTrack
);
currentTrack
=
null
;
return
;
}
if
(
currentTrack
.
type
==
TRACK_TYPE_AUDIO
&&
isCodecSupported
(
currentTrack
.
codecId
))
{
audioTrack
=
currentTrack
;
audioTrack
.
initializeOutput
(
extractorOutput
,
durationUs
);
}
else
if
(
currentTrack
.
type
==
TRACK_TYPE_VIDEO
&&
isCodecSupported
(
currentTrack
.
codecId
))
{
videoTrack
=
currentTrack
;
videoTrack
.
initializeOutput
(
extractorOutput
,
durationUs
);
}
else
{
}
else
{
//
Unsupported track type
. Do nothing.
//
We've seen this track entry before, or the codec is unsupported
. Do nothing.
}
}
currentTrack
=
null
;
currentTrack
=
null
;
return
;
return
;
case
ID_TRACKS:
case
ID_TRACKS:
if
(
videoTrack
==
null
&&
audioTrack
==
null
)
{
if
(
tracks
.
size
()
==
0
)
{
throw
new
ParserException
(
"No valid tracks were found"
);
throw
new
ParserException
(
"No valid tracks were found"
);
}
}
extractorOutput
.
endTracks
();
extractorOutput
.
endTracks
();
...
@@ -614,16 +605,15 @@ public final class WebmExtractor implements Extractor {
...
@@ -614,16 +605,15 @@ public final class WebmExtractor implements Extractor {
scratch
.
reset
();
scratch
.
reset
();
}
}
// Ignore the block if the track number equals neither the audio track nor the video track.
Track
track
=
tracks
.
get
(
blockTrackNumber
);
if
((
audioTrack
==
null
||
audioTrack
.
number
!=
blockTrackNumber
)
&&
(
videoTrack
==
null
||
videoTrack
.
number
!=
blockTrackNumber
))
{
// Ignore the block if we don't know about the track to which it belongs.
if
(
track
==
null
)
{
input
.
skipFully
(
contentSize
-
blockTrackNumberLength
);
input
.
skipFully
(
contentSize
-
blockTrackNumberLength
);
blockState
=
BLOCK_STATE_START
;
blockState
=
BLOCK_STATE_START
;
return
;
return
;
}
}
Track
track
=
(
audioTrack
!=
null
&&
blockTrackNumber
==
audioTrack
.
number
)
?
audioTrack
:
videoTrack
;
if
(
blockState
==
BLOCK_STATE_HEADER
)
{
if
(
blockState
==
BLOCK_STATE_HEADER
)
{
// Read the relative timecode (2 bytes) and flags (1 byte).
// Read the relative timecode (2 bytes) and flags (1 byte).
readScratch
(
input
,
3
);
readScratch
(
input
,
3
);
...
@@ -723,7 +713,7 @@ public final class WebmExtractor implements Extractor {
...
@@ -723,7 +713,7 @@ public final class WebmExtractor implements Extractor {
writeSampleData
(
input
,
track
,
blockLacingSampleSizes
[
blockLacingSampleIndex
]);
writeSampleData
(
input
,
track
,
blockLacingSampleSizes
[
blockLacingSampleIndex
]);
long
sampleTimeUs
=
this
.
blockTimeUs
long
sampleTimeUs
=
this
.
blockTimeUs
+
(
blockLacingSampleIndex
*
track
.
defaultSampleDurationNs
)
/
1000
;
+
(
blockLacingSampleIndex
*
track
.
defaultSampleDurationNs
)
/
1000
;
outputSampleMetadata
(
track
.
output
,
sampleTimeUs
);
outputSampleMetadata
(
track
,
sampleTimeUs
);
blockLacingSampleIndex
++;
blockLacingSampleIndex
++;
}
}
blockState
=
BLOCK_STATE_START
;
blockState
=
BLOCK_STATE_START
;
...
@@ -739,8 +729,8 @@ public final class WebmExtractor implements Extractor {
...
@@ -739,8 +729,8 @@ public final class WebmExtractor implements Extractor {
}
}
}
}
private
void
outputSampleMetadata
(
Track
Output
trackOutput
,
long
timeUs
)
{
private
void
outputSampleMetadata
(
Track
track
,
long
timeUs
)
{
track
O
utput
.
sampleMetadata
(
timeUs
,
blockFlags
,
sampleBytesWritten
,
0
,
blockEncryptionKeyId
);
track
.
o
utput
.
sampleMetadata
(
timeUs
,
blockFlags
,
sampleBytesWritten
,
0
,
blockEncryptionKeyId
);
sampleRead
=
true
;
sampleRead
=
true
;
resetSample
();
resetSample
();
}
}
...
...
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