revert dlna to relative url's

This commit is contained in:
Luke Pulverenti 2015-01-31 18:12:22 -05:00
parent fc60d37a8d
commit d7e2ffee38
4 changed files with 33 additions and 46 deletions

View File

@ -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")
};

View File

@ -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("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>");
builder.Append("<serialNumber>" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + "</serialNumber>");
if (!AbsoluteUrls)
builder.Append("<presentationURL>" + SecurityElement.Escape(_serverAddress) + "</presentationURL>");
if (!EnableAbsoluteUrls)
{
builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
}
@ -153,7 +155,7 @@ namespace MediaBrowser.Dlna.Server
url = "/dlna/" + _serverUdn + "/" + url;
if (AbsoluteUrls)
if (EnableAbsoluteUrls)
{
url = _serverAddress.TrimEnd('/') + url;
}

View File

@ -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; }
/// <summary>
/// The number of times to send the message
/// </summary>
public int TotalSendCount { get; private set; }
public bool IgnoreBindFailure { get; private set; }
/// <summary>
/// The number of times the message has been sent
/// </summary>
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()

View File

@ -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();
}
}
/// <summary>
@ -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();