/** Test the compatibility of the Playstation 3 with the MPG format. */ @Test public void testPlaystationVideoMpgCompatibility() { // This test is only useful if the MediaInfo library is available assumeTrue(mediaInfoParserIsValid); RendererConfiguration conf = RendererConfiguration.getRendererConfigurationByName("Playstation 3"); assertNotNull("No renderer named \"Playstation 3\" found.", conf); // Construct regular two channel MPG information DLNAMediaInfo info = new DLNAMediaInfo(); info.setContainer("avi"); DLNAMediaAudio audio = new DLNAMediaAudio(); audio.setCodecA("ac3"); audio.setNrAudioChannels(5); ArrayList<DLNAMediaAudio> audioCodes = new ArrayList<DLNAMediaAudio>(); audioCodes.add(audio); info.setAudioCodes(audioCodes); info.setCodecV("mp4"); Format format = new MPG(); format.match("test.avi"); assertEquals( "PS3 is reported to be incompatible with MPG", true, conf.isCompatible(info, format)); // Construct MPG with wmv codec that the PS3 does not support natively info.setCodecV("wmv"); assertEquals( "PS3 is reported to be compatible with MPG with wmv codec", false, conf.isCompatible(info, format)); }
/** * This method populates the supplied {@link OutputParams} object with the correct audio track * (aid) based on the MediaInfo metadata and PMS configuration settings. * * @param media The MediaInfo metadata for the file. * @param params The parameters to populate. */ public static void setAudioOutputParameters(DLNAMediaInfo media, OutputParams params) { PmsConfiguration configuration = PMS.getConfiguration(params); if (params.aid == null && media != null && media.getFirstAudioTrack() != null) { // check for preferred audio DLNAMediaAudio dtsTrack = null; StringTokenizer st = new StringTokenizer(configuration.getAudioLanguages(), ","); while (st.hasMoreTokens()) { String lang = st.nextToken().trim(); LOGGER.trace("Looking for an audio track with lang: " + lang); for (DLNAMediaAudio audio : media.getAudioTracksList()) { if (audio.matchCode(lang)) { params.aid = audio; LOGGER.trace("Matched audio track: " + audio); return; } if (dtsTrack == null && audio.isDTS()) { dtsTrack = audio; } } } // preferred audio not found, take a default audio track, dts first if available if (dtsTrack != null) { params.aid = dtsTrack; LOGGER.trace("Found priority audio track with DTS: " + dtsTrack); } else { params.aid = media.getAudioTracksList().get(0); LOGGER.trace("Chose a default audio track: " + params.aid); } } }
/** Test the compatibility of the Playstation 3 with the MP3 format. */ @Test public void testPlaystationAudioMp3Compatibility() { // This test is only useful if the MediaInfo library is available assumeTrue(mediaInfoParserIsValid); RendererConfiguration conf = RendererConfiguration.getRendererConfigurationByName("Playstation 3"); assertNotNull("No renderer named \"Playstation 3\" found.", conf); // Construct regular two channel MP3 information DLNAMediaInfo info = new DLNAMediaInfo(); info.setContainer("mp3"); info.setMimeType(HTTPResource.AUDIO_MP3_TYPEMIME); DLNAMediaAudio audio = new DLNAMediaAudio(); audio.setNrAudioChannels(2); ArrayList<DLNAMediaAudio> audioCodes = new ArrayList<DLNAMediaAudio>(); audioCodes.add(audio); info.setAudioCodes(audioCodes); Format format = new MP3(); format.match("test.mp3"); assertEquals( "PS3 is reported to be incompatible with MP3", true, conf.isCompatible(info, format)); // Construct five channel MP3 that the PS3 does not support natively audio.setNrAudioChannels(5); assertEquals( "PS3 is reported to be incompatible with MP3", false, conf.isCompatible(info, format)); }