use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class TranscodeManagerImpl method processCategory.
void processCategory(Category cat, Object[] details, DownloadManager dm) {
Download download = PluginCoreUtils.wrap(dm);
if (download == null) {
return;
}
if (download.getFlag(Download.FLAG_LOW_NOISE)) {
return;
}
String str = download.getAttribute(category_ta);
String cat_name = cat.getName();
if (cat.getType() == Category.TYPE_UNCATEGORIZED) {
cat_name = "<none>";
}
String cat_tag = cat_name + ";";
if (str != null && str.contains(cat_tag)) {
return;
}
try {
DeviceMediaRenderer device = (DeviceMediaRenderer) details[0];
TranscodeProfile profile = (TranscodeProfile) details[1];
log("Category " + cat_name + " - adding " + download.getName() + " to " + device.getName() + "/" + profile.getName());
DiskManagerFileInfo[] dm_files = download.getDiskManagerFileInfo();
int num_added = 0;
for (DiskManagerFileInfo dm_file : dm_files) {
if (num_added > 64) {
break;
}
if (dm_files.length == 1 || dm_file.getLength() >= 128 * 1024) {
try {
queue.add(device, profile, dm_file, false);
num_added++;
} catch (Throwable e) {
log(" add failed", e);
}
}
}
} finally {
download.setAttribute(category_ta, str == null ? cat_tag : (str + cat_tag));
}
}
use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class TranscodeManagerImpl method processTag.
void processTag(Tag tag, Object[] details, DownloadManager dm) {
Download download = PluginCoreUtils.wrap(dm);
if (download == null) {
return;
}
if (download.getFlag(Download.FLAG_LOW_NOISE)) {
return;
}
String str = download.getAttribute(tag_ta);
String tag_name = tag.getTagName(true);
String tag_tag = tag.getTagType().getTagType() + "." + tag.getTagID() + ";";
if (str != null && str.contains(tag_tag)) {
return;
}
try {
DeviceMediaRenderer device = (DeviceMediaRenderer) details[0];
TranscodeProfile profile = (TranscodeProfile) details[1];
log("Tag " + tag_name + " - adding " + download.getName() + " to " + device.getName() + "/" + profile.getName());
DiskManagerFileInfo[] dm_files = download.getDiskManagerFileInfo();
int num_added = 0;
for (DiskManagerFileInfo dm_file : dm_files) {
if (num_added > 64) {
break;
}
if (dm_files.length == 1 || dm_file.getLength() >= 128 * 1024) {
try {
queue.add(device, profile, dm_file, false);
num_added++;
} catch (Throwable e) {
log(" add failed", e);
}
}
}
} finally {
download.setAttribute(tag_ta, str == null ? tag_tag : (str + tag_tag));
}
}
use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class PlayUtils method isExternallyPlayableSupport.
private static boolean isExternallyPlayableSupport(Download d, int file_index, boolean complete_only) {
int primary_file_index = -1;
if (file_index == -1) {
DownloadManager dm = PluginCoreUtils.unwrap(d);
if (dm == null) {
return (false);
}
DiskManagerFileInfo file = null;
try {
file = PluginCoreUtils.wrap(dm.getDownloadState().getPrimaryFile());
} catch (DownloadException e) {
return false;
}
if (file == null) {
return (false);
}
if (file.getDownloaded() != file.getLength()) {
if (complete_only || getMediaServerContentURL(file) == null) {
return (false);
}
}
primary_file_index = file.getIndex();
} else {
DiskManagerFileInfo file = d.getDiskManagerFileInfo(file_index);
if (file.getDownloaded() != file.getLength()) {
if (complete_only || getMediaServerContentURL(file) == null) {
return (false);
}
}
primary_file_index = file_index;
}
if (primary_file_index == -1) {
return false;
}
return (isExternallyPlayable(d.getDiskManagerFileInfo()[primary_file_index]));
}
use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class PlayUtils method getExternallyPlayableFileIndexes.
public static int[] getExternallyPlayableFileIndexes(Download d, boolean complete_only) {
int[] playableIndexes = {};
DiskManagerFileInfo[] fileInfos = d.getDiskManagerFileInfo();
for (int i = 0; i < fileInfos.length; i++) {
DiskManagerFileInfo fileInfo = fileInfos[i];
if (complete_only && fileInfo.getLength() != fileInfo.getDownloaded()) {
continue;
}
if (isExternallyPlayable(fileInfo)) {
int[] newPlayableIndexes = new int[playableIndexes.length + 1];
System.arraycopy(playableIndexes, 0, newPlayableIndexes, 0, playableIndexes.length);
newPlayableIndexes[playableIndexes.length] = i;
playableIndexes = newPlayableIndexes;
}
}
return playableIndexes;
}
use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class DataSourceUtils method getFileInfo.
public static com.biglybt.core.disk.DiskManagerFileInfo getFileInfo(Object ds) {
try {
if (ds instanceof DiskManagerFileInfo) {
return PluginCoreUtils.unwrap((DiskManagerFileInfo) ds);
} else if (ds instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
return (com.biglybt.core.disk.DiskManagerFileInfo) ds;
} else if ((ds instanceof ISelectedContent) && ((ISelectedContent) ds).getFileIndex() >= 0) {
ISelectedContent sc = (ISelectedContent) ds;
int idx = sc.getFileIndex();
DownloadManager dm = sc.getDownloadManager();
return dm.getDiskManagerFileInfoSet().getFiles()[idx];
} else if (ds instanceof TranscodeJob) {
TranscodeJob tj = (TranscodeJob) ds;
try {
return PluginCoreUtils.unwrap(tj.getFile());
} catch (DownloadException e) {
}
} else if (ds instanceof TranscodeFile) {
TranscodeFile tf = (TranscodeFile) ds;
try {
DiskManagerFileInfo file = tf.getSourceFile();
return PluginCoreUtils.unwrap(file);
} catch (DownloadException e) {
}
}
} catch (Exception e) {
Debug.printStackTrace(e);
}
return null;
}
Aggregations