Search in sources :

Example 1 with ComposerService

use of org.opencastproject.composer.api.ComposerService in project opencast by opencast.

the class ComposeWorkflowOperationHandlerTest method testComposeEncodedTrack.

@Test
public void testComposeEncodedTrack() throws Exception {
    // set up mock profile
    profile = EasyMock.createNiceMock(EncodingProfile.class);
    EasyMock.expect(profile.getIdentifier()).andReturn(PROFILE_ID);
    EasyMock.expect(profile.getApplicableMediaType()).andReturn(MediaType.Stream);
    EasyMock.expect(profile.getOutputType()).andReturn(MediaType.AudioVisual);
    EasyMock.expect(profile.getMimeType()).andReturn(MimeTypes.MPEG4.toString()).times(2);
    profileList = new EncodingProfile[] { profile };
    EasyMock.replay(profile);
    // set up mock composer service
    composerService = EasyMock.createNiceMock(ComposerService.class);
    EasyMock.expect(composerService.getProfile(PROFILE_ID)).andReturn(profile);
    EasyMock.expect(composerService.encode((Track) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(job);
    EasyMock.replay(composerService);
    operationHandler.setComposerService(composerService);
    // operation configuration
    String targetTags = "engage,rss";
    Map<String, String> configurations = new HashMap<String, String>();
    configurations.put("source-flavors", "presentation/source");
    configurations.put("target-tags", targetTags);
    configurations.put("target-flavor", "presenter/delivery");
    configurations.put("encoding-profiles", "flash.http");
    // run the operation handler
    WorkflowOperationResult result = getWorkflowOperationResult(mp, configurations);
    // check track metadata
    MediaPackage mpNew = result.getMediaPackage();
    Track trackEncoded = mpNew.getTrack(ENCODED_TRACK_ID);
    Assert.assertEquals("presenter/delivery", trackEncoded.getFlavor().toString());
    Assert.assertArrayEquals(targetTags.split("\\W"), trackEncoded.getTags());
    Assert.assertEquals(SOURCE_TRACK_ID, trackEncoded.getReference().getIdentifier());
}
Also used : HashMap(java.util.HashMap) ComposerService(org.opencastproject.composer.api.ComposerService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) EncodingProfile(org.opencastproject.composer.api.EncodingProfile) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 2 with ComposerService

use of org.opencastproject.composer.api.ComposerService in project opencast by opencast.

the class PartialImportWorkflowOperationHandlerTest method checkForMuxingInputPresenterVideoPresenterAudioNoAudioSuffixExpectsNoMux.

@Test
public void checkForMuxingInputPresenterVideoPresenterAudioNoAudioSuffixExpectsNoMux() throws EncoderException, MediaPackageException, WorkflowOperationException, NotFoundException, ServiceRegistryException, IOException, URISyntaxException {
    // Setup tracks
    Track audioTrack = createTrack(PRESENTER_TARGET_FLAVOR, "audio.mp4", false, true);
    Track videoTrack = createTrack(PRESENTER_TARGET_FLAVOR, "video.mp4", true, false);
    Track[] tracks = { audioTrack, videoTrack };
    // Setup media package
    MediaPackage mediaPackage = EasyMock.createMock(MediaPackage.class);
    EasyMock.expect(mediaPackage.getTracks()).andReturn(tracks).anyTimes();
    ComposerService composerService = EasyMock.createMock(ComposerService.class);
    // Replay all mocks
    EasyMock.replay(composerService, mediaPackage);
    // Make sure that the composer service was not called.
    EasyMock.verify(composerService);
    PartialImportWorkflowOperationHandler handler = new PartialImportWorkflowOperationHandler();
    handler.setComposerService(composerService);
    handler.checkForMuxing(mediaPackage, PRESENTATION_TARGET_FLAVOR, PRESENTER_TARGET_FLAVOR, false, new ArrayList<MediaPackageElement>());
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) ComposerService(org.opencastproject.composer.api.ComposerService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 3 with ComposerService

use of org.opencastproject.composer.api.ComposerService in project opencast by opencast.

the class PartialImportWorkflowOperationHandlerTest method checkForMuxingInputPresenterVideoPresentationAudioExpectsMux.

@Test
public void checkForMuxingInputPresenterVideoPresentationAudioExpectsMux() throws EncoderException, MediaPackageException, WorkflowOperationException, NotFoundException, ServiceRegistryException, IOException, URISyntaxException {
    // Setup tracks
    Track audioTrack = createTrack(PRESENTER_TARGET_FLAVOR, "audio.mp4", false, true);
    Track videoTrack = createTrack(PRESENTATION_TARGET_FLAVOR, "video.mp4", true, false);
    Track[] tracks = { audioTrack, videoTrack };
    // Setup media package
    MediaPackage mediaPackage = EasyMock.createMock(MediaPackage.class);
    EasyMock.expect(mediaPackage.getTracks()).andReturn(tracks).anyTimes();
    // Create a Job for the mux Job to return.
    Job muxJob = EasyMock.createMock(Job.class);
    EasyMock.expect(muxJob.getId()).andReturn(1L);
    // Create the composer service to track muxing of tracks.
    ComposerService composerService = EasyMock.createMock(ComposerService.class);
    EasyMock.expect(composerService.mux(videoTrack, audioTrack, PrepareAVWorkflowOperationHandler.MUX_AV_PROFILE)).andReturn(muxJob);
    // Service Registry
    ServiceRegistry serviceRegistry = EasyMock.createMock(ServiceRegistry.class);
    EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(muxJob);
    // Replay all mocks
    EasyMock.replay(composerService, mediaPackage, serviceRegistry);
    TestPartialImportWorkflowOperationHandler handler = new TestPartialImportWorkflowOperationHandler(videoTrack, audioTrack);
    handler.setComposerService(composerService);
    handler.setServiceRegistry(serviceRegistry);
    handler.checkForMuxing(mediaPackage, PRESENTATION_TARGET_FLAVOR, PRESENTER_TARGET_FLAVOR, false, new ArrayList<MediaPackageElement>());
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) ComposerService(org.opencastproject.composer.api.ComposerService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 4 with ComposerService

use of org.opencastproject.composer.api.ComposerService in project opencast by opencast.

the class PartialImportWorkflowOperationHandlerTest method checkForMuxingInputPresentationVideoPresentationAudioExpectsNoMux.

@Test
public void checkForMuxingInputPresentationVideoPresentationAudioExpectsNoMux() throws EncoderException, MediaPackageException, WorkflowOperationException, NotFoundException, ServiceRegistryException, IOException, URISyntaxException {
    // Setup tracks
    Track audioTrack = createTrack(PRESENTATION_TARGET_FLAVOR, "audio.mp4", false, true);
    Track videoTrack = createTrack(PRESENTATION_TARGET_FLAVOR, "video.mp4", true, false);
    Track[] tracks = { audioTrack, videoTrack };
    // Setup media package
    MediaPackage mediaPackage = EasyMock.createMock(MediaPackage.class);
    EasyMock.expect(mediaPackage.getTracks()).andReturn(tracks).anyTimes();
    ComposerService composerService = EasyMock.createMock(ComposerService.class);
    // Replay all mocks
    EasyMock.replay(composerService, mediaPackage);
    // Make sure that the composer service was not called.
    EasyMock.verify(composerService);
    PartialImportWorkflowOperationHandler handler = new PartialImportWorkflowOperationHandler();
    handler.setComposerService(composerService);
    handler.checkForMuxing(mediaPackage, PRESENTATION_TARGET_FLAVOR, PRESENTER_TARGET_FLAVOR, false, new ArrayList<MediaPackageElement>());
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) ComposerService(org.opencastproject.composer.api.ComposerService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 5 with ComposerService

use of org.opencastproject.composer.api.ComposerService in project opencast by opencast.

the class PartialImportWorkflowOperationHandlerTest method checkForMuxingInputPresentationVideoPresenterAudioExpectsMux.

@Test
public void checkForMuxingInputPresentationVideoPresenterAudioExpectsMux() throws EncoderException, MediaPackageException, WorkflowOperationException, NotFoundException, ServiceRegistryException, IOException, URISyntaxException {
    // Setup tracks
    Track audioTrack = createTrack(PRESENTATION_TARGET_FLAVOR, "audio.mp4", false, true);
    Track videoTrack = createTrack(PRESENTER_TARGET_FLAVOR, "video.mp4", true, false);
    Track[] tracks = { audioTrack, videoTrack };
    // Setup media package
    MediaPackage mediaPackage = EasyMock.createMock(MediaPackage.class);
    EasyMock.expect(mediaPackage.getTracks()).andReturn(tracks).anyTimes();
    // Create a Job for the mux Job to return.
    Job muxJob = EasyMock.createMock(Job.class);
    EasyMock.expect(muxJob.getId()).andReturn(1L);
    // Create the composer service to track muxing of tracks.
    ComposerService composerService = EasyMock.createMock(ComposerService.class);
    EasyMock.expect(composerService.mux(videoTrack, audioTrack, PrepareAVWorkflowOperationHandler.MUX_AV_PROFILE)).andReturn(muxJob);
    // Service Registry
    ServiceRegistry serviceRegistry = EasyMock.createMock(ServiceRegistry.class);
    EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(muxJob);
    // Replay all mocks
    EasyMock.replay(composerService, mediaPackage, serviceRegistry);
    TestPartialImportWorkflowOperationHandler handler = new TestPartialImportWorkflowOperationHandler(videoTrack, audioTrack);
    handler.setComposerService(composerService);
    handler.setServiceRegistry(serviceRegistry);
    handler.checkForMuxing(mediaPackage, PRESENTATION_TARGET_FLAVOR, PRESENTER_TARGET_FLAVOR, false, new ArrayList<MediaPackageElement>());
}
Also used : MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) ComposerService(org.opencastproject.composer.api.ComposerService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Aggregations

ComposerService (org.opencastproject.composer.api.ComposerService)9 Track (org.opencastproject.mediapackage.Track)8 Test (org.junit.Test)6 MediaPackage (org.opencastproject.mediapackage.MediaPackage)5 Job (org.opencastproject.job.api.Job)4 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)4 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)4 Before (org.junit.Before)3 URI (java.net.URI)2 EncodingProfile (org.opencastproject.composer.api.EncodingProfile)2 EncodingProfileImpl (org.opencastproject.composer.api.EncodingProfileImpl)2 MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)2 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)2 JaxbRole (org.opencastproject.security.api.JaxbRole)2 JaxbUser (org.opencastproject.security.api.JaxbUser)2 Organization (org.opencastproject.security.api.Organization)2 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)2 SecurityService (org.opencastproject.security.api.SecurityService)2 User (org.opencastproject.security.api.User)2 UserDirectoryService (org.opencastproject.security.api.UserDirectoryService)2