Beispiel #1
0
        private async Task RegisterServerEndpoints()
        {
            var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);

            var udn = CreateUuid(_appHost.SystemId);

            foreach (var address in addresses)
            {
                if (address.AddressFamily == AddressFamily.InterNetworkV6)
                {
                    // Not support IPv6 right now
                    continue;
                }

                var fullService = "urn:schemas-upnp-org:device:MediaServer:1";

                _logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);

                var descriptorUri = "/dlna/" + udn + "/description.xml";
                var uri           = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);

                var device = new SsdpRootDevice
                {
                    CacheLifetime = TimeSpan.FromSeconds(1800), //How long SSDP clients can cache this info.
                    Location      = uri,                        // Must point to the URL that serves your devices UPnP description document.
                    Address       = address,
                    SubnetMask    = _networkManager.GetLocalIpSubnetMask(address),
                    FriendlyName  = "Veso",
                    Manufacturer  = "Veso",
                    ModelName     = "Veso Server",
                    Uuid          = udn
                                    // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
                };

                SetProperies(device, fullService);
                _Publisher.AddDevice(device);

                var embeddedDevices = new[]
                {
                    "urn:schemas-upnp-org:service:ContentDirectory:1",
                    "urn:schemas-upnp-org:service:ConnectionManager:1",
                    //"urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1"
                };

                foreach (var subDevice in embeddedDevices)
                {
                    var embeddedDevice = new SsdpEmbeddedDevice
                    {
                        FriendlyName = device.FriendlyName,
                        Manufacturer = device.Manufacturer,
                        ModelName    = device.ModelName,
                        Uuid         = udn
                                       // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
                    };

                    SetProperies(embeddedDevice, subDevice);
                    device.AddDevice(embeddedDevice);
                }
            }
        }
Beispiel #2
0
        private async Task RegisterServerEndpoints()
        {
            var cacheLength = _config.GetDlnaConfiguration().BlastAliveMessageIntervalSeconds;

            var addresses = (await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false)).ToList();

            var udn = CreateUuid(_appHost.SystemId);

            foreach (var address in addresses)
            {
                // TODO: Remove this condition on platforms that support it
                //if (address.AddressFamily == IpAddressFamily.InterNetworkV6)
                //{
                //    continue;
                //}

                var fullService = "urn:schemas-upnp-org:device:MediaServer:1";

                _logger.Info("Registering publisher for {0} on {1}", fullService, address.ToString());

                var descriptorUri = "/dlna/" + udn + "/description.xml";
                var uri           = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);

                var device = new SsdpRootDevice
                {
                    CacheLifetime = TimeSpan.FromSeconds(cacheLength), //How long SSDP clients can cache this info.
                    Location      = uri,                               // Must point to the URL that serves your devices UPnP description document.
                    FriendlyName  = "Emby Server",
                    Manufacturer  = "Emby",
                    ModelName     = "Emby Server",
                    Uuid          = udn
                                    // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
                };

                SetProperies(device, fullService);
                _Publisher.AddDevice(device);

                var embeddedDevices = new []
                {
                    "urn:schemas-upnp-org:service:ContentDirectory:1",
                    "urn:schemas-upnp-org:service:ConnectionManager:1",
                    //"urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1"
                };

                foreach (var subDevice in embeddedDevices)
                {
                    var embeddedDevice = new SsdpEmbeddedDevice
                    {
                        FriendlyName = device.FriendlyName,
                        Manufacturer = device.Manufacturer,
                        ModelName    = device.ModelName,
                        Uuid         = udn
                                       // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
                    };

                    SetProperies(embeddedDevice, subDevice);
                    device.AddDevice(embeddedDevice);
                }
            }
        }
Beispiel #3
0
        private async Task RegisterServerEndpoints()
        {
            foreach (var address in await _appHost.GetLocalIpAddresses().ConfigureAwait(false))
            {
                //if (IPAddress.IsLoopback(address))
                //{
                //    // Should we allow this?
                //    continue;
                //}

                var addressString = address.ToString();
                var udn           = addressString.GetMD5().ToString("N");

                var descriptorURI = "/dlna/" + udn + "/description.xml";

                var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorURI);

                var services = new List <string>
                {
                    "upnp:rootdevice",
                    "urn:schemas-upnp-org:device:MediaServer:1",
                    "urn:schemas-upnp-org:service:ContentDirectory:1",
                    "urn:schemas-upnp-org:service:ConnectionManager:1",
                    "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1",
                    "uuid:" + udn
                };

                _ssdpHandler.RegisterNotification(udn, uri, address, services);

                _registeredServerIds.Add(udn);
            }
        }
Beispiel #4
0
        async void _ssdpHandler_MessageReceived(object sender, SsdpMessageEventArgs e)
        {
            string nts;

            e.Headers.TryGetValue("NTS", out nts);

            if (String.Equals(e.Method, "NOTIFY", StringComparison.OrdinalIgnoreCase) &&
                String.Equals(nts, "ssdp:byebye", StringComparison.OrdinalIgnoreCase) &&
                !_disposed)
            {
                EventHelper.FireEventIfNotNull(DeviceLeft, this, e, _logger);
                return;
            }

            try
            {
                if (e.LocalEndPoint == null)
                {
                    var ip = (await _appHost.GetLocalIpAddresses().ConfigureAwait(false)).FirstOrDefault(i => !IPAddress.IsLoopback(i));
                    if (ip != null)
                    {
                        e.LocalEndPoint = new IPEndPoint(ip, 0);
                    }
                }

                if (e.LocalEndPoint != null)
                {
                    TryCreateDevice(e);
                }
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error creating play to controller", ex);
            }
        }
Beispiel #5
0
        private async Task RegisterServerEndpoints()
        {
            if (!_config.GetDlnaConfiguration().BlastAliveMessages)
            {
                return;
            }

            var cacheLength = _config.GetDlnaConfiguration().BlastAliveMessageIntervalSeconds;

            _Publisher.SupportPnpRootDevice = false;

            var addresses = (await _appHost.GetLocalIpAddresses().ConfigureAwait(false)).ToList();

            foreach (var address in addresses)
            {
                //if (IPAddress.IsLoopback(address))
                //{
                //    // Should we allow this?
                //    continue;
                //}

                var addressString = address.ToString();

                var udn = (addressString).GetMD5().ToString("N");

                var services = new List <string>
                {
                    "urn:schemas-upnp-org:device:MediaServer:1",
                    "urn:schemas-upnp-org:service:ContentDirectory:1",
                    "urn:schemas-upnp-org:service:ConnectionManager:1",
                    "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1"
                };

                foreach (var fullService in services)
                {
                    _logger.Info("Registering publisher for {0} on {1}", fullService, addressString);

                    var descriptorURI = "/dlna/" + udn + "/description.xml";
                    var uri           = new Uri(_appHost.GetLocalApiUrl(address) + descriptorURI);

                    var service = fullService.Replace("urn:", string.Empty).Replace(":1", string.Empty);

                    var serviceParts = service.Split(':');

                    var deviceTypeNamespace = serviceParts[0].Replace('.', '-');

                    var device = new SsdpRootDevice
                    {
                        CacheLifetime       = TimeSpan.FromSeconds(cacheLength), //How long SSDP clients can cache this info.
                        Location            = uri,                               // Must point to the URL that serves your devices UPnP description document.
                        DeviceTypeNamespace = deviceTypeNamespace,
                        DeviceClass         = serviceParts[1],
                        DeviceType          = serviceParts[2],
                        FriendlyName        = "Emby Server",
                        Manufacturer        = "Emby",
                        ModelName           = "Emby Server",
                        Uuid = udn
                               // This must be a globally unique value that survives reboots etc. Get from storage or embedded hardware etc.
                    };

                    _Publisher.AddDevice(device);
                }
            }
        }