Search in sources :

Example 1 with UDN

use of org.fourthline.cling.model.types.UDN in project BeyondUPnP by kevinshine.

the class ContentContainerActivity method loadContent.

private void loadContent() {
    SystemManager systemManager = SystemManager.getInstance();
    Device device = null;
    try {
        device = systemManager.getRegistry().getDevice(new UDN(mIdentifierString), false);
    } catch (NullPointerException e) {
        Log.e(TAG, "Get device error.");
    }
    if (device != null) {
        //Get cds to browse children directories.
        Service contentDeviceService = device.findService(SystemManager.CONTENT_DIRECTORY_SERVICE);
        //Execute Browse action and init list view
        systemManager.getControlPoint().execute(new Browse(contentDeviceService, mObjectId, BrowseFlag.DIRECT_CHILDREN, "*", 0, null, new SortCriterion(true, "dc:title")) {

            @Override
            public void received(ActionInvocation actionInvocation, DIDLContent didl) {
                Message msg = Message.obtain(handler, ADD_OBJECTS, didl);
                msg.sendToTarget();
            }

            @Override
            public void updateStatus(Status status) {
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            }
        });
    }
}
Also used : Message(android.os.Message) UpnpResponse(org.fourthline.cling.model.message.UpnpResponse) Device(org.fourthline.cling.model.meta.Device) ActionInvocation(org.fourthline.cling.model.action.ActionInvocation) SystemManager(com.kevinshen.beyondupnp.core.SystemManager) Service(org.fourthline.cling.model.meta.Service) DIDLContent(org.fourthline.cling.support.model.DIDLContent) Browse(org.fourthline.cling.support.contentdirectory.callback.Browse) SortCriterion(org.fourthline.cling.support.model.SortCriterion) UDN(org.fourthline.cling.model.types.UDN)

Example 2 with UDN

use of org.fourthline.cling.model.types.UDN in project BeyondUPnP by kevinshine.

the class BeyondUpnpService method onCreate.

@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();
}
Also used : BeyondContentDirectoryService(com.kevinshen.beyondupnp.core.upnp.BeyondContentDirectoryService) DeviceIdentity(org.fourthline.cling.model.meta.DeviceIdentity) DeviceDetails(org.fourthline.cling.model.meta.DeviceDetails) ValidationException(org.fourthline.cling.model.ValidationException) LocalDevice(org.fourthline.cling.model.meta.LocalDevice) UDADeviceType(org.fourthline.cling.model.types.UDADeviceType) LocalService(org.fourthline.cling.model.meta.LocalService) AnnotationLocalServiceBinder(org.fourthline.cling.binding.annotations.AnnotationLocalServiceBinder) UDN(org.fourthline.cling.model.types.UDN)

Aggregations

UDN (org.fourthline.cling.model.types.UDN)2 Message (android.os.Message)1 SystemManager (com.kevinshen.beyondupnp.core.SystemManager)1 BeyondContentDirectoryService (com.kevinshen.beyondupnp.core.upnp.BeyondContentDirectoryService)1 AnnotationLocalServiceBinder (org.fourthline.cling.binding.annotations.AnnotationLocalServiceBinder)1 ValidationException (org.fourthline.cling.model.ValidationException)1 ActionInvocation (org.fourthline.cling.model.action.ActionInvocation)1 UpnpResponse (org.fourthline.cling.model.message.UpnpResponse)1 Device (org.fourthline.cling.model.meta.Device)1 DeviceDetails (org.fourthline.cling.model.meta.DeviceDetails)1 DeviceIdentity (org.fourthline.cling.model.meta.DeviceIdentity)1 LocalDevice (org.fourthline.cling.model.meta.LocalDevice)1 LocalService (org.fourthline.cling.model.meta.LocalService)1 Service (org.fourthline.cling.model.meta.Service)1 UDADeviceType (org.fourthline.cling.model.types.UDADeviceType)1 Browse (org.fourthline.cling.support.contentdirectory.callback.Browse)1 DIDLContent (org.fourthline.cling.support.model.DIDLContent)1 SortCriterion (org.fourthline.cling.support.model.SortCriterion)1