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
0a888a0d
authored
Dec 08, 2014
by
ojw28
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #193 from google/dev-hls-spspps
Add SPS/PPS to the media format.
parents
5d782054
7ca1de22
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
library/src/main/java/com/google/android/exoplayer/hls/TsExtractor.java
library/src/main/java/com/google/android/exoplayer/hls/TsExtractor.java
View file @
0a888a0d
...
@@ -712,8 +712,9 @@ public final class TsExtractor {
...
@@ -712,8 +712,9 @@ public final class TsExtractor {
private
class
H264Reader
extends
PesPayloadReader
{
private
class
H264Reader
extends
PesPayloadReader
{
private
static
final
int
NAL_UNIT_TYPE_IDR
=
5
;
private
static
final
int
NAL_UNIT_TYPE_IDR
=
5
;
private
static
final
int
NAL_UNIT_TYPE_AUD
=
9
;
private
static
final
int
NAL_UNIT_TYPE_SPS
=
7
;
private
static
final
int
NAL_UNIT_TYPE_SPS
=
7
;
private
static
final
int
NAL_UNIT_TYPE_PPS
=
8
;
private
static
final
int
NAL_UNIT_TYPE_AUD
=
9
;
public
final
SeiReader
seiReader
;
public
final
SeiReader
seiReader
;
...
@@ -778,15 +779,26 @@ public final class TsExtractor {
...
@@ -778,15 +779,26 @@ public final class TsExtractor {
private
void
parseMediaFormat
(
Sample
sample
)
{
private
void
parseMediaFormat
(
Sample
sample
)
{
BitArray
bitArray
=
new
BitArray
(
sample
.
data
,
sample
.
size
);
BitArray
bitArray
=
new
BitArray
(
sample
.
data
,
sample
.
size
);
// Locate the SPS
unit
.
// Locate the SPS
and PPS units
.
int
spsOffset
=
bitArray
.
findNextNalUnit
(
NAL_UNIT_TYPE_SPS
,
0
);
int
spsOffset
=
bitArray
.
findNextNalUnit
(
NAL_UNIT_TYPE_SPS
,
0
);
if
(
spsOffset
==
bitArray
.
bytesLeft
())
{
int
ppsOffset
=
bitArray
.
findNextNalUnit
(
NAL_UNIT_TYPE_PPS
,
0
);
if
(
spsOffset
==
bitArray
.
bytesLeft
()
||
ppsOffset
==
bitArray
.
bytesLeft
())
{
return
;
return
;
}
}
int
nextNalOffset
=
bitArray
.
findNextNalUnit
(-
1
,
spsOffset
+
3
);
int
spsLength
=
bitArray
.
findNextNalUnit
(-
1
,
spsOffset
+
3
)
-
spsOffset
;
int
ppsLength
=
bitArray
.
findNextNalUnit
(-
1
,
ppsOffset
+
3
)
-
ppsOffset
;
byte
[]
spsData
=
new
byte
[
spsLength
];
byte
[]
ppsData
=
new
byte
[
ppsLength
];
System
.
arraycopy
(
bitArray
.
getData
(),
spsOffset
,
spsData
,
0
,
spsLength
);
System
.
arraycopy
(
bitArray
.
getData
(),
ppsOffset
,
ppsData
,
0
,
ppsLength
);
List
<
byte
[]>
initializationData
=
new
ArrayList
<
byte
[]>();
initializationData
.
add
(
spsData
);
initializationData
.
add
(
ppsData
);
// Unescape the SPS unit.
// Unescape the SPS unit.
byte
[]
unescapedSps
=
unescape
Stream
(
bitArray
.
getData
(),
spsOffset
,
nextNalOffset
);
byte
[]
unescapedSps
=
unescape
Data
(
spsData
,
0
,
spsLength
);
bitArray
.
reset
(
unescapedSps
,
unescapedSps
.
length
);
bitArray
.
reset
(
unescapedSps
,
unescapedSps
.
length
);
// Parse the SPS unit
// Parse the SPS unit
...
@@ -881,7 +893,7 @@ public final class TsExtractor {
...
@@ -881,7 +893,7 @@ public final class TsExtractor {
// Set the format.
// Set the format.
setMediaFormat
(
MediaFormat
.
createVideoFormat
(
MimeTypes
.
VIDEO_H264
,
MediaFormat
.
NO_VALUE
,
setMediaFormat
(
MediaFormat
.
createVideoFormat
(
MimeTypes
.
VIDEO_H264
,
MediaFormat
.
NO_VALUE
,
frameWidth
,
frameHeight
,
null
));
frameWidth
,
frameHeight
,
initializationData
));
}
}
private
void
skipScalingList
(
BitArray
bitArray
,
int
size
)
{
private
void
skipScalingList
(
BitArray
bitArray
,
int
size
)
{
...
@@ -901,7 +913,7 @@ public final class TsExtractor {
...
@@ -901,7 +913,7 @@ public final class TsExtractor {
* <p>
* <p>
* See ISO/IEC 14496-10:2005(E) page 36 for more information.
* See ISO/IEC 14496-10:2005(E) page 36 for more information.
*/
*/
private
byte
[]
unescape
Stream
(
byte
[]
data
,
int
offset
,
int
limit
)
{
private
byte
[]
unescape
Data
(
byte
[]
data
,
int
offset
,
int
limit
)
{
int
position
=
offset
;
int
position
=
offset
;
List
<
Integer
>
escapePositions
=
new
ArrayList
<
Integer
>();
List
<
Integer
>
escapePositions
=
new
ArrayList
<
Integer
>();
while
(
position
<
limit
)
{
while
(
position
<
limit
)
{
...
...
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