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
dc644ae8
authored
Dec 03, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make single MICROS_PER_SECOND constant + use it everywhere.
parent
656fc0b0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
22 deletions
library/src/main/java/com/google/android/exoplayer/C.java
library/src/main/java/com/google/android/exoplayer/audio/AudioTrack.java
library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
library/src/main/java/com/google/android/exoplayer/parser/mp4/FragmentedMp4Extractor.java
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifest.java
library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
library/src/main/java/com/google/android/exoplayer/C.java
View file @
dc644ae8
...
...
@@ -23,7 +23,12 @@ public final class C {
/**
* Represents an unknown microsecond time or duration.
*/
public
static
final
long
UNKNOWN_TIME_US
=
-
1
;
public
static
final
long
UNKNOWN_TIME_US
=
-
1L
;
/**
* The number of microseconds in one second.
*/
public
static
final
long
MICROS_PER_SECOND
=
1000000L
;
/**
* Represents an unbounded length of data.
...
...
library/src/main/java/com/google/android/exoplayer/audio/AudioTrack.java
View file @
dc644ae8
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer
.
audio
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
...
...
@@ -80,22 +81,20 @@ public final class AudioTrack {
private
static
final
String
TAG
=
"AudioTrack"
;
private
static
final
long
MICROS_PER_SECOND
=
1000000L
;
/**
* AudioTrack timestamps are deemed spurious if they are offset from the system clock by more
* than this amount.
*
* <p>This is a fail safe that should not be required on correctly functioning devices.
*/
private
static
final
long
MAX_AUDIO_TIMESTAMP_OFFSET_US
=
10
*
MICROS_PER_SECOND
;
private
static
final
long
MAX_AUDIO_TIMESTAMP_OFFSET_US
=
10
*
C
.
MICROS_PER_SECOND
;
/**
* AudioTrack latencies are deemed impossibly large if they are greater than this amount.
*
* <p>This is a fail safe that should not be required on correctly functioning devices.
*/
private
static
final
long
MAX_LATENCY_US
=
10
*
MICROS_PER_SECOND
;
private
static
final
long
MAX_LATENCY_US
=
10
*
C
.
MICROS_PER_SECOND
;
private
static
final
int
START_NOT_SET
=
0
;
private
static
final
int
START_IN_SYNC
=
1
;
...
...
@@ -624,11 +623,11 @@ public final class AudioTrack {
}
private
long
framesToDurationUs
(
long
frameCount
)
{
return
(
frameCount
*
MICROS_PER_SECOND
)
/
sampleRate
;
return
(
frameCount
*
C
.
MICROS_PER_SECOND
)
/
sampleRate
;
}
private
long
durationUsToFrames
(
long
durationUs
)
{
return
(
durationUs
*
sampleRate
)
/
MICROS_PER_SECOND
;
return
(
durationUs
*
sampleRate
)
/
C
.
MICROS_PER_SECOND
;
}
private
void
resetSyncParams
()
{
...
...
library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
View file @
dc644ae8
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer
.
dash
.
mpd
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.util.Util
;
import
android.net.Uri
;
...
...
@@ -141,11 +142,12 @@ public abstract class SegmentBase {
public
final
long
getSegmentDurationUs
(
int
sequenceNumber
)
{
if
(
segmentTimeline
!=
null
)
{
return
(
segmentTimeline
.
get
(
sequenceNumber
-
startNumber
).
duration
*
1000000
)
/
timescale
;
long
duration
=
segmentTimeline
.
get
(
sequenceNumber
-
startNumber
).
duration
;
return
(
duration
*
C
.
MICROS_PER_SECOND
)
/
timescale
;
}
else
{
return
sequenceNumber
==
getLastSegmentNum
()
?
(
periodDurationMs
*
1000
)
-
getSegmentTimeUs
(
sequenceNumber
)
:
((
duration
*
1000000L
)
/
timescale
);
?
(
(
periodDurationMs
*
1000
)
-
getSegmentTimeUs
(
sequenceNumber
)
)
:
((
duration
*
C
.
MICROS_PER_SECOND
)
/
timescale
);
}
}
...
...
@@ -157,7 +159,7 @@ public abstract class SegmentBase {
}
else
{
unscaledSegmentTime
=
(
sequenceNumber
-
startNumber
)
*
duration
;
}
return
Util
.
scaleLargeTimestamp
(
unscaledSegmentTime
,
1000000
,
timescale
);
return
Util
.
scaleLargeTimestamp
(
unscaledSegmentTime
,
C
.
MICROS_PER_SECOND
,
timescale
);
}
public
abstract
RangedUri
getSegmentUrl
(
Representation
representation
,
int
index
);
...
...
library/src/main/java/com/google/android/exoplayer/parser/mp4/FragmentedMp4Extractor.java
View file @
dc644ae8
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer
.
parser
.
mp4
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.ParserException
;
import
com.google.android.exoplayer.SampleHolder
;
...
...
@@ -26,6 +27,7 @@ import com.google.android.exoplayer.upstream.NonBlockingInputStream;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.CodecSpecificDataUtil
;
import
com.google.android.exoplayer.util.MimeTypes
;
import
com.google.android.exoplayer.util.Util
;
import
android.annotation.SuppressLint
;
import
android.media.MediaCodec
;
...
...
@@ -1053,6 +1055,7 @@ public final class FragmentedMp4Extractor implements Extractor {
long
offset
=
firstOffset
;
long
time
=
earliestPresentationTime
;
long
timeUs
=
Util
.
scaleLargeTimestamp
(
time
,
C
.
MICROS_PER_SECOND
,
timescale
);
for
(
int
i
=
0
;
i
<
referenceCount
;
i
++)
{
int
firstInt
=
atom
.
readInt
();
...
...
@@ -1067,10 +1070,10 @@ public final class FragmentedMp4Extractor implements Extractor {
// Calculate time and duration values such that any rounding errors are consistent. i.e. That
// timesUs[i] + durationsUs[i] == timesUs[i + 1].
timesUs
[
i
]
=
(
time
*
1000000L
)
/
timescale
;
long
nextTimeUs
=
((
time
+
referenceDuration
)
*
1000000L
)
/
timescale
;
durationsUs
[
i
]
=
nextTimeUs
-
timesUs
[
i
];
timesUs
[
i
]
=
timeUs
;
time
+=
referenceDuration
;
timeUs
=
Util
.
scaleLargeTimestamp
(
time
,
C
.
MICROS_PER_SECOND
,
timescale
);
durationsUs
[
i
]
=
timeUs
-
timesUs
[
i
];
atom
.
skip
(
4
);
offset
+=
sizes
[
i
];
...
...
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifest.java
View file @
dc644ae8
...
...
@@ -32,8 +32,6 @@ import java.util.UUID;
*/
public
class
SmoothStreamingManifest
{
private
static
final
long
MICROS_PER_SECOND
=
1000000L
;
/**
* The client manifest major version.
*/
...
...
@@ -102,9 +100,9 @@ public class SmoothStreamingManifest {
this
.
protectionElement
=
protectionElement
;
this
.
streamElements
=
streamElements
;
dvrWindowLengthUs
=
dvrWindowLength
==
0
?
C
.
UNKNOWN_TIME_US
:
Util
.
scaleLargeTimestamp
(
dvrWindowLength
,
MICROS_PER_SECOND
,
timescale
);
:
Util
.
scaleLargeTimestamp
(
dvrWindowLength
,
C
.
MICROS_PER_SECOND
,
timescale
);
durationUs
=
duration
==
0
?
C
.
UNKNOWN_TIME_US
:
Util
.
scaleLargeTimestamp
(
duration
,
MICROS_PER_SECOND
,
timescale
);
:
Util
.
scaleLargeTimestamp
(
duration
,
C
.
MICROS_PER_SECOND
,
timescale
);
}
/**
...
...
@@ -226,9 +224,9 @@ public class SmoothStreamingManifest {
this
.
chunkCount
=
chunkStartTimes
.
size
();
this
.
chunkStartTimes
=
chunkStartTimes
;
lastChunkDurationUs
=
Util
.
scaleLargeTimestamp
(
lastChunkDuration
,
MICROS_PER_SECOND
,
timescale
);
Util
.
scaleLargeTimestamp
(
lastChunkDuration
,
C
.
MICROS_PER_SECOND
,
timescale
);
chunkStartTimesUs
=
Util
.
scaleLargeTimestamps
(
chunkStartTimes
,
MICROS_PER_SECOND
,
timescale
);
Util
.
scaleLargeTimestamps
(
chunkStartTimes
,
C
.
MICROS_PER_SECOND
,
timescale
);
}
/**
...
...
library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
View file @
dc644ae8
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer
.
text
.
ttml
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.ParserException
;
import
com.google.android.exoplayer.text.Subtitle
;
import
com.google.android.exoplayer.text.SubtitleParser
;
...
...
@@ -254,7 +255,7 @@ public class TtmlParser implements SubtitleParser {
String
subframes
=
matcher
.
group
(
6
);
durationSeconds
+=
(
subframes
!=
null
)
?
((
double
)
Long
.
parseLong
(
subframes
))
/
subframeRate
/
frameRate
:
0
;
return
(
long
)
(
durationSeconds
*
1000000
);
return
(
long
)
(
durationSeconds
*
C
.
MICROS_PER_SECOND
);
}
matcher
=
OFFSET_TIME
.
matcher
(
time
);
if
(
matcher
.
matches
())
{
...
...
@@ -274,7 +275,7 @@ public class TtmlParser implements SubtitleParser {
}
else
if
(
unit
.
equals
(
"t"
))
{
offsetSeconds
/=
tickRate
;
}
return
(
long
)
(
offsetSeconds
*
1000000
);
return
(
long
)
(
offsetSeconds
*
C
.
MICROS_PER_SECOND
);
}
throw
new
ParserException
(
"Malformed time expression: "
+
time
);
}
...
...
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