Java 类com.google.android.exoplayer.parser.mp4.Atom.LeafAtom 实例源码

项目:android-exoplayer    文件:FragmentedMp4Extractor.java   
private int readAtomPayload(NonBlockingInputStream inputStream) {
  int bytesRead;
  if (atomData != null) {
    bytesRead = inputStream.read(atomData.data, atomBytesRead, atomSize - atomBytesRead);
  } else {
    bytesRead = inputStream.skip(atomSize - atomBytesRead);
  }
  if (bytesRead == -1) {
    return RESULT_END_OF_STREAM;
  }
  rootAtomBytesRead += bytesRead;
  atomBytesRead += bytesRead;
  if (atomBytesRead != atomSize) {
    return RESULT_NEED_MORE_DATA;
  }

  int results = 0;
  if (atomData != null) {
    results |= onLeafAtomRead(new LeafAtom(atomType, atomData));
  }

  while (!containerAtomEndPoints.isEmpty()
      && containerAtomEndPoints.peek() == rootAtomBytesRead) {
    containerAtomEndPoints.pop();
    results |= onContainerAtomRead(containerAtoms.pop());
  }

  enterState(STATE_READING_ATOM_HEADER);
  return results;
}
项目:android-exoplayer    文件:FragmentedMp4Extractor.java   
private int onLeafAtomRead(LeafAtom leaf) {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    segmentIndex = parseSidx(leaf.data);
    return RESULT_READ_INDEX;
  }
  return 0;
}
项目:android-exoplayer    文件:FragmentedMp4Extractor.java   
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(Track track, DefaultSampleValues extendsDefaults,
    ContainerAtom traf, TrackFragment out, int workaroundFlags, byte[] extendedTypeScratch) {
  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  long decodeTime = tfdtAtom == null ? 0 : parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);

  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  DefaultSampleValues fragmentHeader = parseTfhd(extendsDefaults, tfhd.data);
  out.sampleDescriptionIndex = fragmentHeader.sampleDescriptionIndex;

  LeafAtom trun = traf.getLeafAtomOfType(Atom.TYPE_trun);
  parseTrun(track, fragmentHeader, decodeTime, workaroundFlags, trun.data, out);

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

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

  int childrenSize = traf.children.size();
  for (int i = 0; i < childrenSize; i++) {
    Atom atom = traf.children.get(i);
    if (atom.type == Atom.TYPE_uuid) {
      parseUuid(((LeafAtom) atom).data, out, extendedTypeScratch);
    }
  }
}
项目:edx-app-android    文件:FragmentedMp4Extractor.java   
private int readAtomPayload(NonBlockingInputStream inputStream) {
  int bytesRead;
  if (atomData != null) {
    bytesRead = inputStream.read(atomData.data, atomBytesRead, atomSize - atomBytesRead);
  } else {
    bytesRead = inputStream.skip(atomSize - atomBytesRead);
  }
  if (bytesRead == -1) {
    return RESULT_END_OF_STREAM;
  }
  rootAtomBytesRead += bytesRead;
  atomBytesRead += bytesRead;
  if (atomBytesRead != atomSize) {
    return RESULT_NEED_MORE_DATA;
  }

  int results = 0;
  if (atomData != null) {
    results |= onLeafAtomRead(new LeafAtom(atomType, atomData));
  }

  while (!containerAtomEndPoints.isEmpty()
      && containerAtomEndPoints.peek() == rootAtomBytesRead) {
    containerAtomEndPoints.pop();
    results |= onContainerAtomRead(containerAtoms.pop());
  }

  enterState(STATE_READING_ATOM_HEADER);
  return results;
}
项目:edx-app-android    文件:FragmentedMp4Extractor.java   
private int onLeafAtomRead(LeafAtom leaf) {
  if (!containerAtoms.isEmpty()) {
    containerAtoms.peek().add(leaf);
  } else if (leaf.type == Atom.TYPE_sidx) {
    segmentIndex = parseSidx(leaf.data);
    return RESULT_READ_INDEX;
  }
  return 0;
}
项目:edx-app-android    文件:FragmentedMp4Extractor.java   
/**
 * Parses a traf atom (defined in 14496-12).
 */
private static void parseTraf(Track track, DefaultSampleValues extendsDefaults,
    ContainerAtom traf, TrackFragment out, int workaroundFlags, byte[] extendedTypeScratch) {
  LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
  long decodeTime = tfdtAtom == null ? 0 : parseTfdt(traf.getLeafAtomOfType(Atom.TYPE_tfdt).data);

  LeafAtom tfhd = traf.getLeafAtomOfType(Atom.TYPE_tfhd);
  DefaultSampleValues fragmentHeader = parseTfhd(extendsDefaults, tfhd.data);
  out.sampleDescriptionIndex = fragmentHeader.sampleDescriptionIndex;

  LeafAtom trun = traf.getLeafAtomOfType(Atom.TYPE_trun);
  parseTrun(track, fragmentHeader, decodeTime, workaroundFlags, trun.data, out);

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

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

  LeafAtom uuid = traf.getLeafAtomOfType(Atom.TYPE_uuid);
  if (uuid != null) {
    parseUuid(uuid.data, out, extendedTypeScratch);
  }
}