public static void main(String[] args) throws Exception { System.out.println("Starting Cling..."); UpnpService upnpService = new UpnpServiceImpl(); long noOfDevices = args.length == 1 ? Long.valueOf(args[0]) : 10; System.out.println("Registering BinaryLight devices: " + noOfDevices); for (long i = 0; i <= noOfDevices; i++) { LocalService service = new AnnotationLocalServiceBinder().read(DemoBinaryLight.class); service.setManager(new DefaultServiceManager(service, DemoBinaryLight.class)); upnpService.getRegistry().addDevice( DemoBinaryLight.createDefaultDevice(UDN.uniqueSystemIdentifier(Long.toString(i)), "Device: " + i, service) ); } System.out.println("Completed device registration"); } }
protected LocalDevice createDevice() throws ValidationException, LocalServiceBindingException { DeviceType type = new UDADeviceType("BinaryLight", 1); DeviceDetails details = new DeviceDetails( "Friendly Binary Light", new ManufacturerDetails("ACME"), new ModelDetails("AndroidLight", "A light with on/off switch.", "v1") ); LocalService service = new AnnotationLocalServiceBinder().read(SwitchPower.class); service.setManager( new DefaultServiceManager<>(service, SwitchPower.class) ); return new LocalDevice( new DeviceIdentity(udn), type, details, createDefaultDeviceIcon(), service ); } // DOC:CREATE_DEVICE
public MediaServer(InetAddress localAddress, Context ctx) throws ValidationException { super(null, port, null, true); Log.i(TAG, "Creating media server !"); localService = new AnnotationLocalServiceBinder() .read(ContentDirectoryService.class); localService.setManager(new DefaultServiceManager<ContentDirectoryService>( localService, ContentDirectoryService.class)); udn = UDN.valueOf(new UUID(0,10).toString()); this.localAddress = localAddress; this.ctx = ctx; createLocalDevice(); ContentDirectoryService contentDirectoryService = (ContentDirectoryService)localService.getManager().getImplementation(); contentDirectoryService.setContext(ctx); contentDirectoryService.setBaseURL(getAddress()); }
= binder.read(ContentDirectoryService.class); ServiceManager<ContentDirectoryService> contentDirectoryManger = new DefaultServiceManager<ContentDirectoryService>(contentDirectoryService) { @Override protected ContentDirectoryService createServiceInstance() throws Exception { connectionManagerService.setManager(new DefaultServiceManager<>( connectionManagerService, ConnectionManagerService.class));
cds.setManager(new DefaultServiceManager<ContentDirectoryService>(cds, ContentDirectoryService.class)); cms.setManager(new DefaultServiceManager<ConnectionManagerService>(cms, ConnectionManagerService.class) { @Override protected ConnectionManagerService createServiceInstance() throws Exception { mss.setManager(new DefaultServiceManager<MSMediaReceiverRegistrarService>(mss, MSMediaReceiverRegistrarService.class));
public MediaServer(InetAddress localAddress) throws ValidationException { DeviceType type = new UDADeviceType(deviceType, version); DeviceDetails details = new DeviceDetails(android.os.Build.MODEL, new ManufacturerDetails(android.os.Build.MANUFACTURER), new ModelDetails("GNaP", "GNaP MediaServer for Android", "v1")); LocalService service = new AnnotationLocalServiceBinder() .read(ContentDirectoryService.class); service.setManager(new DefaultServiceManager<ContentDirectoryService>( service, ContentDirectoryService.class)); localDevice = new LocalDevice(new DeviceIdentity(udn), type, details, service); this.localAddress = localAddress; LogUtil.v(TAG, "MediaServer device created: "); LogUtil.v(TAG, "friendly name: " + details.getFriendlyName()); LogUtil.v(TAG, "manufacturer: " + details.getManufacturerDetails().getManufacturer()); LogUtil.v(TAG, "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); } LogUtil.v(TAG, "Started Http Server on port " + port); }
LocalService<ConnectionManagerService> connectionManager = new AnnotationLocalServiceBinder().read( ConnectionManagerService.class ); connectionManager.setManager( new DefaultServiceManager<ConnectionManagerService>( connectionManager, ConnectionManagerService.class ) ); LocalService<MediaReceiverRegistrar> mediaReceiverRegistrar = new AnnotationLocalServiceBinder().read( MediaReceiverRegistrar.class ); mediaReceiverRegistrar.setManager( new DefaultServiceManager<MediaReceiverRegistrar>( mediaReceiverRegistrar, MediaReceiverRegistrar.class ) );