use of org.opencastproject.mediapackage.MediaPackageElement 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>());
}
use of org.opencastproject.mediapackage.MediaPackageElement 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>());
}
use of org.opencastproject.mediapackage.MediaPackageElement 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>());
}
use of org.opencastproject.mediapackage.MediaPackageElement 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>());
}
use of org.opencastproject.mediapackage.MediaPackageElement 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);
}
}
Aggregations