revert dlna to relative url's
This commit is contained in:
parent
fc60d37a8d
commit
d7e2ffee38
|
@ -174,6 +174,8 @@ namespace MediaBrowser.Dlna.Main
|
||||||
"upnp:rootdevice",
|
"upnp:rootdevice",
|
||||||
"urn:schemas-upnp-org:device:MediaServer:1",
|
"urn:schemas-upnp-org:device:MediaServer:1",
|
||||||
"urn:schemas-upnp-org:service:ContentDirectory: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")
|
"uuid:" + guid.ToString("N")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ namespace MediaBrowser.Dlna.Server
|
||||||
_serverAddress = serverAddress;
|
_serverAddress = serverAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AbsoluteUrls
|
private bool EnableAbsoluteUrls
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetXml()
|
public string GetXml()
|
||||||
|
@ -91,7 +91,9 @@ namespace MediaBrowser.Dlna.Server
|
||||||
builder.Append("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>");
|
builder.Append("<modelURL>" + SecurityElement.Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>");
|
||||||
builder.Append("<serialNumber>" + SecurityElement.Escape(_profile.SerialNumber ?? string.Empty) + "</serialNumber>");
|
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>");
|
builder.Append("<URLBase>" + SecurityElement.Escape(_serverAddress) + "</URLBase>");
|
||||||
}
|
}
|
||||||
|
@ -153,7 +155,7 @@ namespace MediaBrowser.Dlna.Server
|
||||||
|
|
||||||
url = "/dlna/" + _serverUdn + "/" + url;
|
url = "/dlna/" + _serverUdn + "/" + url;
|
||||||
|
|
||||||
if (AbsoluteUrls)
|
if (EnableAbsoluteUrls)
|
||||||
{
|
{
|
||||||
url = _serverAddress.TrimEnd('/') + url;
|
url = _serverAddress.TrimEnd('/') + url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,26 +11,15 @@ namespace MediaBrowser.Dlna.Ssdp
|
||||||
public EndPoint ToEndPoint { get; private set; }
|
public EndPoint ToEndPoint { get; private set; }
|
||||||
public EndPoint FromEndPoint { get; private set; }
|
public EndPoint FromEndPoint { get; private set; }
|
||||||
public string Message { 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; }
|
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;
|
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;
|
Message = message;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
IgnoreBindFailure = ignoreBindFailure;
|
IgnoreBindFailure = ignoreBindFailure;
|
||||||
TotalSendCount = totalSendCount;
|
|
||||||
FromEndPoint = fromEndPoint;
|
FromEndPoint = fromEndPoint;
|
||||||
ToEndPoint = toEndPoint;
|
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());
|
_logger.ErrorException("Error sending Datagram to {0} from {1}: " + Message, ex, ToEndPoint, FromEndPoint == null ? "" : FromEndPoint.ToString());
|
||||||
}
|
}
|
||||||
++SendCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Socket CreateSocket()
|
private Socket CreateSocket()
|
||||||
|
|
|
@ -129,18 +129,28 @@ namespace MediaBrowser.Dlna.Ssdp
|
||||||
int sendCount = 1)
|
int sendCount = 1)
|
||||||
{
|
{
|
||||||
var msg = new SsdpMessageBuilder().BuildMessage(header, values);
|
var msg = new SsdpMessageBuilder().BuildMessage(header, values);
|
||||||
|
var queued = false;
|
||||||
|
|
||||||
var dgram = new Datagram(endpoint, localAddress, _logger, msg, sendCount, ignoreBindFailure);
|
for (var i = 0; i < sendCount; i++)
|
||||||
|
{
|
||||||
|
var dgram = new Datagram(endpoint, localAddress, _logger, msg, ignoreBindFailure);
|
||||||
|
|
||||||
if (_messageQueue.Count == 0)
|
if (_messageQueue.Count == 0)
|
||||||
{
|
{
|
||||||
dgram.Send();
|
dgram.Send();
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_messageQueue.Enqueue(dgram);
|
||||||
|
queued = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_messageQueue.Enqueue(dgram);
|
if (queued)
|
||||||
|
{
|
||||||
StartQueueTimer();
|
StartQueueTimer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// According to the spec: http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf
|
/// According to the spec: http://www.upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0-20080424.pdf
|
||||||
|
@ -189,8 +199,8 @@ namespace MediaBrowser.Dlna.Ssdp
|
||||||
values["ST"] = d.Type;
|
values["ST"] = d.Type;
|
||||||
values["USN"] = d.USN;
|
values["USN"] = d.USN;
|
||||||
|
|
||||||
SendDatagram(header, values, endpoint, null, true);
|
SendDatagram(header, values, endpoint, null, true, 1);
|
||||||
SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true);
|
SendDatagram(header, values, endpoint, new IPEndPoint(d.Address, 0), true, 1);
|
||||||
//SendDatagram(header, values, endpoint, null, true);
|
//SendDatagram(header, values, endpoint, null, true);
|
||||||
|
|
||||||
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
if (_config.GetDlnaConfiguration().EnableDebugLogging)
|
||||||
|
@ -208,36 +218,21 @@ namespace MediaBrowser.Dlna.Ssdp
|
||||||
{
|
{
|
||||||
if (_queueTimer == null)
|
if (_queueTimer == null)
|
||||||
{
|
{
|
||||||
_queueTimer = new Timer(QueueTimerCallback, null, 1000, Timeout.Infinite);
|
_queueTimer = new Timer(QueueTimerCallback, null, 500, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_queueTimer.Change(1000, Timeout.Infinite);
|
_queueTimer.Change(500, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void QueueTimerCallback(object state)
|
private void QueueTimerCallback(object state)
|
||||||
{
|
|
||||||
while (_messageQueue.Count != 0)
|
|
||||||
{
|
{
|
||||||
Datagram msg;
|
Datagram msg;
|
||||||
if (!_messageQueue.TryPeek(out msg))
|
while (_messageQueue.TryDequeue(out msg))
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg != null && (!_isDisposed || msg.TotalSendCount > 1))
|
|
||||||
{
|
{
|
||||||
msg.Send();
|
msg.Send();
|
||||||
if (msg.SendCount > msg.TotalSendCount)
|
|
||||||
{
|
|
||||||
_messageQueue.TryDequeue(out msg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_messageQueue.TryDequeue(out msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_datagramPosted.Set();
|
_datagramPosted.Set();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user