mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
clean up unused code.
This commit is contained in:
parent
39607551aa
commit
106ebbf7df
5 changed files with 28 additions and 81 deletions
|
|
@ -107,7 +107,7 @@ public class MediaFormat {
|
|||
}
|
||||
|
||||
public static MediaFormat createTx3GFormat() {
|
||||
return createFormatForMimeType(MimeTypes.TEXT_TX3G);
|
||||
return createFormatForMimeType(MimeTypes.APPLICATION_TX3G);
|
||||
}
|
||||
|
||||
public static MediaFormat createFormatForMimeType(String mimeType) {
|
||||
|
|
|
|||
|
|
@ -20,61 +20,29 @@ import java.util.Comparator;
|
|||
|
||||
class SubtitleData implements Comparable <SubtitleData>, Comparator<SubtitleData> {
|
||||
|
||||
private long mStartTimePosUs;
|
||||
private long mEndTimePosUs;
|
||||
private String strSubtitle;
|
||||
public final long startTimePosUs;
|
||||
public final String strSubtitle;
|
||||
|
||||
SubtitleData()
|
||||
SubtitleData(long startTimePosUs, String strSubtitle)
|
||||
{
|
||||
mStartTimePosUs = 0l;
|
||||
mEndTimePosUs = 0l;
|
||||
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;
|
||||
this.startTimePosUs = startTimePosUs;
|
||||
this.strSubtitle = strSubtitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(SubtitleData o1 , SubtitleData o2) {
|
||||
if (o1.getStartTimePos() < o2.getStartTimePos())
|
||||
if (o1.startTimePosUs < o2.startTimePosUs)
|
||||
return -1;
|
||||
if (o1.getStartTimePos() > o2.getStartTimePos())
|
||||
if (o1.startTimePosUs > o2.startTimePosUs)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(SubtitleData another) {
|
||||
if (getStartTimePos() < another.getStartTimePos())
|
||||
if (startTimePosUs < another.startTimePosUs)
|
||||
return -1;
|
||||
if (getStartTimePos() > another.getStartTimePos())
|
||||
if (startTimePosUs > another.startTimePosUs)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,38 +30,20 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple Text parser that supports Tx3g presentation profile.
|
||||
* <p>
|
||||
* Supported features in this parser are:
|
||||
* <ul>
|
||||
* <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>
|
||||
* A simple Text parser that supports tx3g atom.
|
||||
*
|
||||
* Only support to parse a single text track at this version ,
|
||||
* since ExtractorSampleSource does not handle multiple audio/video tracks.
|
||||
*
|
||||
*/
|
||||
public class TextParser implements SubtitleParser {
|
||||
private static final String TAG = "TextParser";
|
||||
|
||||
private final List<SubtitleData> subtitleList;
|
||||
|
||||
private final List<SubtitleData> mSubtitleList;
|
||||
|
||||
/**
|
||||
* Equivalent to {@code TtmlParser(true)}.
|
||||
*/
|
||||
public TextParser() {
|
||||
Log.i(TAG,"TextParser ");
|
||||
mSubtitleList = new LinkedList<SubtitleData>();
|
||||
subtitleList = new LinkedList<SubtitleData>();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -74,29 +56,27 @@ public class TextParser implements SubtitleParser {
|
|||
text = (text == null) ? "" : text;
|
||||
Log.i(TAG,"parse(" + text + "," + startTimeUs + ")" );
|
||||
|
||||
SubtitleData cue = new SubtitleData();
|
||||
cue.setSubtitleText(text);
|
||||
cue.setStartTimePos(startTimeUs);
|
||||
mSubtitleList.add(cue);
|
||||
SubtitleData cue = new SubtitleData(startTimeUs, text);
|
||||
|
||||
Collections.sort(mSubtitleList, new Comparator<SubtitleData>() {
|
||||
subtitleList.add(cue);
|
||||
|
||||
Collections.sort(subtitleList, new Comparator<SubtitleData>() {
|
||||
@Override
|
||||
public int compare(SubtitleData o1 , SubtitleData o2) {
|
||||
if (o1.getStartTimePos() < o2.getStartTimePos())
|
||||
if (o1.startTimePosUs < o2.startTimePosUs)
|
||||
return -1;
|
||||
if (o1.getStartTimePos() > o2.getStartTimePos())
|
||||
if (o1.startTimePosUs > o2.startTimePosUs)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
TextSubtitle textSubtitle = new TextSubtitle(mSubtitleList);
|
||||
TextSubtitle textSubtitle = new TextSubtitle(subtitleList);
|
||||
return textSubtitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canParse(String mimeType) {
|
||||
boolean rtn = MimeTypes.TEXT_TX3G.equals(mimeType);
|
||||
Log.i(TAG,"canParse " + mimeType + "," + rtn);
|
||||
boolean rtn = MimeTypes.APPLICATION_TX3G.equals(mimeType);
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import com.google.android.exoplayer.text.Cue;
|
|||
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 {
|
||||
static String TAG = "TextSubtitle";
|
||||
|
|
@ -47,7 +47,6 @@ public final class TextSubtitle implements Subtitle {
|
|||
|
||||
@Override
|
||||
public int getEventTimeCount() {
|
||||
//LOG.I(TAG,"getEventTimeCount() = " + text.size());
|
||||
return text.size();
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +54,6 @@ public final class TextSubtitle implements Subtitle {
|
|||
public long getEventTime(int index) {
|
||||
if (index > text.size() - 1) return -1;
|
||||
|
||||
//LOG.I(TAG,"getEventTime(" + index + ") = " + text.get(index).getStartTimePos());
|
||||
return text.get(index).getStartTimePos();
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +75,7 @@ public final class TextSubtitle implements Subtitle {
|
|||
}
|
||||
|
||||
private int findTheClosed(long timeUs) {
|
||||
//TODO : Time complexity is O(n),not good solution.
|
||||
|
||||
int length = text.size();
|
||||
for (int i = 0; i < length ; i++) {
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ public class MimeTypes {
|
|||
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_TX3G = BASE_TYPE_TEXT + "/tx3g";
|
||||
|
||||
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_TTML = BASE_TYPE_APPLICATION + "/ttml+xml";
|
||||
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() {}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue