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
e5acc5a2
authored
Apr 13, 2015
by
Sergio Moreno Mozota
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
resync with Extractor changes
parent
da7ae2a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
17 deletions
library/src/main/java/com/google/android/exoplayer/hls/parser/MpaReader.java → library/src/main/java/com/google/android/exoplayer/extractor/ts/MpaReader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
library/src/main/java/com/google/android/exoplayer/
hls/parser
/MpaReader.java
→
library/src/main/java/com/google/android/exoplayer/
extractor/ts
/MpaReader.java
View file @
e5acc5a2
...
@@ -13,11 +13,11 @@
...
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
com
.
google
.
android
.
exoplayer
.
hls
.
parser
;
package
com
.
google
.
android
.
exoplayer
.
extractor
.
ts
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.C
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.
upstream.BufferPool
;
import
com.google.android.exoplayer.
extractor.TrackOutput
;
import
com.google.android.exoplayer.util.CodecSpecificDataUtil
;
import
com.google.android.exoplayer.util.CodecSpecificDataUtil
;
import
com.google.android.exoplayer.util.MimeTypes
;
import
com.google.android.exoplayer.util.MimeTypes
;
import
com.google.android.exoplayer.util.ParsableBitArray
;
import
com.google.android.exoplayer.util.ParsableBitArray
;
...
@@ -48,7 +48,8 @@ import java.util.Collections;
...
@@ -48,7 +48,8 @@ import java.util.Collections;
// Used to find the header.
// Used to find the header.
private
boolean
hasCrc
;
private
boolean
hasCrc
;
// Parsed from the header.
// Used when parsing the header.
private
boolean
hasOutputFormat
;
private
long
frameDurationUs
;
private
long
frameDurationUs
;
private
int
sampleSize
;
private
int
sampleSize
;
...
@@ -149,8 +150,8 @@ import java.util.Collections;
...
@@ -149,8 +150,8 @@ import java.util.Collections;
1
// Layer3
1
// Layer3
};
};
public
MpaReader
(
BufferPool
bufferPool
)
{
public
MpaReader
(
TrackOutput
output
)
{
super
(
bufferPool
);
super
(
output
);
mpaScratch
=
new
ParsableBitArray
(
new
byte
[
HEADER_SIZE
+
CRC_SIZE
]);
mpaScratch
=
new
ParsableBitArray
(
new
byte
[
HEADER_SIZE
+
CRC_SIZE
]);
state
=
STATE_FINDING_SYNC
;
state
=
STATE_FINDING_SYNC
;
}
}
...
@@ -171,18 +172,17 @@ import java.util.Collections;
...
@@ -171,18 +172,17 @@ import java.util.Collections;
case
STATE_READING_HEADER:
case
STATE_READING_HEADER:
int
targetLength
=
hasCrc
?
HEADER_SIZE
+
CRC_SIZE
:
HEADER_SIZE
;
int
targetLength
=
hasCrc
?
HEADER_SIZE
+
CRC_SIZE
:
HEADER_SIZE
;
if
(
continueRead
(
data
,
mpaScratch
.
getData
(),
targetLength
))
{
if
(
continueRead
(
data
,
mpaScratch
.
getData
(),
targetLength
))
{
startSample
(
timeUs
);
parseHeader
();
parseHeader
();
bytesRead
=
0
;
bytesRead
=
targetLength
;
state
=
STATE_READING_SAMPLE
;
state
=
STATE_READING_SAMPLE
;
}
}
break
;
break
;
case
STATE_READING_SAMPLE:
case
STATE_READING_SAMPLE:
int
bytesToRead
=
Math
.
min
(
data
.
bytesLeft
(),
sampleSize
-
bytesRead
);
int
bytesToRead
=
Math
.
min
(
data
.
bytesLeft
(),
sampleSize
-
bytesRead
);
append
Data
(
data
,
bytesToRead
);
output
.
sample
Data
(
data
,
bytesToRead
);
bytesRead
+=
bytesToRead
;
bytesRead
+=
bytesToRead
;
if
(
bytesRead
==
sampleSize
)
{
if
(
bytesRead
==
sampleSize
)
{
commitSample
(
true
);
output
.
sampleMetadata
(
timeUs
,
C
.
SAMPLE_FLAG_SYNC
,
sampleSize
,
0
,
null
);
timeUs
+=
frameDurationUs
;
timeUs
+=
frameDurationUs
;
bytesRead
=
0
;
bytesRead
=
0
;
state
=
STATE_FINDING_SYNC
;
state
=
STATE_FINDING_SYNC
;
...
@@ -243,7 +243,7 @@ import java.util.Collections;
...
@@ -243,7 +243,7 @@ import java.util.Collections;
* @param LSF Low Sample rate Format (MPEG 2)
* @param LSF Low Sample rate Format (MPEG 2)
* @param bitrate The bitrate in bits per second
* @param bitrate The bitrate in bits per second
* @param samplesPerSec The sampling rate in hertz
* @param samplesPerSec The sampling rate in hertz
* @param paddingSize
* @param
-
paddingSize
* @return Frame size in bytes
* @return Frame size in bytes
*/
*/
private
static
int
CalcMpaFrameSize
(
int
layer
,
int
LSF
,
int
bitrate
,
int
samplesPerSec
,
int
paddingSize
)
{
private
static
int
CalcMpaFrameSize
(
int
layer
,
int
LSF
,
int
bitrate
,
int
samplesPerSec
,
int
paddingSize
)
{
...
@@ -255,9 +255,9 @@ import java.util.Collections;
...
@@ -255,9 +255,9 @@ import java.util.Collections;
*/
*/
private
void
parseHeader
()
{
private
void
parseHeader
()
{
int
headerLength
=
hasCrc
?
HEADER_SIZE
+
CRC_SIZE
:
HEADER_SIZE
;
int
headerLength
=
hasCrc
?
HEADER_SIZE
+
CRC_SIZE
:
HEADER_SIZE
;
mpaScratch
.
setPosition
(
0
);
if
(!
hasMediaFormat
())
{
if
(!
hasOutputFormat
)
{
mpaScratch
.
setPosition
(
0
);
mpaScratch
.
skipBits
(
12
);
mpaScratch
.
skipBits
(
12
);
int
isLSF
=
(!
mpaScratch
.
readBit
())
?
1
:
0
;
int
isLSF
=
(!
mpaScratch
.
readBit
())
?
1
:
0
;
int
layer
=
mpaScratch
.
readBits
(
2
)
^
3
;
int
layer
=
mpaScratch
.
readBits
(
2
)
^
3
;
...
@@ -279,14 +279,15 @@ import java.util.Collections;
...
@@ -279,14 +279,15 @@ import java.util.Collections;
MediaFormat
mediaFormat
=
MediaFormat
.
createAudioFormat
(
/*isLSF == 1 ?*/
MimeTypes
.
AUDIO_MPEG
/* : MimeTypes.AUDIO_MP1L2*/
,
MediaFormat
mediaFormat
=
MediaFormat
.
createAudioFormat
(
/*isLSF == 1 ?*/
MimeTypes
.
AUDIO_MPEG
/* : MimeTypes.AUDIO_MP1L2*/
,
MediaFormat
.
NO_VALUE
,
audioParams
.
second
,
audioParams
.
first
,
MediaFormat
.
NO_VALUE
,
audioParams
.
second
,
audioParams
.
first
,
Collections
.
singletonList
(
audioSpecificConfig
));
Collections
.
singletonList
(
audioSpecificConfig
));
output
.
format
(
mediaFormat
);
hasOutputFormat
=
true
;
frameDurationUs
=
(
C
.
MICROS_PER_SECOND
*
MPA_SAMPLES_PER_FRAME
[
isLSF
][
layer
])
/
mediaFormat
.
sampleRate
;
frameDurationUs
=
(
C
.
MICROS_PER_SECOND
*
MPA_SAMPLES_PER_FRAME
[
isLSF
][
layer
])
/
mediaFormat
.
sampleRate
;
setMediaFormat
(
mediaFormat
);
sampleSize
=
CalcMpaFrameSize
(
layer
,
isLSF
,
bitRate
*
1000
,
sampleRate
,
paddingBit
);
sampleSize
=
CalcMpaFrameSize
(
layer
,
isLSF
,
bitRate
*
1000
,
sampleRate
,
paddingBit
)
-
headerLength
;
}
}
mpaScratch
.
setPosition
(
0
);
mpaScratch
.
setPosition
(
0
);
ParsableByteArray
header
=
new
ParsableByteArray
(
mpaScratch
.
getData
(),
headerLength
);
ParsableByteArray
header
=
new
ParsableByteArray
(
mpaScratch
.
getData
(),
headerLength
);
append
Data
(
header
,
headerLength
);
output
.
sample
Data
(
header
,
headerLength
);
}
}
}
}
library/src/main/java/com/google/android/exoplayer/extractor/ts/TsExtractor.java
View file @
e5acc5a2
...
@@ -248,8 +248,10 @@ public final class TsExtractor implements Extractor {
...
@@ -248,8 +248,10 @@ public final class TsExtractor implements Extractor {
ElementaryStreamReader
pesPayloadReader
=
null
;
ElementaryStreamReader
pesPayloadReader
=
null
;
switch
(
streamType
)
{
switch
(
streamType
)
{
case
TS_STREAM_TYPE_MPA:
case
TS_STREAM_TYPE_MPA:
pesPayloadReader
=
new
MpaReader
(
output
.
track
(
TS_STREAM_TYPE_MPA
));
break
;
case
TS_STREAM_TYPE_MPA_LSF:
case
TS_STREAM_TYPE_MPA_LSF:
pesPayloadReader
=
new
MpaReader
(
bufferPool
);
pesPayloadReader
=
new
MpaReader
(
output
.
track
(
TS_STREAM_TYPE_MPA_LSF
)
);
break
;
break
;
case
TS_STREAM_TYPE_AAC:
case
TS_STREAM_TYPE_AAC:
pesPayloadReader
=
new
AdtsReader
(
output
.
track
(
TS_STREAM_TYPE_AAC
));
pesPayloadReader
=
new
AdtsReader
(
output
.
track
(
TS_STREAM_TYPE_AAC
));
...
...
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
View file @
e5acc5a2
...
@@ -31,7 +31,6 @@ public class MimeTypes {
...
@@ -31,7 +31,6 @@ public class MimeTypes {
public
static
final
String
VIDEO_VP9
=
BASE_TYPE_VIDEO
+
"/x-vnd.on2.vp9"
;
public
static
final
String
VIDEO_VP9
=
BASE_TYPE_VIDEO
+
"/x-vnd.on2.vp9"
;
public
static
final
String
VIDEO_MP4V
=
BASE_TYPE_VIDEO
+
"/mp4v-es"
;
public
static
final
String
VIDEO_MP4V
=
BASE_TYPE_VIDEO
+
"/mp4v-es"
;
public
static
final
String
AUDIO_MPEG
=
BASE_TYPE_AUDIO
+
"/mpeg"
;
public
static
final
String
AUDIO_MP4
=
BASE_TYPE_AUDIO
+
"/mp4"
;
public
static
final
String
AUDIO_MP4
=
BASE_TYPE_AUDIO
+
"/mp4"
;
public
static
final
String
AUDIO_AAC
=
BASE_TYPE_AUDIO
+
"/mp4a-latm"
;
public
static
final
String
AUDIO_AAC
=
BASE_TYPE_AUDIO
+
"/mp4a-latm"
;
public
static
final
String
AUDIO_AC3
=
BASE_TYPE_AUDIO
+
"/ac3"
;
public
static
final
String
AUDIO_AC3
=
BASE_TYPE_AUDIO
+
"/ac3"
;
...
...
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