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
5d782054
authored
Dec 05, 2014
by
ojw28
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #189 from google/dev
dev -> dev-hls
parents
3d775c16
c8e5988e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
library/src/main/java/com/google/android/exoplayer/parser/mp4/FragmentedMp4Extractor.java
library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java
library/src/main/java/com/google/android/exoplayer/util/Util.java
library/src/main/java/com/google/android/exoplayer/parser/mp4/FragmentedMp4Extractor.java
View file @
5d782054
...
@@ -462,7 +462,8 @@ public final class FragmentedMp4Extractor implements Extractor {
...
@@ -462,7 +462,8 @@ public final class FragmentedMp4Extractor implements Extractor {
/**
/**
* Parses a tkhd atom (defined in 14496-12).
* Parses a tkhd atom (defined in 14496-12).
*
*
* @return A {@link Pair} consisting of the track id and duration.
* @return A {@link Pair} consisting of the track id and duration (in the timescale indicated in
* the movie header box). The duration is set to -1 if the duration is unspecified.
*/
*/
private
static
Pair
<
Integer
,
Long
>
parseTkhd
(
ParsableByteArray
tkhd
)
{
private
static
Pair
<
Integer
,
Long
>
parseTkhd
(
ParsableByteArray
tkhd
)
{
tkhd
.
setPosition
(
ATOM_HEADER_SIZE
);
tkhd
.
setPosition
(
ATOM_HEADER_SIZE
);
...
@@ -473,7 +474,23 @@ public final class FragmentedMp4Extractor implements Extractor {
...
@@ -473,7 +474,23 @@ public final class FragmentedMp4Extractor implements Extractor {
int
trackId
=
tkhd
.
readInt
();
int
trackId
=
tkhd
.
readInt
();
tkhd
.
skip
(
4
);
tkhd
.
skip
(
4
);
long
duration
=
version
==
0
?
tkhd
.
readUnsignedInt
()
:
tkhd
.
readUnsignedLongToLong
();
boolean
durationUnknown
=
true
;
int
durationPosition
=
tkhd
.
getPosition
();
int
durationByteCount
=
version
==
0
?
4
:
8
;
for
(
int
i
=
0
;
i
<
durationByteCount
;
i
++)
{
if
(
tkhd
.
data
[
durationPosition
+
i
]
!=
-
1
)
{
durationUnknown
=
false
;
break
;
}
}
long
duration
;
if
(
durationUnknown
)
{
tkhd
.
skip
(
durationByteCount
);
duration
=
-
1
;
}
else
{
duration
=
version
==
0
?
tkhd
.
readUnsignedInt
()
:
tkhd
.
readUnsignedLongToLong
();
}
return
Pair
.
create
(
trackId
,
duration
);
return
Pair
.
create
(
trackId
,
duration
);
}
}
...
...
library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java
View file @
5d782054
...
@@ -376,7 +376,7 @@ public class HttpDataSource implements DataSource {
...
@@ -376,7 +376,7 @@ public class HttpDataSource implements DataSource {
connection
.
setReadTimeout
(
readTimeoutMillis
);
connection
.
setReadTimeout
(
readTimeoutMillis
);
connection
.
setDoOutput
(
false
);
connection
.
setDoOutput
(
false
);
synchronized
(
requestProperties
)
{
synchronized
(
requestProperties
)
{
for
(
Hash
Map
.
Entry
<
String
,
String
>
property
:
requestProperties
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
property
:
requestProperties
.
entrySet
())
{
connection
.
setRequestProperty
(
property
.
getKey
(),
property
.
getValue
());
connection
.
setRequestProperty
(
property
.
getKey
(),
property
.
getValue
());
}
}
}
}
...
...
library/src/main/java/com/google/android/exoplayer/util/Util.java
View file @
5d782054
...
@@ -55,7 +55,7 @@ public final class Util {
...
@@ -55,7 +55,7 @@ public final class Util {
+
"([Zz]|((\\+|\\-)(\\d\\d):(\\d\\d)))?"
);
+
"([Zz]|((\\+|\\-)(\\d\\d):(\\d\\d)))?"
);
private
static
final
Pattern
XS_DURATION_PATTERN
=
private
static
final
Pattern
XS_DURATION_PATTERN
=
Pattern
.
compile
(
"^P(([0-9]*)Y)?(([0-9]*)M)?(([0-9]*)D)?"
Pattern
.
compile
(
"^
(-)?
P(([0-9]*)Y)?(([0-9]*)M)?(([0-9]*)D)?"
+
"(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"
);
+
"(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"
);
private
Util
()
{}
private
Util
()
{}
...
@@ -275,21 +275,23 @@ public final class Util {
...
@@ -275,21 +275,23 @@ public final class Util {
public
static
long
parseXsDuration
(
String
value
)
{
public
static
long
parseXsDuration
(
String
value
)
{
Matcher
matcher
=
XS_DURATION_PATTERN
.
matcher
(
value
);
Matcher
matcher
=
XS_DURATION_PATTERN
.
matcher
(
value
);
if
(
matcher
.
matches
())
{
if
(
matcher
.
matches
())
{
boolean
negated
=
!
TextUtils
.
isEmpty
(
matcher
.
group
(
1
));
// Durations containing years and months aren't completely defined. We assume there are
// Durations containing years and months aren't completely defined. We assume there are
// 30.4368 days in a month, and 365.242 days in a year.
// 30.4368 days in a month, and 365.242 days in a year.
String
years
=
matcher
.
group
(
2
);
String
years
=
matcher
.
group
(
3
);
double
durationSeconds
=
(
years
!=
null
)
?
Double
.
parseDouble
(
years
)
*
31556908
:
0
;
double
durationSeconds
=
(
years
!=
null
)
?
Double
.
parseDouble
(
years
)
*
31556908
:
0
;
String
months
=
matcher
.
group
(
4
);
String
months
=
matcher
.
group
(
5
);
durationSeconds
+=
(
months
!=
null
)
?
Double
.
parseDouble
(
months
)
*
2629739
:
0
;
durationSeconds
+=
(
months
!=
null
)
?
Double
.
parseDouble
(
months
)
*
2629739
:
0
;
String
days
=
matcher
.
group
(
6
);
String
days
=
matcher
.
group
(
7
);
durationSeconds
+=
(
days
!=
null
)
?
Double
.
parseDouble
(
days
)
*
86400
:
0
;
durationSeconds
+=
(
days
!=
null
)
?
Double
.
parseDouble
(
days
)
*
86400
:
0
;
String
hours
=
matcher
.
group
(
9
);
String
hours
=
matcher
.
group
(
10
);
durationSeconds
+=
(
hours
!=
null
)
?
Double
.
parseDouble
(
hours
)
*
3600
:
0
;
durationSeconds
+=
(
hours
!=
null
)
?
Double
.
parseDouble
(
hours
)
*
3600
:
0
;
String
minutes
=
matcher
.
group
(
1
1
);
String
minutes
=
matcher
.
group
(
1
2
);
durationSeconds
+=
(
minutes
!=
null
)
?
Double
.
parseDouble
(
minutes
)
*
60
:
0
;
durationSeconds
+=
(
minutes
!=
null
)
?
Double
.
parseDouble
(
minutes
)
*
60
:
0
;
String
seconds
=
matcher
.
group
(
1
3
);
String
seconds
=
matcher
.
group
(
1
4
);
durationSeconds
+=
(
seconds
!=
null
)
?
Double
.
parseDouble
(
seconds
)
:
0
;
durationSeconds
+=
(
seconds
!=
null
)
?
Double
.
parseDouble
(
seconds
)
:
0
;
return
(
long
)
(
durationSeconds
*
1000
);
long
durationMillis
=
(
long
)
(
durationSeconds
*
1000
);
return
negated
?
-
durationMillis
:
durationMillis
;
}
else
{
}
else
{
return
(
long
)
(
Double
.
parseDouble
(
value
)
*
3600
*
1000
);
return
(
long
)
(
Double
.
parseDouble
(
value
)
*
3600
*
1000
);
}
}
...
...
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