예제 #1
0
  public TextTrackImpl() {
    super("subtitles");
    sampleDescriptionBox = new SampleDescriptionBox();
    TextSampleEntry tx3g = new TextSampleEntry("tx3g");
    tx3g.setDataReferenceIndex(1);
    tx3g.setStyleRecord(new TextSampleEntry.StyleRecord());
    tx3g.setBoxRecord(new TextSampleEntry.BoxRecord());
    sampleDescriptionBox.addBox(tx3g);

    FontTableBox ftab = new FontTableBox();
    ftab.setEntries(Collections.singletonList(new FontTableBox.FontRecord(1, "Serif")));

    tx3g.addBox(ftab);

    trackMetaData.setCreationTime(new Date());
    trackMetaData.setModificationTime(new Date());
    trackMetaData.setTimescale(1000); // Text tracks use millieseconds
  }
  private void parse(InputStream fin) throws IOException {
    inputStream = fin;
    bitRateAndFrameSizeTable = new int[19][2][3][2];
    stts = new LinkedList<TimeToSampleBox.Entry>();
    initBitRateAndFrameSizeTable();
    if (!readVariables()) {
      throw new IOException();
    }

    sampleDescriptionBox = new SampleDescriptionBox();
    AudioSampleEntry audioSampleEntry = new AudioSampleEntry("ac-3");
    audioSampleEntry.setChannelCount(2); // According to  ETSI TS 102 366 Annex F
    audioSampleEntry.setSampleRate(samplerate);
    audioSampleEntry.setDataReferenceIndex(1);
    audioSampleEntry.setSampleSize(16);

    AC3SpecificBox ac3 = new AC3SpecificBox();
    ac3.setAcmod(acmod);
    ac3.setBitRateCode(frmsizecod >> 1);
    ac3.setBsid(bsid);
    ac3.setBsmod(bsmod);
    ac3.setFscod(fscod);
    ac3.setLfeon(lfeon);
    ac3.setReserved(0);

    audioSampleEntry.addBox(ac3);
    sampleDescriptionBox.addBox(audioSampleEntry);

    trackMetaData.setCreationTime(new Date());
    trackMetaData.setModificationTime(new Date());
    trackMetaData.setLanguage(lang);
    trackMetaData.setTimescale(samplerate); // Audio tracks always use samplerate as timescale

    samples = new LinkedList<ByteBuffer>();
    if (!readSamples()) {
      throw new IOException();
    }
  }