Search in sources :

Example 6 with DLNAMediaSubtitle

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

the class AviSynthFFmpeg method isCompatible.

/**
 * {@inheritDoc}
 */
@Override
public boolean isCompatible(DLNAResource resource) {
    Format format = resource.getFormat();
    if (format != null) {
        if (format.getIdentifier() == Format.Identifier.WEB) {
            return false;
        }
    }
    DLNAMediaSubtitle subtitle = resource.getMediaSubtitle();
    // uninitialized DLNAMediaSubtitle objects have a null language.
    if (subtitle != null && subtitle.getLang() != null) {
        // The resource needs a subtitle, but this engine implementation does not support subtitles yet
        return false;
    }
    try {
        String audioTrackName = resource.getMediaAudio().toString();
        String defaultAudioTrackName = resource.getMedia().getAudioTracksList().get(0).toString();
        if (!audioTrackName.equals(defaultAudioTrackName)) {
            // This engine implementation only supports playback of the default audio track at this time
            return false;
        }
    } catch (NullPointerException e) {
        LOGGER.trace("AviSynth/FFmpeg cannot determine compatibility based on audio track for " + resource.getSystemName());
    } catch (IndexOutOfBoundsException e) {
        LOGGER.trace("AviSynth/FFmpeg cannot determine compatibility based on default audio track for " + resource.getSystemName());
    }
    if (PlayerUtil.isVideo(resource, Format.Identifier.MKV) || PlayerUtil.isVideo(resource, Format.Identifier.MPG) || PlayerUtil.isVideo(resource, Format.Identifier.OGG)) {
        return true;
    }
    return false;
}
Also used : DLNAMediaSubtitle(net.pms.dlna.DLNAMediaSubtitle) Format(net.pms.formats.Format)

Example 7 with DLNAMediaSubtitle

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

the class SubtitleUtilsTest method testGetSubCpOptionForMencoder_withoutDetectedCharset.

@Test
public void testGetSubCpOptionForMencoder_withoutDetectedCharset() throws Exception {
    DLNAMediaSubtitle subtitle = new DLNAMediaSubtitle();
    File file_cp1251 = FileUtils.toFile(CLASS.getResource("../../util/russian-cp1251.srt"));
    subtitle.setType(VOBSUB);
    subtitle.setExternalFile(file_cp1251, null);
    assertThat(subtitle.getSubCharacterSet()).isNull();
    assertThat(getSubCpOptionForMencoder(subtitle)).isNull();
}
Also used : DLNAMediaSubtitle(net.pms.dlna.DLNAMediaSubtitle) File(java.io.File) Test(org.junit.Test)

Example 8 with DLNAMediaSubtitle

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

the class SubtitleUtilsTest method testGetSubCpOptionForMencoder.

@Test
public void testGetSubCpOptionForMencoder() throws Exception {
    File file_big5 = FileUtils.toFile(CLASS.getResource("../../util/chinese-big5.srt"));
    DLNAMediaSubtitle sub1 = new DLNAMediaSubtitle();
    sub1.setExternalFile(file_big5, null);
    assertThat(getSubCpOptionForMencoder(sub1)).isEqualTo("enca:zh:big5");
    File file_gb18030 = FileUtils.toFile(CLASS.getResource("../../util/chinese-gb18030.srt"));
    DLNAMediaSubtitle sub2 = new DLNAMediaSubtitle();
    sub2.setExternalFile(file_gb18030, null);
    assertThat(getSubCpOptionForMencoder(sub2)).isEqualTo("enca:zh:big5");
    File file_cp1251 = FileUtils.toFile(CLASS.getResource("../../util/russian-cp1251.srt"));
    DLNAMediaSubtitle sub3 = new DLNAMediaSubtitle();
    sub3.setExternalFile(file_cp1251, null);
    assertThat(getSubCpOptionForMencoder(sub3)).isEqualTo("enca:ru:cp1251");
    // File file_ibm866 = FileUtils.toFile(CLASS.getResource("../../util/russian-ibm866.srt"));
    // DLNAMediaSubtitle sub4 = new DLNAMediaSubtitle();
    // sub4.setExternalFile(file_ibm866);
    // assertThat(getSubCpOptionForMencoder(sub4)).isEqualTo("enca:ru:cp1251");
    File file_koi8_r = FileUtils.toFile(CLASS.getResource("../../util/russian-koi8-r.srt"));
    DLNAMediaSubtitle sub5 = new DLNAMediaSubtitle();
    sub5.setExternalFile(file_koi8_r, null);
    assertThat(getSubCpOptionForMencoder(sub5)).isEqualTo("enca:ru:cp1251");
    File file_cp1250 = FileUtils.toFile(CLASS.getResource("../../util/czech-cp1250.srt"));
    DLNAMediaSubtitle sub6 = new DLNAMediaSubtitle();
    sub6.setExternalFile(file_cp1250, null);
    assertThat(getSubCpOptionForMencoder(sub6)).isEqualTo("cp1250");
    File file_iso_8859_2 = FileUtils.toFile(CLASS.getResource("../../util/hungarian-iso-8859-2.srt"));
    DLNAMediaSubtitle sub7 = new DLNAMediaSubtitle();
    sub7.setExternalFile(file_iso_8859_2, null);
    assertThat(getSubCpOptionForMencoder(sub7)).isEqualTo("ISO-8859-2");
}
Also used : DLNAMediaSubtitle(net.pms.dlna.DLNAMediaSubtitle) File(java.io.File) Test(org.junit.Test)

Example 9 with DLNAMediaSubtitle

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

the class SubtitleUtilsTest method testGetSubCpOptionForMencoder_withoutExternalSubtitles.

@Test
public void testGetSubCpOptionForMencoder_withoutExternalSubtitles() throws Exception {
    DLNAMediaSubtitle subtitle = new DLNAMediaSubtitle();
    assertThat(getSubCpOptionForMencoder(subtitle)).isNull();
}
Also used : DLNAMediaSubtitle(net.pms.dlna.DLNAMediaSubtitle) Test(org.junit.Test)

Example 10 with DLNAMediaSubtitle

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

the class SubtitleUtilsTest method testGetSubCpOptionForMencoder_UTF.

@Test
public void testGetSubCpOptionForMencoder_UTF() throws Exception {
    File file_utf8 = FileUtils.toFile(CLASS.getResource("../../util/russian-utf8-without-bom.srt"));
    DLNAMediaSubtitle sub1 = new DLNAMediaSubtitle();
    sub1.setExternalFile(file_utf8, null);
    assertThat(getSubCpOptionForMencoder(sub1)).isNull();
    File file_utf8_2 = FileUtils.toFile(CLASS.getResource("../../util/russian-utf8-with-bom.srt"));
    DLNAMediaSubtitle sub2 = new DLNAMediaSubtitle();
    sub2.setExternalFile(file_utf8_2, null);
    assertThat(getSubCpOptionForMencoder(sub2)).isNull();
    File file_utf16_le = FileUtils.toFile(CLASS.getResource("../../util/russian-utf16-le.srt"));
    DLNAMediaSubtitle sub3 = new DLNAMediaSubtitle();
    sub3.setExternalFile(file_utf16_le, null);
    assertThat(getSubCpOptionForMencoder(sub3)).isNull();
    File file_utf16_be = FileUtils.toFile(CLASS.getResource("../../util/russian-utf16-be.srt"));
    DLNAMediaSubtitle sub4 = new DLNAMediaSubtitle();
    sub4.setExternalFile(file_utf16_be, null);
    assertThat(getSubCpOptionForMencoder(sub4)).isNull();
    File file_utf32_le = FileUtils.toFile(CLASS.getResource("../../util/russian-utf32-le.srt"));
    DLNAMediaSubtitle sub5 = new DLNAMediaSubtitle();
    sub5.setExternalFile(file_utf32_le, null);
    assertThat(getSubCpOptionForMencoder(sub5)).isNull();
    File file_utf32_be = FileUtils.toFile(CLASS.getResource("../../util/russian-utf32-be.srt"));
    DLNAMediaSubtitle sub6 = new DLNAMediaSubtitle();
    sub6.setExternalFile(file_utf32_be, null);
    assertThat(getSubCpOptionForMencoder(sub6)).isNull();
    File file_utf8_3 = FileUtils.toFile(CLASS.getResource("../../util/english-utf8-with-bom.srt"));
    DLNAMediaSubtitle sub7 = new DLNAMediaSubtitle();
    sub7.setExternalFile(file_utf8_3, null);
    assertThat(getSubCpOptionForMencoder(sub7)).isNull();
}
Also used : DLNAMediaSubtitle(net.pms.dlna.DLNAMediaSubtitle) File(java.io.File) Test(org.junit.Test)

Aggregations

DLNAMediaSubtitle (net.pms.dlna.DLNAMediaSubtitle)10 File (java.io.File)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 Format (net.pms.formats.Format)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Socket (java.net.Socket)1 URL (java.net.URL)1 StringTokenizer (java.util.StringTokenizer)1 Matcher (java.util.regex.Matcher)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 PmsConfiguration (net.pms.configuration.PmsConfiguration)1 RendererConfiguration (net.pms.configuration.RendererConfiguration)1 DLNAImageInputStream (net.pms.dlna.DLNAImageInputStream)1 DLNAImageProfile (net.pms.dlna.DLNAImageProfile)1 DLNAResource (net.pms.dlna.DLNAResource)1 DLNAThumbnailInputStream (net.pms.dlna.DLNAThumbnailInputStream)1