The Free Software Media System - Server Backend & API
update direct stream url for improved caching
Luke Pulverenti6164049919f8
diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.csindex 5866ad15bc..3280358dfa 100644--- a/MediaBrowser.Api/Images/ImageService.cs+++ b/MediaBrowser.Api/Images/ImageService.cs@@ -573,11 +573,9 @@ namespace MediaBrowser.Api.Imagesvar outputFormats = GetOutputFormats(request, imageInfo, cropwhitespace, supportedImageEnhancers);- var cacheGuid = new Guid(_imageProcessor.GetImageCacheTag(item, imageInfo, supportedImageEnhancers));-TimeSpan? cacheDuration = null;- if (!string.IsNullOrEmpty(request.Tag) && cacheGuid == new Guid(request.Tag))+ if (!string.IsNullOrEmpty(request.Tag)){cacheDuration = TimeSpan.FromDays(365);}diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex a9489cecce..ac967e1949 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -1589,6 +1589,10 @@ namespace MediaBrowser.Api.PlaybackvideoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);}}+ else if (i == 29)+ {+ request.Tag = val;+ }}}diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.csindex f4cc9f4bc6..56842e69dd 100644--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs@@ -154,12 +154,20 @@ namespace MediaBrowser.Api.Playback.Progressiveusing (state){+ TimeSpan? cacheDuration = null;++ if (!string.IsNullOrEmpty(request.Tag))+ {+ cacheDuration = TimeSpan.FromDays(365);+ }+return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions{ResponseHeaders = responseHeaders,ContentType = contentType,IsHeadRequest = isHeadRequest,- Path = state.MediaPath+ Path = state.MediaPath,+ CacheDuration = cacheDuration}).ConfigureAwait(false);}diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.csindex a8ca6aaa3b..e1a577f525 100644--- a/MediaBrowser.Api/Playback/StreamRequest.cs+++ b/MediaBrowser.Api/Playback/StreamRequest.cs@@ -74,6 +74,7 @@ namespace MediaBrowser.Api.Playbackpublic string Params { get; set; }public string PlaySessionId { get; set; }public string LiveStreamId { get; set; }+ public string Tag { get; set; }}public class VideoStreamRequest : StreamRequestdiff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.csindex 6326bbd4f4..1af55a389f 100644--- a/MediaBrowser.Controller/Entities/Audio/Audio.cs+++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs@@ -5,9 +5,11 @@ using MediaBrowser.Model.Entities;using MediaBrowser.Model.MediaInfo;using System;using System.Collections.Generic;+using System.Globalization;using System.Linq;using System.Runtime.Serialization;using System.Threading;+using MediaBrowser.Common.Extensions;using MediaBrowser.Controller.Channels;namespace MediaBrowser.Controller.Entities.Audio@@ -266,6 +268,11 @@ namespace MediaBrowser.Controller.Entities.AudioSize = i.Size};+ if (info.Protocol == MediaProtocol.File)+ {+ info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");+ }+if (string.IsNullOrEmpty(info.Container)){if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual)diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.csindex 830747d3c9..8809f155c3 100644--- a/MediaBrowser.Controller/Entities/Video.cs+++ b/MediaBrowser.Controller/Entities/Video.cs@@ -12,6 +12,7 @@ using System.Runtime.Serialization;using System.Threading;using System.Threading.Tasks;using CommonIO;+using MediaBrowser.Common.Extensions;using MediaBrowser.Controller.Channels;namespace MediaBrowser.Controller.Entities@@ -611,6 +612,11 @@ namespace MediaBrowser.Controller.EntitiesSupportsDirectStream = i.VideoType == VideoType.VideoFile};+ if (info.Protocol == MediaProtocol.File)+ {+ info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");+ }+if (i.IsShortcut){info.Path = i.ShortcutPath;diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.csindex f95c6a0707..02239aa484 100644--- a/MediaBrowser.Model/Dlna/StreamInfo.cs+++ b/MediaBrowser.Model/Dlna/StreamInfo.cs@@ -252,6 +252,8 @@ namespace MediaBrowser.Model.Dlnalist.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? StringHelper.ToStringCultureInvariant(item.TranscodingMaxAudioChannels.Value) : string.Empty));list.Add(new NameValuePair("EnableSubtitlesInManifest", item.EnableSubtitlesInManifest.ToString().ToLower()));+ list.Add(new NameValuePair("Tag", item.MediaSource.ETag ?? string.Empty));+return list;}diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.csindex 4e3e600635..bb07d9cb6f 100644--- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs+++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs@@ -20,6 +20,7 @@ namespace MediaBrowser.Model.Dtopublic string Name { get; set; }+ public string ETag { get; set; }public long? RunTimeTicks { get; set; }public bool ReadAtNativeFramerate { get; set; }public bool SupportsTranscoding { get; set; }