org.fourthline.cling.model.meta.DeviceIdentity Java Examples
The following examples show how to use
org.fourthline.cling.model.meta.DeviceIdentity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeyondUpnpService.java From BeyondUPnP with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); //Create LocalDevice LocalService localService = new AnnotationLocalServiceBinder().read(BeyondContentDirectoryService.class); localService.setManager(new DefaultServiceManager<>( localService, BeyondContentDirectoryService.class)); String macAddress = Utils.getMACAddress(Utils.WLAN0); //Generate UUID by MAC address UDN udn = UDN.valueOf(UUID.nameUUIDFromBytes(macAddress.getBytes()).toString()); try { mLocalDevice = new LocalDevice(new DeviceIdentity(udn), new UDADeviceType("MediaServer"), new DeviceDetails("Local Media Server"), new LocalService[]{localService}); } catch (ValidationException e) { e.printStackTrace(); } upnpService.getRegistry().addDevice(mLocalDevice); //LocalBinder instead of binder binder = new LocalBinder(); }
Example #2
Source File: MediaServer.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public MediaServer(Context context ) throws ValidationException { mContext = context; DeviceType type = new UDADeviceType(deviceType, version); DeviceDetails details = new DeviceDetails(SettingActivity.getDeviceName(context) + " (" + android.os.Build.MODEL + ")", new ManufacturerDetails( android.os.Build.MANUFACTURER), new ModelDetails(android.os.Build.MODEL, Utils.DMS_DESC, "v1")); LocalService service = new AnnotationLocalServiceBinder() .read(ContentDirectoryService.class); service.setManager(new DefaultServiceManager<ContentDirectoryService>(service, ContentDirectoryService.class)); udn = UpnpUtil.uniqueSystemIdentifier("msidms"); localDevice = new LocalDevice(new DeviceIdentity(udn), type, details, createDefaultDeviceIcon(), service); Log.v(LOGTAG, "MediaServer device created: "); Log.v(LOGTAG, "friendly name: " + details.getFriendlyName()); Log.v(LOGTAG, "manufacturer: " + details.getManufacturerDetails().getManufacturer()); Log.v(LOGTAG, "model: " + details.getModelDetails().getModelName()); // start http server try { new HttpServer(PORT); } catch (IOException ioe) { System.err.println("Couldn't start server:\n" + ioe); System.exit(-1); } Log.v(LOGTAG, "Started Http Server on port " + PORT); }
Example #3
Source File: ZxtMediaRenderer.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public ZxtMediaRenderer(int numberOfPlayers, String name, Context context) { mContext = context; // This is the backend which manages the actual player instances mediaPlayers = new ZxtMediaPlayers( numberOfPlayers, context, avTransportLastChange, renderingControlLastChange ) { // These overrides connect the player instances to the output/display @Override protected void onPlay(ZxtMediaPlayer player) { // getDisplayHandler().onPlay(player); } @Override protected void onStop(ZxtMediaPlayer player) { // getDisplayHandler().onStop(player); } }; // The connection manager doesn't have to do much, HTTP is stateless LocalService connectionManagerService = binder.read(ZxtConnectionManagerService.class); connectionManager = new DefaultServiceManager(connectionManagerService) { @Override protected Object createServiceInstance() throws Exception { return new ZxtConnectionManagerService(); } }; connectionManagerService.setManager(connectionManager); // The AVTransport just passes the calls on to the backend players LocalService<AVTransportService> avTransportService = binder.read(AVTransportService.class); avTransport = new LastChangeAwareServiceManager<AVTransportService>( avTransportService, new AVTransportLastChangeParser() ) { @Override protected AVTransportService createServiceInstance() throws Exception { return new AVTransportService(avTransportLastChange, mediaPlayers); } }; avTransportService.setManager(avTransport); // The Rendering Control just passes the calls on to the backend players LocalService<AudioRenderingControl> renderingControlService = binder.read(AudioRenderingControl.class); renderingControl = new LastChangeAwareServiceManager<AudioRenderingControl>( renderingControlService, new RenderingControlLastChangeParser() ) { @Override protected AudioRenderingControl createServiceInstance() throws Exception { return new AudioRenderingControl(renderingControlLastChange, mediaPlayers); } }; renderingControlService.setManager(renderingControl); try { UDN udn = UpnpUtil.uniqueSystemIdentifier("msidmr"); device = new LocalDevice( //TODO zxt new DeviceIdentity(udn), new UDADeviceType("MediaRenderer", 1), new DeviceDetails( name, new ManufacturerDetails(Utils.MANUFACTURER), new ModelDetails(Utils.DMR_NAME, Utils.DMR_DESC, "1", Utils.DMR_MODEL_URL), new DLNADoc[] { new DLNADoc("DMR", DLNADoc.Version.V1_5) }, new DLNACaps(new String[] { "av-upload" //, "image-upload", "audio-upload" }) ), new Icon[]{createDefaultDeviceIcon()}, new LocalService[]{ avTransportService, renderingControlService, connectionManagerService } ); Log.i(TAG, "getType: " + device.getType().toString()); } catch (ValidationException ex) { throw new RuntimeException(ex); } runLastChangePushThread(); }
Example #4
Source File: MediaServer.java From HPlayer with Apache License 2.0 | 4 votes |
public MediaServer(final Context context) throws ValidationException, UnknownHostException { localAddress = getWIFIIpAddress(context); generateContentTask = new GenerateContentTask(); generateContentTask.execute(context); udn = new UDN(UUID.randomUUID()); DeviceType type = new UDADeviceType(deviceType, version); DeviceDetails details = new DeviceDetails(android.os.Build.MODEL, new ManufacturerDetails(android.os.Build.MANUFACTURER), new ModelDetails("HPlayer", "HPlayer MediaServer for Android", "v1")); LocalServiceBinder binder = new AnnotationLocalServiceBinder(); // 文件共享服务 LocalService<ContentDirectoryService> contentDirectoryService = binder.read(ContentDirectoryService.class); ServiceManager<ContentDirectoryService> contentDirectoryManger = new DefaultServiceManager<ContentDirectoryService>(contentDirectoryService) { @Override protected ContentDirectoryService createServiceInstance() throws Exception { return new ContentDirectoryService(); } }; contentDirectoryService.setManager(contentDirectoryManger); // 连接管理服务 LocalService<ConnectionManagerService> connectionManagerService = binder.read(ConnectionManagerService.class); connectionManagerService.setManager(new DefaultServiceManager<>( connectionManagerService, ConnectionManagerService.class)); // TODO 添加 AVTransportService // TODO 添加 AudioRenderingControl localDevice = new LocalDevice(new DeviceIdentity(udn), type, details, new LocalService[]{contentDirectoryService, connectionManagerService}); // 启动服务器 try { nanoHttpServer = new NanoHttpServer(port); nanoHttpServer.start(); Log.d(TAG, "Started Http Server on port " + port); } catch (IOException e) { Log.d(TAG, "Started Http Server on error:" + e.getMessage()); Toast.makeText(context, "启动服务器失败!", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } }
Example #5
Source File: UPnPService.java From subsonic with GNU General Public License v3.0 | 4 votes |
private LocalDevice createMediaServerDevice() throws Exception { String serverName = settingsService.getDlnaServerName(); DeviceIdentity identity = new DeviceIdentity(UDN.uniqueSystemIdentifier(serverName)); DeviceType type = new UDADeviceType("MediaServer", 1); // TODO: DLNACaps Version version = versionService.getLocalVersion(); String versionString = version == null ? null : version.toString(); String licenseEmail = settingsService.getLicenseEmail(); String licenseString = licenseEmail == null ? "Unlicensed" : ("Licensed to " + licenseEmail); DeviceDetails details = new DeviceDetails(serverName, new ManufacturerDetails(serverName), new ModelDetails(serverName, licenseString, versionString), new DLNADoc[]{new DLNADoc("DMS", DLNADoc.Version.V1_5)}, null); Icon icon = new Icon("image/png", 512, 512, 32, getClass().getResource("subsonic-512.png")); LocalService<FolderBasedContentDirectory> contentDirectoryservice = new AnnotationLocalServiceBinder().read(FolderBasedContentDirectory.class); contentDirectoryservice.setManager(new DefaultServiceManager<FolderBasedContentDirectory>(contentDirectoryservice) { @Override protected FolderBasedContentDirectory createServiceInstance() throws Exception { return folderBasedContentDirectory; } }); final ProtocolInfos protocols = new ProtocolInfos(); for (DLNAProfiles dlnaProfile : DLNAProfiles.values()) { if (dlnaProfile == DLNAProfiles.NONE) { continue; } try { protocols.add(new DLNAProtocolInfo(dlnaProfile)); } catch (Exception e) { // Silently ignored. } } LocalService<ConnectionManagerService> connetionManagerService = new AnnotationLocalServiceBinder().read(ConnectionManagerService.class); connetionManagerService.setManager(new DefaultServiceManager<ConnectionManagerService>(connetionManagerService) { @Override protected ConnectionManagerService createServiceInstance() throws Exception { return new ConnectionManagerService(protocols, null); } }); // For compatibility with Microsoft LocalService<MSMediaReceiverRegistrarService> receiverService = new AnnotationLocalServiceBinder().read(MSMediaReceiverRegistrarService.class); receiverService.setManager(new DefaultServiceManager<MSMediaReceiverRegistrarService>(receiverService, MSMediaReceiverRegistrarService.class)); return new LocalDevice(identity, type, details, new Icon[]{icon}, new LocalService[]{contentDirectoryservice, connetionManagerService, receiverService}); }
Example #6
Source File: ZxtMediaRenderer.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public ZxtMediaRenderer(int numberOfPlayers,Context context) { mContext = context; // This is the backend which manages the actual player instances mediaPlayers = new ZxtMediaPlayers( numberOfPlayers, context, avTransportLastChange, renderingControlLastChange ) { // These overrides connect the player instances to the output/display @Override protected void onPlay(ZxtMediaPlayer player) { // getDisplayHandler().onPlay(player); } @Override protected void onStop(ZxtMediaPlayer player) { // getDisplayHandler().onStop(player); } }; // The connection manager doesn't have to do much, HTTP is stateless LocalService connectionManagerService = binder.read(ZxtConnectionManagerService.class); connectionManager = new DefaultServiceManager(connectionManagerService) { @Override protected Object createServiceInstance() throws Exception { return new ZxtConnectionManagerService(); } }; connectionManagerService.setManager(connectionManager); // The AVTransport just passes the calls on to the backend players LocalService<AVTransportService> avTransportService = binder.read(AVTransportService.class); avTransport = new LastChangeAwareServiceManager<AVTransportService>( avTransportService, new AVTransportLastChangeParser() ) { @Override protected AVTransportService createServiceInstance() throws Exception { return new AVTransportService(avTransportLastChange, mediaPlayers); } }; avTransportService.setManager(avTransport); // The Rendering Control just passes the calls on to the backend players LocalService<AudioRenderingControl> renderingControlService = binder.read(AudioRenderingControl.class); renderingControl = new LastChangeAwareServiceManager<AudioRenderingControl>( renderingControlService, new RenderingControlLastChangeParser() ) { @Override protected AudioRenderingControl createServiceInstance() throws Exception { return new AudioRenderingControl(renderingControlLastChange, mediaPlayers); } }; renderingControlService.setManager(renderingControl); try { UDN udn = UpnpUtil.uniqueSystemIdentifier("msidmr"); device = new LocalDevice( //TODO zxt new DeviceIdentity(udn), new UDADeviceType("MediaRenderer", 1), new DeviceDetails( SettingActivity.getRenderName(context) + " (" + android.os.Build.MODEL + ")", new ManufacturerDetails(Utils.MANUFACTURER), new ModelDetails(Utils.DMR_NAME, Utils.DMR_DESC, "1", Utils.DMR_MODEL_URL), new DLNADoc[] { new DLNADoc("DMR", DLNADoc.Version.V1_5) }, new DLNACaps(new String[] { "av-upload", "image-upload", "audio-upload" }) ), new Icon[]{createDefaultDeviceIcon()}, new LocalService[]{ avTransportService, renderingControlService, connectionManagerService } ); Log.i(TAG, "getType: " + device.getType().toString()); } catch (ValidationException ex) { throw new RuntimeException(ex); } runLastChangePushThread(); }