private TranscodeProfile[] getTranscodeProfiles(String classification) { List<TranscodeProfile> profiles = new ArrayList<TranscodeProfile>(); DeviceManagerImpl dm = getManager(); TranscodeProvider[] providers = dm.getProviders(); for (TranscodeProvider provider : providers) { TranscodeProfile[] ps = provider.getProfiles(); for (TranscodeProfile p : ps) { String c = p.getDeviceClassification(); if (c == null) { log("Device classification missing for " + p.getName()); } else { if (c.toLowerCase().startsWith(classification.toLowerCase())) { profiles.add(p); } } } } return (profiles.toArray(new TranscodeProfile[profiles.size()])); }
protected DeviceTivo foundTiVo( InetAddress address, String uid, String classification, String machine) { uid = "tivo:" + uid; DeviceImpl[] devices = device_manager.getDevices(); String server_name = device_manager.getLocalServiceName(); for (DeviceImpl device : devices) { if (device instanceof DeviceTivo) { DeviceTivo tivo = (DeviceTivo) device; if (device.getID().equals(uid)) { if (classification != null) { String existing_classification = device.getClassification(); if (!classification.equals(existing_classification)) { device.setPersistentStringProperty(DeviceImpl.PP_REND_CLASSIFICATION, classification); } } tivo.found(this, address, server_name, machine); return (tivo); } } } // unfortunately we can't deduce the series from the browse request so start off with a series 3 // this will be corrected later if we receive a beacon which *does* contain the series details if (classification == null) { classification = "tivo.series3"; } DeviceTivo new_device = new DeviceTivo(device_manager, uid, classification); DeviceTivo result = (DeviceTivo) device_manager.addDevice(new_device); // possible race here so handle case where device already present if (result == new_device) { new_device.found(this, address, server_name, machine); } return (result); }
public TranscodeProfile getDefaultTranscodeProfile() { String uid = getPersistentStringProperty(PP_REND_DEF_TRANS_PROF); DeviceManagerImpl dm = getManager(); TranscodeManagerImpl tm = dm.getTranscodeManager(); TranscodeProfile profile = tm.getProfileFromUID(uid); if (profile != null) { return (profile); } return (null); }
protected void log(String str) { if (device_manager == null) { System.out.println(str); } else { device_manager.log("TiVo: " + str); } }
protected void startUp() { plugin_interface = PluginInitializer.getDefaultInterface(); if (COConfigurationManager.getStringParameter("ui").equals("az2")) { is_enabled = false; } else { is_enabled = COConfigurationManager.getBooleanParameter("devices.tivo.enabled", true); } uid = COConfigurationManager.getStringParameter("devices.tivo.uid", null); if (uid == null) { byte[] bytes = new byte[8]; RandomUtils.nextBytes(bytes); uid = Base32.encode(bytes); COConfigurationManager.setParameter("devices.tivo.uid", uid); } boolean found_tivo = false; for (Device device : device_manager.getDevices()) { if (device instanceof DeviceTivo) { found_tivo = true; break; } } if (found_tivo || device_manager.getAutoSearch()) { search(found_tivo, false); } }
protected void log(String str, Throwable e) { if (device_manager == null) { System.out.println(str); e.printStackTrace(); } else { device_manager.log("TiVo: " + str, e); } }
private TranscodeProfile[] getTranscodeProfiles(String classification) { List<TranscodeProfile> profiles = new ArrayList<TranscodeProfile>(); DeviceManagerImpl dm = getManager(); TranscodeProvider[] providers = dm.getProviders(); for (TranscodeProvider provider : providers) { TranscodeProfile[] ps = provider.getProfiles(classification); if (providers.length == 1) { return (ps); } profiles.addAll(Arrays.asList(ps)); } return (profiles.toArray(new TranscodeProfile[profiles.size()])); }
public File getWorkingDirectory(boolean persist) { String result = getPersistentStringProperty(PP_REND_WORK_DIR); if (result.length() == 0) { File f = manager.getDefaultWorkingDirectory(persist); if (persist) { f.mkdirs(); } String name = FileUtil.convertOSSpecificChars(getName(), true); for (int i = 0; i < 1024; i++) { String test_name = name + (i == 0 ? "" : ("_" + i)); File test_file = new File(f, test_name); if (!test_file.exists()) { f = test_file; break; } } result = f.getAbsolutePath(); if (persist) { setPersistentStringProperty(PP_REND_WORK_DIR, result); } } File f_result = new File(result); if (!f_result.exists()) { if (persist) { f_result.mkdirs(); } } return (f_result); }
protected void setEnabled(boolean enabled) { COConfigurationManager.setParameter("devices.tivo.enabled", enabled); if (enabled) { search(false, true); } else { for (Device device : device_manager.getDevices()) { if (device instanceof DeviceTivo) { device.remove(); } } } }
protected void setBusy(boolean busy) { boolean changed = false; synchronized (this) { if (busy) { changed = busy_count++ == 0; } else { changed = busy_count-- == 1; } } if (changed) { manager.deviceChanged(this, false); } }
protected byte[] encodeBeacon(boolean is_broadcast, int my_port) throws IOException { String beacon = "tivoconnect=1" + LF + "swversion=1" + LF + "method=" + (is_broadcast ? "broadcast" : "connected") + LF + "identity=" + uid + LF + "machine=" + device_manager.getLocalServiceName() + LF + "platform=pc" + LF + "services=TiVoMediaServer:" + my_port + "/http"; return (beacon.getBytes("ISO-8859-1")); }
protected void setInfo(Object key, String info) { boolean changed = false; if (info == null || info.length() == 0) { synchronized (infos) { changed = infos.remove(key) != null; } } else { String existing; synchronized (infos) { existing = infos.put(key, info); } changed = existing == null || !existing.equals(info); } if (changed) { manager.deviceChanged(this, false); } }
protected void setError(Object key, String error) { boolean changed = false; if (error == null || error.length() == 0) { synchronized (errors) { changed = errors.remove(key) != null; } } else { String existing; synchronized (errors) { existing = errors.put(key, error); } changed = existing == null || !existing.equals(error); } if (changed) { manager.deviceChanged(this, false); } }
protected void setTranscoding(boolean _transcoding) { transcoding = _transcoding; manager.deviceChanged(this, false); }
public void requestAttention() { manager.requestAttention(this); }
protected void setDirty(boolean save_changes) { manager.configDirty(this, save_changes); }
public void remove() { manager.removeDevice(this); }
protected void log(String str, Throwable e) { manager.log(str, e); }
protected String getMimeType(TranscodeFileImpl file) { return (manager.getMimeType(file)); }
protected URL getStreamURL(TranscodeFileImpl file, String host) { return (manager.getStreamURL(file, host)); }
protected void log(String str) { manager.log(str); }
public VuzeFile getVuzeFile() throws IOException { return (manager.exportVuzeFile(this)); }