Exemplo n.º 1
0
  /**
   * Gets the chunk sizes for the given track.
   *
   * @param track the track we are talking about
   * @return the size of each chunk in number of samples
   */
  int[] getChunkSizes(Track track) {

    long[] referenceChunkStarts = fragmenter.sampleNumbers(track);
    int[] chunkSizes = new int[referenceChunkStarts.length];

    for (int i = 0; i < referenceChunkStarts.length; i++) {
      long start = referenceChunkStarts[i] - 1;
      long end;
      if (referenceChunkStarts.length == i + 1) {
        end = track.getSamples().size();
      } else {
        end = referenceChunkStarts[i + 1] - 1;
      }

      chunkSizes[i] = l2i(end - start);
      // The Stretch makes sure that there are as much audio and video chunks!
    }
    assert DefaultMp4Builder.this.track2Sample.get(track).size() == sum(chunkSizes)
        : "The number of samples and the sum of all chunk lengths must be equal";
    return chunkSizes;
  }