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
bc99435b
authored
Feb 13, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add C.SAMPLE_FLAG_SYNC and removed InlinedApi suppression in a few places.
parent
5f64a1fd
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
24 deletions
library/src/main/java/com/google/android/exoplayer/C.java
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/chunk/parser/mp4/FragmentedMp4Extractor.java
library/src/main/java/com/google/android/exoplayer/chunk/parser/webm/WebmExtractor.java
library/src/main/java/com/google/android/exoplayer/hls/parser/SampleQueue.java
library/src/main/java/com/google/android/exoplayer/mp4/CommonMp4AtomParsers.java
library/src/main/java/com/google/android/exoplayer/mp4/Mp4TrackSampleTable.java
library/src/main/java/com/google/android/exoplayer/C.java
View file @
bc99435b
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer
;
package
com
.
google
.
android
.
exoplayer
;
import
android.media.MediaExtractor
;
/**
/**
* Defines constants that are generally useful throughout the library.
* Defines constants that are generally useful throughout the library.
*/
*/
...
@@ -40,6 +42,12 @@ public final class C {
...
@@ -40,6 +42,12 @@ public final class C {
*/
*/
public
static
final
String
UTF8_NAME
=
"UTF-8"
;
public
static
final
String
UTF8_NAME
=
"UTF-8"
;
/**
* Sample flag that indicates the sample is a synchronization sample.
*/
@SuppressWarnings
(
"InlinedApi"
)
public
static
final
int
SAMPLE_FLAG_SYNC
=
MediaExtractor
.
SAMPLE_FLAG_SYNC
;
private
C
()
{}
private
C
()
{}
}
}
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
View file @
bc99435b
...
@@ -572,7 +572,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
...
@@ -572,7 +572,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
if
(
waitingForFirstSyncFrame
)
{
if
(
waitingForFirstSyncFrame
)
{
// TODO: Find out if it's possible to supply samples prior to the first sync
// TODO: Find out if it's possible to supply samples prior to the first sync
// frame for HE-AAC.
// frame for HE-AAC.
if
((
sampleHolder
.
flags
&
MediaExtractor
.
SAMPLE_FLAG_SYNC
)
==
0
)
{
if
((
sampleHolder
.
flags
&
C
.
SAMPLE_FLAG_SYNC
)
==
0
)
{
sampleHolder
.
data
.
clear
();
sampleHolder
.
data
.
clear
();
if
(
codecReconfigurationState
==
RECONFIGURATION_STATE_QUEUE_PENDING
)
{
if
(
codecReconfigurationState
==
RECONFIGURATION_STATE_QUEUE_PENDING
)
{
// The buffer we just cleared contained reconfiguration data. We need to re-write this
// The buffer we just cleared contained reconfiguration data. We need to re-write this
...
...
library/src/main/java/com/google/android/exoplayer/chunk/parser/mp4/FragmentedMp4Extractor.java
View file @
bc99435b
...
@@ -762,7 +762,6 @@ public final class FragmentedMp4Extractor implements Extractor {
...
@@ -762,7 +762,6 @@ public final class FragmentedMp4Extractor implements Extractor {
return
0
;
return
0
;
}
}
@SuppressLint
(
"InlinedApi"
)
private
int
readSample
(
NonBlockingInputStream
inputStream
,
int
sampleSize
,
SampleHolder
out
)
{
private
int
readSample
(
NonBlockingInputStream
inputStream
,
int
sampleSize
,
SampleHolder
out
)
{
if
(
out
==
null
)
{
if
(
out
==
null
)
{
return
RESULT_NEED_SAMPLE_HOLDER
;
return
RESULT_NEED_SAMPLE_HOLDER
;
...
@@ -770,7 +769,7 @@ public final class FragmentedMp4Extractor implements Extractor {
...
@@ -770,7 +769,7 @@ public final class FragmentedMp4Extractor implements Extractor {
out
.
timeUs
=
fragmentRun
.
getSamplePresentationTime
(
sampleIndex
)
*
1000L
;
out
.
timeUs
=
fragmentRun
.
getSamplePresentationTime
(
sampleIndex
)
*
1000L
;
out
.
flags
=
0
;
out
.
flags
=
0
;
if
(
fragmentRun
.
sampleIsSyncFrameTable
[
sampleIndex
])
{
if
(
fragmentRun
.
sampleIsSyncFrameTable
[
sampleIndex
])
{
out
.
flags
|=
MediaExtractor
.
SAMPLE_FLAG_SYNC
;
out
.
flags
|=
C
.
SAMPLE_FLAG_SYNC
;
lastSyncSampleIndex
=
sampleIndex
;
lastSyncSampleIndex
=
sampleIndex
;
}
}
if
(
out
.
data
==
null
||
out
.
data
.
capacity
()
<
sampleSize
)
{
if
(
out
.
data
==
null
||
out
.
data
.
capacity
()
<
sampleSize
)
{
...
...
library/src/main/java/com/google/android/exoplayer/chunk/parser/webm/WebmExtractor.java
View file @
bc99435b
...
@@ -25,9 +25,6 @@ import com.google.android.exoplayer.upstream.NonBlockingInputStream;
...
@@ -25,9 +25,6 @@ import com.google.android.exoplayer.upstream.NonBlockingInputStream;
import
com.google.android.exoplayer.util.LongArray
;
import
com.google.android.exoplayer.util.LongArray
;
import
com.google.android.exoplayer.util.MimeTypes
;
import
com.google.android.exoplayer.util.MimeTypes
;
import
android.annotation.TargetApi
;
import
android.media.MediaExtractor
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -42,7 +39,6 @@ import java.util.concurrent.TimeUnit;
...
@@ -42,7 +39,6 @@ import java.util.concurrent.TimeUnit;
* Matroska is available <a href="http://www.matroska.org/technical/specs/index.html">here</a>.
* Matroska is available <a href="http://www.matroska.org/technical/specs/index.html">here</a>.
* More info about WebM is <a href="http://www.webmproject.org/code/specs/container/">here</a>.
* More info about WebM is <a href="http://www.webmproject.org/code/specs/container/">here</a>.
*/
*/
@TargetApi
(
16
)
public
final
class
WebmExtractor
implements
Extractor
{
public
final
class
WebmExtractor
implements
Extractor
{
private
static
final
String
DOC_TYPE_WEBM
=
"webm"
;
private
static
final
String
DOC_TYPE_WEBM
=
"webm"
;
...
@@ -412,7 +408,7 @@ public final class WebmExtractor implements Extractor {
...
@@ -412,7 +408,7 @@ public final class WebmExtractor implements Extractor {
case
LACING_NONE:
case
LACING_NONE:
long
elementEndOffsetBytes
=
elementOffsetBytes
+
headerSizeBytes
+
contentsSizeBytes
;
long
elementEndOffsetBytes
=
elementOffsetBytes
+
headerSizeBytes
+
contentsSizeBytes
;
simpleBlockTimecodeUs
=
clusterTimecodeUs
+
timecodeUs
;
simpleBlockTimecodeUs
=
clusterTimecodeUs
+
timecodeUs
;
sampleHolder
.
flags
=
keyframe
?
MediaExtractor
.
SAMPLE_FLAG_SYNC
:
0
;
sampleHolder
.
flags
=
keyframe
?
C
.
SAMPLE_FLAG_SYNC
:
0
;
sampleHolder
.
decodeOnly
=
invisible
;
sampleHolder
.
decodeOnly
=
invisible
;
sampleHolder
.
timeUs
=
clusterTimecodeUs
+
timecodeUs
;
sampleHolder
.
timeUs
=
clusterTimecodeUs
+
timecodeUs
;
sampleHolder
.
size
=
(
int
)
(
elementEndOffsetBytes
-
reader
.
getBytesRead
());
sampleHolder
.
size
=
(
int
)
(
elementEndOffsetBytes
-
reader
.
getBytesRead
());
...
...
library/src/main/java/com/google/android/exoplayer/hls/parser/SampleQueue.java
View file @
bc99435b
...
@@ -15,14 +15,12 @@
...
@@ -15,14 +15,12 @@
*/
*/
package
com
.
google
.
android
.
exoplayer
.
hls
.
parser
;
package
com
.
google
.
android
.
exoplayer
.
hls
.
parser
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.SampleHolder
;
import
com.google.android.exoplayer.SampleHolder
;
import
com.google.android.exoplayer.upstream.BufferPool
;
import
com.google.android.exoplayer.upstream.BufferPool
;
import
com.google.android.exoplayer.util.ParsableByteArray
;
import
com.google.android.exoplayer.util.ParsableByteArray
;
import
android.annotation.SuppressLint
;
import
android.media.MediaExtractor
;
/**
/**
* Wraps a {@link RollingSampleBuffer}, adding higher level functionality such as enforcing that
* Wraps a {@link RollingSampleBuffer}, adding higher level functionality such as enforcing that
* the first sample returned from the queue is a keyframe, allowing splicing to another queue, and
* the first sample returned from the queue is a keyframe, allowing splicing to another queue, and
...
@@ -117,7 +115,6 @@ import android.media.MediaExtractor;
...
@@ -117,7 +115,6 @@ import android.media.MediaExtractor;
* @param nextQueue The queue being spliced to.
* @param nextQueue The queue being spliced to.
* @return Whether the splice was configured successfully.
* @return Whether the splice was configured successfully.
*/
*/
@SuppressLint
(
"InlinedApi"
)
public
boolean
configureSpliceTo
(
SampleQueue
nextQueue
)
{
public
boolean
configureSpliceTo
(
SampleQueue
nextQueue
)
{
if
(
spliceOutTimeUs
!=
Long
.
MIN_VALUE
)
{
if
(
spliceOutTimeUs
!=
Long
.
MIN_VALUE
)
{
// We've already configured the splice.
// We've already configured the splice.
...
@@ -132,7 +129,7 @@ import android.media.MediaExtractor;
...
@@ -132,7 +129,7 @@ import android.media.MediaExtractor;
RollingSampleBuffer
nextRollingBuffer
=
nextQueue
.
rollingBuffer
;
RollingSampleBuffer
nextRollingBuffer
=
nextQueue
.
rollingBuffer
;
while
(
nextRollingBuffer
.
peekSample
(
sampleInfoHolder
)
while
(
nextRollingBuffer
.
peekSample
(
sampleInfoHolder
)
&&
(
sampleInfoHolder
.
timeUs
<
firstPossibleSpliceTime
&&
(
sampleInfoHolder
.
timeUs
<
firstPossibleSpliceTime
||
(
sampleInfoHolder
.
flags
&
MediaExtractor
.
SAMPLE_FLAG_SYNC
)
==
0
))
{
||
(
sampleInfoHolder
.
flags
&
C
.
SAMPLE_FLAG_SYNC
)
==
0
))
{
// Discard samples from the next queue for as long as they are before the earliest possible
// Discard samples from the next queue for as long as they are before the earliest possible
// splice time, or not keyframes.
// splice time, or not keyframes.
nextRollingBuffer
.
skipSample
();
nextRollingBuffer
.
skipSample
();
...
@@ -152,11 +149,10 @@ import android.media.MediaExtractor;
...
@@ -152,11 +149,10 @@ import android.media.MediaExtractor;
* @boolean True if an eligible sample was found. False otherwise, in which case the underlying
* @boolean True if an eligible sample was found. False otherwise, in which case the underlying
* buffer has been emptied.
* buffer has been emptied.
*/
*/
@SuppressLint
(
"InlinedApi"
)
private
boolean
advanceToEligibleSample
()
{
private
boolean
advanceToEligibleSample
()
{
boolean
haveNext
=
rollingBuffer
.
peekSample
(
sampleInfoHolder
);
boolean
haveNext
=
rollingBuffer
.
peekSample
(
sampleInfoHolder
);
if
(
needKeyframe
)
{
if
(
needKeyframe
)
{
while
(
haveNext
&&
(
sampleInfoHolder
.
flags
&
MediaExtractor
.
SAMPLE_FLAG_SYNC
)
==
0
)
{
while
(
haveNext
&&
(
sampleInfoHolder
.
flags
&
C
.
SAMPLE_FLAG_SYNC
)
==
0
)
{
rollingBuffer
.
skipSample
();
rollingBuffer
.
skipSample
();
haveNext
=
rollingBuffer
.
peekSample
(
sampleInfoHolder
);
haveNext
=
rollingBuffer
.
peekSample
(
sampleInfoHolder
);
}
}
...
...
library/src/main/java/com/google/android/exoplayer/mp4/CommonMp4AtomParsers.java
View file @
bc99435b
...
@@ -24,8 +24,6 @@ import com.google.android.exoplayer.util.MimeTypes;
...
@@ -24,8 +24,6 @@ import com.google.android.exoplayer.util.MimeTypes;
import
com.google.android.exoplayer.util.ParsableByteArray
;
import
com.google.android.exoplayer.util.ParsableByteArray
;
import
com.google.android.exoplayer.util.Util
;
import
com.google.android.exoplayer.util.Util
;
import
android.annotation.SuppressLint
;
import
android.media.MediaExtractor
;
import
android.util.Pair
;
import
android.util.Pair
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -81,7 +79,6 @@ public final class CommonMp4AtomParsers {
...
@@ -81,7 +79,6 @@ public final class CommonMp4AtomParsers {
* @param stblAtom stbl (sample table) atom to parse.
* @param stblAtom stbl (sample table) atom to parse.
* @return Sample table described by the stbl atom.
* @return Sample table described by the stbl atom.
*/
*/
@SuppressLint
(
"InlinedApi"
)
public
static
Mp4TrackSampleTable
parseStbl
(
Track
track
,
Atom
.
ContainerAtom
stblAtom
)
{
public
static
Mp4TrackSampleTable
parseStbl
(
Track
track
,
Atom
.
ContainerAtom
stblAtom
)
{
// Array of sample sizes.
// Array of sample sizes.
ParsableByteArray
stsz
=
stblAtom
.
getLeafAtomOfType
(
Atom
.
TYPE_stsz
).
data
;
ParsableByteArray
stsz
=
stblAtom
.
getLeafAtomOfType
(
Atom
.
TYPE_stsz
).
data
;
...
@@ -174,9 +171,9 @@ public final class CommonMp4AtomParsers {
...
@@ -174,9 +171,9 @@ public final class CommonMp4AtomParsers {
timestamps
[
i
]
=
timestampTimeUnits
+
timestampOffset
;
timestamps
[
i
]
=
timestampTimeUnits
+
timestampOffset
;
// All samples are synchronization samples if the stss is not present.
// All samples are synchronization samples if the stss is not present.
flags
[
i
]
=
stss
==
null
?
MediaExtractor
.
SAMPLE_FLAG_SYNC
:
0
;
flags
[
i
]
=
stss
==
null
?
C
.
SAMPLE_FLAG_SYNC
:
0
;
if
(
i
==
nextSynchronizationSampleIndex
)
{
if
(
i
==
nextSynchronizationSampleIndex
)
{
flags
[
i
]
=
MediaExtractor
.
SAMPLE_FLAG_SYNC
;
flags
[
i
]
=
C
.
SAMPLE_FLAG_SYNC
;
remainingSynchronizationSamples
--;
remainingSynchronizationSamples
--;
if
(
remainingSynchronizationSamples
>
0
)
{
if
(
remainingSynchronizationSamples
>
0
)
{
nextSynchronizationSampleIndex
=
stss
.
readUnsignedIntToInt
()
-
1
;
nextSynchronizationSampleIndex
=
stss
.
readUnsignedIntToInt
()
-
1
;
...
...
library/src/main/java/com/google/android/exoplayer/mp4/Mp4TrackSampleTable.java
View file @
bc99435b
...
@@ -15,11 +15,10 @@
...
@@ -15,11 +15,10 @@
*/
*/
package
com
.
google
.
android
.
exoplayer
.
mp4
;
package
com
.
google
.
android
.
exoplayer
.
mp4
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
import
com.google.android.exoplayer.util.Util
;
import
android.media.MediaExtractor
;
/** Sample table for a track in an MP4 file. */
/** Sample table for a track in an MP4 file. */
public
final
class
Mp4TrackSampleTable
{
public
final
class
Mp4TrackSampleTable
{
...
@@ -59,7 +58,7 @@ public final class Mp4TrackSampleTable {
...
@@ -59,7 +58,7 @@ public final class Mp4TrackSampleTable {
public
int
getIndexOfEarlierOrEqualSynchronizationSample
(
long
timeUs
)
{
public
int
getIndexOfEarlierOrEqualSynchronizationSample
(
long
timeUs
)
{
int
startIndex
=
Util
.
binarySearchFloor
(
timestampsUs
,
timeUs
,
true
,
false
);
int
startIndex
=
Util
.
binarySearchFloor
(
timestampsUs
,
timeUs
,
true
,
false
);
for
(
int
i
=
startIndex
;
i
>=
0
;
i
--)
{
for
(
int
i
=
startIndex
;
i
>=
0
;
i
--)
{
if
(
timestampsUs
[
i
]
<=
timeUs
&&
(
flags
[
i
]
&
MediaExtractor
.
SAMPLE_FLAG_SYNC
)
!=
0
)
{
if
(
timestampsUs
[
i
]
<=
timeUs
&&
(
flags
[
i
]
&
C
.
SAMPLE_FLAG_SYNC
)
!=
0
)
{
return
i
;
return
i
;
}
}
}
}
...
@@ -77,7 +76,7 @@ public final class Mp4TrackSampleTable {
...
@@ -77,7 +76,7 @@ public final class Mp4TrackSampleTable {
public
int
getIndexOfLaterOrEqualSynchronizationSample
(
long
timeUs
)
{
public
int
getIndexOfLaterOrEqualSynchronizationSample
(
long
timeUs
)
{
int
startIndex
=
Util
.
binarySearchCeil
(
timestampsUs
,
timeUs
,
true
,
false
);
int
startIndex
=
Util
.
binarySearchCeil
(
timestampsUs
,
timeUs
,
true
,
false
);
for
(
int
i
=
startIndex
;
i
<
timestampsUs
.
length
;
i
++)
{
for
(
int
i
=
startIndex
;
i
<
timestampsUs
.
length
;
i
++)
{
if
(
timestampsUs
[
i
]
>=
timeUs
&&
(
flags
[
i
]
&
MediaExtractor
.
SAMPLE_FLAG_SYNC
)
!=
0
)
{
if
(
timestampsUs
[
i
]
>=
timeUs
&&
(
flags
[
i
]
&
C
.
SAMPLE_FLAG_SYNC
)
!=
0
)
{
return
i
;
return
i
;
}
}
}
}
...
...
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