diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index c75f2e40cd..f6c04cdbe9 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -174,6 +174,8 @@ namespace MediaBrowser.Dlna.Main "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:" + guid.ToString("N") }; diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index 47c10ac2c9..ae544cb6c7 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -33,9 +33,9 @@ namespace MediaBrowser.Dlna.Server _serverAddress = serverAddress; } - private bool AbsoluteUrls + private bool EnableAbsoluteUrls { - get { return true; } + get { return false; } } public string GetXml() @@ -91,7 +91,9 @@ namespace MediaBrowser.Dlna.Server builder.Append("" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + ""); builder.Append("" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + ""); - if (!AbsoluteUrls) + builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); + + if (!EnableAbsoluteUrls) { builder.Append("" + SecurityElement.Escape(_serverAddress) + ""); } @@ -153,7 +155,7 @@ namespace MediaBrowser.Dlna.Server url = "/dlna/" + _serverUdn + "/" + url; - if (AbsoluteUrls) + if (EnableAbsoluteUrls) { url = _serverAddress.TrimEnd('/') + url; } diff --git a/MediaBrowser.Dlna/Ssdp/Datagram.cs b/MediaBrowser.Dlna/Ssdp/Datagram.cs index f16464209b..ae79ab44f1 100644 --- a/MediaBrowser.Dlna/Ssdp/Datagram.cs +++ b/MediaBrowser.Dlna/Ssdp/Datagram.cs @@ -11,26 +11,15 @@ namespace MediaBrowser.Dlna.Ssdp public EndPoint ToEndPoint { get; private set; } public EndPoint FromEndPoint { get; private set; } public string Message { get; private set; } - - /// - /// The number of times to send the message - /// - public int TotalSendCount { get; private set; } public bool IgnoreBindFailure { get; private set; } - /// - /// The number of times the message has been sent - /// - public int SendCount { get; private set; } - private readonly ILogger _logger; - public Datagram(EndPoint toEndPoint, EndPoint fromEndPoint, ILogger logger, string message, int totalSendCount, bool ignoreBindFailure) + public Datagram(EndPoint toEndPoint, EndPoint fromEndPoint, ILogger logger, string message, bool ignoreBindFailure) { Message = message; _logger = logger; IgnoreBindFailure = ignoreBindFailure; - TotalSendCount = totalSendCount; FromEndPoint = fromEndPoint; ToEndPoint = toEndPoint; } @@ -83,7 +72,6 @@ namespace MediaBrowser.Dlna.Ssdp { _logger.ErrorException("Error sending Datagram to {0} from {1}: " + Message, ex, ToEndPoint, FromEndPoint == null ? "" : FromEndPoint.ToString()); } - ++SendCount; } private Socket CreateSocket() diff --git a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs index 105ecc650f..8ca16832da 100644 --- a/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs +++ b/MediaBrowser.Dlna/Ssdp/SsdpHandler.cs @@ -129,17 +129,27 @@ namespace MediaBrowser.Dlna.Ssdp int sendCount = 1) { var msg = new SsdpMessageBuilder().BuildMessage(header, values); + var queued = false; - var dgram = new Datagram(endpoint, localAddress, _logger, msg, sendCount, ignoreBindFailure); - - if (_messageQueue.Count == 0) + for (var i = 0; i < sendCount; i++) { - dgram.Send(); - return; + var dgram = new Datagram(endpoint, localAddress, _logger, msg, ignoreBindFailure); + + if (_messageQueue.Count == 0) + { + dgram.Send(); + } + else + { + _messageQueue.Enqueue(dgram); + queued = true; + } } - _messageQueue.Enqueue(dgram); - StartQueueTimer(); + if (queued) + { + StartQueueTimer(); + } } /// @@ -189,8 +199,8 @@ namespace MediaBrowser.Dlna.Ssdp values["ST"] = d.Type; values["USN"] = d.USN; - SendDatagram(header, values, endpoint, null, true); - SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true); + SendDatagram(header, values, endpoint, null, true, 1); + SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true, 1); //SendDatagram(header, values, endpoint, null, true); if (_config.GetDlnaConfiguration().EnableDebugLogging) @@ -208,36 +218,21 @@ namespace MediaBrowser.Dlna.Ssdp { if (_queueTimer == null) { - _queueTimer = new Timer(QueueTimerCallback, null, 1000, Timeout.Infinite); + _queueTimer = new Timer(QueueTimerCallback, null, 500, Timeout.Infinite); } else { - _queueTimer.Change(1000, Timeout.Infinite); + _queueTimer.Change(500, Timeout.Infinite); } } } private void QueueTimerCallback(object state) { - while (_messageQueue.Count != 0) + Datagram msg; + while (_messageQueue.TryDequeue(out msg)) { - Datagram msg; - if (!_messageQueue.TryPeek(out msg)) - { - continue; - } - - if (msg != null && (!_isDisposed || msg.TotalSendCount > 1)) - { - msg.Send(); - if (msg.SendCount > msg.TotalSendCount) - { - _messageQueue.TryDequeue(out msg); - } - break; - } - - _messageQueue.TryDequeue(out msg); + msg.Send(); } _datagramPosted.Set();