Search in sources :

Example 36 with TrackImpl

use of org.opencastproject.mediapackage.track.TrackImpl in project opencast by opencast.

the class SmilServiceImplTest method testAddClipStartValueBiggerThanDuration.

@Test(expected = SmilException.class)
public void testAddClipStartValueBiggerThanDuration() throws Exception {
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setIdentifier("track-1");
    videoTrack.setFlavor(new MediaPackageElementFlavor("source", "presentation"));
    videoTrack.setURI(new URI("http://hostname/video.mp4"));
    videoTrack.addStream(new VideoStreamImpl());
    videoTrack.setDuration(new Long(1000));
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addClip(smilResponse.getSmil(), null, videoTrack, 1000, 10);
    fail("Sequence start value is equal track duration but SmilService does not throw an SmilException.");
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) SmilResponse(org.opencastproject.smil.api.SmilResponse) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) URI(java.net.URI) Test(org.junit.Test)

Example 37 with TrackImpl

use of org.opencastproject.mediapackage.track.TrackImpl in project opencast by opencast.

the class SmilServiceImplTest method testAddClipWithUnsetTrackDuration.

@Test
public void testAddClipWithUnsetTrackDuration() throws Exception {
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setIdentifier("track-1");
    videoTrack.setFlavor(new MediaPackageElementFlavor("source", "presentation"));
    videoTrack.setURI(new URI("http://hostname/video.mp4"));
    videoTrack.addStream(new VideoStreamImpl());
    // no track duration set
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addClip(smilResponse.getSmil(), null, videoTrack, 0, 10);
    assertTrue("Smil service does not add new par element", smilResponse.getEntitiesCount() > 0);
    assertNotNull(smilResponse.getEntities());
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) SmilResponse(org.opencastproject.smil.api.SmilResponse) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) URI(java.net.URI) Test(org.junit.Test)

Example 38 with TrackImpl

use of org.opencastproject.mediapackage.track.TrackImpl in project opencast by opencast.

the class SmilServiceImplTest method testAddClipWithInvalidTrack.

@Test(expected = SmilException.class)
public void testAddClipWithInvalidTrack() throws Exception {
    TrackImpl videoTrack = new TrackImpl();
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addClip(smilResponse.getSmil(), null, videoTrack, 0, 10);
    fail("SmilException schould be thrown if you try to add an invalid track.");
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) SmilResponse(org.opencastproject.smil.api.SmilResponse) Test(org.junit.Test)

Example 39 with TrackImpl

use of org.opencastproject.mediapackage.track.TrackImpl in project opencast by opencast.

the class SoxServiceTest method testAnalyzeAudio.

@Test
public void testAnalyzeAudio() throws Exception {
    if (!soxInstalled)
        return;
    assertTrue(source.isFile());
    String sourceTrackXml = "<track xmlns=\"http://mediapackage.opencastproject.org\" id=\"track-1\" type=\"presentation/source\"><mimetype>audio/flac</mimetype>" + "<url>http://localhost:8080/workflow/samples/camera.mpg</url>" + "<checksum type=\"md5\">43b7d843b02c4a429b2f547a4f230d31</checksum><duration>14546</duration>" + "<audio><device type=\"UFG03\" version=\"30112007\" vendor=\"Unigraf\" />" + "<encoder type=\"H.264\" version=\"7.4\" vendor=\"Apple Inc\" /><channels>2</channels>" + "<bitdepth>16</bitdepth><samplingrate>44100</samplingrate></audio></track>";
    Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml);
    List<Job> jobs = new ArrayList<Job>();
    for (int i = 0; i < 10; i++) {
        jobs.add(soxService.analyze(sourceTrack));
    }
    boolean success = new JobBarrier(null, serviceRegistry, jobs.toArray(new Job[jobs.size()])).waitForJobs().isSuccess();
    assertTrue(success);
    for (Job j : jobs) {
        // Always check the service registry for the latest version of the job
        Job job = serviceRegistry.getJob(j.getId());
        TrackImpl track = (TrackImpl) MediaPackageElementParser.getFromXml(job.getPayload());
        AudioStream audioStream = track.getAudio().get(0);
        assertEquals(-8.55f, audioStream.getPkLevDb().floatValue(), 0.0002);
        assertEquals(-27.78f, audioStream.getRmsLevDb().floatValue(), 0.0002);
        assertEquals(-20.12f, audioStream.getRmsPkDb().floatValue(), 0.0002);
        assertEquals(Job.Status.FINISHED, job.getStatus());
    }
}
Also used : AudioStream(org.opencastproject.mediapackage.AudioStream) TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) ArrayList(java.util.ArrayList) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 40 with TrackImpl

use of org.opencastproject.mediapackage.track.TrackImpl in project opencast by opencast.

the class SoxServiceTest method testNormalizeDecreaseAudio.

@Test
public void testNormalizeDecreaseAudio() throws Exception {
    if (!soxInstalled)
        return;
    assertTrue(source.isFile());
    String sourceTrackXml = "<track xmlns=\"http://mediapackage.opencastproject.org\" id=\"track-1\" type=\"presentation/source\"><mimetype>audio/flac</mimetype>" + "<url>http://localhost:8080/workflow/samples/camera.mpg</url>" + "<checksum type=\"md5\">43b7d843b02c4a429b2f547a4f230d31</checksum><duration>14546</duration>" + "<audio><device type=\"UFG03\" version=\"30112007\" vendor=\"Unigraf\" />" + "<encoder type=\"H.264\" version=\"7.4\" vendor=\"Apple Inc\" /><channels>2</channels>" + "<bitdepth>16</bitdepth><rmsleveldb>-27.78</rmsleveldb><samplingrate>44100</samplingrate></audio></track>";
    Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml);
    List<Job> jobs = new ArrayList<Job>();
    for (int i = 0; i < 10; i++) {
        jobs.add(soxService.normalize(sourceTrack, -30f));
    }
    boolean success = new JobBarrier(null, serviceRegistry, jobs.toArray(new Job[jobs.size()])).waitForJobs().isSuccess();
    assertTrue(success);
    for (Job j : jobs) {
        // Always check the service registry for the latest version of the job
        Job job = serviceRegistry.getJob(j.getId());
        TrackImpl track = (TrackImpl) MediaPackageElementParser.getFromXml(job.getPayload());
        AudioStream audioStream = track.getAudio().get(0);
        assertEquals(-30f, audioStream.getRmsLevDb().floatValue(), 0.1);
        assertEquals(Job.Status.FINISHED, job.getStatus());
    }
}
Also used : AudioStream(org.opencastproject.mediapackage.AudioStream) TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) ArrayList(java.util.ArrayList) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Aggregations

TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)42 Test (org.junit.Test)21 Track (org.opencastproject.mediapackage.Track)20 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)17 URI (java.net.URI)14 MediaPackage (org.opencastproject.mediapackage.MediaPackage)13 VideoStreamImpl (org.opencastproject.mediapackage.track.VideoStreamImpl)12 WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)11 Job (org.opencastproject.job.api.Job)9 ArrayList (java.util.ArrayList)7 AudioStream (org.opencastproject.mediapackage.AudioStream)7 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)7 File (java.io.File)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 VideoStream (org.opencastproject.mediapackage.VideoStream)6 InputStream (java.io.InputStream)5 SmilResponse (org.opencastproject.smil.api.SmilResponse)5 NotFoundException (org.opencastproject.util.NotFoundException)5 FileInputStream (java.io.FileInputStream)4