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
106ebbf7
authored
Jun 02, 2015
by
ood_tsen
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
clean up unused code.
parent
39607551
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
81 deletions
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
library/src/main/java/com/google/android/exoplayer/text/tx3g/SubtitleData.java
library/src/main/java/com/google/android/exoplayer/text/tx3g/TextParser.java
library/src/main/java/com/google/android/exoplayer/text/tx3g/TextSubtitle.java
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
View file @
106ebbf7
...
@@ -107,7 +107,7 @@ public class MediaFormat {
...
@@ -107,7 +107,7 @@ public class MediaFormat {
}
}
public
static
MediaFormat
createTx3GFormat
()
{
public
static
MediaFormat
createTx3GFormat
()
{
return
createFormatForMimeType
(
MimeTypes
.
TEXT
_TX3G
);
return
createFormatForMimeType
(
MimeTypes
.
APPLICATION
_TX3G
);
}
}
public
static
MediaFormat
createFormatForMimeType
(
String
mimeType
)
{
public
static
MediaFormat
createFormatForMimeType
(
String
mimeType
)
{
...
...
library/src/main/java/com/google/android/exoplayer/text/tx3g/SubtitleData.java
View file @
106ebbf7
...
@@ -20,61 +20,29 @@ import java.util.Comparator;
...
@@ -20,61 +20,29 @@ import java.util.Comparator;
class
SubtitleData
implements
Comparable
<
SubtitleData
>,
Comparator
<
SubtitleData
>
{
class
SubtitleData
implements
Comparable
<
SubtitleData
>,
Comparator
<
SubtitleData
>
{
private
long
mStartTimePosUs
;
public
final
long
startTimePosUs
;
private
long
mEndTimePosUs
;
public
final
String
strSubtitle
;
private
String
strSubtitle
;
SubtitleData
()
SubtitleData
(
long
startTimePosUs
,
String
strSubtitle
)
{
{
mStartTimePosUs
=
0
l
;
this
.
startTimePosUs
=
startTimePosUs
;
mEndTimePosUs
=
0
l
;
this
.
strSubtitle
=
strSubtitle
;
strSubtitle
=
""
;
}
protected
void
setStartTimePos
(
long
time
)
{
mStartTimePosUs
=
time
;
}
protected
void
setEndTimePos
(
long
time
)
{
mEndTimePosUs
=
time
;
}
protected
void
setSubtitleText
(
String
text
)
{
strSubtitle
=
text
;
}
protected
long
getStartTimePos
()
{
return
mStartTimePosUs
;
}
protected
long
getEndTimePos
()
{
return
mEndTimePosUs
;
}
protected
String
getsubtitleText
()
{
return
strSubtitle
;
}
}
@Override
@Override
public
int
compare
(
SubtitleData
o1
,
SubtitleData
o2
)
{
public
int
compare
(
SubtitleData
o1
,
SubtitleData
o2
)
{
if
(
o1
.
getStartTimePos
()
<
o2
.
getStartTimePos
()
)
if
(
o1
.
startTimePosUs
<
o2
.
startTimePosUs
)
return
-
1
;
return
-
1
;
if
(
o1
.
getStartTimePos
()
>
o2
.
getStartTimePos
()
)
if
(
o1
.
startTimePosUs
>
o2
.
startTimePosUs
)
return
1
;
return
1
;
return
0
;
return
0
;
}
}
@Override
@Override
public
int
compareTo
(
SubtitleData
another
)
{
public
int
compareTo
(
SubtitleData
another
)
{
if
(
getStartTimePos
()
<
another
.
getStartTimePos
()
)
if
(
startTimePosUs
<
another
.
startTimePosUs
)
return
-
1
;
return
-
1
;
if
(
getStartTimePos
()
>
another
.
getStartTimePos
()
)
if
(
startTimePosUs
>
another
.
startTimePosUs
)
return
1
;
return
1
;
return
0
;
return
0
;
}
}
...
...
library/src/main/java/com/google/android/exoplayer/text/tx3g/TextParser.java
View file @
106ebbf7
...
@@ -30,38 +30,20 @@ import java.util.LinkedList;
...
@@ -30,38 +30,20 @@ import java.util.LinkedList;
import
java.util.List
;
import
java.util.List
;
/**
/**
* A simple Text parser that supports Tx3g presentation profile.
* A simple Text parser that supports tx3g atom.
* <p>
*
* Supported features in this parser are:
* Only support to parse a single text track at this version ,
* <ul>
* since ExtractorSampleSource does not handle multiple audio/video tracks.
* <li>content
*
* <li>core
* <li>presentation
* <li>profile
* <li>structure
* <li>time-offset
* <li>timing
* <li>tickRate
* <li>time-clock-with-frames
* <li>time-clock
* <li>time-offset-with-frames
* <li>time-offset-with-ticks
* </ul>
* </p>
* @see <a href="http://www.w3.org/TR/ttaf1-dfxp/">TTML specification</a>
*/
*/
public
class
TextParser
implements
SubtitleParser
{
public
class
TextParser
implements
SubtitleParser
{
private
static
final
String
TAG
=
"TextParser"
;
private
static
final
String
TAG
=
"TextParser"
;
private
final
List
<
SubtitleData
>
subtitleList
;
private
final
List
<
SubtitleData
>
mSubtitleList
;
/**
* Equivalent to {@code TtmlParser(true)}.
*/
public
TextParser
()
{
public
TextParser
()
{
Log
.
i
(
TAG
,
"TextParser "
);
Log
.
i
(
TAG
,
"TextParser "
);
mS
ubtitleList
=
new
LinkedList
<
SubtitleData
>();
s
ubtitleList
=
new
LinkedList
<
SubtitleData
>();
}
}
...
@@ -74,29 +56,27 @@ public class TextParser implements SubtitleParser {
...
@@ -74,29 +56,27 @@ public class TextParser implements SubtitleParser {
text
=
(
text
==
null
)
?
""
:
text
;
text
=
(
text
==
null
)
?
""
:
text
;
Log
.
i
(
TAG
,
"parse("
+
text
+
","
+
startTimeUs
+
")"
);
Log
.
i
(
TAG
,
"parse("
+
text
+
","
+
startTimeUs
+
")"
);
SubtitleData
cue
=
new
SubtitleData
();
SubtitleData
cue
=
new
SubtitleData
(
startTimeUs
,
text
);
cue
.
setSubtitleText
(
text
);
cue
.
setStartTimePos
(
startTimeUs
);
subtitleList
.
add
(
cue
);
mSubtitleList
.
add
(
cue
);
Collections
.
sort
(
mS
ubtitleList
,
new
Comparator
<
SubtitleData
>()
{
Collections
.
sort
(
s
ubtitleList
,
new
Comparator
<
SubtitleData
>()
{
@Override
@Override
public
int
compare
(
SubtitleData
o1
,
SubtitleData
o2
)
{
public
int
compare
(
SubtitleData
o1
,
SubtitleData
o2
)
{
if
(
o1
.
getStartTimePos
()
<
o2
.
getStartTimePos
()
)
if
(
o1
.
startTimePosUs
<
o2
.
startTimePosUs
)
return
-
1
;
return
-
1
;
if
(
o1
.
getStartTimePos
()
>
o2
.
getStartTimePos
()
)
if
(
o1
.
startTimePosUs
>
o2
.
startTimePosUs
)
return
1
;
return
1
;
return
0
;
return
0
;
}
}
});
});
TextSubtitle
textSubtitle
=
new
TextSubtitle
(
mS
ubtitleList
);
TextSubtitle
textSubtitle
=
new
TextSubtitle
(
s
ubtitleList
);
return
textSubtitle
;
return
textSubtitle
;
}
}
@Override
@Override
public
boolean
canParse
(
String
mimeType
)
{
public
boolean
canParse
(
String
mimeType
)
{
boolean
rtn
=
MimeTypes
.
TEXT_TX3G
.
equals
(
mimeType
);
boolean
rtn
=
MimeTypes
.
APPLICATION_TX3G
.
equals
(
mimeType
);
Log
.
i
(
TAG
,
"canParse "
+
mimeType
+
","
+
rtn
);
return
rtn
;
return
rtn
;
}
}
}
}
library/src/main/java/com/google/android/exoplayer/text/tx3g/TextSubtitle.java
View file @
106ebbf7
...
@@ -22,7 +22,7 @@ import com.google.android.exoplayer.text.Cue;
...
@@ -22,7 +22,7 @@ import com.google.android.exoplayer.text.Cue;
import
com.google.android.exoplayer.text.Subtitle
;
import
com.google.android.exoplayer.text.Subtitle
;
/**
/**
* A representation of a
TTML
subtitle.
* A representation of a
tx3g
subtitle.
*/
*/
public
final
class
TextSubtitle
implements
Subtitle
{
public
final
class
TextSubtitle
implements
Subtitle
{
static
String
TAG
=
"TextSubtitle"
;
static
String
TAG
=
"TextSubtitle"
;
...
@@ -47,7 +47,6 @@ public final class TextSubtitle implements Subtitle {
...
@@ -47,7 +47,6 @@ public final class TextSubtitle implements Subtitle {
@Override
@Override
public
int
getEventTimeCount
()
{
public
int
getEventTimeCount
()
{
//LOG.I(TAG,"getEventTimeCount() = " + text.size());
return
text
.
size
();
return
text
.
size
();
}
}
...
@@ -55,7 +54,6 @@ public final class TextSubtitle implements Subtitle {
...
@@ -55,7 +54,6 @@ public final class TextSubtitle implements Subtitle {
public
long
getEventTime
(
int
index
)
{
public
long
getEventTime
(
int
index
)
{
if
(
index
>
text
.
size
()
-
1
)
return
-
1
;
if
(
index
>
text
.
size
()
-
1
)
return
-
1
;
//LOG.I(TAG,"getEventTime(" + index + ") = " + text.get(index).getStartTimePos());
return
text
.
get
(
index
).
getStartTimePos
();
return
text
.
get
(
index
).
getStartTimePos
();
}
}
...
@@ -77,6 +75,7 @@ public final class TextSubtitle implements Subtitle {
...
@@ -77,6 +75,7 @@ public final class TextSubtitle implements Subtitle {
}
}
private
int
findTheClosed
(
long
timeUs
)
{
private
int
findTheClosed
(
long
timeUs
)
{
//TODO : Time complexity is O(n),not good solution.
int
length
=
text
.
size
();
int
length
=
text
.
size
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
...
...
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
View file @
106ebbf7
...
@@ -53,12 +53,12 @@ public class MimeTypes {
...
@@ -53,12 +53,12 @@ public class MimeTypes {
public
static
final
String
AUDIO_OPUS
=
BASE_TYPE_AUDIO
+
"/opus"
;
public
static
final
String
AUDIO_OPUS
=
BASE_TYPE_AUDIO
+
"/opus"
;
public
static
final
String
TEXT_VTT
=
BASE_TYPE_TEXT
+
"/vtt"
;
public
static
final
String
TEXT_VTT
=
BASE_TYPE_TEXT
+
"/vtt"
;
public
static
final
String
TEXT_TX3G
=
BASE_TYPE_TEXT
+
"/tx3g"
;
public
static
final
String
APPLICATION_ID3
=
BASE_TYPE_APPLICATION
+
"/id3"
;
public
static
final
String
APPLICATION_ID3
=
BASE_TYPE_APPLICATION
+
"/id3"
;
public
static
final
String
APPLICATION_EIA608
=
BASE_TYPE_APPLICATION
+
"/eia-608"
;
public
static
final
String
APPLICATION_EIA608
=
BASE_TYPE_APPLICATION
+
"/eia-608"
;
public
static
final
String
APPLICATION_TTML
=
BASE_TYPE_APPLICATION
+
"/ttml+xml"
;
public
static
final
String
APPLICATION_TTML
=
BASE_TYPE_APPLICATION
+
"/ttml+xml"
;
public
static
final
String
APPLICATION_M3U8
=
BASE_TYPE_APPLICATION
+
"/x-mpegURL"
;
public
static
final
String
APPLICATION_M3U8
=
BASE_TYPE_APPLICATION
+
"/x-mpegURL"
;
public
static
final
String
APPLICATION_TX3G
=
BASE_TYPE_APPLICATION
+
"/x-quicktime-tx3g"
;
private
MimeTypes
()
{}
private
MimeTypes
()
{}
...
...
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