FileDocCategorySizeDatePackage
RoundTripTest.javaAPI Docmp4parser 1.0-RC-174507Wed Dec 19 20:10:22 GMT 2012com.coremedia.drm.packager.isoparser

RoundTripTest

public class RoundTripTest extends TestCase
Tests ISO Roundtrip.

Fields Summary
Constructors Summary
Methods Summary
public static voidcopy(java.io.InputStream input, java.io.OutputStream output)

        assert input != null && output != null;

        byte[] buffer = new byte[4096];
        int count = input.read(buffer);
        while (count > 0) {
            output.write(buffer, 0, count);
            count = input.read(buffer);
        }
    
protected voidsetUp()

        super.setUp();
/*        Logger.getLogger("").setLevel(Level.ALL);
    Handler[] handlers = Logger.getLogger("").getHandlers();
    for (Handler handler : handlers) {
      handler.setLevel(Level.ALL);
    }*/
    
public voidtestRoundTrip_1(java.lang.String resource)


        long start1 = System.currentTimeMillis();
        File originalFile = File.createTempFile("RoundTripTest", "testRoundTrip_1");
        FileOutputStream fos = new FileOutputStream(originalFile);
        IOUtils.copy(getClass().getResourceAsStream(resource), fos);
        fos.close();
        long start2 = System.currentTimeMillis();


        IsoFile isoFile = new IsoFile(new FileInputStream(originalFile).getChannel());
        long start3 = System.currentTimeMillis();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        WritableByteChannel wbc = Channels.newChannel(baos);
        long start4 = System.currentTimeMillis();
        Walk.through(isoFile);
        long start5 = System.currentTimeMillis();
        isoFile.getBox(wbc);
        wbc.close();
        long start6 = System.currentTimeMillis();

     /*   System.err.println("Preparing tmp copy took: " + (start2 - start1) + "ms");
        System.err.println("Parsing took           : " + (start3 - start2) + "ms");
        System.err.println("Writing took           : " + (start6 - start3) + "ms");
        System.err.println("Walking took           : " + (start5 - start4) + "ms");*/

    //    BoxComparator.check(isoFile, new IsoFile(Channels.newChannel(new ByteArrayInputStream(baos.toByteArray()))), "/moov[0]/mvhd[0]", "/moov[0]/trak[0]/tkhd[0]", "/moov[0]/trak[0]/mdia[0]/mdhd[0]");

        byte[] a = IOUtils.toByteArray(getClass().getResourceAsStream(resource));
        byte[] b = baos.toByteArray();
    //    new FileOutputStream("a.mp4").write(a);
    //    new FileOutputStream("b.mp4").write(b);
        Assert.assertArrayEquals(a, b);

    
public voidtestRoundTrip_1a()

        testRoundTrip_1("/multiTrack.3gp");
    
public voidtestRoundTrip_1b()

        testRoundTrip_1("/MOV00006.3gp");
    
public voidtestRoundTrip_1c()

        testRoundTrip_1("/Beethoven - Bagatelle op.119 no.11 i.m4a");
    
public voidtestRoundTrip_1d()

        testRoundTrip_1("/test.m4p");
    
public voidtestRoundTrip_1e()

        testRoundTrip_1("/test-pod.m4a");
    
public voidtestRoundTrip_TinyExamples_Metaxed()

        testRoundTrip_1("/Tiny Sample - NEW - Metaxed.mp4");
    
public voidtestRoundTrip_TinyExamples_Old()

        testRoundTrip_1("/Tiny Sample - OLD.mp4");
    
public voidtestRoundTrip_TinyExamples_Untouched()

        testRoundTrip_1("/Tiny Sample - NEW - Untouched.mp4");