Search in sources :

Example 66 with MediaPackage

use of org.opencastproject.mediapackage.MediaPackage 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 67 with MediaPackage

use of org.opencastproject.mediapackage.MediaPackage 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 68 with MediaPackage

use of org.opencastproject.mediapackage.MediaPackage 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 69 with MediaPackage

use of org.opencastproject.mediapackage.MediaPackage 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)

Example 70 with MediaPackage

use of org.opencastproject.mediapackage.MediaPackage in project opencast by opencast.

the class OaiPmhUpdatedEventHandler method handleEvent.

public void handleEvent(AssetManagerItem.TakeSnapshot snapshotItem) {
    if (!propagateEpisode) {
        logger.trace("Skipping automatic propagation of episode meta data to OAI-PMH since it is turned off.");
        return;
    }
    // An episode or its ACL has been updated. Construct the MediaPackage and publish it to OAI-PMH.
    logger.debug("Handling update event for media package {}", snapshotItem.getMediapackage().getIdentifier().compact());
    // We must be an administrative user to make a query to the OaiPmhPublicationService
    final User prevUser = securityService.getUser();
    final Organization prevOrg = securityService.getOrganization();
    try {
        securityService.setUser(SecurityUtil.createSystemUser(systemAccount, prevOrg));
        // Check weather the media package contains elements to republish
        MediaPackage snapshotMp = snapshotItem.getMediapackage();
        SimpleElementSelector mpeSelector = new SimpleElementSelector();
        for (String flavor : flavors) {
            mpeSelector.addFlavor(flavor);
        }
        for (String tag : tags) {
            mpeSelector.addTag(tag);
        }
        Collection<MediaPackageElement> elementsToUpdate = mpeSelector.select(snapshotMp, true);
        if (elementsToUpdate == null || elementsToUpdate.isEmpty()) {
            logger.debug("The media package {} does not contain any elements matching the given flavors and tags", snapshotMp.getIdentifier().compact());
            return;
        }
        SearchResult result = oaiPmhPersistence.search(QueryBuilder.query().mediaPackageId(snapshotMp).isDeleted(false).build());
        for (SearchResultItem searchResultItem : result.getItems()) {
            try {
                Job job = oaiPmhPublicationService.updateMetadata(snapshotMp, searchResultItem.getRepository(), flavors, tags, false);
            // we don't want to wait for job completion here because it will block the message queue
            } catch (Exception e) {
                logger.error("Unable to update OAI-PMH publication for the media package {} in repository {}", snapshotItem.getMediapackage().getIdentifier().compact(), searchResultItem.getRepository(), e);
            }
        }
    } finally {
        securityService.setOrganization(prevOrg);
        securityService.setUser(prevUser);
    }
}
Also used : User(org.opencastproject.security.api.User) Organization(org.opencastproject.security.api.Organization) MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) MediaPackage(org.opencastproject.mediapackage.MediaPackage) SearchResultItem(org.opencastproject.oaipmh.persistence.SearchResultItem) SearchResult(org.opencastproject.oaipmh.persistence.SearchResult) SimpleElementSelector(org.opencastproject.mediapackage.selector.SimpleElementSelector) Job(org.opencastproject.job.api.Job) ConfigurationException(org.osgi.service.cm.ConfigurationException)

Aggregations

MediaPackage (org.opencastproject.mediapackage.MediaPackage)407 Test (org.junit.Test)180 NotFoundException (org.opencastproject.util.NotFoundException)108 Job (org.opencastproject.job.api.Job)89 Date (java.util.Date)82 IOException (java.io.IOException)77 URI (java.net.URI)74 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)72 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)70 ArrayList (java.util.ArrayList)69 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)60 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)59 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)55 Path (javax.ws.rs.Path)53 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)52 RestQuery (org.opencastproject.util.doc.rest.RestQuery)52 Track (org.opencastproject.mediapackage.Track)48 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)48 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)45 HashSet (java.util.HashSet)43