com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom Java Examples

The following examples show how to use com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FragmentedMp4Extractor.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) {
  ArrayList<SchemeData> schemeDatas = null;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom child = leafChildren.get(i);
    if (child.type == Atom.TYPE_pssh) {
      if (schemeDatas == null) {
        schemeDatas = new ArrayList<>();
      }
      byte[] psshData = child.data.data;
      UUID uuid = PsshAtomUtil.parseUuid(psshData);
      if (uuid == null) {
        Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
      } else {
        schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
      }
    }
  }
  return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
 
Example #2
Source File: FragmentedMp4Extractor.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<LeafAtom> leafChildren) {
  ArrayList<SchemeData> schemeDatas = null;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom child = leafChildren.get(i);
    if (child.type == Atom.TYPE_pssh) {
      if (schemeDatas == null) {
        schemeDatas = new ArrayList<>();
      }
      byte[] psshData = child.data.data;
      UUID uuid = PsshAtomUtil.parseUuid(psshData);
      if (uuid == null) {
        Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
      } else {
        schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
      }
    }
  }
  return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
 
Example #3
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) {
  ArrayList<SchemeData> schemeDatas = null;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom child = leafChildren.get(i);
    if (child.type == Atom.TYPE_pssh) {
      if (schemeDatas == null) {
        schemeDatas = new ArrayList<>();
      }
      byte[] psshData = child.data.data;
      UUID uuid = PsshAtomUtil.parseUuid(psshData);
      if (uuid == null) {
        Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
      } else {
        schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
      }
    }
  }
  return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
 
Example #4
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) {
  ArrayList<SchemeData> schemeDatas = null;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom child = leafChildren.get(i);
    if (child.type == Atom.TYPE_pssh) {
      if (schemeDatas == null) {
        schemeDatas = new ArrayList<>();
      }
      byte[] psshData = child.data.data;
      UUID uuid = PsshAtomUtil.parseUuid(psshData);
      if (uuid == null) {
        Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
      } else {
        schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
      }
    }
  }
  return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
 
Example #5
Source File: FragmentedMp4Extractor.java    From K-Sonic with MIT License 6 votes vote down vote up
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) {
  ArrayList<SchemeData> schemeDatas = null;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom child = leafChildren.get(i);
    if (child.type == Atom.TYPE_pssh) {
      if (schemeDatas == null) {
        schemeDatas = new ArrayList<>();
      }
      byte[] psshData = child.data.data;
      UUID uuid = PsshAtomUtil.parseUuid(psshData);
      if (uuid == null) {
        Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
      } else {
        schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
      }
    }
  }
  return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
 
Example #6
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/** Returns DrmInitData from leaf atoms. */
private static DrmInitData getDrmInitDataFromAtoms(List<Atom.LeafAtom> leafChildren) {
  ArrayList<SchemeData> schemeDatas = null;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom child = leafChildren.get(i);
    if (child.type == Atom.TYPE_pssh) {
      if (schemeDatas == null) {
        schemeDatas = new ArrayList<>();
      }
      byte[] psshData = child.data.data;
      UUID uuid = PsshAtomUtil.parseUuid(psshData);
      if (uuid == null) {
        Log.w(TAG, "Skipped pssh atom (failed to extract uuid)");
      } else {
        schemeDatas.add(new SchemeData(uuid, MimeTypes.VIDEO_MP4, psshData));
      }
    }
  }
  return schemeDatas == null ? null : new DrmInitData(schemeDatas);
}
 
Example #7
Source File: FragmentedMp4Extractor.java    From K-Sonic with MIT License 5 votes vote down vote up
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
  int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
  if (atomData != null) {
    input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
    onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition());
  } else {
    input.skipFully(atomPayloadSize);
  }
  processAtomEnded(input.getPosition());
}
 
Example #8
Source File: FragmentedMp4Extractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
Example #9
Source File: FragmentedMp4Extractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition);
    segmentIndexEarliestPresentationTimeUs = result.first;
    extractorOutput.seekMap(result.second);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    onEmsgLeafAtomRead(leaf.data);
  }
}
 
Example #10
Source File: FragmentedMp4Extractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
  int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
  if (atomData != null) {
    input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
    onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition());
  } else {
    input.skipFully(atomPayloadSize);
  }
  processAtomEnded(input.getPosition());
}
 
Example #11
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
Example #12
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition);
    segmentIndexEarliestPresentationTimeUs = result.first;
    extractorOutput.seekMap(result.second);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    onEmsgLeafAtomRead(leaf.data);
  }
}
 
Example #13
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
  int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
  if (atomData != null) {
    input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
    onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition());
  } else {
    input.skipFully(atomPayloadSize);
  }
  processAtomEnded(input.getPosition());
}
 
Example #14
Source File: FragmentedMp4Extractor.java    From K-Sonic with MIT License 5 votes vote down vote up
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
Example #15
Source File: FragmentedMp4Extractor.java    From K-Sonic with MIT License 5 votes vote down vote up
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition);
    segmentIndexEarliestPresentationTimeUs = result.first;
    extractorOutput.seekMap(result.second);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    onEmsgLeafAtomRead(leaf.data);
  }
}
 
Example #16
Source File: FragmentedMp4Extractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
  int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
  if (atomData != null) {
    input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
    onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition());
  } else {
    input.skipFully(atomPayloadSize);
  }
  processAtomEnded(input.getPosition());
}
 
Example #17
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
Example #18
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition);
    segmentIndexEarliestPresentationTimeUs = result.first;
    extractorOutput.seekMap(result.second);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    onEmsgLeafAtomRead(leaf.data);
  }
}
 
Example #19
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
  int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
  if (atomData != null) {
    input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
    onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition());
  } else {
    input.skipFully(atomPayloadSize);
  }
  processAtomEnded(input.getPosition());
}
 
Example #20
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
Example #21
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition);
    segmentIndexEarliestPresentationTimeUs = result.first;
    extractorOutput.seekMap(result.second);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    onEmsgLeafAtomRead(leaf.data);
  }
}
 
Example #22
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void readAtomPayload(ExtractorInput input) throws IOException, InterruptedException {
  int atomPayloadSize = (int) atomSize - atomHeaderBytesRead;
  if (atomData != null) {
    input.readFully(atomData.data, Atom.HEADER_SIZE, atomPayloadSize);
    onLeafAtomRead(new LeafAtom(atomType, atomData), input.getPosition());
  } else {
    input.skipFully(atomPayloadSize);
  }
  processAtomEnded(input.getPosition());
}
 
Example #23
Source File: FragmentedMp4Extractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static void parseTruns(ContainerAtom traf, TrackBundle trackBundle, long decodeTime,
    @Flags int flags) {
  int trunCount = 0;
  int totalSampleCount = 0;
  List<LeafAtom> leafChildren = traf.leafChildren;
  int leafChildrenSize = leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = leafChildren.get(i);
    if (atom.type == Atom.TYPE_trun) {
      ParsableByteArray trunData = atom.data;
      trunData.setPosition(Atom.FULL_HEADER_SIZE);
      int trunSampleCount = trunData.readUnsignedIntToInt();
      if (trunSampleCount > 0) {
        totalSampleCount += trunSampleCount;
        trunCount++;
      }
    }
  }
  trackBundle.currentTrackRunIndex = 0;
  trackBundle.currentSampleInTrackRun = 0;
  trackBundle.currentSampleIndex = 0;
  trackBundle.fragment.initTables(trunCount, totalSampleCount);

  int trunIndex = 0;
  int trunStartPosition = 0;
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom trun = leafChildren.get(i);
    if (trun.type == Atom.TYPE_trun) {
      trunStartPosition = parseTrun(trackBundle, trunIndex++, decodeTime, flags, trun.data,
          trunStartPosition);
    }
  }
}
 
Example #24
Source File: FragmentedMp4Extractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition);
    segmentIndexEarliestPresentationTimeUs = result.first;
    extractorOutput.seekMap(result.second);
    haveOutputSeekMap = true;
  } else if (leaf.type == Atom.TYPE_emsg) {
    onEmsgLeafAtomRead(leaf.data);
  }
}
 
Example #25
Source File: FragmentedMp4Extractor.java    From K-Sonic with MIT License 4 votes vote down vote up
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(ContainerAtom traf, SparseArray<TrackBundle> trackBundleArray,
    @Flags int flags, byte[] extendedTypeScratch) throws ParserException {
  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray, flags);
  if (trackBundle == null) {
    return;
  }

  TrackFragment fragment = trackBundle.fragment;
  long decodeTime = fragment.nextFragmentDecodeTime;
  trackBundle.reset();

  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
    decodeTime = parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);
  }

  parseTruns(traf, trackBundle, decodeTime, flags);

  LeafAtom saiz = traf.getLeafAtomOfType(Atom.TYPE_saiz);
  if (saiz != null) {
    TrackEncryptionBox trackEncryptionBox = trackBundle.track
        .sampleDescriptionEncryptionBoxes[fragment.header.sampleDescriptionIndex];
    parseSaiz(trackEncryptionBox, saiz.data, fragment);
  }

  LeafAtom saio = traf.getLeafAtomOfType(Atom.TYPE_saio);
  if (saio != null) {
    parseSaio(saio.data, fragment);
  }

  LeafAtom senc = traf.getLeafAtomOfType(Atom.TYPE_senc);
  if (senc != null) {
    parseSenc(senc.data, fragment);
  }

  LeafAtom sbgp = traf.getLeafAtomOfType(Atom.TYPE_sbgp);
  LeafAtom sgpd = traf.getLeafAtomOfType(Atom.TYPE_sgpd);
  if (sbgp != null && sgpd != null) {
    parseSgpd(sbgp.data, sgpd.data, fragment);
  }

  int leafChildrenSize = traf.leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = traf.leafChildren.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(atom.data, fragment, extendedTypeScratch);
    }
  }
}
 
Example #26
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(ContainerAtom traf, SparseArray<TrackBundle> trackBundleArray,
    @Flags int flags, byte[] extendedTypeScratch) throws ParserException {
  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray);
  if (trackBundle == null) {
    return;
  }

  TrackFragment fragment = trackBundle.fragment;
  long decodeTime = fragment.nextFragmentDecodeTime;
  trackBundle.reset();

  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
    decodeTime = parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);
  }

  parseTruns(traf, trackBundle, decodeTime, flags);

  TrackEncryptionBox encryptionBox = trackBundle.track
      .getSampleDescriptionEncryptionBox(fragment.header.sampleDescriptionIndex);

  LeafAtom saiz = traf.getLeafAtomOfType(Atom.TYPE_saiz);
  if (saiz != null) {
    parseSaiz(encryptionBox, saiz.data, fragment);
  }

  LeafAtom saio = traf.getLeafAtomOfType(Atom.TYPE_saio);
  if (saio != null) {
    parseSaio(saio.data, fragment);
  }

  LeafAtom senc = traf.getLeafAtomOfType(Atom.TYPE_senc);
  if (senc != null) {
    parseSenc(senc.data, fragment);
  }

  LeafAtom sbgp = traf.getLeafAtomOfType(Atom.TYPE_sbgp);
  LeafAtom sgpd = traf.getLeafAtomOfType(Atom.TYPE_sgpd);
  if (sbgp != null && sgpd != null) {
    parseSgpd(sbgp.data, sgpd.data, encryptionBox != null ? encryptionBox.schemeType : null,
        fragment);
  }

  int leafChildrenSize = traf.leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = traf.leafChildren.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(atom.data, fragment, extendedTypeScratch);
    }
  }
}
 
Example #27
Source File: FragmentedMp4Extractor.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(ContainerAtom traf, SparseArray<TrackBundle> trackBundleArray,
    @Flags int flags, byte[] extendedTypeScratch) throws ParserException {
  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray);
  if (trackBundle == null) {
    return;
  }

  TrackFragment fragment = trackBundle.fragment;
  long decodeTime = fragment.nextFragmentDecodeTime;
  trackBundle.reset();

  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
    decodeTime = parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);
  }

  parseTruns(traf, trackBundle, decodeTime, flags);

  TrackEncryptionBox encryptionBox = trackBundle.track
      .getSampleDescriptionEncryptionBox(fragment.header.sampleDescriptionIndex);

  LeafAtom saiz = traf.getLeafAtomOfType(Atom.TYPE_saiz);
  if (saiz != null) {
    parseSaiz(encryptionBox, saiz.data, fragment);
  }

  LeafAtom saio = traf.getLeafAtomOfType(Atom.TYPE_saio);
  if (saio != null) {
    parseSaio(saio.data, fragment);
  }

  LeafAtom senc = traf.getLeafAtomOfType(Atom.TYPE_senc);
  if (senc != null) {
    parseSenc(senc.data, fragment);
  }

  LeafAtom sbgp = traf.getLeafAtomOfType(Atom.TYPE_sbgp);
  LeafAtom sgpd = traf.getLeafAtomOfType(Atom.TYPE_sgpd);
  if (sbgp != null && sgpd != null) {
    parseSgpd(sbgp.data, sgpd.data, encryptionBox != null ? encryptionBox.schemeType : null,
        fragment);
  }

  int leafChildrenSize = traf.leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = traf.leafChildren.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(atom.data, fragment, extendedTypeScratch);
    }
  }
}
 
Example #28
Source File: FragmentedMp4Extractor.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(ContainerAtom traf, SparseArray<TrackBundle> trackBundleArray,
    @Flags int flags, byte[] extendedTypeScratch) throws ParserException {
  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray);
  if (trackBundle == null) {
    return;
  }

  TrackFragment fragment = trackBundle.fragment;
  long decodeTime = fragment.nextFragmentDecodeTime;
  trackBundle.reset();

  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
    decodeTime = parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);
  }

  parseTruns(traf, trackBundle, decodeTime, flags);

  TrackEncryptionBox encryptionBox = trackBundle.track
      .getSampleDescriptionEncryptionBox(fragment.header.sampleDescriptionIndex);

  LeafAtom saiz = traf.getLeafAtomOfType(Atom.TYPE_saiz);
  if (saiz != null) {
    parseSaiz(encryptionBox, saiz.data, fragment);
  }

  LeafAtom saio = traf.getLeafAtomOfType(Atom.TYPE_saio);
  if (saio != null) {
    parseSaio(saio.data, fragment);
  }

  LeafAtom senc = traf.getLeafAtomOfType(Atom.TYPE_senc);
  if (senc != null) {
    parseSenc(senc.data, fragment);
  }

  LeafAtom sbgp = traf.getLeafAtomOfType(Atom.TYPE_sbgp);
  LeafAtom sgpd = traf.getLeafAtomOfType(Atom.TYPE_sgpd);
  if (sbgp != null && sgpd != null) {
    parseSgpd(sbgp.data, sgpd.data, encryptionBox != null ? encryptionBox.schemeType : null,
        fragment);
  }

  int leafChildrenSize = traf.leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = traf.leafChildren.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(atom.data, fragment, extendedTypeScratch);
    }
  }
}
 
Example #29
Source File: FragmentedMp4Extractor.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(ContainerAtom traf, SparseArray<TrackBundle> trackBundleArray,
    @Flags int flags, byte[] extendedTypeScratch) throws ParserException {
  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray);
  if (trackBundle == null) {
    return;
  }

  TrackFragment fragment = trackBundle.fragment;
  long decodeTime = fragment.nextFragmentDecodeTime;
  trackBundle.reset();

  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
    decodeTime = parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);
  }

  parseTruns(traf, trackBundle, decodeTime, flags);

  TrackEncryptionBox encryptionBox = trackBundle.track
      .getSampleDescriptionEncryptionBox(fragment.header.sampleDescriptionIndex);

  LeafAtom saiz = traf.getLeafAtomOfType(Atom.TYPE_saiz);
  if (saiz != null) {
    parseSaiz(encryptionBox, saiz.data, fragment);
  }

  LeafAtom saio = traf.getLeafAtomOfType(Atom.TYPE_saio);
  if (saio != null) {
    parseSaio(saio.data, fragment);
  }

  LeafAtom senc = traf.getLeafAtomOfType(Atom.TYPE_senc);
  if (senc != null) {
    parseSenc(senc.data, fragment);
  }

  LeafAtom sbgp = traf.getLeafAtomOfType(Atom.TYPE_sbgp);
  LeafAtom sgpd = traf.getLeafAtomOfType(Atom.TYPE_sgpd);
  if (sbgp != null && sgpd != null) {
    parseSgpd(sbgp.data, sgpd.data, encryptionBox != null ? encryptionBox.schemeType : null,
        fragment);
  }

  int leafChildrenSize = traf.leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = traf.leafChildren.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(atom.data, fragment, extendedTypeScratch);
    }
  }
}
 
Example #30
Source File: FragmentedMp4Extractor.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(ContainerAtom traf, SparseArray<TrackBundle> trackBundleArray,
    @Flags int flags, byte[] extendedTypeScratch) throws ParserException {
  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray);
  if (trackBundle == null) {
    return;
  }

  TrackFragment fragment = trackBundle.fragment;
  long decodeTime = fragment.nextFragmentDecodeTime;
  trackBundle.reset();

  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
    decodeTime = parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);
  }

  parseTruns(traf, trackBundle, decodeTime, flags);

  TrackEncryptionBox encryptionBox = trackBundle.track
      .getSampleDescriptionEncryptionBox(fragment.header.sampleDescriptionIndex);

  LeafAtom saiz = traf.getLeafAtomOfType(Atom.TYPE_saiz);
  if (saiz != null) {
    parseSaiz(encryptionBox, saiz.data, fragment);
  }

  LeafAtom saio = traf.getLeafAtomOfType(Atom.TYPE_saio);
  if (saio != null) {
    parseSaio(saio.data, fragment);
  }

  LeafAtom senc = traf.getLeafAtomOfType(Atom.TYPE_senc);
  if (senc != null) {
    parseSenc(senc.data, fragment);
  }

  LeafAtom sbgp = traf.getLeafAtomOfType(Atom.TYPE_sbgp);
  LeafAtom sgpd = traf.getLeafAtomOfType(Atom.TYPE_sgpd);
  if (sbgp != null && sgpd != null) {
    parseSgpd(sbgp.data, sgpd.data, encryptionBox != null ? encryptionBox.schemeType : null,
        fragment);
  }

  int leafChildrenSize = traf.leafChildren.size();
  for (int i = 0; i < leafChildrenSize; i++) {
    LeafAtom atom = traf.leafChildren.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(atom.data, fragment, extendedTypeScratch);
    }
  }
}