Added the CEA-708 support to the open-source project.
Issue: #1807 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144726542
This commit is contained in:
parent
1ffe7753c6
commit
18a24a1fde
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.text;
|
|||||||
|
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.text.cea.Cea608Decoder;
|
import com.google.android.exoplayer2.text.cea.Cea608Decoder;
|
||||||
|
import com.google.android.exoplayer2.text.cea.Cea708Decoder;
|
||||||
import com.google.android.exoplayer2.text.subrip.SubripDecoder;
|
import com.google.android.exoplayer2.text.subrip.SubripDecoder;
|
||||||
import com.google.android.exoplayer2.text.ttml.TtmlDecoder;
|
import com.google.android.exoplayer2.text.ttml.TtmlDecoder;
|
||||||
import com.google.android.exoplayer2.text.tx3g.Tx3gDecoder;
|
import com.google.android.exoplayer2.text.tx3g.Tx3gDecoder;
|
||||||
@ -58,6 +59,7 @@ public interface SubtitleDecoderFactory {
|
|||||||
* <li>SubRip ({@link SubripDecoder})</li>
|
* <li>SubRip ({@link SubripDecoder})</li>
|
||||||
* <li>TX3G ({@link Tx3gDecoder})</li>
|
* <li>TX3G ({@link Tx3gDecoder})</li>
|
||||||
* <li>Cea608 ({@link Cea608Decoder})</li>
|
* <li>Cea608 ({@link Cea608Decoder})</li>
|
||||||
|
* <li>Cea708 ({@link Cea708Decoder})</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
SubtitleDecoderFactory DEFAULT = new SubtitleDecoderFactory() {
|
SubtitleDecoderFactory DEFAULT = new SubtitleDecoderFactory() {
|
||||||
@ -78,6 +80,9 @@ public interface SubtitleDecoderFactory {
|
|||||||
|| format.sampleMimeType.equals(MimeTypes.APPLICATION_MP4CEA608)) {
|
|| format.sampleMimeType.equals(MimeTypes.APPLICATION_MP4CEA608)) {
|
||||||
return clazz.asSubclass(SubtitleDecoder.class).getConstructor(String.class, Integer.TYPE)
|
return clazz.asSubclass(SubtitleDecoder.class).getConstructor(String.class, Integer.TYPE)
|
||||||
.newInstance(format.sampleMimeType, format.accessibilityChannel);
|
.newInstance(format.sampleMimeType, format.accessibilityChannel);
|
||||||
|
} else if (format.sampleMimeType.equals(MimeTypes.APPLICATION_CEA708)) {
|
||||||
|
return clazz.asSubclass(SubtitleDecoder.class).getConstructor(Integer.TYPE)
|
||||||
|
.newInstance(format.accessibilityChannel);
|
||||||
} else {
|
} else {
|
||||||
return clazz.asSubclass(SubtitleDecoder.class).getConstructor().newInstance();
|
return clazz.asSubclass(SubtitleDecoder.class).getConstructor().newInstance();
|
||||||
}
|
}
|
||||||
@ -105,6 +110,8 @@ public interface SubtitleDecoderFactory {
|
|||||||
case MimeTypes.APPLICATION_CEA608:
|
case MimeTypes.APPLICATION_CEA608:
|
||||||
case MimeTypes.APPLICATION_MP4CEA608:
|
case MimeTypes.APPLICATION_MP4CEA608:
|
||||||
return Class.forName("com.google.android.exoplayer2.text.cea.Cea608Decoder");
|
return Class.forName("com.google.android.exoplayer2.text.cea.Cea608Decoder");
|
||||||
|
case MimeTypes.APPLICATION_CEA708:
|
||||||
|
return Class.forName("com.google.android.exoplayer2.text.cea.Cea708Decoder");
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.text.cea;
|
||||||
|
|
||||||
|
import android.text.Layout.Alignment;
|
||||||
|
import com.google.android.exoplayer2.text.Cue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link Cue} for CEA-708.
|
||||||
|
*/
|
||||||
|
/* package */ final class Cea708Cue extends Cue implements Comparable<Cea708Cue> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An unset priority.
|
||||||
|
*/
|
||||||
|
public static final int PRIORITY_UNSET = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The priority of the cue box.
|
||||||
|
*/
|
||||||
|
public final int priority;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param text See {@link #text}.
|
||||||
|
* @param textAlignment See {@link #textAlignment}.
|
||||||
|
* @param line See {@link #line}.
|
||||||
|
* @param lineType See {@link #lineType}.
|
||||||
|
* @param lineAnchor See {@link #lineAnchor}.
|
||||||
|
* @param position See {@link #position}.
|
||||||
|
* @param positionAnchor See {@link #positionAnchor}.
|
||||||
|
* @param size See {@link #size}.
|
||||||
|
* @param windowColorSet See {@link #windowColorSet}.
|
||||||
|
* @param windowColor See {@link #windowColor}.
|
||||||
|
* @param priority See (@link #priority}.
|
||||||
|
*/
|
||||||
|
public Cea708Cue(CharSequence text, Alignment textAlignment, float line, @LineType int lineType,
|
||||||
|
@AnchorType int lineAnchor, float position, @AnchorType int positionAnchor, float size,
|
||||||
|
boolean windowColorSet, int windowColor, int priority) {
|
||||||
|
super(text, textAlignment, line, lineType, lineAnchor, position, positionAnchor, size,
|
||||||
|
windowColorSet, windowColor);
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Cea708Cue other) {
|
||||||
|
if (other.priority < priority) {
|
||||||
|
return -1;
|
||||||
|
} else if (other.priority > priority) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user