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());
}
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());
}
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.");
}
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);
}
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());
}
Aggregations