* reduce unnecessary messages that may confuse users that have the libraries install via the mediainfo packages

This commit is contained in:
Reinhard Pointner 2014-05-01 02:14:33 +00:00
parent b777a8ea54
commit f88c7fcff7
1 changed files with 47 additions and 77 deletions

View File

@ -1,7 +1,5 @@
package net.filebot.mediainfo;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
@ -12,14 +10,12 @@ import java.util.EnumMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import com.sun.jna.NativeLibrary;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
public class MediaInfo implements Closeable {
static {
@ -31,13 +27,12 @@ public class MediaInfo implements Closeable {
NativeLibrary.getInstance("zen");
}
} catch (Throwable e) {
Logger.getLogger(MediaInfo.class.getName()).warning("Failed to preload libzen");
// Logger.getLogger(MediaInfo.class.getName()).warning("Failed to preload libzen");
}
}
private Pointer handle;
public MediaInfo() {
try {
handle = MediaInfoLibrary.INSTANCE.New();
@ -46,7 +41,6 @@ public class MediaInfo implements Closeable {
}
}
public synchronized boolean open(File file) {
if (!file.isFile())
return false;
@ -59,57 +53,46 @@ public class MediaInfo implements Closeable {
return MediaInfoLibrary.INSTANCE.Open(handle, new WString(path)) > 0;
}
public synchronized String inform() {
return MediaInfoLibrary.INSTANCE.Inform(handle).toString();
}
public String option(String option) {
return option(option, "");
}
public synchronized String option(String option, String value) {
return MediaInfoLibrary.INSTANCE.Option(handle, new WString(option), new WString(value)).toString();
}
public String get(StreamKind streamKind, int streamNumber, String parameter) {
return get(streamKind, streamNumber, parameter, InfoKind.Text, InfoKind.Name);
}
public String get(StreamKind streamKind, int streamNumber, String parameter, InfoKind infoKind) {
return get(streamKind, streamNumber, parameter, infoKind, InfoKind.Name);
}
public synchronized String get(StreamKind streamKind, int streamNumber, String parameter, InfoKind infoKind, InfoKind searchKind) {
return MediaInfoLibrary.INSTANCE.Get(handle, streamKind.ordinal(), streamNumber, new WString(parameter), infoKind.ordinal(), searchKind.ordinal()).toString();
}
public String get(StreamKind streamKind, int streamNumber, int parameterIndex) {
return get(streamKind, streamNumber, parameterIndex, InfoKind.Text);
}
public synchronized String get(StreamKind streamKind, int streamNumber, int parameterIndex, InfoKind infoKind) {
return MediaInfoLibrary.INSTANCE.GetI(handle, streamKind.ordinal(), streamNumber, parameterIndex, infoKind.ordinal()).toString();
}
public synchronized int streamCount(StreamKind streamKind) {
return MediaInfoLibrary.INSTANCE.Count_Get(handle, streamKind.ordinal(), -1);
}
public synchronized int parameterCount(StreamKind streamKind, int streamNumber) {
return MediaInfoLibrary.INSTANCE.Count_Get(handle, streamKind.ordinal(), streamNumber);
}
public Map<StreamKind, List<Map<String, String>>> snapshot() {
Map<StreamKind, List<Map<String, String>>> mediaInfo = new EnumMap<StreamKind, List<Map<String, String>>>(StreamKind.class);
@ -130,7 +113,6 @@ public class MediaInfo implements Closeable {
return mediaInfo;
}
public Map<String, String> snapshot(StreamKind streamKind, int streamNumber) {
Map<String, String> streamInfo = new LinkedHashMap<String, String>();
@ -145,13 +127,11 @@ public class MediaInfo implements Closeable {
return streamInfo;
}
@Override
public synchronized void close() {
MediaInfoLibrary.INSTANCE.Close(handle);
}
public synchronized void dispose() {
if (handle == null)
return;
@ -161,18 +141,15 @@ public class MediaInfo implements Closeable {
handle = null;
}
@Override
protected void finalize() {
dispose();
}
public enum StreamKind {
General, Video, Audio, Text, Chapters, Image, Menu;
}
public enum InfoKind {
/**
* Unique name of parameter.
@ -217,32 +194,26 @@ public class MediaInfo implements Closeable {
Domain;
}
public static String version() {
return staticOption("Info_Version");
}
public static String parameters() {
return staticOption("Info_Parameters");
}
public static String codecs() {
return staticOption("Info_Codecs");
}
public static String capacities() {
return staticOption("Info_Capacities");
}
public static String staticOption(String option) {
return staticOption(option, "");
}
public static String staticOption(String option, String value) {
try {
return MediaInfoLibrary.INSTANCE.Option(null, new WString(option), new WString(value)).toString();
@ -251,7 +222,6 @@ public class MediaInfo implements Closeable {
}
}
/**
* Helper for easy usage
*/