Search in sources :

Example 6 with ComposerService

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

the class PartialImportWorkflowOperationHandlerTest method testDetermineDimension.

@Test
public void testDetermineDimension() throws Exception {
    // Setup tracks
    VideoStreamImpl videoStream = new VideoStreamImpl("test1");
    videoStream.setFrameWidth(80);
    videoStream.setFrameHeight(30);
    VideoStreamImpl videoStream2 = new VideoStreamImpl("test2");
    videoStream2.setFrameWidth(101);
    videoStream2.setFrameHeight(50);
    TrackImpl videoTrack = new TrackImpl();
    videoTrack.setURI(URI.create("/test"));
    videoTrack.setVideo(Collections.list((VideoStream) videoStream));
    TrackImpl videoTrack2 = new TrackImpl();
    videoTrack2.setURI(URI.create("/test"));
    videoTrack2.setVideo(Collections.list((VideoStream) videoStream2));
    List<Track> tracks = Collections.list((Track) videoTrack, (Track) videoTrack2);
    EncodingProfileImpl encodingProfile = new EncodingProfileImpl();
    encodingProfile.setIdentifier("test");
    ComposerService composerService = EasyMock.createMock(ComposerService.class);
    EasyMock.expect(composerService.concat(encodingProfile.getIdentifier(), Dimension.dimension(101, 50), tracks.toArray(new Track[tracks.size()]))).andReturn(null).once();
    EasyMock.expect(composerService.concat(encodingProfile.getIdentifier(), Dimension.dimension(100, 50), tracks.toArray(new Track[tracks.size()]))).andReturn(null).once();
    EasyMock.replay(composerService);
    PartialImportWorkflowOperationHandler handler = new PartialImportWorkflowOperationHandler();
    handler.setComposerService(composerService);
    handler.startConcatJob(encodingProfile, tracks, -1.0F, false);
    handler.startConcatJob(encodingProfile, tracks, -1.0F, true);
}
Also used : TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) ComposerService(org.opencastproject.composer.api.ComposerService) VideoStream(org.opencastproject.mediapackage.VideoStream) VideoStreamImpl(org.opencastproject.mediapackage.track.VideoStreamImpl) EncodingProfileImpl(org.opencastproject.composer.api.EncodingProfileImpl) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 7 with ComposerService

use of org.opencastproject.composer.api.ComposerService 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)

Example 8 with ComposerService

use of org.opencastproject.composer.api.ComposerService 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);
}
Also used : IncidentService(org.opencastproject.serviceregistry.api.IncidentService) User(org.opencastproject.security.api.User) JaxbUser(org.opencastproject.security.api.JaxbUser) Organization(org.opencastproject.security.api.Organization) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) JaxbUser(org.opencastproject.security.api.JaxbUser) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) URI(java.net.URI) UserDirectoryService(org.opencastproject.security.api.UserDirectoryService) JaxbRole(org.opencastproject.security.api.JaxbRole) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) SecurityService(org.opencastproject.security.api.SecurityService) ComposerService(org.opencastproject.composer.api.ComposerService) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) SoxService(org.opencastproject.sox.api.SoxService) ServiceRegistryInMemoryImpl(org.opencastproject.serviceregistry.api.ServiceRegistryInMemoryImpl) Track(org.opencastproject.mediapackage.Track) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) OrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 9 with ComposerService

use of org.opencastproject.composer.api.ComposerService 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);
}
Also used : IncidentService(org.opencastproject.serviceregistry.api.IncidentService) User(org.opencastproject.security.api.User) JaxbUser(org.opencastproject.security.api.JaxbUser) Organization(org.opencastproject.security.api.Organization) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) JaxbUser(org.opencastproject.security.api.JaxbUser) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) URI(java.net.URI) UserDirectoryService(org.opencastproject.security.api.UserDirectoryService) JaxbRole(org.opencastproject.security.api.JaxbRole) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) SecurityService(org.opencastproject.security.api.SecurityService) ComposerService(org.opencastproject.composer.api.ComposerService) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) SoxService(org.opencastproject.sox.api.SoxService) ServiceRegistryInMemoryImpl(org.opencastproject.serviceregistry.api.ServiceRegistryInMemoryImpl) Track(org.opencastproject.mediapackage.Track) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) OrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

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