本文整理汇总了Java中com.coremedia.iso.boxes.fragment.TrackRunBox类的典型用法代码示例。如果您正苦于以下问题:Java TrackRunBox类的具体用法?Java TrackRunBox怎么用?Java TrackRunBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrackRunBox类属于com.coremedia.iso.boxes.fragment包,在下文中一共展示了TrackRunBox类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMoof
import com.coremedia.iso.boxes.fragment.TrackRunBox; //导入依赖的package包/类
/**
* Creates a 'moof' box for a given sequence of samples.
*
* @param startSample low endpoint (inclusive) of the sample sequence
* @param endSample high endpoint (exclusive) of the sample sequence
* @param track source of the samples
* @param sequenceNumber the fragment index of the requested list of samples
* @return the list of TrackRun boxes.
*/
protected Box createMoof(long startSample, long endSample, Track track, int sequenceNumber) {
MovieFragmentBox moof = new MovieFragmentBox();
moof.addBox(createMfhd(startSample, endSample, track, sequenceNumber));
moof.addBox(createTraf(startSample, endSample, track, sequenceNumber));
TrackRunBox firstTrun = moof.getTrackRunBoxes().get(0);
firstTrun.setDataOffset(1); // dummy to make size correct
firstTrun.setDataOffset((int) (8 + moof.getSize())); // mdat header + moof size
return moof;
}
示例2: getDuration
import com.coremedia.iso.boxes.fragment.TrackRunBox; //导入依赖的package包/类
@Override
public long getDuration() {
long dur = 0;
for (IsoFile fragment : fragments) {
TrackRunBox trun = (TrackRunBox) Path.getPath(fragment, "/moof[0]/traf[0]/trun[0]");
for (TrackRunBox.Entry entry : trun.getEntries()) {
dur += entry.getSampleDuration();
}
}
return dur;
}
示例3: getCompositionTimeEntries
import com.coremedia.iso.boxes.fragment.TrackRunBox; //导入依赖的package包/类
@Override
public List<CompositionTimeToSample.Entry> getCompositionTimeEntries() {
List<CompositionTimeToSample.Entry> entries = new LinkedList<CompositionTimeToSample.Entry>();
for (IsoFile fragment : fragments) {
TrackRunBox trun = (TrackRunBox) Path.getPath(fragment, "/moof[0]/traf[0]/trun[0]");
for (TrackRunBox.Entry entry : trun.getEntries()) {
entries.add(new CompositionTimeToSample.Entry(l2i(entry.getSampleCompositionTimeOffset()), 1));
}
}
return entries;
}
示例4: createTfra
import com.coremedia.iso.boxes.fragment.TrackRunBox; //导入依赖的package包/类
/**
* Creates a 'tfra' - track fragment random access box for the given track with the isoFile.
* The tfra contains a map of random access points with time as key and offset within the isofile
* as value.
*
* @param track the concerned track
* @param isoFile the track is contained in
* @return a track fragment random access box.
*/
protected Box createTfra(Track track, IsoFile isoFile) {
TrackFragmentRandomAccessBox tfra = new TrackFragmentRandomAccessBox();
tfra.setVersion(1); // use long offsets and times
List<TrackFragmentRandomAccessBox.Entry> offset2timeEntries = new LinkedList<TrackFragmentRandomAccessBox.Entry>();
List<Box> boxes = isoFile.getBoxes();
long offset = 0;
long duration = 0;
for (Box box : boxes) {
if (box instanceof MovieFragmentBox) {
List<TrackFragmentBox> trafs = ((MovieFragmentBox) box).getBoxes(TrackFragmentBox.class);
for (int i = 0; i < trafs.size(); i++) {
TrackFragmentBox traf = trafs.get(i);
if (traf.getTrackFragmentHeaderBox().getTrackId() == track.getTrackMetaData().getTrackId()) {
// here we are at the offset required for the current entry.
List<TrackRunBox> truns = traf.getBoxes(TrackRunBox.class);
for (int j = 0; j < truns.size(); j++) {
List<TrackFragmentRandomAccessBox.Entry> offset2timeEntriesThisTrun = new LinkedList<TrackFragmentRandomAccessBox.Entry>();
TrackRunBox trun = truns.get(j);
for (int k = 0; k < trun.getEntries().size(); k++) {
TrackRunBox.Entry trunEntry = trun.getEntries().get(k);
SampleFlags sf = null;
if (k == 0 && trun.isFirstSampleFlagsPresent()) {
sf = trun.getFirstSampleFlags();
} else if (trun.isSampleFlagsPresent()) {
sf = trunEntry.getSampleFlags();
} else {
List<MovieExtendsBox> mvexs = isoFile.getMovieBox().getBoxes(MovieExtendsBox.class);
for (MovieExtendsBox mvex : mvexs) {
List<TrackExtendsBox> trexs = mvex.getBoxes(TrackExtendsBox.class);
for (TrackExtendsBox trex : trexs) {
if (trex.getTrackId() == track.getTrackMetaData().getTrackId()) {
sf = trex.getDefaultSampleFlags();
}
}
}
}
if (sf == null) {
throw new RuntimeException("Could not find any SampleFlags to indicate random access or not");
}
if (sf.getSampleDependsOn() == 2) {
offset2timeEntriesThisTrun.add(new TrackFragmentRandomAccessBox.Entry(
duration,
offset,
i + 1, j + 1, k + 1));
}
duration += trunEntry.getSampleDuration();
}
if (offset2timeEntriesThisTrun.size() == trun.getEntries().size() && trun.getEntries().size() > 0) {
// Oooops every sample seems to be random access sample
// is this an audio track? I don't care.
// I just use the first for trun sample for tfra random access
offset2timeEntries.add(offset2timeEntriesThisTrun.get(0));
} else {
offset2timeEntries.addAll(offset2timeEntriesThisTrun);
}
}
}
}
}
offset += box.getSize();
}
tfra.setEntries(offset2timeEntries);
tfra.setTrackId(track.getTrackMetaData().getTrackId());
return tfra;
}
示例5: getOffsets
import com.coremedia.iso.boxes.fragment.TrackRunBox; //导入依赖的package包/类
Map<Long, Long> getOffsets(MovieFragmentBox moof, long trackId, TrackExtendsBox trex) {
Map<Long, Long> offsets2Sizes = new HashMap<Long, Long>();
List<TrackFragmentBox> traf = moof.getBoxes(TrackFragmentBox.class);
for (TrackFragmentBox trackFragmentBox : traf) {
if (trackFragmentBox.getTrackFragmentHeaderBox().getTrackId() == trackId) {
long baseDataOffset;
if (trackFragmentBox.getTrackFragmentHeaderBox().hasBaseDataOffset()) {
baseDataOffset = trackFragmentBox.getTrackFragmentHeaderBox().getBaseDataOffset();
} else {
baseDataOffset = moof.getOffset();
}
for (TrackRunBox trun : trackFragmentBox.getBoxes(TrackRunBox.class)) {
long sampleBaseOffset = baseDataOffset + trun.getDataOffset();
final TrackFragmentHeaderBox tfhd = ((TrackFragmentBox) trun.getParent()).getTrackFragmentHeaderBox();
long offset = 0;
for (TrackRunBox.Entry entry : trun.getEntries()) {
final long sampleSize;
if (trun.isSampleSizePresent()) {
sampleSize = entry.getSampleSize();
offsets2Sizes.put(offset + sampleBaseOffset, sampleSize);
offset += sampleSize;
} else {
if (tfhd.hasDefaultSampleSize()) {
sampleSize = tfhd.getDefaultSampleSize();
offsets2Sizes.put(offset + sampleBaseOffset, sampleSize);
offset += sampleSize;
} else {
if (trex == null) {
throw new RuntimeException("File doesn't contain trex box but track fragments aren't fully self contained. Cannot determine sample size.");
}
sampleSize = trex.getDefaultSampleSize();
offsets2Sizes.put(offset + sampleBaseOffset, sampleSize);
offset += sampleSize;
}
}
}
}
}
}
return offsets2Sizes;
}