mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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() {
|
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) {
|
||||||
|
|
|
||||||
|
|
@ -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 = 0l;
|
this.startTimePosUs = startTimePosUs;
|
||||||
mEndTimePosUs = 0l;
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 ");
|
||||||
mSubtitleList = new LinkedList<SubtitleData>();
|
subtitleList = new LinkedList<SubtitleData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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);
|
|
||||||
mSubtitleList.add(cue);
|
|
||||||
|
|
||||||
Collections.sort(mSubtitleList, new Comparator<SubtitleData>() {
|
subtitleList.add(cue);
|
||||||
|
|
||||||
|
Collections.sort(subtitleList, 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(mSubtitleList);
|
TextSubtitle textSubtitle = new TextSubtitle(subtitleList);
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
||||||
@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 {
|
||||||
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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
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++) {
|
||||||
|
|
|
||||||
|
|
@ -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() {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue