FileDocCategorySizeDatePackage
TrackRunBoxTest.javaAPI Docmp4parser 1.0-RC-173417Wed Dec 19 20:10:22 GMT 2012com.coremedia.iso.boxes.fragment

TrackRunBoxTest

public class TrackRunBoxTest extends Object

Fields Summary
Constructors Summary
Methods Summary
public voidsimpleRoundTrip(boolean isSampleSizePresent, boolean isSampleDurationPresent, boolean isSampleCompositionTimeOffsetPresent, int dataOffset, SampleFlags sf)

        TrackRunBox trun = new TrackRunBox();
        trun.setFirstSampleFlags(sf);
        trun.setSampleSizePresent(!isSampleSizePresent);
        trun.setSampleSizePresent(isSampleSizePresent);
        trun.setSampleDurationPresent(!isSampleDurationPresent);
        trun.setSampleDurationPresent(isSampleDurationPresent);
        trun.setSampleCompositionTimeOffsetPresent(!isSampleCompositionTimeOffsetPresent);
        trun.setSampleCompositionTimeOffsetPresent(isSampleCompositionTimeOffsetPresent);
        trun.setDataOffset(dataOffset);
        List<TrackRunBox.Entry> entries = new LinkedList<TrackRunBox.Entry>();
        entries.add(new TrackRunBox.Entry(1000, 2000, new SampleFlags(), 3000));
        entries.add(new TrackRunBox.Entry(1001, 2001, new SampleFlags(), 3001));
        trun.setEntries(entries);
        ByteBuffer b = ByteBuffer.allocate(l2i(trun.getSize()));
        trun.getBox(new ByteBufferByteChannel(b));
        b.rewind();
        IsoFile isoFile = new IsoFile(new ByteBufferByteChannel(b));
        TrackRunBox trun2 = (TrackRunBox) isoFile.getBoxes().get(0);

        Assert.assertEquals(trun.isDataOffsetPresent(), trun2.isDataOffsetPresent());
        Assert.assertEquals(trun.isSampleCompositionTimeOffsetPresent(), trun2.isSampleCompositionTimeOffsetPresent());
        Assert.assertEquals(trun.isSampleDurationPresent(), trun2.isSampleDurationPresent());
        Assert.assertEquals(trun.isSampleFlagsPresent(), trun2.isSampleFlagsPresent());
        Assert.assertEquals(trun.isSampleSizePresent(), trun2.isSampleSizePresent());
        Assert.assertEquals(trun.getDataOffset(), trun2.getDataOffset());

        Assert.assertEquals(trun.getDataOffset(), trun2.getDataOffset());
        Assert.assertEquals(trun.getFirstSampleFlags(), trun2.getFirstSampleFlags());


    
public voidtest()

        testAllFlagsWithDataOffset(new SampleFlags(ByteBuffer.wrap(new byte[]{32, 3, 65, 127})));
        testAllFlagsWithDataOffset(null);
    
public voidtestAllFlags(int dataOffset, SampleFlags sf)

        simpleRoundTrip(false, false, false, dataOffset, sf);
        simpleRoundTrip(false, false, true, dataOffset, sf);
        simpleRoundTrip(false, true, false, dataOffset, sf);
        simpleRoundTrip(false, true, true, dataOffset, sf);
        simpleRoundTrip(true, false, false, dataOffset, sf);
        simpleRoundTrip(true, false, true, dataOffset, sf);
        simpleRoundTrip(true, true, false, dataOffset, sf);
        simpleRoundTrip(true, true, true, dataOffset, sf);
    
public voidtestAllFlagsWithDataOffset(SampleFlags sf)

        testAllFlags(-1, sf);
        testAllFlags(1000, sf);