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
f4f13d91
authored
Apr 09, 2020
by
sneelavara
Committed by
Ian Baker
Apr 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Pass the Clock interface into the constructor
parent
0ef38fcd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java
library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderFactory.java
View file @
f4f13d91
...
@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.text.ttml.TtmlDecoder;
...
@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.text.ttml.TtmlDecoder;
import
com.google.android.exoplayer2.text.tx3g.Tx3gDecoder
;
import
com.google.android.exoplayer2.text.tx3g.Tx3gDecoder
;
import
com.google.android.exoplayer2.text.webvtt.Mp4WebvttDecoder
;
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.Clock
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
/**
/**
...
@@ -108,7 +109,8 @@ public interface SubtitleDecoderFactory {
...
@@ -108,7 +109,8 @@ public interface SubtitleDecoderFactory {
return
new
Tx3gDecoder
(
format
.
initializationData
);
return
new
Tx3gDecoder
(
format
.
initializationData
);
case
MimeTypes
.
APPLICATION_CEA608
:
case
MimeTypes
.
APPLICATION_CEA608
:
case
MimeTypes
.
APPLICATION_MP4CEA608
:
case
MimeTypes
.
APPLICATION_MP4CEA608
:
return
new
Cea608Decoder
(
mimeType
,
format
.
accessibilityChannel
);
return
new
Cea608Decoder
(
mimeType
,
format
.
accessibilityChannel
16000L
,
Clock
.
DEFAULT
);
case
MimeTypes
.
APPLICATION_CEA708
:
case
MimeTypes
.
APPLICATION_CEA708
:
return
new
Cea708Decoder
(
format
.
accessibilityChannel
,
format
.
initializationData
);
return
new
Cea708Decoder
(
format
.
accessibilityChannel
,
format
.
initializationData
);
case
MimeTypes
.
APPLICATION_DVBSUBS
:
case
MimeTypes
.
APPLICATION_DVBSUBS
:
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java
View file @
f4f13d91
...
@@ -31,6 +31,7 @@ import com.google.android.exoplayer2.text.Subtitle;
...
@@ -31,6 +31,7 @@ import com.google.android.exoplayer2.text.Subtitle;
import
com.google.android.exoplayer2.text.SubtitleDecoder
;
import
com.google.android.exoplayer2.text.SubtitleDecoder
;
import
com.google.android.exoplayer2.text.SubtitleInputBuffer
;
import
com.google.android.exoplayer2.text.SubtitleInputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Clock
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
...
@@ -260,18 +261,23 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -260,18 +261,23 @@ public final class Cea608Decoder extends CeaDecoder {
// Static counter to keep track of last CC rendered. This is used to force erase the caption when
// Static counter to keep track of last CC rendered. This is used to force erase the caption when
// the stream does not explicitly send control codes to remove caption as specified by
// the stream does not explicitly send control codes to remove caption as specified by
// CEA-608 Annex C.9
// CEA-608 Annex C.9
private
long
ccTimeOutCounter
=
C
.
TIME_UNSET
;
private
long
lastCueUpdateMs
=
C
.
TIME_UNSET
;
private
boolean
captionEraseCommandSeen
=
false
;
private
boolean
captionEraseCommandSeen
=
false
;
// CEA-608 Annex C.9 propose that if no data are received for the selected caption channel within
// CEA-608 Annex C.9 propose that if no data are received for the selected caption channel within
// a given time, the decoder should automatically erase the caption. The time limit should be no
// a given time, the decoder should automatically erase the caption. The time limit should be no
// less than 16 seconds
// less than 16 seconds
public
static
final
int
VALID_DATA_CHANNEL_TIMEOUT_MS
=
16000
;
public
Cea608Decoder
(
String
mimeType
,
int
accessibilityChannel
)
{
// This value is set in the constructor. The automatic erasure is disabled when this value is 0
private
long
validDataChannelTimeoutMs
=
0
;
private
Clock
clock
;
public
Cea608Decoder
(
String
mimeType
,
int
accessibilityChannel
,
long
timeoutMs
,
Clock
clock
)
{
ccData
=
new
ParsableByteArray
();
ccData
=
new
ParsableByteArray
();
cueBuilders
=
new
ArrayList
<>();
cueBuilders
=
new
ArrayList
<>();
currentCueBuilder
=
new
CueBuilder
(
CC_MODE_UNKNOWN
,
DEFAULT_CAPTIONS_ROW_COUNT
);
currentCueBuilder
=
new
CueBuilder
(
CC_MODE_UNKNOWN
,
DEFAULT_CAPTIONS_ROW_COUNT
);
currentChannel
=
NTSC_CC_CHANNEL_1
;
currentChannel
=
NTSC_CC_CHANNEL_1
;
validDataChannelTimeoutMs
=
timeoutMs
;
this
.
clock
=
clock
;
packetLength
=
MimeTypes
.
APPLICATION_MP4CEA608
.
equals
(
mimeType
)
?
2
:
3
;
packetLength
=
MimeTypes
.
APPLICATION_MP4CEA608
.
equals
(
mimeType
)
?
2
:
3
;
switch
(
accessibilityChannel
)
{
switch
(
accessibilityChannel
)
{
case
1
:
case
1
:
...
@@ -320,7 +326,7 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -320,7 +326,7 @@ public final class Cea608Decoder extends CeaDecoder {
repeatableControlCc2
=
0
;
repeatableControlCc2
=
0
;
currentChannel
=
NTSC_CC_CHANNEL_1
;
currentChannel
=
NTSC_CC_CHANNEL_1
;
isInCaptionService
=
true
;
isInCaptionService
=
true
;
ccTimeOutCounter
=
C
.
TIME_UNSET
;
lastCueUpdateMs
=
C
.
TIME_UNSET
;
}
}
@Override
@Override
...
@@ -433,8 +439,8 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -433,8 +439,8 @@ public final class Cea608Decoder extends CeaDecoder {
if
(
captionDataProcessed
)
{
if
(
captionDataProcessed
)
{
if
(
captionMode
==
CC_MODE_ROLL_UP
||
captionMode
==
CC_MODE_PAINT_ON
)
{
if
(
captionMode
==
CC_MODE_ROLL_UP
||
captionMode
==
CC_MODE_PAINT_ON
)
{
cues
=
getDisplayCues
();
cues
=
getDisplayCues
();
if
(!
captionEraseCommandSeen
)
{
if
(
(
validDataChannelTimeoutMs
!=
0
)
&&
!
captionEraseCommandSeen
)
{
ccTimeOutCounter
=
System
.
currentTimeMillis
();
lastCueUpdateMs
=
clock
.
elapsedRealtime
();
}
}
}
}
}
}
...
@@ -1036,13 +1042,14 @@ public final class Cea608Decoder extends CeaDecoder {
...
@@ -1036,13 +1042,14 @@ public final class Cea608Decoder extends CeaDecoder {
protected
void
clearStuckCaptions
()
protected
void
clearStuckCaptions
()
{
{
if
(
ccTimeOutCounter
!=
C
.
TIME_UNSET
)
{
if
((
validDataChannelTimeoutMs
!=
0
)
&&
long
timeElapsed
=
System
.
currentTimeMillis
()
-
ccTimeOutCounter
;
(
lastCueUpdateMs
!=
C
.
TIME_UNSET
))
{
if
(
timeElapsed
>=
VALID_DATA_CHANNEL_TIMEOUT_MS
)
{
long
timeElapsed
=
clock
.
elapsedRealtime
()
-
lastCueUpdateMs
;
if
(
timeElapsed
>=
validDataChannelTimeoutMs
)
{
// Force erase captions. There might be stale captions stuck on screen.
// Force erase captions. There might be stale captions stuck on screen.
// (CEA-608 Annex C.9)
// (CEA-608 Annex C.9)
cues
=
Collections
.
emptyList
();
cues
=
Collections
.
emptyList
();
ccTimeOutCounter
=
C
.
TIME_UNSET
;
lastCueUpdateMs
=
C
.
TIME_UNSET
;
}
}
}
}
}
}
...
...
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