Search in sources :

Example 6 with DLNAMediaAudio

use of net.pms.dlna.DLNAMediaAudio in project UniversalMediaServer by UniversalMediaServer.

the class FormatRecognitionTest method testPlaystationAudioMp3Compatibility.

/**
 * 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("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.getAudioProperties().setNumberOfChannels(2);
    List<DLNAMediaAudio> audioCodes = new ArrayList<>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    Format format = new MP3();
    format.match("test.mp3");
    assertEquals("PS3 is compatible with MP3", true, conf.isCompatible(info, format, configuration));
    // Construct five channel MP3 that the PS3 does not support natively
    audio.getAudioProperties().setNumberOfChannels(5);
    assertEquals("PS3 is incompatible with five channel MP3", false, conf.isCompatible(info, format, configuration));
}
Also used : DLNAMediaAudio(net.pms.dlna.DLNAMediaAudio) MP3(net.pms.formats.audio.MP3) Format(net.pms.formats.Format) DLNAMediaInfo(net.pms.dlna.DLNAMediaInfo) RendererConfiguration(net.pms.configuration.RendererConfiguration) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with DLNAMediaAudio

use of net.pms.dlna.DLNAMediaAudio in project UniversalMediaServer by UniversalMediaServer.

the class FormatRecognitionTest method testVirtualVideoActionInitializationCompatibility.

/**
 * When PMS is in the process of starting up, something particular happens.
 * The RootFolder is initialized and several VirtualVideoActions are added
 * as children. VirtualVideoActions use the MPG format and at the time of
 * initialization getDefaultRenderer() is used to determine whether or not
 * the format can be streamed.
 * <p>
 * Under these conditions Format.isCompatible() must return true, or
 * selecting the VirtualVideoAction will result in a "Corrupted data"
 * message.
 * <p>
 * This test verifies the case above.
 */
@Test
public void testVirtualVideoActionInitializationCompatibility() {
    boolean configurationLoaded = false;
    try {
        // Initialize PMS configuration like at initialization time, this
        // is relevant for RendererConfiguration.isCompatible().
        PMS.setConfiguration(new PmsConfiguration());
        configurationLoaded = true;
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    // Continue the test if the configuration loaded, otherwise skip it.
    assumeTrue(configurationLoaded);
    // Continue the test if the LibMediaInfoParser can be loaded, otherwise skip it.
    assumeTrue(LibMediaInfoParser.isValid());
    // Construct media info exactly as VirtualVideoAction does
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("mpegps");
    List<DLNAMediaAudio> audioCodes = new ArrayList<>();
    info.setAudioTracksList(audioCodes);
    info.setMimeType("video/mpeg");
    info.setCodecV("mpeg2");
    info.setMediaparsed(true);
    Format format = new MPG();
    format.match("test.mpg");
    // Test without rendererConfiguration, as can happen when plugins
    // create virtual video actions under a folder.
    assertEquals("VirtualVideoAction is initialized as compatible with null configuration", true, format.isCompatible(info, null));
}
Also used : DLNAMediaAudio(net.pms.dlna.DLNAMediaAudio) Format(net.pms.formats.Format) PmsConfiguration(net.pms.configuration.PmsConfiguration) ConfigurationException(org.apache.commons.configuration.ConfigurationException) MPG(net.pms.formats.MPG) DLNAMediaInfo(net.pms.dlna.DLNAMediaInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DLNAMediaAudio (net.pms.dlna.DLNAMediaAudio)7 ArrayList (java.util.ArrayList)4 DLNAMediaInfo (net.pms.dlna.DLNAMediaInfo)4 Format (net.pms.formats.Format)4 Test (org.junit.Test)4 RendererConfiguration (net.pms.configuration.RendererConfiguration)3 MPG (net.pms.formats.MPG)3 PmsConfiguration (net.pms.configuration.PmsConfiguration)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 StringTokenizer (java.util.StringTokenizer)1 MP3 (net.pms.formats.audio.MP3)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 ID3v1Tag (org.jaudiotagger.tag.id3.ID3v1Tag)1