FileDocCategorySizeDatePackage
FragmentFileSetTest.javaAPI Docmp4parser 1.0-RC-173082Wed Dec 19 20:10:19 GMT 2012com.googlecode.mp4parser.tools.smoothstreamingfragmenter

FragmentFileSetTest

public class FragmentFileSetTest extends Object

Fields Summary
Constructors Summary
Methods Summary
private voidcopyResource(java.lang.String resource, java.io.File targetDir)

        InputStream is = FragmentFileSetTest.class.getResourceAsStream(resource);
        Assume.assumeNotNull(is);
        int i = resource.lastIndexOf("/");
        String filename;
        if (i == -1) {
            filename = resource;
        } else {
            filename = resource.substring(i + 1);
        }
        try {
            FileOutputStream fos = new FileOutputStream(new File(targetDir, filename));
            IOUtils.copy(is, fos);
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
            Assert.fail(e.getMessage());
        }

    
private java.io.FilecreateTmpDir()

        try {
            File tmpDir = File.createTempFile("FragmentFileSetTest", "testCommandLine");
            Assume.assumeTrue(tmpDir.delete());
            Assume.assumeTrue(tmpDir.mkdir());
            return tmpDir;
        } catch (IOException e) {
            e.printStackTrace();
            Assert.fail(e.getMessage());
        }
        return null;
    
public voidtestCommandLine()

        File tmpDir = createTmpDir();
        File outputDir = createTmpDir();
        copyResource("/smoothstreaming/audio-96000.mp4", tmpDir);
        copyResource("/smoothstreaming/video-128h-75kbps.mp4", tmpDir);
        copyResource("/smoothstreaming/video-192h-155kbps.mp4", tmpDir);
        copyResource("/smoothstreaming/video-240h-231kbps.mp4", tmpDir);
        copyResource("/smoothstreaming/video-320h-388kbps.mp4", tmpDir);

        FragmentFileSet fragmentFileSet = new FragmentFileSet();
        File inputs[] = tmpDir.listFiles();
        Assert.assertNotNull(inputs);
        fragmentFileSet.inputFiles = Arrays.asList(inputs);
        fragmentFileSet.outputDir = outputDir;
        fragmentFileSet.run();
        System.err.println(outputDir);

        Assert.assertTrue(new File(outputDir, "Manifest").exists());
        Assert.assertTrue(new File(outputDir, "video").exists());
        Assert.assertTrue(new File(outputDir, "audio").exists());
        // todo This is merely a smoke test. I should have a better test.
        // but how does this better test look like? Get some samples?
        // search first and last sample of each file for a start?