FileDocCategorySizeDatePackage
QuicktimeTextTrackImpl.javaAPI Docmp4parser 1.0-RC-175128Wed Dec 19 20:10:37 GMT 2012com.googlecode.mp4parser.authoring.tracks

QuicktimeTextTrackImpl

public class QuicktimeTextTrackImpl extends com.googlecode.mp4parser.authoring.AbstractTrack
A Text track as Quicktime Pro would create.

Fields Summary
com.googlecode.mp4parser.authoring.TrackMetaData
trackMetaData
SampleDescriptionBox
sampleDescriptionBox
List
subs
Constructors Summary
public QuicktimeTextTrackImpl()

        sampleDescriptionBox = new SampleDescriptionBox();
        QuicktimeTextSampleEntry textTrack = new QuicktimeTextSampleEntry();
        textTrack.setDataReferenceIndex(1);
        sampleDescriptionBox.addBox(textTrack);


        trackMetaData.setCreationTime(new Date());
        trackMetaData.setModificationTime(new Date());
        trackMetaData.setTimescale(1000);


    
Methods Summary
public java.util.ListgetCompositionTimeEntries()

        return null;
    
public java.util.ListgetDecodingTimeEntries()

        List<TimeToSampleBox.Entry> stts = new LinkedList<TimeToSampleBox.Entry>();
        long lastEnd = 0;
        for (Line sub : subs) {
            long silentTime = sub.from - lastEnd;
            if (silentTime > 0) {
                stts.add(new TimeToSampleBox.Entry(1, silentTime));
            } else if (silentTime < 0) {
                throw new Error("Subtitle display times may not intersect");
            }
            stts.add(new TimeToSampleBox.Entry(1, sub.to - sub.from));
            lastEnd = sub.to;
        }
        return stts;
    
public java.lang.StringgetHandler()

        return "text";
    
public BoxgetMediaHeaderBox()

        GenericMediaHeaderAtom ghmd = new GenericMediaHeaderAtom();
        ghmd.addBox(new BaseMediaInfoAtom());
        ghmd.addBox(new GenericMediaHeaderTextAtom());
        return ghmd;
    
public java.util.ListgetSampleDependencies()

        return null;
    
public SampleDescriptionBoxgetSampleDescriptionBox()

        return sampleDescriptionBox;
    
public java.util.ListgetSamples()

        List<ByteBuffer> samples = new LinkedList<ByteBuffer>();
        long lastEnd = 0;
        for (Line sub : subs) {
            long silentTime = sub.from - lastEnd;
            if (silentTime > 0) {
                samples.add(ByteBuffer.wrap(new byte[]{0, 0}));
            } else if (silentTime < 0) {
                throw new Error("Subtitle display times may not intersect");
            }
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream dos = new DataOutputStream(baos);
            try {
                dos.writeShort(sub.text.getBytes("UTF-8").length);
                dos.write(sub.text.getBytes("UTF-8"));
                dos.close();
            } catch (IOException e) {
                throw new Error("VM is broken. Does not support UTF-8");
            }
            samples.add(ByteBuffer.wrap(baos.toByteArray()));
            lastEnd = sub.to;
        }
        return samples;
    
public java.util.ListgetSubs()


       
        return subs;
    
public SubSampleInformationBoxgetSubsampleInformationBox()

        return null;
    
public long[]getSyncSamples()

        return null;
    
public com.googlecode.mp4parser.authoring.TrackMetaDatagetTrackMetaData()

        return trackMetaData;