The Free Software Media System - Server Backend & API
3.2.25.10
Luke Pulverentid826b9844952
diff --git a/Emby.Dlna/Eventing/EventManager.cs b/Emby.Dlna/Eventing/EventManager.csindex cf2c8d9956..0516585ae0 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.EventingTimeoutSeconds = 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.Eventingreturn 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.csindex 574d749588..ddc37da095 100644--- a/Emby.Dlna/Service/BaseService.cs+++ b/Emby.Dlna/Service/BaseService.cs@@ -24,14 +24,14 @@ namespace Emby.Dlna.Servicereturn 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.csindex 6e59cceecd..fc8c0edf6b 100644--- a/MediaBrowser.Api/Dlna/DlnaServerService.cs+++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs@@ -219,20 +219,20 @@ namespace MediaBrowser.Api.Dlnaprivate 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.csindex 54e2a02dd5..8c91bd889d 100644--- a/MediaBrowser.Controller/Dlna/IEventManager.cs+++ b/MediaBrowser.Controller/Dlna/IEventManager.cs@@ -12,18 +12,11 @@ namespace MediaBrowser.Controller.Dlna/// <summary>/// Renews the event subscription./// </summary>- /// <param name="subscriptionId">The subscription identifier.</param>- /// <param name="timeoutSeconds">The timeout seconds.</param>- /// <returns>EventSubscriptionResponse.</returns>- EventSubscriptionResponse RenewEventSubscription(string subscriptionId, int? timeoutSeconds);+ EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string requestedTimeoutString);/// <summary>/// Creates the event subscription./// </summary>- /// <param name="notificationType">Type of the notification.</param>- /// <param name="timeoutSeconds">The timeout seconds.</param>- /// <param name="callbackUrl">The callback URL.</param>- /// <returns>EventSubscriptionResponse.</returns>- EventSubscriptionResponse CreateEventSubscription(string notificationType, int? timeoutSeconds, string callbackUrl);+ EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl);}}diff --git a/SharedVersion.cs b/SharedVersion.csindex df89e08a23..7fed66523b 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")]