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
8ae8ac79
authored
Jan 11, 2017
by
Julian Cable
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
move Matroska specific things to the MatroskaExtractor
parent
ac988740
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
15 deletions
library/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
library/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java
library/src/main/java/com/google/android/exoplayer2/text/ssa/SSADecoder.java
library/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
View file @
8ae8ac79
...
...
@@ -1498,7 +1498,10 @@ public final class MatroskaExtractor implements Extractor {
break
;
case
CODEC_ID_ASS:
mimeType
=
MimeTypes
.
TEXT_SSA
;
initializationData
=
Collections
.
singletonList
(
codecPrivate
);
initializationData
=
new
ArrayList
<>(
3
);
// this dialogue format is specific to Matroska
initializationData
.
add
(
"Start, End, ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
.
getBytes
());
initializationData
.
add
(
codecPrivate
);
break
;
case
CODEC_ID_VOBSUB:
mimeType
=
MimeTypes
.
APPLICATION_VOBSUB
;
...
...
library/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java
View file @
8ae8ac79
...
...
@@ -25,6 +25,9 @@ import com.google.android.exoplayer2.text.webvtt.Mp4WebvttDecoder;
import
com.google.android.exoplayer2.text.webvtt.WebvttDecoder
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.util.List
;
import
static
android
.
R
.
attr
.
initialKeyguardLayout
;
import
static
android
.
R
.
attr
.
mimeType
;
/**
...
...
@@ -79,8 +82,10 @@ public interface SubtitleDecoderFactory {
throw
new
IllegalArgumentException
(
"Attempted to create decoder for unsupported format"
);
}
if
(
clazz
==
SSADecoder
.
class
)
{
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
(
byte
[].
class
)
.
newInstance
(
format
.
initializationData
.
get
(
0
));
byte
[]
header
=
format
.
initializationData
.
get
(
1
);
byte
[]
dialogueFormat
=
format
.
initializationData
.
get
(
0
);
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
(
byte
[].
class
,
byte
[].
class
)
.
newInstance
(
header
,
dialogueFormat
);
}
if
(
clazz
==
Cea608Decoder
.
class
)
{
return
clazz
.
asSubclass
(
SubtitleDecoder
.
class
).
getConstructor
(
String
.
class
,
Integer
.
TYPE
)
...
...
library/src/main/java/com/google/android/exoplayer2/text/ssa/SSADecoder.java
View file @
8ae8ac79
...
...
@@ -8,12 +8,14 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
import
java.io.UnsupportedEncodingException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
static
android
.
R
.
attr
.
data
;
import
static
android
.
R
.
attr
.
subtitle
;
import
static
android
.
R
.
attr
.
x
;
import
static
android
.
media
.
CamcorderProfile
.
get
;
/**
* Created by cablej01 on 26/12/2016.
...
...
@@ -65,26 +67,23 @@ import static android.R.attr.x;
*/
public
class
SSADecoder
extends
SimpleSubtitleDecoder
{
private
static
final
String
TAG
=
"SSADecoder"
;
private
static
String
defaultDialogueFormat
=
"Start, End, ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
;
private
static
String
defaultStyleFormat
=
"Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding"
;
private
String
[]
dialogueFormat
;
private
String
[]
styleFormat
;
private
String
[]
dialogueFormat
=
null
;
private
String
[]
styleFormat
=
null
;
private
Map
<
String
,
Style
>
styles
=
new
HashMap
<>();
// 0,0,Watamote-internal/narrator,Serinuma,0000,0000,0000, ,The prince should be with the princess.
// , ,style ,name ,L ,R, V ,Effect, text
public
SSADecoder
()
{
super
(
"SSADecoder"
);
dialogueFormat
=
parseKeys
(
defaultDialogueFormat
);
styleFormat
=
parseKeys
(
defaultStyleFormat
);
}
public
SSADecoder
(
byte
[]
header
)
{
public
SSADecoder
(
byte
[]
header
,
byte
[]
dialogueFormatBytes
)
{
super
(
"SSADecoder"
);
styleFormat
=
parseKeys
(
defaultStyleFormat
);
decodeHeader
(
header
,
header
.
length
);
// put back the Matroska format
dialogueFormat
=
parseKeys
(
defaultDialogueFormat
);
try
{
dialogueFormat
=
parseKeys
(
new
String
(
dialogueFormatBytes
,
"UTF-8"
));
}
catch
(
UnsupportedEncodingException
e
)
{
// can't happen?
}
}
/**
...
...
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