use of org.opencastproject.composer.api.EncodingProfileList in project opencast by opencast.
the class ComposerServiceRemoteImpl method listProfiles.
/**
* {@inheritDoc}
*
* @see org.opencastproject.composer.api.ComposerService#listProfiles()
*/
@Override
public EncodingProfile[] listProfiles() {
HttpGet get = new HttpGet("/profiles.xml");
HttpResponse response = null;
try {
response = getResponse(get);
if (response != null) {
EncodingProfileList profileList = EncodingProfileBuilder.getInstance().parseProfileList(response.getEntity().getContent());
List<EncodingProfileImpl> list = profileList.getProfiles();
return list.toArray(new EncodingProfile[list.size()]);
}
} catch (Exception e) {
throw new RuntimeException("Unable to list the encoding profiles registered with the remote composer service proxy", e);
} finally {
closeConnection(response);
}
throw new RuntimeException("Unable to list the encoding profiles registered with the remote composer service proxy");
}
use of org.opencastproject.composer.api.EncodingProfileList in project opencast by opencast.
the class ComposerRestServiceTest method testProfiles.
@Test
public void testProfiles() throws Exception {
Response response = restService.getProfile(profileId);
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Assert.assertEquals(profile, response.getEntity());
try {
restService.getProfile("some other ID");
Assert.fail("This ID should cause the rest endpoint to throw");
} catch (NotFoundException e) {
// expected
}
EncodingProfileList list = restService.listProfiles();
Assert.assertEquals(profileList, list);
}
use of org.opencastproject.composer.api.EncodingProfileList in project opencast by opencast.
the class ComposerRestServiceTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder();
// Set up our arguments and return values
audioTrack = (Track) builder.newElement(Track.TYPE, MediaPackageElements.PRESENTATION_SOURCE);
audioTrack.setIdentifier("audio1");
videoTrack = (Track) builder.newElement(Track.TYPE, MediaPackageElements.PRESENTATION_SOURCE);
videoTrack.setIdentifier("video1");
profileId = "profile1";
job = new JobImpl(1);
job.setStatus(Job.Status.QUEUED);
job.setJobType(ComposerService.JOB_TYPE);
profile = new EncodingProfileImpl();
profile.setIdentifier(profileId);
List<EncodingProfileImpl> list = new ArrayList<EncodingProfileImpl>();
list.add(profile);
profileList = new EncodingProfileList(list);
// Train a mock composer with some known behavior
ComposerService composer = EasyMock.createNiceMock(ComposerService.class);
EasyMock.expect(composer.encode(videoTrack, profileId)).andReturn(job).anyTimes();
EasyMock.expect(composer.mux(videoTrack, audioTrack, profileId)).andReturn(job).anyTimes();
EasyMock.expect(composer.listProfiles()).andReturn(list.toArray(new EncodingProfile[list.size()]));
EasyMock.expect(composer.getProfile(profileId)).andReturn(profile);
EasyMock.expect(composer.concat(EasyMock.eq(profileId), EasyMock.eq(new Dimension(640, 480)), (Track) EasyMock.notNull(), (Track) EasyMock.notNull())).andReturn(job);
EasyMock.expect(composer.concat(EasyMock.eq(profileId), EasyMock.eq(new Dimension(640, 480)), EasyMock.gt(0.0f), (Track) EasyMock.notNull(), (Track) EasyMock.notNull())).andReturn(job);
EasyMock.replay(composer);
// Set up the rest endpoint
restService = new ComposerRestService();
restService.setComposerService(composer);
restService.activate(null);
}
Aggregations