Search in sources :

Example 16 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class AEPluginProxyHandler method getPluginProxy.

public static PluginProxyImpl getPluginProxy(String reason, String host, int port, Map<String, Object> properties) {
    if (isEnabled()) {
        checkPluginInstallation(null, reason);
        if (properties == null) {
            properties = new HashMap<>();
        }
        for (PluginInterface pi : plugins) {
            try {
                IPCInterface ipc = pi.getIPC();
                Object[] proxy_details;
                if (ipc.canInvoke("getProxy", new Object[] { reason, host, port, properties })) {
                    proxy_details = (Object[]) ipc.invoke("getProxy", new Object[] { reason, host, port, properties });
                } else {
                    proxy_details = (Object[]) ipc.invoke("getProxy", new Object[] { reason, host, port });
                }
                if (proxy_details != null) {
                    return (new PluginProxyImpl(host + ":" + port, reason, ipc, properties, proxy_details));
                }
            } catch (Throwable e) {
            }
        }
    }
    return (null);
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) DHTPluginInterface(com.biglybt.plugin.dht.DHTPluginInterface) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 17 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class DeviceUPnPImpl method setupStreamXCode.

protected boolean setupStreamXCode(TranscodeFileImpl transcode_file) {
    final TranscodeJobImpl job = transcode_file.getJob();
    if (job == null) {
        return (transcode_file.isComplete());
    }
    final String tf_key = transcode_file.getKey();
    ContentFile acf;
    synchronized (acf_map) {
        acf = acf_map.get(tf_key);
    }
    if (acf != null) {
        return (true);
    }
    IPCInterface ipc = upnpav_ipc;
    if (ipc == null) {
        return (false);
    }
    if (transcode_file.getDurationMillis() == 0) {
        return (false);
    }
    try {
        final DiskManagerFileInfo stream_file = new TranscodeJobOutputLeecher(job, transcode_file);
        acf = new ContentFile() {

            @Override
            public DiskManagerFileInfo getFile() {
                return (stream_file);
            }

            @Override
            public Object getProperty(String name) {
                if (name.equals(MY_ACF_KEY)) {
                    return (new Object[] { DeviceUPnPImpl.this, tf_key });
                } else if (name.equals(PT_PERCENT_DONE)) {
                    return (new Long(1000));
                } else if (name.equals(PT_ETA)) {
                    return (new Long(0));
                }
                return (null);
            }
        };
        synchronized (acf_map) {
            acf_map.put(tf_key, acf);
        }
        ipc.invoke("addContent", new Object[] { acf });
        log("Set up stream-xcode for " + transcode_file.getName());
        return (true);
    } catch (Throwable e) {
        return (false);
    }
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) ContentFile(com.biglybt.core.content.ContentFile) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 18 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class DeviceUPnPImpl method fileAdded.

public void fileAdded(TranscodeFile _transcode_file, boolean _new_file) {
    TranscodeFileImpl transcode_file = (TranscodeFileImpl) _transcode_file;
    IPCInterface ipc = upnpav_ipc;
    synchronized (this) {
        if (ipc == null) {
            return;
        }
        if (!transcode_file.isComplete()) {
            syncCategoriesAndTags(transcode_file, _new_file);
            return;
        }
        ContentFile acf = (ContentFile) transcode_file.getTransientProperty(UPNPAV_FILE_KEY);
        if (acf != null) {
            return;
        }
        final String tf_key = transcode_file.getKey();
        synchronized (acf_map) {
            acf = acf_map.get(tf_key);
        }
        if (acf != null) {
            return;
        }
        try {
            final DiskManagerFileInfo f = transcode_file.getTargetFile();
            acf = new ContentFile() {

                @Override
                public DiskManagerFileInfo getFile() {
                    return (f);
                }

                @Override
                public Object getProperty(String name) {
                    if (name.equals(MY_ACF_KEY)) {
                        return (new Object[] { DeviceUPnPImpl.this, tf_key });
                    } else if (name.equals(PT_CATEGORIES)) {
                        TranscodeFileImpl tf = getTranscodeFile(tf_key);
                        if (tf != null) {
                            return (tf.getCategories());
                        }
                        return (new String[0]);
                    } else if (name.equals(PT_TAGS)) {
                        TranscodeFileImpl tf = getTranscodeFile(tf_key);
                        if (tf != null) {
                            return (tf.getTags(true));
                        }
                        return (new String[0]);
                    } else if (name.equals(PT_TITLE)) {
                        TranscodeFileImpl tf = getTranscodeFile(tf_key);
                        if (tf != null) {
                            return (tf.getName());
                        }
                    } else {
                        TranscodeFileImpl tf = getTranscodeFile(tf_key);
                        if (tf != null) {
                            long res = 0;
                            if (name.equals(PT_DURATION)) {
                                res = tf.getDurationMillis();
                            } else if (name.equals(PT_VIDEO_WIDTH)) {
                                res = tf.getVideoWidth();
                            } else if (name.equals(PT_VIDEO_HEIGHT)) {
                                res = tf.getVideoHeight();
                            } else if (name.equals(PT_DATE)) {
                                res = tf.getCreationDateMillis();
                            } else if (name.equals(PT_PERCENT_DONE)) {
                                if (tf.isComplete()) {
                                    res = 1000;
                                } else {
                                    TranscodeJob job = tf.getJob();
                                    if (job == null) {
                                        res = 0;
                                    } else {
                                        res = 10 * job.getPercentComplete();
                                    }
                                }
                                return (res);
                            } else if (name.equals(PT_ETA)) {
                                if (tf.isComplete()) {
                                    res = 0;
                                } else {
                                    TranscodeJob job = tf.getJob();
                                    if (job == null) {
                                        res = Long.MAX_VALUE;
                                    } else {
                                        res = job.getETASecs();
                                    }
                                }
                                return (res);
                            }
                            if (res > 0) {
                                return (new Long(res));
                            }
                        }
                    }
                    return (null);
                }
            };
            transcode_file.setTransientProperty(UPNPAV_FILE_KEY, acf);
            synchronized (acf_map) {
                acf_map.put(tf_key, acf);
            }
            syncCategoriesAndTags(transcode_file, _new_file);
            try {
                ipc.invoke("addContent", new Object[] { acf });
            } catch (Throwable e) {
                Debug.out(e);
            }
        } catch (TranscodeException e) {
        // file deleted
        }
    }
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) ContentFile(com.biglybt.core.content.ContentFile) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 19 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class DeviceUPnPImpl method fileRemoved.

@Override
public void fileRemoved(TranscodeFile file) {
    IPCInterface ipc = upnp_manager.getUPnPAVIPC();
    if (ipc == null) {
        return;
    }
    synchronized (this) {
        ContentFile acf = (ContentFile) file.getTransientProperty(UPNPAV_FILE_KEY);
        if (acf == null) {
            return;
        }
        file.setTransientProperty(UPNPAV_FILE_KEY, null);
        try {
            ipc.invoke("removeContent", new Object[] { acf });
        } catch (Throwable e) {
            Debug.out(e);
        }
    }
    synchronized (acf_map) {
        acf_map.remove(((TranscodeFileImpl) file).getKey());
    }
}
Also used : ContentFile(com.biglybt.core.content.ContentFile) IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Example 20 with IPCInterface

use of com.biglybt.pif.ipc.IPCInterface in project BiglyBT by BiglySoftware.

the class DeviceUPnPImpl method setFilterFilesView.

public void setFilterFilesView(boolean filter) {
    boolean existing = getFilterFilesView();
    if (existing != filter) {
        setPersistentBooleanProperty(PP_FILTER_FILES, filter);
        IPCInterface ipc = upnpav_ipc;
        if (ipc != null) {
            try {
                ipc.invoke("invalidateDirectory", new Object[] {});
            } catch (Throwable e) {
            }
        }
    }
}
Also used : IPCInterface(com.biglybt.pif.ipc.IPCInterface)

Aggregations

IPCInterface (com.biglybt.pif.ipc.IPCInterface)24 PluginInterface (com.biglybt.pif.PluginInterface)14 DHTPluginInterface (com.biglybt.plugin.dht.DHTPluginInterface)6 Map (java.util.Map)6 DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)5 URL (java.net.URL)5 HashMap (java.util.HashMap)5 ContentFile (com.biglybt.core.content.ContentFile)4 IPCException (com.biglybt.pif.ipc.IPCException)4 DiskManagerFileInfoURL (com.biglybt.core.download.DiskManagerFileInfoURL)3 File (java.io.File)3 AEThread2 (com.biglybt.core.util.AEThread2)2 UIFunctions (com.biglybt.ui.UIFunctions)2 IOException (java.io.IOException)2 ContentDownload (com.biglybt.core.content.ContentDownload)1 ContentFilter (com.biglybt.core.content.ContentFilter)1 DeviceMediaRenderer (com.biglybt.core.devices.DeviceMediaRenderer)1 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)1 DownloadManagerStateAttributeListener (com.biglybt.core.download.DownloadManagerStateAttributeListener)1 MessageText (com.biglybt.core.internat.MessageText)1