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
bdc7633f
authored
Dec 08, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Cleanup in TsExtractor.
parent
84307eff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
24 deletions
library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
View file @
bdc7633f
...
...
@@ -235,12 +235,15 @@ public final class TsExtractor implements Extractor {
*/
private
class
PmtReader
extends
TsPayloadReader
{
private
final
ParsableByteArray
data
;
private
final
ParsableBitArray
pmtScratch
;
private
final
ParsableByteArray
sectionData
;
private
int
sectionLength
;
private
int
sectionBytesRead
;
public
PmtReader
()
{
data
=
new
ParsableByteArray
();
pmtScratch
=
new
ParsableBitArray
(
new
byte
[
5
]);
sectionData
=
new
ParsableByteArray
();
}
@Override
...
...
@@ -249,47 +252,47 @@ public final class TsExtractor implements Extractor {
}
@Override
public
void
consume
(
ParsableByteArray
data
Part
,
boolean
payloadUnitStartIndicator
,
public
void
consume
(
ParsableByteArray
data
,
boolean
payloadUnitStartIndicator
,
ExtractorOutput
output
)
{
if
(
payloadUnitStartIndicator
)
{
// Skip pointer.
int
pointerField
=
data
Part
.
readUnsignedByte
();
data
Part
.
skipBytes
(
pointerField
);
int
pointerField
=
data
.
readUnsignedByte
();
data
.
skipBytes
(
pointerField
);
// Note: see ISO/IEC 13818-1, section 2.4.4.8 for detailed information on the format of
// the header.
data
Part
.
readBytes
(
pmtScratch
,
3
);
pmtScratch
.
skipBits
(
12
);
// table_id (8), section_syntax_indicator (1),
'0'
(1), reserved (2)
int
sectionLength
=
pmtScratch
.
readBits
(
12
);
data
.
readBytes
(
pmtScratch
,
3
);
pmtScratch
.
skipBits
(
12
);
// table_id (8), section_syntax_indicator (1),
0
(1), reserved (2)
sectionLength
=
pmtScratch
.
readBits
(
12
);
if
(
data
.
capacity
()
==
sectionLength
)
{
data
.
reset
(
);
if
(
sectionData
.
capacity
()
<
sectionLength
)
{
sectionData
.
reset
(
new
byte
[
sectionLength
],
sectionLength
);
}
else
{
data
.
reset
(
new
byte
[
sectionLength
],
0
);
sectionData
.
reset
();
sectionData
.
setLimit
(
sectionLength
);
}
}
// read part of the section from single TS packet (dataPart)
int
partLength
=
Math
.
min
(
dataPart
.
bytesLeft
(),
data
.
capacity
()-
data
.
limit
()
);
dataPart
.
readBytes
(
data
.
data
,
data
.
limit
(),
partLength
)
;
data
.
setLimit
(
data
.
limit
()+
partLength
);
if
(
data
.
limit
()
!=
data
.
capacity
())
{
// section is not complete yet
int
bytesToRead
=
Math
.
min
(
data
.
bytesLeft
(),
sectionLength
-
sectionBytesRead
);
data
.
readBytes
(
sectionData
.
data
,
sectionBytesRead
,
bytesToRead
);
sectionBytesRead
+=
bytesToRead
;
if
(
sectionBytesRead
<
sectionLength
)
{
// Not yet fully read.
return
;
}
int
sectionLength
=
data
.
capacity
();
// program_number (16), reserved (2), version_number (5), current_next_indicator (1),
// section_number (8), last_section_number (8), reserved (3), PCR_PID (13)
// Skip the rest of the PMT header.
d
ata
.
skipBytes
(
7
);
sectionD
ata
.
skipBytes
(
7
);
data
.
readBytes
(
pmtScratch
,
2
);
// Read program_info_length.
sectionData
.
readBytes
(
pmtScratch
,
2
);
pmtScratch
.
skipBits
(
4
);
int
programInfoLength
=
pmtScratch
.
readBits
(
12
);
// Skip the descriptors.
d
ata
.
skipBytes
(
programInfoLength
);
sectionD
ata
.
skipBytes
(
programInfoLength
);
if
(
id3Reader
==
null
)
{
// Setup an ID3 track regardless of whether there's a corresponding entry, in case one
...
...
@@ -300,7 +303,7 @@ public final class TsExtractor implements Extractor {
int
remainingEntriesLength
=
sectionLength
-
9
/* Length of fields before descriptors */
-
programInfoLength
-
4
/* CRC length */
;
while
(
remainingEntriesLength
>
0
)
{
d
ata
.
readBytes
(
pmtScratch
,
5
);
sectionD
ata
.
readBytes
(
pmtScratch
,
5
);
int
streamType
=
pmtScratch
.
readBits
(
8
);
pmtScratch
.
skipBits
(
3
);
// reserved
int
elementaryPid
=
pmtScratch
.
readBits
(
13
);
...
...
@@ -308,9 +311,9 @@ public final class TsExtractor implements Extractor {
int
esInfoLength
=
pmtScratch
.
readBits
(
12
);
// ES_info_length
if
(
streamType
==
0x06
)
{
// Read descriptors in PES packets containing private data.
streamType
=
readPrivateDataStreamType
(
d
ata
,
esInfoLength
);
streamType
=
readPrivateDataStreamType
(
sectionD
ata
,
esInfoLength
);
}
else
{
d
ata
.
skipBytes
(
esInfoLength
);
sectionD
ata
.
skipBytes
(
esInfoLength
);
}
remainingEntriesLength
-=
esInfoLength
+
5
;
if
(
streamTypes
.
get
(
streamType
))
{
...
...
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