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
3e14ce10
authored
Apr 29, 2019
by
Zsolt Matyas
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Code changes suggested by tonihei
parent
2f356bad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
View file @
3e14ce10
...
@@ -83,12 +83,6 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -83,12 +83,6 @@ public final class Cea608Decoder extends CeaDecoder {
private
static
final
byte
CTRL_BACKSPACE
=
0x21
;
private
static
final
byte
CTRL_BACKSPACE
=
0x21
;
@SuppressWarnings
(
"unused"
)
private
static
final
byte
CTRL_ALARM_OFF
=
0x22
;
// not supported any more
@SuppressWarnings
(
"unused"
)
private
static
final
byte
CTRL_ALARM_ON
=
0x23
;
// not supported any more
private
static
final
byte
CTRL_DELETE_TO_END_OF_ROW
=
0x24
;
private
static
final
byte
CTRL_DELETE_TO_END_OF_ROW
=
0x24
;
/**
/**
...
@@ -258,7 +252,7 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -258,7 +252,7 @@ public final class Cea608Decoder extends CeaDecoder {
// The incoming characters may belong to 3 different services based on the last received control
// The incoming characters may belong to 3 different services based on the last received control
// codes. The 3 services are Captioning, Text and XDS. In this decoder we only intend to process
// codes. The 3 services are Captioning, Text and XDS. In this decoder we only intend to process
// bytes belonging to the Captioning service.
// bytes belonging to the Captioning service.
private
boolean
isInCaptionMode
=
true
;
private
boolean
isInCaptionMode
;
public
Cea608Decoder
(
String
mimeType
,
int
accessibilityChannel
)
{
public
Cea608Decoder
(
String
mimeType
,
int
accessibilityChannel
)
{
ccData
=
new
ParsableByteArray
();
ccData
=
new
ParsableByteArray
();
...
@@ -291,6 +285,7 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -291,6 +285,7 @@ public final class Cea608Decoder extends CeaDecoder {
setCaptionMode
(
CC_MODE_UNKNOWN
);
setCaptionMode
(
CC_MODE_UNKNOWN
);
resetCueBuilders
();
resetCueBuilders
();
isInCaptionMode
=
true
;
}
}
@Override
@Override
...
@@ -330,14 +325,14 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -330,14 +325,14 @@ public final class Cea608Decoder extends CeaDecoder {
return
new
CeaSubtitle
(
cues
);
return
new
CeaSubtitle
(
cues
);
}
}
private
boolean
isCodeForUnsupportedMode
(
byte
cc1
,
byte
cc2
)
{
private
static
boolean
isCodeForUnsupportedMode
(
byte
cc1
,
byte
cc2
)
{
// Control codes from 0x01 to 0x0F indicate the beginning of XDS Data
// Control codes from 0x01 to 0x0F indicate the beginning of XDS Data
if
(
0x01
<=
cc1
&&
cc1
<=
0x0F
)
{
if
(
0x01
<=
cc1
&&
cc1
<=
0x0F
)
{
return
true
;
return
true
;
}
}
// 2 commands switch to TEXT mode.
// 2 commands switch to TEXT mode.
if
((
(
cc1
&
0xF7
)
==
0x14
)
// first byte must be 0x14 or 0x1C based on channel
if
((
isModeSwitchCommand
(
cc1
))
&&
(
cc2
==
CTRL_TEXT_RESTART
||
cc2
==
CTRL_RESUME_TEXT_DISPLAY
))
{
&&
(
cc2
==
CTRL_TEXT_RESTART
||
cc2
==
CTRL_RESUME_TEXT_DISPLAY
))
{
return
true
;
return
true
;
}
}
...
@@ -345,8 +340,13 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -345,8 +340,13 @@ public final class Cea608Decoder extends CeaDecoder {
return
false
;
return
false
;
}
}
// first byte of these commands must be 0x14 or 0x1C based on channel
private
static
boolean
isModeSwitchCommand
(
byte
cc1
)
{
return
(
cc1
&
0xF7
)
==
0x14
;
}
private
static
boolean
isControlCodeSwitchingToCaptionMode
(
byte
cc1
,
byte
cc2
)
{
private
static
boolean
isControlCodeSwitchingToCaptionMode
(
byte
cc1
,
byte
cc2
)
{
if
(
(
cc1
&
0xF7
)
!=
0x14
)
{
// Matching commands must have the CC1 value: 0|0|0|1|CH|1|0|0 where CH is the channel bit
if
(
!
isModeSwitchCommand
(
cc1
))
{
return
false
;
return
false
;
}
}
...
...
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