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
8c05b5b1
authored
Apr 06, 2017
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'tresvecesseis-dev-v2-dvbsubs' into dev-v2
parents
6caa3e79
538e71c0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
296 additions
and
10 deletions
library/core/proguard-rules.txt
library/core/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitlesReader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java
library/core/src/main/java/com/google/android/exoplayer2/text/Cue.java
library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbSubtitle.java
library/core/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitlePainter.java
library/core/proguard-rules.txt
View file @
8c05b5b1
...
@@ -5,3 +5,6 @@
...
@@ -5,3 +5,6 @@
-keepclassmembers class com.google.android.exoplayer2.text.cea.Cea708Decoder {
-keepclassmembers class com.google.android.exoplayer2.text.cea.Cea708Decoder {
public <init>(int);
public <init>(int);
}
}
-keepclassmembers class com.google.android.exoplayer2.text.dvb.DvbDecoder {
public <init>(java.util.List);
}
\ No newline at end of file
library/core/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
View file @
8c05b5b1
...
@@ -99,6 +99,7 @@ public final class MatroskaExtractor implements Extractor {
...
@@ -99,6 +99,7 @@ public final class MatroskaExtractor implements Extractor {
private
static
final
String
CODEC_ID_SUBRIP
=
"S_TEXT/UTF8"
;
private
static
final
String
CODEC_ID_SUBRIP
=
"S_TEXT/UTF8"
;
private
static
final
String
CODEC_ID_VOBSUB
=
"S_VOBSUB"
;
private
static
final
String
CODEC_ID_VOBSUB
=
"S_VOBSUB"
;
private
static
final
String
CODEC_ID_PGS
=
"S_HDMV/PGS"
;
private
static
final
String
CODEC_ID_PGS
=
"S_HDMV/PGS"
;
private
static
final
String
CODEC_ID_DVBSUB
=
"S_DVBSUB"
;
private
static
final
int
VORBIS_MAX_INPUT_SIZE
=
8192
;
private
static
final
int
VORBIS_MAX_INPUT_SIZE
=
8192
;
private
static
final
int
OPUS_MAX_INPUT_SIZE
=
5760
;
private
static
final
int
OPUS_MAX_INPUT_SIZE
=
5760
;
...
@@ -1233,7 +1234,8 @@ public final class MatroskaExtractor implements Extractor {
...
@@ -1233,7 +1234,8 @@ public final class MatroskaExtractor implements Extractor {
||
CODEC_ID_PCM_INT_LIT
.
equals
(
codecId
)
||
CODEC_ID_PCM_INT_LIT
.
equals
(
codecId
)
||
CODEC_ID_SUBRIP
.
equals
(
codecId
)
||
CODEC_ID_SUBRIP
.
equals
(
codecId
)
||
CODEC_ID_VOBSUB
.
equals
(
codecId
)
||
CODEC_ID_VOBSUB
.
equals
(
codecId
)
||
CODEC_ID_PGS
.
equals
(
codecId
);
||
CODEC_ID_PGS
.
equals
(
codecId
)
||
CODEC_ID_DVBSUB
.
equals
(
codecId
);
}
}
/**
/**
...
@@ -1461,6 +1463,11 @@ public final class MatroskaExtractor implements Extractor {
...
@@ -1461,6 +1463,11 @@ public final class MatroskaExtractor implements Extractor {
case
CODEC_ID_PGS:
case
CODEC_ID_PGS:
mimeType
=
MimeTypes
.
APPLICATION_PGS
;
mimeType
=
MimeTypes
.
APPLICATION_PGS
;
break
;
break
;
case
CODEC_ID_DVBSUB:
mimeType
=
MimeTypes
.
APPLICATION_DVBSUBS
;
initializationData
=
Collections
.
singletonList
(
new
byte
[]
{
(
byte
)
0x01
,
codecPrivate
[
0
],
codecPrivate
[
1
],
codecPrivate
[
2
],
codecPrivate
[
3
]});
break
;
default
:
default
:
throw
new
ParserException
(
"Unrecognized codec identifier."
);
throw
new
ParserException
(
"Unrecognized codec identifier."
);
}
}
...
@@ -1495,7 +1502,8 @@ public final class MatroskaExtractor implements Extractor {
...
@@ -1495,7 +1502,8 @@ public final class MatroskaExtractor implements Extractor {
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
null
,
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
null
,
Format
.
NO_VALUE
,
selectionFlags
,
language
,
drmInitData
);
Format
.
NO_VALUE
,
selectionFlags
,
language
,
drmInitData
);
}
else
if
(
MimeTypes
.
APPLICATION_VOBSUB
.
equals
(
mimeType
)
}
else
if
(
MimeTypes
.
APPLICATION_VOBSUB
.
equals
(
mimeType
)
||
MimeTypes
.
APPLICATION_PGS
.
equals
(
mimeType
))
{
||
MimeTypes
.
APPLICATION_PGS
.
equals
(
mimeType
)
||
MimeTypes
.
APPLICATION_DVBSUBS
.
equals
(
mimeType
))
{
type
=
C
.
TRACK_TYPE_TEXT
;
type
=
C
.
TRACK_TYPE_TEXT
;
format
=
Format
.
createImageSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
null
,
format
=
Format
.
createImageSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
null
,
Format
.
NO_VALUE
,
initializationData
,
language
,
drmInitData
);
Format
.
NO_VALUE
,
initializationData
,
language
,
drmInitData
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java
View file @
8c05b5b1
...
@@ -109,6 +109,8 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
...
@@ -109,6 +109,8 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
?
null
:
new
SectionReader
(
new
SpliceInfoSectionReader
());
?
null
:
new
SectionReader
(
new
SpliceInfoSectionReader
());
case
TsExtractor
.
TS_STREAM_TYPE_ID3
:
case
TsExtractor
.
TS_STREAM_TYPE_ID3
:
return
new
PesReader
(
new
Id3Reader
());
return
new
PesReader
(
new
Id3Reader
());
case
TsExtractor
.
TS_STREAM_TYPE_DVBSUBS
:
return
new
PesReader
(
new
DvbSubtitlesReader
(
esInfo
));
default
:
default
:
return
null
;
return
null
;
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitlesReader.java
0 → 100644
View file @
8c05b5b1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
ts
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.extractor.ExtractorOutput
;
import
com.google.android.exoplayer2.extractor.TrackOutput
;
import
com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Output PES packets to a {@link TrackOutput}.
*/
public
final
class
DvbSubtitlesReader
implements
ElementaryStreamReader
{
private
class
SubtitleTrack
{
private
String
language
;
private
List
<
byte
[]>
initializationData
;
}
private
List
<
SubtitleTrack
>
subtitles
=
new
ArrayList
<>();
private
long
sampleTimeUs
;
private
int
sampleBytesWritten
;
private
boolean
writingSample
;
private
List
<
TrackOutput
>
outputTracks
=
new
ArrayList
<>();
public
DvbSubtitlesReader
(
TsPayloadReader
.
EsInfo
esInfo
)
{
int
pos
=
2
;
while
(
pos
<
esInfo
.
descriptorBytes
.
length
)
{
SubtitleTrack
subtitle
=
new
SubtitleTrack
();
subtitle
.
language
=
new
String
(
new
byte
[]
{
esInfo
.
descriptorBytes
[
pos
],
esInfo
.
descriptorBytes
[
pos
+
1
],
esInfo
.
descriptorBytes
[
pos
+
2
]});
if
(((
esInfo
.
descriptorBytes
[
pos
+
3
]
&
0xF0
)
>>
4
)
==
2
)
{
subtitle
.
language
+=
" for hard of hearing"
;
}
subtitle
.
initializationData
=
Collections
.
singletonList
(
new
byte
[]
{(
byte
)
0x00
,
esInfo
.
descriptorBytes
[
pos
+
4
],
esInfo
.
descriptorBytes
[
pos
+
5
],
esInfo
.
descriptorBytes
[
pos
+
6
],
esInfo
.
descriptorBytes
[
pos
+
7
]});
subtitles
.
add
(
subtitle
);
pos
+=
8
;
}
}
@Override
public
void
seek
()
{
writingSample
=
false
;
}
@Override
public
void
createTracks
(
ExtractorOutput
extractorOutput
,
TrackIdGenerator
idGenerator
)
{
TrackOutput
output
;
SubtitleTrack
subtitle
;
for
(
int
i
=
0
;
i
<
subtitles
.
size
();
i
++)
{
subtitle
=
subtitles
.
get
(
i
);
idGenerator
.
generateNewId
();
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_TEXT
);
output
.
format
(
Format
.
createImageSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_DVBSUBS
,
null
,
Format
.
NO_VALUE
,
subtitle
.
initializationData
,
subtitle
.
language
,
null
));
outputTracks
.
add
(
output
);
}
}
@Override
public
void
packetStarted
(
long
pesTimeUs
,
boolean
dataAlignmentIndicator
)
{
if
(!
dataAlignmentIndicator
)
{
return
;
}
writingSample
=
true
;
sampleTimeUs
=
pesTimeUs
;
sampleBytesWritten
=
0
;
}
@Override
public
void
packetFinished
()
{
TrackOutput
output
;
for
(
int
i
=
0
;
i
<
outputTracks
.
size
();
i
++)
{
output
=
outputTracks
.
get
(
i
);
output
.
sampleMetadata
(
sampleTimeUs
,
C
.
BUFFER_FLAG_KEY_FRAME
,
sampleBytesWritten
,
0
,
null
);
}
writingSample
=
false
;
}
@Override
public
void
consume
(
ParsableByteArray
data
)
{
if
(
writingSample
)
{
int
bytesAvailable
=
data
.
bytesLeft
();
TrackOutput
output
;
int
dataPosition
=
data
.
getPosition
();
for
(
int
i
=
0
;
i
<
outputTracks
.
size
();
i
++)
{
data
.
setPosition
(
dataPosition
);
output
=
outputTracks
.
get
(
i
);
output
.
sampleData
(
data
,
bytesAvailable
);
}
sampleBytesWritten
+=
bytesAvailable
;
}
}
}
\ No newline at end of file
library/core/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java
View file @
8c05b5b1
...
@@ -92,6 +92,7 @@ public final class TsExtractor implements Extractor {
...
@@ -92,6 +92,7 @@ public final class TsExtractor implements Extractor {
public
static
final
int
TS_STREAM_TYPE_H265
=
0x24
;
public
static
final
int
TS_STREAM_TYPE_H265
=
0x24
;
public
static
final
int
TS_STREAM_TYPE_ID3
=
0x15
;
public
static
final
int
TS_STREAM_TYPE_ID3
=
0x15
;
public
static
final
int
TS_STREAM_TYPE_SPLICE_INFO
=
0x86
;
public
static
final
int
TS_STREAM_TYPE_SPLICE_INFO
=
0x86
;
public
static
final
int
TS_STREAM_TYPE_DVBSUBS
=
0x59
;
private
static
final
int
TS_PACKET_SIZE
=
188
;
private
static
final
int
TS_PACKET_SIZE
=
188
;
private
static
final
int
TS_SYNC_BYTE
=
0x47
;
// First byte of each TS packet.
private
static
final
int
TS_SYNC_BYTE
=
0x47
;
// First byte of each TS packet.
...
@@ -356,6 +357,7 @@ public final class TsExtractor implements Extractor {
...
@@ -356,6 +357,7 @@ public final class TsExtractor implements Extractor {
private
static
final
int
TS_PMT_DESC_AC3
=
0x6A
;
private
static
final
int
TS_PMT_DESC_AC3
=
0x6A
;
private
static
final
int
TS_PMT_DESC_EAC3
=
0x7A
;
private
static
final
int
TS_PMT_DESC_EAC3
=
0x7A
;
private
static
final
int
TS_PMT_DESC_DTS
=
0x7B
;
private
static
final
int
TS_PMT_DESC_DTS
=
0x7B
;
private
static
final
int
TS_PMT_DESC_DVBSUBS
=
0x59
;
private
final
ParsableBitArray
pmtScratch
;
private
final
ParsableBitArray
pmtScratch
;
private
final
int
pid
;
private
final
int
pid
;
...
@@ -498,6 +500,9 @@ public final class TsExtractor implements Extractor {
...
@@ -498,6 +500,9 @@ public final class TsExtractor implements Extractor {
}
else
if
(
descriptorTag
==
TS_PMT_DESC_ISO639_LANG
)
{
}
else
if
(
descriptorTag
==
TS_PMT_DESC_ISO639_LANG
)
{
language
=
new
String
(
data
.
data
,
data
.
getPosition
(),
3
).
trim
();
language
=
new
String
(
data
.
data
,
data
.
getPosition
(),
3
).
trim
();
// Audio type is ignored.
// Audio type is ignored.
}
else
if
(
descriptorTag
==
TS_PMT_DESC_DVBSUBS
)
{
streamType
=
TS_STREAM_TYPE_DVBSUBS
;
language
=
new
String
(
data
.
data
,
data
.
getPosition
(),
3
).
trim
();
}
}
// Skip unused bytes of current descriptor.
// Skip unused bytes of current descriptor.
data
.
skipBytes
(
positionOfNextDescriptor
-
data
.
getPosition
());
data
.
skipBytes
(
positionOfNextDescriptor
-
data
.
getPosition
());
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/Cue.java
View file @
8c05b5b1
...
@@ -168,6 +168,12 @@ public class Cue {
...
@@ -168,6 +168,12 @@ public class Cue {
public
final
float
size
;
public
final
float
size
;
/**
/**
* The bitmap height as a fraction of the of the viewport size, or -1 if the bitmap should be
* displayed at its natural height given for its specified {@link #size}.
*/
public
final
float
bitmapHeight
;
/**
* Specifies whether or not the {@link #windowColor} property is set.
* Specifies whether or not the {@link #windowColor} property is set.
*/
*/
public
final
boolean
windowColorSet
;
public
final
boolean
windowColorSet
;
...
@@ -190,11 +196,13 @@ public class Cue {
...
@@ -190,11 +196,13 @@ public class Cue {
* @param verticalPositionAnchor The vertical anchor. One of {@link #ANCHOR_TYPE_START},
* @param verticalPositionAnchor The vertical anchor. One of {@link #ANCHOR_TYPE_START},
* {@link #ANCHOR_TYPE_MIDDLE}, {@link #ANCHOR_TYPE_END} and {@link #TYPE_UNSET}.
* {@link #ANCHOR_TYPE_MIDDLE}, {@link #ANCHOR_TYPE_END} and {@link #TYPE_UNSET}.
* @param width The width of the cue, expressed as a fraction of the viewport width.
* @param width The width of the cue, expressed as a fraction of the viewport width.
* @param height The width of the cue, expressed as a fraction of the viewport width.
*/
*/
public
Cue
(
Bitmap
bitmap
,
float
horizontalPosition
,
@AnchorType
int
horizontalPositionAnchor
,
public
Cue
(
Bitmap
bitmap
,
float
horizontalPosition
,
@AnchorType
int
horizontalPositionAnchor
,
float
verticalPosition
,
@AnchorType
int
verticalPositionAnchor
,
float
width
)
{
float
verticalPosition
,
@AnchorType
int
verticalPositionAnchor
,
float
width
,
float
height
)
{
this
(
null
,
null
,
bitmap
,
verticalPosition
,
LINE_TYPE_FRACTION
,
verticalPositionAnchor
,
this
(
null
,
null
,
bitmap
,
verticalPosition
,
LINE_TYPE_FRACTION
,
verticalPositionAnchor
,
horizontalPosition
,
horizontalPositionAnchor
,
width
,
false
,
Color
.
BLACK
);
horizontalPosition
,
horizontalPositionAnchor
,
width
,
height
,
false
,
Color
.
BLACK
);
}
}
/**
/**
...
@@ -240,15 +248,16 @@ public class Cue {
...
@@ -240,15 +248,16 @@ public class Cue {
* @param windowColor See {@link #windowColor}.
* @param windowColor See {@link #windowColor}.
*/
*/
public
Cue
(
CharSequence
text
,
Alignment
textAlignment
,
float
line
,
@LineType
int
lineType
,
public
Cue
(
CharSequence
text
,
Alignment
textAlignment
,
float
line
,
@LineType
int
lineType
,
@AnchorType
int
lineAnchor
,
float
position
,
@AnchorType
int
positionAnchor
,
float
size
,
@AnchorType
int
lineAnchor
,
float
position
,
@AnchorType
int
positionAnchor
,
float
size
,
boolean
windowColorSet
,
int
windowColor
)
{
boolean
windowColorSet
,
int
windowColor
)
{
this
(
text
,
textAlignment
,
null
,
line
,
lineType
,
lineAnchor
,
position
,
positionAnchor
,
size
,
this
(
text
,
textAlignment
,
null
,
line
,
lineType
,
lineAnchor
,
position
,
positionAnchor
,
size
,
windowColorSet
,
windowColor
);
-
1
,
windowColorSet
,
windowColor
);
}
}
private
Cue
(
CharSequence
text
,
Alignment
textAlignment
,
Bitmap
bitmap
,
float
line
,
private
Cue
(
CharSequence
text
,
Alignment
textAlignment
,
Bitmap
bitmap
,
float
line
,
@LineType
int
lineType
,
@AnchorType
int
lineAnchor
,
float
position
,
@LineType
int
lineType
,
@AnchorType
int
lineAnchor
,
float
position
,
@AnchorType
int
positionAnchor
,
float
size
,
boolean
windowColorSet
,
int
windowColor
)
{
@AnchorType
int
positionAnchor
,
float
size
,
float
bitmapHeight
,
boolean
windowColorSet
,
int
windowColor
)
{
this
.
text
=
text
;
this
.
text
=
text
;
this
.
textAlignment
=
textAlignment
;
this
.
textAlignment
=
textAlignment
;
this
.
bitmap
=
bitmap
;
this
.
bitmap
=
bitmap
;
...
@@ -258,6 +267,7 @@ public class Cue {
...
@@ -258,6 +267,7 @@ public class Cue {
this
.
position
=
position
;
this
.
position
=
position
;
this
.
positionAnchor
=
positionAnchor
;
this
.
positionAnchor
=
positionAnchor
;
this
.
size
=
size
;
this
.
size
=
size
;
this
.
bitmapHeight
=
bitmapHeight
;
this
.
windowColorSet
=
windowColorSet
;
this
.
windowColorSet
=
windowColorSet
;
this
.
windowColor
=
windowColor
;
this
.
windowColor
=
windowColor
;
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java
View file @
8c05b5b1
...
@@ -25,6 +25,8 @@ import com.google.android.exoplayer2.text.webvtt.Mp4WebvttDecoder;
...
@@ -25,6 +25,8 @@ import com.google.android.exoplayer2.text.webvtt.Mp4WebvttDecoder;
import
com.google.android.exoplayer2.text.webvtt.WebvttDecoder
;
import
com.google.android.exoplayer2.text.webvtt.WebvttDecoder
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.util.List
;
/**
/**
* A factory for {@link SubtitleDecoder} instances.
* A factory for {@link SubtitleDecoder} instances.
*/
*/
...
@@ -83,6 +85,8 @@ public interface SubtitleDecoderFactory {
...
@@ -83,6 +85,8 @@ public interface SubtitleDecoderFactory {
}
else
if
(
format
.
sampleMimeType
.
equals
(
MimeTypes
.
APPLICATION_CEA708
))
{
}
else
if
(
format
.
sampleMimeType
.
equals
(
MimeTypes
.
APPLICATION_CEA708
))
{
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
(
Integer
.
TYPE
)
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
(
Integer
.
TYPE
)
.
newInstance
(
format
.
accessibilityChannel
);
.
newInstance
(
format
.
accessibilityChannel
);
}
else
if
(
format
.
sampleMimeType
.
equals
(
MimeTypes
.
APPLICATION_DVBSUBS
))
{
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
(
List
.
class
).
newInstance
(
format
.
initializationData
);
}
else
{
}
else
{
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
().
newInstance
();
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
().
newInstance
();
}
}
...
@@ -112,6 +116,8 @@ public interface SubtitleDecoderFactory {
...
@@ -112,6 +116,8 @@ public interface SubtitleDecoderFactory {
return
Class
.
forName
(
"com.google.android.exoplayer2.text.cea.Cea608Decoder"
);
return
Class
.
forName
(
"com.google.android.exoplayer2.text.cea.Cea608Decoder"
);
case
MimeTypes
.
APPLICATION_CEA708
:
case
MimeTypes
.
APPLICATION_CEA708
:
return
Class
.
forName
(
"com.google.android.exoplayer2.text.cea.Cea708Decoder"
);
return
Class
.
forName
(
"com.google.android.exoplayer2.text.cea.Cea708Decoder"
);
case
MimeTypes
.
APPLICATION_DVBSUBS
:
return
Class
.
forName
(
"com.google.android.exoplayer2.text.dvb.DvbDecoder"
);
default
:
default
:
return
null
;
return
null
;
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbDecoder.java
0 → 100644
View file @
8c05b5b1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
text
.
dvb
;
import
com.google.android.exoplayer2.text.SimpleSubtitleDecoder
;
import
java.util.List
;
/**
* A {@link SimpleSubtitleDecoder} for DVB Subtitles.
*/
public
final
class
DvbDecoder
extends
SimpleSubtitleDecoder
{
private
final
DvbParser
parser
;
public
DvbDecoder
(
List
<
byte
[]>
initializationData
)
{
super
(
"DvbDecoder"
);
int
subtitleCompositionPage
=
1
;
int
subtitleAncillaryPage
=
1
;
int
flags
=
0
;
byte
[]
tempByteArray
;
if
((
tempByteArray
=
initializationData
.
get
(
0
))
!=
null
&&
tempByteArray
.
length
==
5
)
{
if
(
tempByteArray
[
0
]
==
0x01
)
{
flags
|=
DvbParser
.
FLAG_PES_STRIPPED_DVBSUB
;
}
subtitleCompositionPage
=
((
tempByteArray
[
1
]
&
0xFF
)
<<
8
)
|
(
tempByteArray
[
2
]
&
0xFF
);
subtitleAncillaryPage
=
((
tempByteArray
[
3
]
&
0xFF
)
<<
8
)
|
(
tempByteArray
[
4
]
&
0xFF
);
}
parser
=
new
DvbParser
(
subtitleCompositionPage
,
subtitleAncillaryPage
,
flags
);
}
@Override
protected
DvbSubtitle
decode
(
byte
[]
data
,
int
length
)
{
return
new
DvbSubtitle
(
parser
.
dvbSubsDecode
(
data
,
length
));
}
}
\ No newline at end of file
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java
0 → 100644
View file @
8c05b5b1
This diff is collapsed.
Click to expand it.
library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbSubtitle.java
0 → 100644
View file @
8c05b5b1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
text
.
dvb
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.Subtitle
;
import
java.util.Collections
;
import
java.util.List
;
/**
* A representation of a DVB subtitle.
*/
/* package */
final
class
DvbSubtitle
implements
Subtitle
{
private
final
List
<
Cue
>
cues
;
public
DvbSubtitle
(
List
<
Cue
>
cues
)
{
if
(
cues
==
null
)
{
this
.
cues
=
Collections
.
emptyList
();
}
else
{
this
.
cues
=
cues
;
}
}
@Override
public
int
getNextEventTimeIndex
(
long
timeUs
)
{
return
C
.
INDEX_UNSET
;
}
@Override
public
int
getEventTimeCount
()
{
return
1
;
}
@Override
public
long
getEventTime
(
int
index
)
{
return
0
;
}
@Override
public
List
<
Cue
>
getCues
(
long
timeUs
)
{
return
cues
;
}
}
\ No newline at end of file
library/core/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
View file @
8c05b5b1
...
@@ -81,6 +81,7 @@ public final class MimeTypes {
...
@@ -81,6 +81,7 @@ public final class MimeTypes {
public
static
final
String
APPLICATION_SCTE35
=
BASE_TYPE_APPLICATION
+
"/x-scte35"
;
public
static
final
String
APPLICATION_SCTE35
=
BASE_TYPE_APPLICATION
+
"/x-scte35"
;
public
static
final
String
APPLICATION_CAMERA_MOTION
=
BASE_TYPE_APPLICATION
+
"/x-camera-motion"
;
public
static
final
String
APPLICATION_CAMERA_MOTION
=
BASE_TYPE_APPLICATION
+
"/x-camera-motion"
;
public
static
final
String
APPLICATION_EMSG
=
BASE_TYPE_APPLICATION
+
"/x-emsg"
;
public
static
final
String
APPLICATION_EMSG
=
BASE_TYPE_APPLICATION
+
"/x-emsg"
;
public
static
final
String
APPLICATION_DVBSUBS
=
BASE_TYPE_APPLICATION
+
"/dvbsubs"
;
private
MimeTypes
()
{}
private
MimeTypes
()
{}
...
@@ -222,7 +223,7 @@ public final class MimeTypes {
...
@@ -222,7 +223,7 @@ public final class MimeTypes {
||
APPLICATION_SUBRIP
.
equals
(
mimeType
)
||
APPLICATION_TTML
.
equals
(
mimeType
)
||
APPLICATION_SUBRIP
.
equals
(
mimeType
)
||
APPLICATION_TTML
.
equals
(
mimeType
)
||
APPLICATION_TX3G
.
equals
(
mimeType
)
||
APPLICATION_MP4VTT
.
equals
(
mimeType
)
||
APPLICATION_TX3G
.
equals
(
mimeType
)
||
APPLICATION_MP4VTT
.
equals
(
mimeType
)
||
APPLICATION_RAWCC
.
equals
(
mimeType
)
||
APPLICATION_VOBSUB
.
equals
(
mimeType
)
||
APPLICATION_RAWCC
.
equals
(
mimeType
)
||
APPLICATION_VOBSUB
.
equals
(
mimeType
)
||
APPLICATION_PGS
.
equals
(
mimeType
))
{
||
APPLICATION_PGS
.
equals
(
mimeType
)
||
APPLICATION_DVBSUBS
.
equals
(
mimeType
)
)
{
return
C
.
TRACK_TYPE_TEXT
;
return
C
.
TRACK_TYPE_TEXT
;
}
else
if
(
APPLICATION_ID3
.
equals
(
mimeType
)
}
else
if
(
APPLICATION_ID3
.
equals
(
mimeType
)
||
APPLICATION_EMSG
.
equals
(
mimeType
)
||
APPLICATION_EMSG
.
equals
(
mimeType
)
...
...
library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitlePainter.java
View file @
8c05b5b1
...
@@ -77,6 +77,7 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -77,6 +77,7 @@ import com.google.android.exoplayer2.util.Util;
@Cue
.
AnchorType
@Cue
.
AnchorType
private
int
cuePositionAnchor
;
private
int
cuePositionAnchor
;
private
float
cueSize
;
private
float
cueSize
;
private
float
cueBitmapHeight
;
private
boolean
applyEmbeddedStyles
;
private
boolean
applyEmbeddedStyles
;
private
int
foregroundColor
;
private
int
foregroundColor
;
private
int
backgroundColor
;
private
int
backgroundColor
;
...
@@ -173,6 +174,7 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -173,6 +174,7 @@ import com.google.android.exoplayer2.util.Util;
&&
this
.
cuePosition
==
cue
.
position
&&
this
.
cuePosition
==
cue
.
position
&&
Util
.
areEqual
(
this
.
cuePositionAnchor
,
cue
.
positionAnchor
)
&&
Util
.
areEqual
(
this
.
cuePositionAnchor
,
cue
.
positionAnchor
)
&&
this
.
cueSize
==
cue
.
size
&&
this
.
cueSize
==
cue
.
size
&&
this
.
cueBitmapHeight
==
cue
.
bitmapHeight
&&
this
.
applyEmbeddedStyles
==
applyEmbeddedStyles
&&
this
.
applyEmbeddedStyles
==
applyEmbeddedStyles
&&
this
.
foregroundColor
==
style
.
foregroundColor
&&
this
.
foregroundColor
==
style
.
foregroundColor
&&
this
.
backgroundColor
==
style
.
backgroundColor
&&
this
.
backgroundColor
==
style
.
backgroundColor
...
@@ -200,6 +202,7 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -200,6 +202,7 @@ import com.google.android.exoplayer2.util.Util;
this
.
cuePosition
=
cue
.
position
;
this
.
cuePosition
=
cue
.
position
;
this
.
cuePositionAnchor
=
cue
.
positionAnchor
;
this
.
cuePositionAnchor
=
cue
.
positionAnchor
;
this
.
cueSize
=
cue
.
size
;
this
.
cueSize
=
cue
.
size
;
this
.
cueBitmapHeight
=
cue
.
bitmapHeight
;
this
.
applyEmbeddedStyles
=
applyEmbeddedStyles
;
this
.
applyEmbeddedStyles
=
applyEmbeddedStyles
;
this
.
foregroundColor
=
style
.
foregroundColor
;
this
.
foregroundColor
=
style
.
foregroundColor
;
this
.
backgroundColor
=
style
.
backgroundColor
;
this
.
backgroundColor
=
style
.
backgroundColor
;
...
@@ -312,7 +315,8 @@ import com.google.android.exoplayer2.util.Util;
...
@@ -312,7 +315,8 @@ import com.google.android.exoplayer2.util.Util;
float
anchorX
=
parentLeft
+
(
parentWidth
*
cuePosition
);
float
anchorX
=
parentLeft
+
(
parentWidth
*
cuePosition
);
float
anchorY
=
parentTop
+
(
parentHeight
*
cueLine
);
float
anchorY
=
parentTop
+
(
parentHeight
*
cueLine
);
int
width
=
Math
.
round
(
parentWidth
*
cueSize
);
int
width
=
Math
.
round
(
parentWidth
*
cueSize
);
int
height
=
Math
.
round
(
width
*
((
float
)
cueBitmap
.
getHeight
()
/
cueBitmap
.
getWidth
()));
int
height
=
cueBitmapHeight
!=
-
1
?
Math
.
round
(
parentHeight
*
cueBitmapHeight
)
:
Math
.
round
(
width
*
((
float
)
cueBitmap
.
getHeight
()
/
cueBitmap
.
getWidth
()));
int
x
=
Math
.
round
(
cueLineAnchor
==
Cue
.
ANCHOR_TYPE_END
?
(
anchorX
-
width
)
int
x
=
Math
.
round
(
cueLineAnchor
==
Cue
.
ANCHOR_TYPE_END
?
(
anchorX
-
width
)
:
cueLineAnchor
==
Cue
.
ANCHOR_TYPE_MIDDLE
?
(
anchorX
-
(
width
/
2
))
:
anchorX
);
:
cueLineAnchor
==
Cue
.
ANCHOR_TYPE_MIDDLE
?
(
anchorX
-
(
width
/
2
))
:
anchorX
);
int
y
=
Math
.
round
(
cuePositionAnchor
==
Cue
.
ANCHOR_TYPE_END
?
(
anchorY
-
height
)
int
y
=
Math
.
round
(
cuePositionAnchor
==
Cue
.
ANCHOR_TYPE_END
?
(
anchorY
-
height
)
...
...
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