Search in sources :

Example 1 with EncodingProfileList

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");
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) EncodingProfileList(org.opencastproject.composer.api.EncodingProfileList) HttpResponse(org.apache.http.HttpResponse) EncodingProfileImpl(org.opencastproject.composer.api.EncodingProfileImpl) IOException(java.io.IOException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) EncoderException(org.opencastproject.composer.api.EncoderException)

Example 2 with EncodingProfileList

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);
}
Also used : Response(javax.ws.rs.core.Response) EncodingProfileList(org.opencastproject.composer.api.EncodingProfileList) NotFoundException(org.opencastproject.util.NotFoundException) Test(org.junit.Test)

Example 3 with EncodingProfileList

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);
}
Also used : MediaPackageElementBuilder(org.opencastproject.mediapackage.MediaPackageElementBuilder) JobImpl(org.opencastproject.job.api.JobImpl) ComposerService(org.opencastproject.composer.api.ComposerService) ArrayList(java.util.ArrayList) EncodingProfileList(org.opencastproject.composer.api.EncodingProfileList) EncodingProfile(org.opencastproject.composer.api.EncodingProfile) Dimension(org.opencastproject.composer.layout.Dimension) EncodingProfileImpl(org.opencastproject.composer.api.EncodingProfileImpl) Before(org.junit.Before)

Aggregations

EncodingProfileList (org.opencastproject.composer.api.EncodingProfileList)3 EncodingProfileImpl (org.opencastproject.composer.api.EncodingProfileImpl)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Response (javax.ws.rs.core.Response)1 HttpResponse (org.apache.http.HttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ComposerService (org.opencastproject.composer.api.ComposerService)1 EncoderException (org.opencastproject.composer.api.EncoderException)1 EncodingProfile (org.opencastproject.composer.api.EncodingProfile)1 Dimension (org.opencastproject.composer.layout.Dimension)1 JobImpl (org.opencastproject.job.api.JobImpl)1 MediaPackageElementBuilder (org.opencastproject.mediapackage.MediaPackageElementBuilder)1 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)1 NotFoundException (org.opencastproject.util.NotFoundException)1