Search in sources :

Example 1 with DeviceManager

use of com.biglybt.core.devices.DeviceManager in project BiglyBT by BiglySoftware.

the class TrancodeUIUtils method getTranscodeTargets.

public static TranscodeTarget[] getTranscodeTargets() {
    List<TranscodeTarget> result = new ArrayList<>();
    if (!COConfigurationManager.getStringParameter("ui").equals("az2")) {
        try {
            DeviceManager dm = DeviceManagerFactory.getSingleton();
            Device[] devices = dm.getDevices();
            for (final Device d : devices) {
                if (d instanceof DeviceMediaRenderer) {
                    final DeviceMediaRenderer dmr = (DeviceMediaRenderer) d;
                    boolean hide_device = d.isHidden();
                    if (COConfigurationManager.getBooleanParameter("device.sidebar.ui.rend.hidegeneric", true)) {
                        if (dmr.isNonSimple()) {
                            hide_device = true;
                        }
                    }
                    if (hide_device) {
                        continue;
                    }
                    result.add(new TranscodeTarget() {

                        @Override
                        public String getName() {
                            return (d.getName());
                        }

                        @Override
                        public String getID() {
                            return (d.getID());
                        }

                        @Override
                        public TranscodeProfile[] getProfiles() {
                            List<TranscodeProfile> ps = new ArrayList<>();
                            com.biglybt.core.devices.TranscodeProfile[] profs = dmr.getTranscodeProfiles();
                            if (profs.length == 0) {
                                if (dmr.getTranscodeRequirement() == com.biglybt.core.devices.TranscodeTarget.TRANSCODE_NEVER) {
                                    ps.add(new TranscodeProfile() {

                                        @Override
                                        public String getUID() {
                                            return (dmr.getID() + "/" + dmr.getBlankProfile().getName());
                                        }

                                        @Override
                                        public String getName() {
                                            return (MessageText.getString("devices.profile.direct"));
                                        }
                                    });
                                }
                            } else {
                                for (final com.biglybt.core.devices.TranscodeProfile prof : profs) {
                                    ps.add(new TranscodeProfile() {

                                        @Override
                                        public String getUID() {
                                            return (prof.getUID());
                                        }

                                        @Override
                                        public String getName() {
                                            return (prof.getName());
                                        }
                                    });
                                }
                            }
                            return (ps.toArray(new TranscodeProfile[ps.size()]));
                        }
                    });
                }
            }
        } catch (Throwable e) {
            Debug.out(e);
        }
    }
    Collections.sort(result, new Comparator<TranscodeTarget>() {

        @Override
        public int compare(TranscodeTarget o1, TranscodeTarget o2) {
            return (o1.getName().compareTo(o2.getName()));
        }
    });
    return (result.toArray(new TranscodeTarget[result.size()]));
}
Also used : Device(com.biglybt.core.devices.Device) ArrayList(java.util.ArrayList) DeviceManager(com.biglybt.core.devices.DeviceManager) DeviceMediaRenderer(com.biglybt.core.devices.DeviceMediaRenderer) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Device (com.biglybt.core.devices.Device)1 DeviceManager (com.biglybt.core.devices.DeviceManager)1 DeviceMediaRenderer (com.biglybt.core.devices.DeviceMediaRenderer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1