Search in sources :

Example 6 with UPnPDevice

use of com.biglybt.net.upnp.UPnPDevice in project BiglyBT by BiglySoftware.

the class DeviceManagerImpl method findDevice.

@Override
public Device findDevice(UPnPDevice upnpDevice) {
    DeviceImpl[] devices = getDevices();
    for (DeviceImpl device : devices) {
        if (device instanceof DeviceUPnPImpl) {
            DeviceUPnPImpl deviceUPnP = (DeviceUPnPImpl) device;
            UPnPDevice uPnPDevice2 = deviceUPnP.getUPnPDevice();
            if (upnpDevice.equals(uPnPDevice2)) {
                return device;
            }
        }
    }
    return null;
}
Also used : UPnPDevice(com.biglybt.net.upnp.UPnPDevice)

Example 7 with UPnPDevice

use of com.biglybt.net.upnp.UPnPDevice in project BiglyBT by BiglySoftware.

the class DeviceMediaRendererImpl method setAddress.

@Override
public void setAddress(InetAddress address) {
    super.setAddress(address);
    if (getType() == DT_MEDIA_RENDERER) {
        // System.out.println("Set Address " + address.getHostAddress() + "; " + getName() + "/" + getClassification());
        boolean hasUPnPDevice = getUPnPDevice() != null;
        DeviceImpl[] devices = getManager().getDevices();
        for (DeviceImpl device : devices) {
            if (device == this || device.getID().equals(getID()) || !((device instanceof DeviceUPnPImpl))) {
                continue;
            }
            DeviceUPnPImpl deviceUPnP = ((DeviceUPnPImpl) device);
            if (!address.equals(device.getAddress()) || !device.isAlive()) {
                continue;
            }
            if (hasUPnPDevice) {
                boolean no_auto_hide = device.getPersistentBooleanProperty(DeviceImpl.PP_DONT_AUTO_HIDE, false);
                if (device.getType() == DT_MEDIA_RENDERER && !no_auto_hide) {
                    // prefer UPnP Device over Manual one added by a Browse event
                    if (deviceUPnP.getUPnPDevice() != null) {
                        int fileCount = deviceUPnP.getFileCount();
                        if (fileCount == 0 && !device.isHidden()) {
                            log("Hiding " + device.getName() + "/" + device.getClassification() + "/" + device.getID() + " due to " + getName() + "/" + getClassification() + "/" + getID());
                            device.setHidden(true);
                        }
                    }
                }
            } else {
                if (device.getType() == DT_MEDIA_RENDERER) {
                    boolean no_auto_hide = getPersistentBooleanProperty(DeviceImpl.PP_DONT_AUTO_HIDE, false);
                    if (!no_auto_hide) {
                        int fileCount = getFileCount();
                        // prefer UPnP Device over Manual one added by a Browse event
                        if (fileCount == 0 && !isHidden()) {
                            log("hiding " + getName() + "/" + getClassification() + "/" + getID() + " due to " + device.getName() + "/" + device.getClassification() + "/" + device.getID());
                            setHidden(true);
                        } else if (fileCount > 0 && Constants.IS_CVS_VERSION && isHidden()) {
                            // Fix beta bug where we hid devices that had files.  Remove after 4605
                            setHidden(false);
                        }
                    }
                } else {
                    // Device has UPnP stuff, but did not register itself as
                    // renderer.
                    UPnPDevice upnpDevice = deviceUPnP.getUPnPDevice();
                    if (upnpDevice != null) {
                        String manufacturer = upnpDevice.getManufacturer();
                        if (manufacturer == null || !(manufacturer.startsWith("Vuze") || manufacturer.startsWith("BiglyBT"))) {
                            log("Linked " + getName() + " to UPnP Device " + device.getName());
                            setUPnPDevice(upnpDevice);
                            setDirty();
                        }
                    }
                }
            }
            break;
        }
    }
}
Also used : UPnPDevice(com.biglybt.net.upnp.UPnPDevice)

Example 8 with UPnPDevice

use of com.biglybt.net.upnp.UPnPDevice in project BiglyBT by BiglySoftware.

the class DeviceUPnPImpl method generate.

@Override
public void generate(IndentWriter writer) {
    super.generate(writer);
    try {
        writer.indent();
        UPnPDevice device = device_may_be_null;
        if (device == null) {
            writer.println("upnp_device=null");
        } else {
            writer.println("upnp_device=" + device.getFriendlyName());
        }
        writer.println("dyn_xcode=" + (dynamic_transcode_profile == null ? "null" : dynamic_transcode_profile.getName()));
    } finally {
        writer.exdent();
    }
}
Also used : UPnPDevice(com.biglybt.net.upnp.UPnPDevice)

Example 9 with UPnPDevice

use of com.biglybt.net.upnp.UPnPDevice in project BiglyBT by BiglySoftware.

the class DeviceUPnPImpl method getAddress.

@Override
public InetAddress getAddress() {
    try {
        UPnPDevice device = device_may_be_null;
        if (device != null) {
            UPnPRootDevice root = device.getRootDevice();
            URL location = root.getLocation();
            return (InetAddress.getByName(location.getHost()));
        } else {
            InetAddress address = (InetAddress) getTransientProperty(TP_IP_ADDRESS);
            if (address != null) {
                return (address);
            }
            String last = getPersistentStringProperty(PP_IP_ADDRESS);
            if (last != null && last.length() > 0) {
                return (InetAddress.getByName(last));
            }
        }
    } catch (Throwable e) {
        Debug.printStackTrace(e);
    }
    return (null);
}
Also used : UPnPDevice(com.biglybt.net.upnp.UPnPDevice) InetAddress(java.net.InetAddress) URL(java.net.URL) UPnPRootDevice(com.biglybt.net.upnp.UPnPRootDevice)

Aggregations

UPnPDevice (com.biglybt.net.upnp.UPnPDevice)9 URL (java.net.URL)3 UPnPRootDevice (com.biglybt.net.upnp.UPnPRootDevice)2 InetAddress (java.net.InetAddress)2 SimpleDateFormat (java.text.SimpleDateFormat)1