use of org.opencastproject.sox.api.SoxService in project opencast by opencast.
the class SoxRestServiceTest 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");
job = new JobImpl();
job.setStatus(Job.Status.QUEUED);
job.setJobType(SoxService.JOB_TYPE);
// Train a mock composer with some known behavior
SoxService sox = EasyMock.createNiceMock(SoxService.class);
EasyMock.expect(sox.analyze(audioTrack)).andReturn(job).anyTimes();
EasyMock.expect(sox.normalize(audioTrack, -30f)).andReturn(job).anyTimes();
EasyMock.replay(sox);
// Set up the rest endpoint
restService = new SoxRestService();
restService.setSoxService(sox);
restService.activate(null);
}
use of org.opencastproject.sox.api.SoxService in project opencast by opencast.
the class AnalyzeAudioWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
uriMP = AnalyzeAudioWorkflowOperationHandler.class.getResource("/sox_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
URI soxTrackUri = AnalyzeAudioWorkflowOperationHandler.class.getResource("/sox-track.xml").toURI();
URI soxEncodeUri = AnalyzeAudioWorkflowOperationHandler.class.getResource("/sox-encode-track.xml").toURI();
String soxTrackXml = IOUtils.toString(soxTrackUri.toURL().openStream());
String encodeTrackXml = IOUtils.toString(soxEncodeUri.toURL().openStream());
instance = EasyMock.createNiceMock(WorkflowInstance.class);
EasyMock.expect(instance.getMediaPackage()).andReturn(mp).anyTimes();
EasyMock.expect(instance.getCurrentOperation()).andReturn(operationInstance).anyTimes();
EasyMock.replay(instance);
DefaultOrganization org = new DefaultOrganization();
User anonymous = new JaxbUser("anonymous", "test", org, new JaxbRole(DefaultOrganization.DEFAULT_ORGANIZATION_ANONYMOUS, org));
UserDirectoryService userDirectoryService = EasyMock.createMock(UserDirectoryService.class);
EasyMock.expect(userDirectoryService.loadUser((String) EasyMock.anyObject())).andReturn(anonymous).anyTimes();
EasyMock.replay(userDirectoryService);
Organization organization = new DefaultOrganization();
OrganizationDirectoryService organizationDirectoryService = EasyMock.createMock(OrganizationDirectoryService.class);
EasyMock.expect(organizationDirectoryService.getOrganization((String) EasyMock.anyObject())).andReturn(organization).anyTimes();
EasyMock.replay(organizationDirectoryService);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(anonymous).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(organization).anyTimes();
EasyMock.replay(securityService);
IncidentService incidentService = EasyMock.createNiceMock(IncidentService.class);
EasyMock.replay(incidentService);
ServiceRegistry serviceRegistry = new ServiceRegistryInMemoryImpl(null, securityService, userDirectoryService, organizationDirectoryService, incidentService);
Job analyzeJob = serviceRegistry.createJob(SoxService.JOB_TYPE, "Analyze", null, soxTrackXml, false);
analyzeJob.setStatus(Status.FINISHED);
analyzeJob = serviceRegistry.updateJob(analyzeJob);
Job encodeJob = serviceRegistry.createJob(ComposerService.JOB_TYPE, "Encode", null, encodeTrackXml, false);
encodeJob.setStatus(Status.FINISHED);
encodeJob = serviceRegistry.updateJob(encodeJob);
SoxService sox = EasyMock.createNiceMock(SoxService.class);
EasyMock.expect(sox.analyze((Track) EasyMock.anyObject())).andReturn(analyzeJob).anyTimes();
EasyMock.replay(sox);
ComposerService composer = EasyMock.createNiceMock(ComposerService.class);
EasyMock.expect(composer.encode((Track) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(encodeJob);
EasyMock.replay(composer);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.replay(workspace);
// set up the handler
operationHandler = new AnalyzeAudioWorkflowOperationHandler();
operationHandler.setJobBarrierPollingInterval(0);
operationHandler.setComposerService(composer);
operationHandler.setSoxService(sox);
operationHandler.setWorkspace(workspace);
operationHandler.setServiceRegistry(serviceRegistry);
}
use of org.opencastproject.sox.api.SoxService in project opencast by opencast.
the class NormalizeAudioWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
uriMP = NormalizeAudioWorkflowOperationHandler.class.getResource("/sox_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
URI soxTrackUri = NormalizeAudioWorkflowOperationHandler.class.getResource("/sox-track.xml").toURI();
URI normalizedTrackUri = NormalizeAudioWorkflowOperationHandler.class.getResource("/normalized-track.xml").toURI();
URI soxEncodeUri = NormalizeAudioWorkflowOperationHandler.class.getResource("/sox-encode-track.xml").toURI();
URI soxMuxUri = NormalizeAudioWorkflowOperationHandler.class.getResource("/sox-mux-track.xml").toURI();
String soxTrackXml = IOUtils.toString(soxTrackUri.toURL().openStream());
String encodeTrackXml = IOUtils.toString(soxEncodeUri.toURL().openStream());
String normalizedTrackXml = IOUtils.toString(normalizedTrackUri.toURL().openStream());
String muxedTrackXml = IOUtils.toString(soxMuxUri.toURL().openStream());
instance = EasyMock.createNiceMock(WorkflowInstance.class);
EasyMock.expect(instance.getMediaPackage()).andReturn(mp).anyTimes();
EasyMock.expect(instance.getCurrentOperation()).andReturn(operationInstance).anyTimes();
EasyMock.replay(instance);
DefaultOrganization org = new DefaultOrganization();
User anonymous = new JaxbUser("anonymous", "test", org, new JaxbRole(DefaultOrganization.DEFAULT_ORGANIZATION_ANONYMOUS, org));
UserDirectoryService userDirectoryService = EasyMock.createMock(UserDirectoryService.class);
EasyMock.expect(userDirectoryService.loadUser((String) EasyMock.anyObject())).andReturn(anonymous).anyTimes();
EasyMock.replay(userDirectoryService);
Organization organization = new DefaultOrganization();
OrganizationDirectoryService organizationDirectoryService = EasyMock.createMock(OrganizationDirectoryService.class);
EasyMock.expect(organizationDirectoryService.getOrganization((String) EasyMock.anyObject())).andReturn(organization).anyTimes();
EasyMock.replay(organizationDirectoryService);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(anonymous).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(organization).anyTimes();
EasyMock.replay(securityService);
IncidentService incidentService = EasyMock.createNiceMock(IncidentService.class);
EasyMock.replay(incidentService);
ServiceRegistry serviceRegistry = new ServiceRegistryInMemoryImpl(null, securityService, userDirectoryService, organizationDirectoryService, incidentService);
Job analyzeJob = serviceRegistry.createJob(SoxService.JOB_TYPE, "Analyze", null, soxTrackXml, false);
analyzeJob.setStatus(Status.FINISHED);
analyzeJob = serviceRegistry.updateJob(analyzeJob);
Job normalizeJob = serviceRegistry.createJob(SoxService.JOB_TYPE, "Normalize", null, normalizedTrackXml, false);
normalizeJob.setStatus(Status.FINISHED);
normalizeJob = serviceRegistry.updateJob(normalizeJob);
Job encodeJob = serviceRegistry.createJob(ComposerService.JOB_TYPE, "Encode", null, encodeTrackXml, false);
encodeJob.setStatus(Status.FINISHED);
encodeJob = serviceRegistry.updateJob(encodeJob);
Job muxJob = serviceRegistry.createJob(ComposerService.JOB_TYPE, "Mux", null, muxedTrackXml, false);
muxJob.setStatus(Status.FINISHED);
muxJob = serviceRegistry.updateJob(muxJob);
SoxService sox = EasyMock.createNiceMock(SoxService.class);
EasyMock.expect(sox.analyze((Track) EasyMock.anyObject())).andReturn(analyzeJob).anyTimes();
EasyMock.expect(sox.normalize((Track) EasyMock.anyObject(), (Float) EasyMock.anyObject())).andReturn(normalizeJob).anyTimes();
EasyMock.replay(sox);
ComposerService composer = EasyMock.createNiceMock(ComposerService.class);
EasyMock.expect(composer.encode((Track) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(encodeJob);
EasyMock.expect(composer.mux((Track) EasyMock.anyObject(), (Track) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(muxJob);
EasyMock.replay(composer);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.moveTo((URI) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(new URI("fooVideo.flv"));
EasyMock.replay(workspace);
// set up the handler
operationHandler = new NormalizeAudioWorkflowOperationHandler();
operationHandler.setJobBarrierPollingInterval(0);
operationHandler.setComposerService(composer);
operationHandler.setSoxService(sox);
operationHandler.setWorkspace(workspace);
operationHandler.setServiceRegistry(serviceRegistry);
}
Aggregations