Search in sources :

Example 21 with SmilResponse

use of org.opencastproject.smil.api.SmilResponse 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 22 with SmilResponse

use of org.opencastproject.smil.api.SmilResponse in project opencast by opencast.

the class SmilServiceImplTest method testAddParallel.

/**
 * Test of addParallel methods, of class SmilServiceImpl.
 */
@Test
public void testAddParallel() throws Exception {
    SmilResponse smilResponse = smilService.createNewSmil();
    smilResponse = smilService.addParallel(smilResponse.getSmil());
    assertNotNull(smilResponse.getSmil().getBody().getMediaElements().get(0));
    assertEquals(smilResponse.getSmil().getBody().getMediaElements().get(0), smilResponse.getEntity());
    assertTrue(smilResponse.getSmil().getBody().getMediaElements().get(0) instanceof SmilMediaParallelImpl);
    SmilMediaContainer par = (SmilMediaContainer) smilResponse.getEntity();
    assertTrue(par.isContainer());
    assertSame(SmilMediaContainer.ContainerType.PAR, par.getContainerType());
    smilResponse = smilService.addParallel(smilResponse.getSmil(), smilResponse.getEntity().getId());
    assertNotNull(smilResponse.getSmil().getBody().getMediaElements().get(0));
    assertTrue(smilResponse.getSmil().getBody().getMediaElements().get(0) instanceof SmilMediaContainer);
    SmilMediaContainer parent = (SmilMediaContainer) smilResponse.getSmil().getBody().getMediaElements().get(0);
    assertNotNull(parent.getElements().get(0));
    assertTrue(parent.getElements().get(0) instanceof SmilMediaParallelImpl);
    assertEquals(parent.getElements().get(0).getId(), smilResponse.getEntity().getId());
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilMediaParallelImpl(org.opencastproject.smil.entity.media.container.SmilMediaParallelImpl) SmilMediaContainer(org.opencastproject.smil.entity.media.container.api.SmilMediaContainer) Test(org.junit.Test)

Example 23 with SmilResponse

use of org.opencastproject.smil.api.SmilResponse 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 24 with SmilResponse

use of org.opencastproject.smil.api.SmilResponse in project opencast by opencast.

the class SmilServiceImpl method addClips.

/**
 * {@inheritDoc}
 */
@Override
public SmilResponse addClips(Smil smil, String parentId, Track[] tracks, long start, long duration) throws SmilException {
    List<SmilObject> trackEntities = new ArrayList<SmilObject>(tracks.length);
    List<SmilObject> otherEntities = new ArrayList<SmilObject>(tracks.length);
    for (Track track : tracks) {
        // add single clip and collect entities from response
        SmilResponse response = addClip(smil, parentId, track, start, duration);
        if (response.getEntitiesCount() == 1) {
            trackEntities.add(response.getEntity());
        } else {
            trackEntities.add(response.getEntities()[0]);
            for (int e = 1; e < response.getEntitiesCount(); e++) {
                otherEntities.add(response.getEntities()[e]);
            }
        }
    }
    // merge entities (track entities first)
    SmilObject[] entities = new SmilObject[trackEntities.size() + otherEntities.size()];
    for (int e = 0; e < entities.length; e++) {
        entities[e] = (e < trackEntities.size() ? trackEntities.get(e) : otherEntities.get(e - trackEntities.size()));
    }
    // create new response
    return new SmilResponseImpl(smil, entities);
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilObject(org.opencastproject.smil.entity.api.SmilObject) ArrayList(java.util.ArrayList) Track(org.opencastproject.mediapackage.Track)

Example 25 with SmilResponse

use of org.opencastproject.smil.api.SmilResponse in project opencast by opencast.

the class SmilResponseImplTest method testGetEntitiesCount.

/**
 * Test of getEntitiesCount method, of class SmilResponseImpl.
 */
@Test
public void testGetEntitiesCount() {
    Smil smil = new SmilImpl();
    SmilResponse response = new SmilResponseImpl(smil);
    assertSame(0, response.getEntitiesCount());
    response = new SmilResponseImpl(smil, smil.getBody());
    assertSame(1, response.getEntitiesCount());
    response = new SmilResponseImpl(smil, new SmilObject[] { smil.getHead(), smil.getBody() });
    assertSame(2, response.getEntitiesCount());
}
Also used : SmilResponse(org.opencastproject.smil.api.SmilResponse) SmilImpl(org.opencastproject.smil.entity.SmilImpl) SmilObject(org.opencastproject.smil.entity.api.SmilObject) Smil(org.opencastproject.smil.entity.api.Smil) Test(org.junit.Test)

Aggregations

SmilResponse (org.opencastproject.smil.api.SmilResponse)30 Test (org.junit.Test)16 Smil (org.opencastproject.smil.entity.api.Smil)11 SmilMediaContainer (org.opencastproject.smil.entity.media.container.api.SmilMediaContainer)10 SmilException (org.opencastproject.smil.api.SmilException)8 URI (java.net.URI)7 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)7 Track (org.opencastproject.mediapackage.Track)7 SmilMediaElement (org.opencastproject.smil.entity.media.element.api.SmilMediaElement)7 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)6 VideoStreamImpl (org.opencastproject.mediapackage.track.VideoStreamImpl)6 SmilObject (org.opencastproject.smil.entity.api.SmilObject)6 SmilMediaObject (org.opencastproject.smil.entity.media.api.SmilMediaObject)6 ArrayList (java.util.ArrayList)5 POST (javax.ws.rs.POST)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)5 SmilImpl (org.opencastproject.smil.entity.SmilImpl)5 SmilMediaParamGroup (org.opencastproject.smil.entity.media.param.api.SmilMediaParamGroup)4