Skip to content
Browse files

clean up renderer format matching

  • Loading branch information...
1 parent cae7f74 commit b7bc555a0975374d8398f50a5289ca3f3bfe826b @chocolateboy chocolateboy committed Oct 7, 2012
View
495 src/main/java/net/pms/configuration/FormatConfiguration.java
@@ -5,6 +5,9 @@
import net.pms.dlna.InputFile;
import net.pms.dlna.LibMediaInfoParser;
import net.pms.formats.Format;
+
+import org.apache.commons.lang.StringUtils;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,219 +16,221 @@
import java.util.regex.PatternSyntaxException;
public class FormatConfiguration {
- private static final Logger logger = LoggerFactory.getLogger(FormatConfiguration.class);
- public static final String MPEGPS = "mpegps";
- public static final String MPEGTS = "mpegts";
- public static final String WMV = "wmv";
- public static final String AVI = "avi";
- public static final String MP4 = "mp4";
- public static final String MOV = "mov";
- public static final String FLV = "flv";
- public static final String WEBM = "WebM";
- public static final String RM = "rm";
- public static final String MATROSKA = "mkv";
- public static final String WAV = "wav";
- public static final String WAVPACK = "wavpack";
- public static final String LPCM = "lpcm";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FormatConfiguration.class);
+ private ArrayList<SupportSpec> supportSpecs;
+ // Use old parser for JPEG files (MediaInfo does not support EXIF)
+ private static final String[] PARSER_V1_EXTENSIONS = new String[] { ".jpg", ".jpe", ".jpeg" };
+
public static final String AAC = "aac";
public static final String AC3 = "ac3";
- public static final String MP3 = "mp3";
- public static final String SHORTEN = "shn";
- public static final String MPA = "mpa";
- public static final String OGG = "ogg";
- public static final String WMA = "wma";
+ public static final String AIFF = "aiff";
public static final String ALAC = "alac";
+ public static final String APE = "ape";
+ public static final String ATRAC = "atrac";
+ public static final String AVI = "avi";
+ public static final String BMP = "bmp";
+ public static final String DIVX = "divx";
public static final String DTS = "dts";
public static final String DTSHD = "dtshd";
- public static final String TRUEHD = "truehd";
+ public static final String DV = "dv";
public static final String EAC3 = "eac3";
- public static final String ATRAC = "atrac";
public static final String FLAC = "flac";
- public static final String APE = "ape";
- public static final String RA = "ra";
+ public static final String FLV = "flv";
+ public static final String GIF = "gif";
+ public static final String H264 = "h264";
+ public static final String JPG = "jpg";
+ public static final String LPCM = "lpcm";
+ public static final String MATROSKA = "mkv";
+ public static final String MI_GMC = "gmc";
+ public static final String MI_QPEL = "qpel";
+ public static final String MJPEG = "mjpeg";
+ public static final String MLP = "mlp";
+ public static final String MOV = "mov";
+ public static final String MP3 = "mp3";
+ public static final String MP4 = "mp4";
+ public static final String MPA = "mpa";
public static final String MPC = "mpc";
- public static final String AIFF = "aiff";
- public static final String DV = "dv";
public static final String MPEG1 = "mpeg1";
public static final String MPEG2 = "mpeg2";
- public static final String DIVX = "divx";
- public static final String H264 = "h264";
- public static final String MLP = "mlp";
- public static final String MJPEG = "mjpeg";
- public static final String VC1 = "vc1";
- public static final String JPG = "jpg";
+ public static final String MPEGPS = "mpegps";
+ public static final String MPEGTS = "mpegts";
+ public static final String OGG = "ogg";
public static final String PNG = "png";
- public static final String GIF = "gif";
+ public static final String RA = "ra";
+ public static final String RM = "rm";
+ public static final String SHORTEN = "shn";
public static final String TIFF = "tiff";
- public static final String BMP = "bmp";
- public static final String und = "und";
- public static final String MI_QPEL = "qpel";
- public static final String MI_GMC = "gmc";
-
- // Use old parser for Jpeg files (MediaInfo does not support EXIF)
- private static final String PARSER_V1_EXTENSIONS[] = new String[]{".jpg", ".jpe", ".jpeg"};
-
- public void parse(DLNAMediaInfo media, InputFile file, Format ext, int type) {
- boolean force_v1 = false;
- if (file.getFile() != null) {
- String fName = file.getFile().getName().toLowerCase();
- for (String e : PARSER_V1_EXTENSIONS) {
- if (fName.endsWith(e)) {
- force_v1 = true;
- break;
- }
- }
- if (force_v1) {
- media.parse(file, ext, type, false);
- } else {
- LibMediaInfoParser.parse(media, file, type);
- }
- } else {
- media.parse(file, ext, type, false);
- }
- }
+ public static final String TRUEHD = "truehd";
+ public static final String VC1 = "vc1";
+ public static final String WAVPACK = "wavpack";
+ public static final String WAV = "wav";
+ public static final String WEBM = "WebM";
+ public static final String WMA = "wma";
+ public static final String WMV = "wmv";
public static final String MIMETYPE_AUTO = "MIMETYPE_AUTO";
- private ArrayList<Supports> list;
-
- private class Supports {
- String format;
- String videocodec;
- String audiocodec;
- String mimetype;
- String maxnbchannels;
- String maxfrequency;
- String maxbitrate;
- String maxvideowidth;
- String maxvideoheight;
- Map<String, Pattern> miExtras;
- Pattern pformat;
- Pattern pvideocodec;
- Pattern paudiocodec;
- int imaxnbchannels = Integer.MAX_VALUE;
- int imaxfrequency = Integer.MAX_VALUE;
- int imaxbitrate = Integer.MAX_VALUE;
- int imaxvideowidth = Integer.MAX_VALUE;
- int imaxvideoheight = Integer.MAX_VALUE;
-
- Supports() {
- mimetype = MIMETYPE_AUTO;
+ public static final String und = "und";
+
+ private class SupportSpec {
+ private int iMaxBitrate = Integer.MAX_VALUE;
+ private int iMaxFrequency = Integer.MAX_VALUE;
+ private int iMaxNbChannels = Integer.MAX_VALUE;
+ private int iMaxVideoHeight = Integer.MAX_VALUE;
+ private int iMaxVideoWidth = Integer.MAX_VALUE;
+ private Map<String, Pattern> miExtras;
+ private Pattern pAudioCodec;
+ private Pattern pFormat;
+ private Pattern pVideoCodec;
+ private String audioCodec;
+ private String format;
+ private String line;
+ private String maxBitrate;
+ private String maxFrequency;
+ private String maxNbChannels;
+ private String maxVideoHeight;
+ private String maxVideoWidth;
+ private String mimeType;
+ private String videoCodec;
+
+ SupportSpec() {
+ this.mimeType = MIMETYPE_AUTO;
}
boolean isValid() {
- boolean v = format != null && format.length() > 0;
- if (v) {
+ if (StringUtils.isBlank(format)) { // required
+ LOGGER.warn("No format supplied");
+ return false;
+ } else {
try {
- pformat = Pattern.compile(format);
- } catch (PatternSyntaxException pe) {
- logger.info("Couldn't resolve this pattern: " + format + " / " + pe.getMessage());
- v = false;
+ pFormat = Pattern.compile(format);
+ } catch (PatternSyntaxException pse) {
+ LOGGER.error("Error parsing format: " + format, pse);
+ return false;
}
- if (videocodec != null) {
- try {
- pvideocodec = Pattern.compile(videocodec);
- } catch (PatternSyntaxException pe) {
- logger.info("Couldn't resolve this pattern: " + videocodec + " / " + pe.getMessage());
- v = false;
- }
+ }
+
+ if (videoCodec != null) {
+ try {
+ pVideoCodec = Pattern.compile(videoCodec);
+ } catch (PatternSyntaxException pse) {
+ LOGGER.error("Error parsing video codec: " + videoCodec, pse);
+ return false;
}
- if (audiocodec != null) {
- try {
- paudiocodec = Pattern.compile(audiocodec);
- } catch (PatternSyntaxException pe) {
- logger.info("Couldn't resolve this pattern: " + audiocodec + " / " + pe.getMessage());
- v = false;
- }
+ }
+
+ if (audioCodec != null) {
+ try {
+ pAudioCodec = Pattern.compile(audioCodec);
+ } catch (PatternSyntaxException pse) {
+ LOGGER.error("Error parsing audio codec: " + audioCodec, pse);
+ return false;
}
+ }
+
+ if (maxNbChannels != null) {
try {
- if (maxnbchannels != null) {
- imaxnbchannels = Integer.parseInt(maxnbchannels);
- }
- } catch (Exception e) {
- logger.info("Error in parsing number: " + maxnbchannels);
- v = false;
+ iMaxNbChannels = Integer.parseInt(maxNbChannels);
+ } catch (NumberFormatException nfe) {
+ LOGGER.error("Error parsing number of channels: " + maxNbChannels, nfe);
+ return false;
}
+ }
+
+ if (maxFrequency != null) {
try {
- if (maxfrequency != null) {
- imaxfrequency = Integer.parseInt(maxfrequency);
- }
- } catch (Exception e) {
- logger.info("Error in parsing number: " + maxfrequency);
- v = false;
+ iMaxFrequency = Integer.parseInt(maxFrequency);
+ } catch (NumberFormatException nfe) {
+ LOGGER.error("Error parsing maximum frequency: " + maxFrequency, nfe);
+ return false;
}
+ }
+
+ if (maxBitrate != null) {
try {
- if (maxbitrate != null) {
- imaxbitrate = Integer.parseInt(maxbitrate);
- }
- } catch (Exception e) {
- logger.info("Error in parsing number: " + maxbitrate);
- v = false;
+ iMaxBitrate = Integer.parseInt(maxBitrate);
+ } catch (NumberFormatException nfe) {
+ LOGGER.error("Error parsing maximum bitrate: " + maxBitrate, nfe);
+ return false;
}
+ }
+
+ if (maxVideoWidth != null) {
try {
- if (maxvideowidth != null) {
- imaxvideowidth = Integer.parseInt(maxvideowidth);
- }
- } catch (Exception e) {
- logger.info("Error in parsing number: " + maxvideowidth);
- v = false;
+ iMaxVideoWidth = Integer.parseInt(maxVideoWidth);
+ } catch (Exception nfe) {
+ LOGGER.error("Error parsing maximum video width: " + maxVideoWidth, nfe);
+ return false;
}
+ }
+
+ if (maxVideoHeight != null) {
try {
- if (maxvideoheight != null) {
- imaxvideoheight = Integer.parseInt(maxvideoheight);
- }
- } catch (Exception e) {
- logger.info("Error in parsing number: " + maxvideoheight);
- v = false;
+ iMaxVideoHeight = Integer.parseInt(maxVideoHeight);
+ } catch (NumberFormatException nfe) {
+ LOGGER.error("Error parsing maximum video height: " + maxVideoHeight, nfe);
+ return false;
}
}
- return v;
- }
- public boolean match(String container, String videocodec, String audiocodec) {
- return match(container, videocodec, audiocodec, 0, 0, 0, 0, 0, null);
+ return true;
}
- public boolean match(String format, String videocodec, String audiocodec, int nbAudioChannels, int frequency, int bitrate, int videowidth, int videoheight, Map<String, String> extras) {
+ public boolean match(String container, String videoCodec, String audioCodec) {
+ return match(container, videoCodec, audioCodec, 0, 0, 0, 0, 0, null);
+ }
+ public boolean match(
+ String format,
+ String videoCodec,
+ String audioCodec,
+ int nbAudioChannels,
+ int frequency,
+ int bitrate,
+ int videoWidth,
+ int videoHeight,
+ Map<String, String> extras
+ ) {
boolean matched = false;
- if (format != null && !(matched = pformat.matcher(format).matches())) {
+ if (format != null && !(matched = pFormat.matcher(format).matches())) {
return false;
}
- if (matched && videocodec != null && pvideocodec != null && !(matched = pvideocodec.matcher(videocodec).matches())) {
+ if (matched && videoCodec != null && pVideoCodec != null && !(matched = pVideoCodec.matcher(videoCodec).matches())) {
return false;
}
- if (matched && audiocodec != null && paudiocodec != null && !(matched = paudiocodec.matcher(audiocodec).matches())) {
+ if (matched && audioCodec != null && pAudioCodec != null && !(matched = pAudioCodec.matcher(audioCodec).matches())) {
return false;
}
- if (matched && nbAudioChannels > 0 && imaxnbchannels > 0 && nbAudioChannels > imaxnbchannels) {
+ if (matched && nbAudioChannels > 0 && iMaxNbChannels > 0 && nbAudioChannels > iMaxNbChannels) {
return false;
}
- if (matched && frequency > 0 && imaxfrequency > 0 && frequency > imaxfrequency) {
+ if (matched && frequency > 0 && iMaxFrequency > 0 && frequency > iMaxFrequency) {
return false;
}
- if (matched && bitrate > 0 && imaxbitrate > 0 && bitrate > imaxbitrate) {
+ if (matched && bitrate > 0 && iMaxBitrate > 0 && bitrate > iMaxBitrate) {
return false;
}
- if (matched && videowidth > 0 && imaxvideowidth > 0 && videowidth > imaxvideowidth) {
+ if (matched && videoWidth > 0 && iMaxVideoWidth > 0 && videoWidth > iMaxVideoWidth) {
return false;
}
- if (matched && videoheight > 0 && imaxvideoheight > 0 && videoheight > imaxvideoheight) {
+ if (matched && videoHeight > 0 && iMaxVideoHeight > 0 && videoHeight > iMaxVideoHeight) {
return false;
}
if (matched && extras != null && miExtras != null) {
Iterator<String> keyIt = extras.keySet().iterator();
+
while (keyIt.hasNext()) {
String key = keyIt.next();
String value = extras.get(key);
+
if (matched && key.equals(MI_QPEL) && miExtras.get(MI_QPEL) != null) {
matched = miExtras.get(MI_QPEL).matcher(value).matches();
} else if (matched && key.equals(MI_GMC) && miExtras.get(MI_GMC) != null) {
@@ -238,6 +243,47 @@ public boolean match(String format, String videocodec, String audiocodec, int nb
}
}
+ public FormatConfiguration(List<?> lines) {
+ supportSpecs = new ArrayList<SupportSpec>();
+
+ for (Object line : lines) {
+ if (line != null) {
+ SupportSpec supportSpec = parseSupportLine(line.toString());
+
+ if (supportSpec.isValid()) {
+ supportSpecs.add(supportSpec);
+ } else {
+ LOGGER.warn("Invalid configuration line: " + line);
+ }
+ }
+ }
+ }
+
+ public void parse(DLNAMediaInfo media, InputFile file, Format ext, int type) {
+ boolean forceV1 = false;
+
+ if (file.getFile() != null) {
+ String fName = file.getFile().getName().toLowerCase();
+
+ for (String e : PARSER_V1_EXTENSIONS) {
+ if (fName.endsWith(e)) {
+ forceV1 = true;
+ break;
+ }
+ }
+
+ if (forceV1) {
+ media.parse(file, ext, type, false);
+ } else {
+ LibMediaInfoParser.parse(media, file, type);
+ }
+ } else {
+ media.parse(file, ext, type, false);
+ }
+ }
+
+ // XXX Unused
+ @Deprecated
public boolean isDVDVideoRemuxSupported() {
return match(MPEGPS, MPEG2, null) != null;
}
@@ -258,127 +304,182 @@ public boolean isMpeg2Supported() {
return match(MPEGPS, MPEG2, null) != null || match(MPEGTS, MPEG2, null) != null;
}
+ // XXX Unused
+ @Deprecated
public boolean isHiFiMusicFileSupported() {
return match(WAV, null, null, 0, 96000, 0, 0, 0, null) != null || match(MP3, null, null, 0, 96000, 0, 0, 0, null) != null;
}
public String getPrimaryVideoTranscoder() {
- for (Supports conf : list) {
- if (conf.match(MPEGPS, MPEG2, AC3)) {
+ for (SupportSpec supportSpec : supportSpecs) {
+ if (supportSpec.match(MPEGPS, MPEG2, AC3)) {
return MPEGPS;
}
- if (conf.match(MPEGTS, MPEG2, AC3)) {
+
+ if (supportSpec.match(MPEGTS, MPEG2, AC3)) {
return MPEGTS;
}
- if (conf.match(WMV, WMV, WMA)) {
+
+ if (supportSpec.match(WMV, WMV, WMA)) {
return WMV;
}
}
+
return null;
}
+ // XXX Unused
+ @Deprecated
public String getPrimaryAudioTranscoder() {
- for (Supports conf : list) {
- if (conf.match(WAV, null, null)) {
+ for (SupportSpec supportSpec : supportSpecs) {
+ if (supportSpec.match(WAV, null, null)) {
return WAV;
}
- if (conf.match(MP3, null, null)) {
+
+ if (supportSpec.match(MP3, null, null)) {
return MP3;
}
- }
- return null;
- }
- public FormatConfiguration(List<?> supported) {
- list = new ArrayList<Supports>();
- for (Object line : supported) {
- if (line != null) {
- Supports conf = parseSupportLine(line.toString());
- if (conf.isValid()) {
- list.add(conf);
- } else {
- logger.info("Invalid configuration line: " + line);
- }
- }
+ // FIXME LPCM?
}
+
+ return null;
}
/**
- * Match a media information to available audio codes for the renderer
- * and return its mimetype if the match is successful. Returns null if
+ * Match media information to audio codecs supported by the renderer
+ * and return its MIME-type if the match is successful. Returns null if
* the media is not natively supported by the renderer, which means it
* has to be transcoded.
- * @param media The media information
- * @return The mimetype or null if no match was found.
+ * @param media The MediaInfo metadata
+ * @return The MIME type or null if no match was found.
*/
public String match(DLNAMediaInfo media) {
if (media.getFirstAudioTrack() == null) {
// no sound
- return match(media.getContainer(), media.getCodecV(), null, 0, 0, media.getBitrate(), media.getWidth(), media.getHeight(), media.getExtras());
+ return match(
+ media.getContainer(),
+ media.getCodecV(),
+ null,
+ 0,
+ 0,
+ media.getBitrate(),
+ media.getWidth(),
+ media.getHeight(),
+ media.getExtras()
+ );
} else {
String finalMimeType = null;
+
for (DLNAMediaAudio audio : media.getAudioTracksList()) {
- String mimeType = match(media.getContainer(), media.getCodecV(), audio.getCodecA(), audio.getAudioProperties().getNumberOfChannels(), audio.getSampleRate(), media.getBitrate(), media.getWidth(), media.getHeight(), media.getExtras());
+ String mimeType = match(
+ media.getContainer(),
+ media.getCodecV(),
+ audio.getCodecA(),
+ audio.getAudioProperties().getNumberOfChannels(),
+ audio.getSampleRate(),
+ media.getBitrate(),
+ media.getWidth(),
+ media.getHeight(),
+ media.getExtras()
+ );
+
finalMimeType = mimeType;
- if (mimeType == null) // if at least one audio track is not compatible, the file must be transcoded.
- {
+
+ if (mimeType == null) { // if at least one audio track is not compatible, the file must be transcoded.
return null;
}
}
+
return finalMimeType;
}
}
- public String match(String container, String videocodec, String audiocodec) {
- return match(container, videocodec, audiocodec, 0, 0, 0, 0, 0, null);
+ public String match(String container, String videoCodec, String audioCodec) {
+ return match(
+ container,
+ videoCodec,
+ audioCodec,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ null
+ );
}
- public String match(String container, String videocodec, String audiocodec, int nbAudioChannels, int frequency, int bitrate, int videowidth, int videoheight, Map<String, String> extras) {
+ public String match(
+ String container,
+ String videoCodec,
+ String audioCodec,
+ int nbAudioChannels,
+ int frequency,
+ int bitrate,
+ int videoWidth,
+ int videoHeight,
+ Map<String,
+ String> extras
+ ) {
String matchedMimeType = null;
- for (Supports conf : list) {
- if (conf.match(container, videocodec, audiocodec, nbAudioChannels, frequency, bitrate, videowidth, videoheight, extras)) {
- matchedMimeType = conf.mimetype;
+ for (SupportSpec supportSpec : supportSpecs) {
+ if (supportSpec.match(
+ container,
+ videoCodec,
+ audioCodec,
+ nbAudioChannels,
+ frequency,
+ bitrate,
+ videoWidth,
+ videoHeight,
+ extras
+ )) {
+ matchedMimeType = supportSpec.mimeType;
break;
}
}
return matchedMimeType;
}
- private Supports parseSupportLine(String line) {
+ private SupportSpec parseSupportLine(String line) {
StringTokenizer st = new StringTokenizer(line, "\t ");
- Supports conf = new Supports();
+ SupportSpec supportSpec = new SupportSpec();
+
while (st.hasMoreTokens()) {
String token = st.nextToken();
+
if (token.startsWith("f:")) {
- conf.format = token.substring(2).trim();
+ supportSpec.format = token.substring(2).trim();
} else if (token.startsWith("v:")) {
- conf.videocodec = token.substring(2).trim();
+ supportSpec.videoCodec = token.substring(2).trim();
} else if (token.startsWith("a:")) {
- conf.audiocodec = token.substring(2).trim();
+ supportSpec.audioCodec = token.substring(2).trim();
} else if (token.startsWith("n:")) {
- conf.maxnbchannels = token.substring(2).trim();
+ supportSpec.maxNbChannels = token.substring(2).trim();
} else if (token.startsWith("s:")) {
- conf.maxfrequency = token.substring(2).trim();
+ supportSpec.maxFrequency = token.substring(2).trim();
} else if (token.startsWith("w:")) {
- conf.maxvideowidth = token.substring(2).trim();
+ supportSpec.maxVideoWidth = token.substring(2).trim();
} else if (token.startsWith("h:")) {
- conf.maxvideoheight = token.substring(2).trim();
+ supportSpec.maxVideoHeight = token.substring(2).trim();
} else if (token.startsWith("m:")) {
- conf.mimetype = token.substring(2).trim();
+ supportSpec.mimeType = token.substring(2).trim();
} else if (token.startsWith("b:")) {
- conf.maxbitrate = token.substring(2).trim();
+ supportSpec.maxBitrate = token.substring(2).trim();
} else if (token.contains(":")) {
- // extra mediainfo stuff
- if (conf.miExtras == null) {
- conf.miExtras = new HashMap<String, Pattern>();
+ // extra MediaInfo stuff
+ if (supportSpec.miExtras == null) {
+ supportSpec.miExtras = new HashMap<String, Pattern>();
}
+
String key = token.substring(0, token.indexOf(":"));
String value = token.substring(token.indexOf(":") + 1);
- conf.miExtras.put(key, Pattern.compile(value));
+ supportSpec.miExtras.put(key, Pattern.compile(value));
}
}
- return conf;
+
+ return supportSpec;
}
}
View
19 src/main/java/net/pms/configuration/RendererConfiguration.java
@@ -29,9 +29,6 @@
import java.util.regex.Pattern;
public class RendererConfiguration {
- /*
- * Static section
- */
private static final Logger LOGGER = LoggerFactory.getLogger(RendererConfiguration.class);
private static ArrayList<RendererConfiguration> rendererConfs;
private static PmsConfiguration pmsConfiguration;
@@ -202,6 +199,7 @@ public RootFolder getRootFolder() {
rootFolder = new RootFolder();
rootFolder.discoverChildren();
}
+
return rootFolder;
}
@@ -244,6 +242,7 @@ public static RendererConfiguration getRendererConfigurationByUA(String userAgen
}
}
}
+
return null;
}
@@ -257,6 +256,7 @@ private static RendererConfiguration manageRendererMatch(RendererConfiguration r
// to be the only way to get here.
LOGGER.info("Another renderer like " + r.getRendererName() + " was found!");
}
+
return r;
}
@@ -513,21 +513,25 @@ public String getMimeType(String mimetype) {
}
} else if (mimetype != null && mimetype.equals(HTTPResource.AUDIO_TRANSCODE)) {
mimetype = getFormatConfiguration().match(FormatConfiguration.LPCM, null, null);
+
if (mimetype != null) {
if (isTranscodeAudioTo441()) {
mimetype += ";rate=44100;channels=2";
} else {
mimetype += ";rate=48000;channels=2";
}
}
+
if (isTranscodeToWAV()) {
mimetype = getFormatConfiguration().match(FormatConfiguration.WAV, null, null);
} else if (isTranscodeToMP3()) {
mimetype = getFormatConfiguration().match(FormatConfiguration.MP3, null, null);
}
}
+
return mimetype;
}
+
if (mimetype != null && mimetype.equals(HTTPResource.VIDEO_TRANSCODE)) {
mimetype = HTTPResource.MPEG_TYPEMIME;
if (isTranscodeToWMV()) {
@@ -542,16 +546,20 @@ public String getMimeType(String mimetype) {
mimetype += ";rate=48000;channels=2";
}
}
+
if (isTranscodeToMP3()) {
mimetype = HTTPResource.AUDIO_MP3_TYPEMIME;
}
+
if (isTranscodeToWAV()) {
mimetype = HTTPResource.AUDIO_WAV_TYPEMIME;
}
}
+
if (mimes.containsKey(mimetype)) {
return mimes.get(mimetype);
}
+
return mimetype;
}
@@ -676,11 +684,13 @@ public String getUserAgentAdditionalHttpHeaderSearch() {
public String getUseSameExtension(String file) {
String s = getString(USE_SAME_EXTENSION, null);
+
if (s != null) {
s = file + "." + s;
} else {
s = file;
}
+
return s;
}
@@ -693,9 +703,11 @@ public boolean isMuxH264MpegTS() {
if (isMediaParserV2()) {
muxCompatible = getFormatConfiguration().match(FormatConfiguration.MPEGTS, FormatConfiguration.H264, null) != null;
}
+
if (Platform.isMac() && System.getProperty("os.version") != null && System.getProperty("os.version").contains("10.4.")) {
muxCompatible = false; // no tsMuxeR for 10.4 (yet?)
}
+
return muxCompatible;
}
@@ -722,6 +734,7 @@ public boolean isMuxLPCMToMpeg() {
if (isMediaParserV2()) {
return getFormatConfiguration().isLPCMSupported();
}
+
return getBoolean(MUX_LPCM_TO_MPEG, true);
}
View
2 src/main/java/net/pms/dlna/LibMediaInfoParser.java
@@ -205,9 +205,11 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile file, int t
if (media.getContainer() == null) {
media.setContainer(DLNAMediaLang.UND);
}
+
if (media.getCodecV() == null) {
media.setCodecV(DLNAMediaLang.UND);
}
+
media.setMediaparsed(true);
}
}

0 comments on commit b7bc555

Please sign in to comment.
Something went wrong with that request. Please try again.