mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
move Matroska specific things to the MatroskaExtractor
This commit is contained in:
parent
ac98874021
commit
8ae8ac79bc
3 changed files with 22 additions and 15 deletions
|
|
@ -1498,7 +1498,10 @@ public final class MatroskaExtractor implements Extractor {
|
|||
break;
|
||||
case CODEC_ID_ASS:
|
||||
mimeType = MimeTypes.TEXT_SSA;
|
||||
initializationData = Collections.singletonList(codecPrivate);
|
||||
initializationData = new ArrayList<>(3);
|
||||
// this dialogue format is specific to Matroska
|
||||
initializationData.add("Start, End, ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text".getBytes());
|
||||
initializationData.add(codecPrivate);
|
||||
break;
|
||||
case CODEC_ID_VOBSUB:
|
||||
mimeType = MimeTypes.APPLICATION_VOBSUB;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ import com.google.android.exoplayer2.text.webvtt.Mp4WebvttDecoder;
|
|||
import com.google.android.exoplayer2.text.webvtt.WebvttDecoder;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static android.R.attr.initialKeyguardLayout;
|
||||
import static android.R.attr.mimeType;
|
||||
|
||||
/**
|
||||
|
|
@ -79,8 +82,10 @@ public interface SubtitleDecoderFactory {
|
|||
throw new IllegalArgumentException("Attempted to create decoder for unsupported format");
|
||||
}
|
||||
if(clazz == SSADecoder.class) {
|
||||
return clazz.asSubclass(SubtitleDecoder.class).getConstructor(byte[].class)
|
||||
.newInstance(format.initializationData.get(0));
|
||||
byte[] header = format.initializationData.get(1);
|
||||
byte[] dialogueFormat = format.initializationData.get(0);
|
||||
return clazz.asSubclass(SubtitleDecoder.class).getConstructor(byte[].class, byte[].class)
|
||||
.newInstance(header, dialogueFormat);
|
||||
}
|
||||
if (clazz == Cea608Decoder.class) {
|
||||
return clazz.asSubclass(SubtitleDecoder.class).getConstructor(String.class, Integer.TYPE)
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ import com.google.android.exoplayer2.util.ParsableByteArray;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.R.attr.data;
|
||||
import static android.R.attr.subtitle;
|
||||
import static android.R.attr.x;
|
||||
import static android.media.CamcorderProfile.get;
|
||||
|
||||
/**
|
||||
* Created by cablej01 on 26/12/2016.
|
||||
|
|
@ -65,26 +67,23 @@ import static android.R.attr.x;
|
|||
*/
|
||||
public class SSADecoder extends SimpleSubtitleDecoder {
|
||||
private static final String TAG = "SSADecoder";
|
||||
private static String defaultDialogueFormat = "Start, End, ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text";
|
||||
private static String defaultStyleFormat = "Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding";
|
||||
private String[] dialogueFormat;
|
||||
private String[] styleFormat;
|
||||
private String[] dialogueFormat = null;
|
||||
private String[] styleFormat = null;
|
||||
private Map<String,Style> styles = new HashMap<>();
|
||||
|
||||
// 0,0,Watamote-internal/narrator,Serinuma,0000,0000,0000, ,The prince should be with the princess.
|
||||
// , ,style ,name ,L ,R, V ,Effect, text
|
||||
public SSADecoder() {
|
||||
super("SSADecoder");
|
||||
dialogueFormat = parseKeys(defaultDialogueFormat);
|
||||
styleFormat = parseKeys(defaultStyleFormat);
|
||||
}
|
||||
|
||||
public SSADecoder(byte[] header) {
|
||||
public SSADecoder(byte[] header, byte[] dialogueFormatBytes) {
|
||||
super("SSADecoder");
|
||||
styleFormat = parseKeys(defaultStyleFormat);
|
||||
decodeHeader(header, header.length);
|
||||
// put back the Matroska format
|
||||
dialogueFormat = parseKeys(defaultDialogueFormat);
|
||||
try {
|
||||
dialogueFormat = parseKeys(new String(dialogueFormatBytes, "UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
// can't happen?
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue