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
1545a052
authored
Feb 26, 2015
by
Sergio Moreno Mozota
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added MPEG audio support to TsExtractor
parent
ea95db23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
13 deletions
library/src/main/java/com/google/android/exoplayer/hls/parser/MpaReader.java
library/src/main/java/com/google/android/exoplayer/hls/parser/TsExtractor.java
library/src/main/java/com/google/android/exoplayer/util/CodecSpecificDataUtil.java
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
library/src/main/java/com/google/android/exoplayer/hls/parser/MpaReader.java
0 → 100644
View file @
1545a052
This diff is collapsed.
Click to expand it.
library/src/main/java/com/google/android/exoplayer/hls/parser/TsExtractor.java
View file @
1545a052
...
...
@@ -40,6 +40,8 @@ public final class TsExtractor extends HlsExtractor {
private
static
final
int
TS_SYNC_BYTE
=
0x47
;
// First byte of each TS packet.
private
static
final
int
TS_PAT_PID
=
0
;
private
static
final
int
TS_STREAM_TYPE_MPA
=
0x03
;
private
static
final
int
TS_STREAM_TYPE_MPA_LSF
=
0x04
;
private
static
final
int
TS_STREAM_TYPE_AAC
=
0x0F
;
private
static
final
int
TS_STREAM_TYPE_H264
=
0x1B
;
private
static
final
int
TS_STREAM_TYPE_ID3
=
0x15
;
...
...
@@ -329,6 +331,10 @@ public final class TsExtractor extends HlsExtractor {
ElementaryStreamReader
pesPayloadReader
=
null
;
switch
(
streamType
)
{
case
TS_STREAM_TYPE_MPA:
case
TS_STREAM_TYPE_MPA_LSF:
pesPayloadReader
=
new
MpaReader
(
bufferPool
);
break
;
case
TS_STREAM_TYPE_AAC:
pesPayloadReader
=
new
AdtsReader
(
bufferPool
);
break
;
...
...
library/src/main/java/com/google/android/exoplayer/util/CodecSpecificDataUtil.java
View file @
1545a052
...
...
@@ -29,11 +29,11 @@ public final class CodecSpecificDataUtil {
private
static
final
byte
[]
NAL_START_CODE
=
new
byte
[]
{
0
,
0
,
0
,
1
};
p
rivate
static
final
int
[]
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
=
new
int
[]
{
p
ublic
static
final
int
[]
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
=
new
int
[]
{
96000
,
88200
,
64000
,
48000
,
44100
,
32000
,
24000
,
22050
,
16000
,
12000
,
11025
,
8000
,
7350
};
p
rivate
static
final
int
[]
AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE
=
new
int
[]
{
p
ublic
static
final
int
[]
AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE
=
new
int
[]
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
8
};
...
...
@@ -49,13 +49,22 @@ public final class CodecSpecificDataUtil {
*/
public
static
Pair
<
Integer
,
Integer
>
parseAudioSpecificConfig
(
byte
[]
audioSpecificConfig
)
{
int
audioObjectType
=
(
audioSpecificConfig
[
0
]
>>
3
)
&
0x1F
;
int
byteOffset
=
audioObjectType
==
5
||
audioObjectType
==
29
?
1
:
0
;
int
frequencyIndex
=
(
audioSpecificConfig
[
byteOffset
]
&
0x7
)
<<
1
|
((
audioSpecificConfig
[
byteOffset
+
1
]
>>
7
)
&
0x1
);
Assertions
.
checkState
(
frequencyIndex
<
13
);
int
sampleRate
=
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
[
frequencyIndex
];
int
channelCount
=
(
audioSpecificConfig
[
byteOffset
+
1
]
>>
3
)
&
0xF
;
return
Pair
.
create
(
sampleRate
,
channelCount
);
if
(
audioObjectType
!=
31
)
{
int
byteOffset
=
audioObjectType
==
5
||
audioObjectType
==
29
?
1
:
0
;
int
frequencyIndex
=
(
audioSpecificConfig
[
byteOffset
]
&
0x7
)
<<
1
|
((
audioSpecificConfig
[
byteOffset
+
1
]
>>
7
)
&
0x1
);
Assertions
.
checkState
(
frequencyIndex
<
13
);
int
sampleRate
=
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
[
frequencyIndex
];
int
channelCount
=
(
audioSpecificConfig
[
byteOffset
+
1
]
>>
3
)
&
0xF
;
return
Pair
.
create
(
sampleRate
,
channelCount
);
}
else
{
int
frequencyIndex
=
(
audioSpecificConfig
[
1
]
&
0x1E
)
>>
1
;
Assertions
.
checkState
(
frequencyIndex
<
13
);
int
sampleRate
=
AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE
[
frequencyIndex
];
int
channelCount
=
(
audioSpecificConfig
[
1
]
&
0x01
)
<<
2
|
((
audioSpecificConfig
[
2
]
>>
6
)
&
0x03
);
return
Pair
.
create
(
sampleRate
,
channelCount
);
}
}
/**
...
...
@@ -68,10 +77,25 @@ public final class CodecSpecificDataUtil {
*/
public
static
byte
[]
buildAudioSpecificConfig
(
int
audioObjectType
,
int
sampleRateIndex
,
int
channelConfig
)
{
byte
[]
audioSpecificConfig
=
new
byte
[
2
];
audioSpecificConfig
[
0
]
=
(
byte
)
((
audioObjectType
<<
3
)
&
0xF8
|
(
sampleRateIndex
>>
1
)
&
0x07
);
audioSpecificConfig
[
1
]
=
(
byte
)
((
sampleRateIndex
<<
7
)
&
0x80
|
(
channelConfig
<<
3
)
&
0x78
);
return
audioSpecificConfig
;
if
(
audioObjectType
<
31
)
{
byte
[]
audioSpecificConfig
=
new
byte
[
2
];
audioSpecificConfig
[
0
]
=
(
byte
)
((
audioObjectType
<<
3
)
&
0xF8
|
(
sampleRateIndex
>>
1
)
&
0x07
);
audioSpecificConfig
[
1
]
=
(
byte
)
((
sampleRateIndex
<<
7
)
&
0x80
|
(
channelConfig
<<
3
)
&
0x78
);
return
audioSpecificConfig
;
}
else
{
byte
[]
audioSpecificConfig
=
new
byte
[
3
];
int
audioObjectTypeExt
=
audioObjectType
-
32
;
audioObjectType
=
31
;
audioSpecificConfig
[
0
]
=
(
byte
)
((
audioObjectType
<<
3
)
&
0xF8
|
(
audioObjectTypeExt
>>
3
)
&
0x07
);
audioSpecificConfig
[
1
]
=
(
byte
)
((
audioObjectTypeExt
<<
5
)
&
0xE0
|
(
sampleRateIndex
<<
1
)
&
0x1E
|
(
channelConfig
>>
2
)
&
0x01
);
audioSpecificConfig
[
2
]
=
(
byte
)
((
channelConfig
<<
6
)
&
0xC0
);
return
audioSpecificConfig
;
}
}
/**
...
...
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
View file @
1545a052
...
...
@@ -31,6 +31,7 @@ public class MimeTypes {
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
AUDIO_MPEG
=
BASE_TYPE_AUDIO
+
"/mpeg"
;
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_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