MediaInspectionServiceImpl extends AbstractJobProducer implements MediaInspectionService, ManagedService { @Override public Job enrich(final MediaPackageElement element, final boolean override) throws MediaInspectionException, MediaPackageException { return enrich(element, override, Options.NO_OPTION); } MediaInspectionServiceImpl(); @Override @Activate void activate(ComponentContext cc); @Override @SuppressWarnings("rawtypes") void updated(Dictionary properties); @Override Job inspect(URI uri); @Override Job inspect(URI uri, final Map<String,String> options); @Override Job enrich(final MediaPackageElement element, final boolean override); @Override Job enrich(final MediaPackageElement element, final boolean override, final Map<String,String> options); @Reference(name = "security-service") void setSecurityService(SecurityService securityService); @Reference(name = "user-directory") void setUserDirectoryService(UserDirectoryService userDirectoryService); @Reference(name = "orgDirectory") void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory); static final float DEFAULT_INSPECT_JOB_LOAD; static final float DEFAULT_ENRICH_JOB_LOAD; static final String INSPECT_JOB_LOAD_KEY; static final String ENRICH_JOB_LOAD_KEY; }
@Test public void testEnrichment() throws Exception { final URI trackUri = getResource("/test.mp4"); for (MediaInspector mi : init(trackUri)) { Track track = mi.inspectTrack(trackUri, Options.NO_OPTION); Checksum cs = track.getChecksum(); track.setChecksum(null); MimeType mt = mimeType("video", "flash"); track.setMimeType(mt); Track newTrack = (Track) mi.enrich(track, false, Options.NO_OPTION); VideoStream[] videoStreams = TrackSupport.byType(newTrack.getStreams(), VideoStream.class); assertTrue(videoStreams[0].getFrameCount() > 0); AudioStream[] audioStreams = TrackSupport.byType(newTrack.getStreams(), AudioStream.class); assertTrue(audioStreams[0].getFrameCount() > 0); assertEquals(newTrack.getChecksum(), cs); assertEquals(newTrack.getMimeType(), mt); assertNotNull(newTrack.getDuration()); assertTrue(newTrack.getDuration() > 0); newTrack = (Track) mi.enrich(track, true, Options.NO_OPTION); assertEquals(newTrack.getChecksum(), cs); assertNotSame(newTrack.getMimeType(), mt); assertTrue(newTrack.getDuration() > 0); } for (MediaInspector mi : init(trackUri)) { Track track = mi.inspectTrack(trackUri, Options.NO_OPTION); Checksum cs = track.getChecksum(); track.setChecksum(null); MimeType mt = mimeType("video", "flash"); track.setMimeType(mt); Track newTrack = (Track) mi.enrich(track, false, Options.NO_OPTION); VideoStream[] videoStreams = TrackSupport.byType(newTrack.getStreams(), VideoStream.class); assertTrue(videoStreams[0].getFrameCount() > 0); AudioStream[] audioStreams = TrackSupport.byType(newTrack.getStreams(), AudioStream.class); assertTrue(audioStreams[0].getFrameCount() > 0); assertEquals(newTrack.getChecksum(), cs); assertEquals(newTrack.getMimeType(), mt); assertNotNull(newTrack.getDuration()); assertTrue(newTrack.getDuration() > 0); newTrack = (Track) mi.enrich(track, true, Options.NO_OPTION); assertEquals(newTrack.getChecksum(), cs); assertNotSame(newTrack.getMimeType(), mt); assertTrue(newTrack.getDuration() > 0); } }
@Test public void testEnrichmentEmptyContainer() throws Exception { final URI trackUri = getResource("/nostreams.mp4"); for (MediaInspector mi : init(trackUri)) { Track track = mi.inspectTrack(trackUri, Options.NO_OPTION); Checksum cs = track.getChecksum(); track.setChecksum(null); MimeType mt = mimeType("video", "flash"); track.setMimeType(mt); Track newTrack = (Track) mi.enrich(track, false, Options.NO_OPTION); assertEquals(newTrack.getChecksum(), cs); assertEquals(newTrack.getMimeType(), mt); assertNull(newTrack.getDuration()); newTrack = (Track) mi.enrich(track, true, Options.NO_OPTION); assertEquals(newTrack.getChecksum(), cs); assertNotSame(newTrack.getMimeType(), mt); assertNull(newTrack.getDuration()); } }