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
525b3097
authored
Sep 19, 2014
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
SmoothStreaming - Parse last chunk duration.
parent
f52742b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifest.java
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifestParser.java
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifest.java
View file @
525b3097
...
...
@@ -173,11 +173,12 @@ public class SmoothStreamingManifest {
private
final
String
chunkTemplate
;
private
final
List
<
Long
>
chunkStartTimes
;
private
final
long
lastChunkDuration
;
public
StreamElement
(
Uri
baseUri
,
String
chunkTemplate
,
int
type
,
String
subType
,
long
timescale
,
String
name
,
int
qualityLevels
,
int
maxWidth
,
int
maxHeight
,
int
displayWidth
,
int
displayHeight
,
String
language
,
TrackElement
[]
tracks
,
List
<
Long
>
chunkStartTimes
)
{
List
<
Long
>
chunkStartTimes
,
long
lastChunkDuration
)
{
this
.
baseUri
=
baseUri
;
this
.
chunkTemplate
=
chunkTemplate
;
this
.
type
=
type
;
...
...
@@ -193,6 +194,7 @@ public class SmoothStreamingManifest {
this
.
tracks
=
tracks
;
this
.
chunkCount
=
chunkStartTimes
.
size
();
this
.
chunkStartTimes
=
chunkStartTimes
;
this
.
lastChunkDuration
=
lastChunkDuration
;
}
/**
...
...
@@ -216,6 +218,18 @@ public class SmoothStreamingManifest {
}
/**
* Gets the duration of the specified chunk.
*
* @param chunkIndex The index of the chunk.
* @return The duration of the chunk, in microseconds.
*/
public
long
getChunkDurationUs
(
int
chunkIndex
)
{
long
chunkDuration
=
(
chunkIndex
==
chunkCount
-
1
)
?
lastChunkDuration
:
chunkStartTimes
.
get
(
chunkIndex
+
1
)
-
chunkStartTimes
.
get
(
chunkIndex
);
return
chunkDuration
/
timescale
;
}
/**
* Builds a uri for requesting the specified chunk of the specified track.
*
* @param track The index of the track for which to build the URL.
...
...
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifestParser.java
View file @
525b3097
...
...
@@ -467,7 +467,7 @@ public class SmoothStreamingManifestParser implements ManifestParser<SmoothStrea
private
String
language
;
private
ArrayList
<
Long
>
startTimes
;
private
long
previous
ChunkDuration
;
private
long
last
ChunkDuration
;
public
StreamElementParser
(
ElementParser
parent
,
Uri
baseUri
)
{
super
(
parent
,
baseUri
,
TAG
);
...
...
@@ -496,16 +496,16 @@ public class SmoothStreamingManifestParser implements ManifestParser<SmoothStrea
if
(
chunkIndex
==
0
)
{
// Assume the track starts at t = 0.
startTime
=
0
;
}
else
if
(
previous
ChunkDuration
!=
-
1L
)
{
}
else
if
(
last
ChunkDuration
!=
-
1L
)
{
// Infer the start time from the previous chunk's start time and duration.
startTime
=
startTimes
.
get
(
chunkIndex
-
1
)
+
previous
ChunkDuration
;
startTime
=
startTimes
.
get
(
chunkIndex
-
1
)
+
last
ChunkDuration
;
}
else
{
// We don't have the start time, and we're unable to infer it.
throw
new
ParserException
(
"Unable to infer start time"
);
}
}
startTimes
.
add
(
startTime
);
previous
ChunkDuration
=
parseLong
(
parser
,
KEY_FRAGMENT_DURATION
,
-
1L
);
last
ChunkDuration
=
parseLong
(
parser
,
KEY_FRAGMENT_DURATION
,
-
1L
);
chunkIndex
++;
}
...
...
@@ -560,7 +560,8 @@ public class SmoothStreamingManifestParser implements ManifestParser<SmoothStrea
TrackElement
[]
trackElements
=
new
TrackElement
[
tracks
.
size
()];
tracks
.
toArray
(
trackElements
);
return
new
StreamElement
(
baseUri
,
url
,
type
,
subType
,
timescale
,
name
,
qualityLevels
,
maxWidth
,
maxHeight
,
displayWidth
,
displayHeight
,
language
,
trackElements
,
startTimes
);
maxWidth
,
maxHeight
,
displayWidth
,
displayHeight
,
language
,
trackElements
,
startTimes
,
lastChunkDuration
);
}
}
...
...
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