diff --git a/Emby.Dlna/Eventing/EventManager.cs b/Emby.Dlna/Eventing/EventManager.cs
index cf2c8d995..0516585ae 100644
--- a/Emby.Dlna/Eventing/EventManager.cs
+++ b/Emby.Dlna/Eventing/EventManager.cs
@@ -26,32 +26,34 @@ namespace Emby.Dlna.Eventing
_logger = logger;
}
- public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds)
+ public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string requestedTimeoutString)
{
- var timeout = timeoutSeconds ?? 300;
-
var subscription = GetSubscription(subscriptionId, true);
- _logger.Debug("Renewing event subscription for {0} with timeout of {1} to {2}",
- subscription.NotificationType,
- timeout,
- subscription.CallbackUrl);
+ // Remove logging for now because some devices are sending this very frequently
+ // TODO re-enable with dlna debug logging setting
+ //_logger.Debug("Renewing event subscription for {0} with timeout of {1} to {2}",
+ // subscription.NotificationType,
+ // timeout,
+ // subscription.CallbackUrl);
- subscription.TimeoutSeconds = timeout;
+ subscription.TimeoutSeconds = ParseTimeout(requestedTimeoutString) ?? 300;
subscription.SubscriptionTime = DateTime.UtcNow;
- return GetEventSubscriptionResponse(subscriptionId, timeout);
+ return GetEventSubscriptionResponse(subscriptionId, requestedTimeoutString, subscription.TimeoutSeconds);
}
- public EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl)
+ public EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl)
{
- var timeout = timeoutSeconds ?? 300;
+ var timeout = ParseTimeout(requestedTimeoutString) ?? 300;
var id = "uuid:" + Guid.NewGuid().ToString("N");
- _logger.Debug("Creating event subscription for {0} with timeout of {1} to {2}",
- notificationType,
- timeout,
- callbackUrl);
+ // Remove logging for now because some devices are sending this very frequently
+ // TODO re-enable with dlna debug logging setting
+ //_logger.Debug("Creating event subscription for {0} with timeout of {1} to {2}",
+ // notificationType,
+ // timeout,
+ // callbackUrl);
_subscriptions.TryAdd(id, new EventSubscription
{
@@ -61,7 +63,25 @@ namespace Emby.Dlna.Eventing
TimeoutSeconds = timeout
});
- return GetEventSubscriptionResponse(id, timeout);
+ return GetEventSubscriptionResponse(id, requestedTimeoutString, timeout);
+ }
+
+ private int? ParseTimeout(string header)
+ {
+ if (!string.IsNullOrEmpty(header))
+ {
+ // Starts with SECOND-
+ header = header.Split('-').Last();
+
+ int val;
+
+ if (int.TryParse(header, NumberStyles.Any, _usCulture, out val))
+ {
+ return val;
+ }
+ }
+
+ return null;
}
public EventSubscriptionResponse CancelEventSubscription(string subscriptionId)
@@ -73,22 +93,22 @@ namespace Emby.Dlna.Eventing
return new EventSubscriptionResponse
{
- Content = "\r\n",
+ Content = string.Empty,
ContentType = "text/plain"
};
}
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- private EventSubscriptionResponse GetEventSubscriptionResponse(string subscriptionId, int timeoutSeconds)
+ private EventSubscriptionResponse GetEventSubscriptionResponse(string subscriptionId, string requestedTimeoutString, int timeoutSeconds)
{
var response = new EventSubscriptionResponse
{
- Content = "\r\n",
+ Content = string.Empty,
ContentType = "text/plain"
};
response.Headers["SID"] = subscriptionId;
- response.Headers["TIMEOUT"] = "SECOND-" + timeoutSeconds.ToString(_usCulture);
+ response.Headers["TIMEOUT"] = string.IsNullOrWhiteSpace(requestedTimeoutString) ? ("SECOND-" + timeoutSeconds.ToString(_usCulture)) : requestedTimeoutString;
return response;
}
diff --git a/Emby.Dlna/Service/BaseService.cs b/Emby.Dlna/Service/BaseService.cs
index 574d74958..ddc37da09 100644
--- a/Emby.Dlna/Service/BaseService.cs
+++ b/Emby.Dlna/Service/BaseService.cs
@@ -24,14 +24,14 @@ namespace Emby.Dlna.Service
return EventManager.CancelEventSubscription(subscriptionId);
}
- public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds)
+ public EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string timeoutString)
{
- return EventManager.RenewEventSubscription(subscriptionId, timeoutSeconds);
+ return EventManager.RenewEventSubscription(subscriptionId, timeoutString);
}
- public EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl)
+ public EventSubscriptionResponse CreateEventSubscription(string notificationType, string timeoutString, string callbackUrl)
{
- return EventManager.CreateEventSubscription(notificationType, timeoutSeconds, callbackUrl);
+ return EventManager.CreateEventSubscription(notificationType, timeoutString, callbackUrl);
}
}
}
diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs
index 6e59cceec..fc8c0edf6 100644
--- a/MediaBrowser.Api/Dlna/DlnaServerService.cs
+++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs
@@ -219,20 +219,20 @@ namespace MediaBrowser.Api.Dlna
private object ProcessEventRequest(IEventManager eventManager)
{
var subscriptionId = GetHeader("SID");
- var notificationType = GetHeader("NT");
- var callback = GetHeader("CALLBACK");
- var timeoutString = GetHeader("TIMEOUT");
-
- var timeout = ParseTimeout(timeoutString);
if (string.Equals(Request.Verb, "SUBSCRIBE", StringComparison.OrdinalIgnoreCase))
{
+ var notificationType = GetHeader("NT");
+
+ var callback = GetHeader("CALLBACK");
+ var timeoutString = GetHeader("TIMEOUT");
+
if (string.IsNullOrEmpty(notificationType))
{
- return GetSubscriptionResponse(eventManager.RenewEventSubscription(subscriptionId, timeout));
+ return GetSubscriptionResponse(eventManager.RenewEventSubscription(subscriptionId, timeoutString));
}
- return GetSubscriptionResponse(eventManager.CreateEventSubscription(notificationType, timeout, callback));
+ return GetSubscriptionResponse(eventManager.CreateEventSubscription(notificationType, timeoutString, callback));
}
return GetSubscriptionResponse(eventManager.CancelEventSubscription(subscriptionId));
@@ -242,24 +242,5 @@ namespace MediaBrowser.Api.Dlna
{
return ResultFactory.GetResult(response.Content, response.ContentType, response.Headers);
}
-
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
- private int? ParseTimeout(string header)
- {
- if (!string.IsNullOrEmpty(header))
- {
- // Starts with SECOND-
- header = header.Split('-').Last();
-
- int val;
-
- if (int.TryParse(header, NumberStyles.Any, _usCulture, out val))
- {
- return val;
- }
- }
-
- return null;
- }
}
}
diff --git a/MediaBrowser.Controller/Dlna/IEventManager.cs b/MediaBrowser.Controller/Dlna/IEventManager.cs
index 54e2a02dd..8c91bd889 100644
--- a/MediaBrowser.Controller/Dlna/IEventManager.cs
+++ b/MediaBrowser.Controller/Dlna/IEventManager.cs
@@ -12,18 +12,11 @@ namespace MediaBrowser.Controller.Dlna
///
/// Renews the event subscription.
///
- /// The subscription identifier.
- /// The timeout seconds.
- /// EventSubscriptionResponse.
- EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds);
+ EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string requestedTimeoutString);
///
/// Creates the event subscription.
///
- /// Type of the notification.
- /// The timeout seconds.
- /// The callback URL.
- /// EventSubscriptionResponse.
- EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl);
+ EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl);
}
}
diff --git a/SharedVersion.cs b/SharedVersion.cs
index df89e08a2..7fed66523 100644
--- a/SharedVersion.cs
+++ b/SharedVersion.cs
@@ -1,3 +1,3 @@
using System.Reflection;
-[assembly: AssemblyVersion("3.2.25.9")]
+[assembly: AssemblyVersion("3.2.25.10")]