update direct stream url for improved caching

This commit is contained in:
Luke Pulverenti 2016-08-13 15:52:58 -04:00
parent c18b8ec608
commit 6164049919
8 changed files with 31 additions and 4 deletions

View file

@ -573,11 +573,9 @@ namespace MediaBrowser.Api.Images
var outputFormats = GetOutputFormats(request, imageInfo, cropwhitespace, supportedImageEnhancers); var outputFormats = GetOutputFormats(request, imageInfo, cropwhitespace, supportedImageEnhancers);
var cacheGuid = new Guid(_imageProcessor.GetImageCacheTag(item, imageInfo, supportedImageEnhancers));
TimeSpan? cacheDuration = null; TimeSpan? cacheDuration = null;
if (!string.IsNullOrEmpty(request.Tag) && cacheGuid == new Guid(request.Tag)) if (!string.IsNullOrEmpty(request.Tag))
{ {
cacheDuration = TimeSpan.FromDays(365); cacheDuration = TimeSpan.FromDays(365);
} }

View file

@ -1589,6 +1589,10 @@ namespace MediaBrowser.Api.Playback
videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
} }
} }
else if (i == 29)
{
request.Tag = val;
}
} }
} }

View file

@ -154,12 +154,20 @@ namespace MediaBrowser.Api.Playback.Progressive
using (state) using (state)
{ {
TimeSpan? cacheDuration = null;
if (!string.IsNullOrEmpty(request.Tag))
{
cacheDuration = TimeSpan.FromDays(365);
}
return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
{ {
ResponseHeaders = responseHeaders, ResponseHeaders = responseHeaders,
ContentType = contentType, ContentType = contentType,
IsHeadRequest = isHeadRequest, IsHeadRequest = isHeadRequest,
Path = state.MediaPath Path = state.MediaPath,
CacheDuration = cacheDuration
}).ConfigureAwait(false); }).ConfigureAwait(false);
} }

View file

@ -74,6 +74,7 @@ namespace MediaBrowser.Api.Playback
public string Params { get; set; } public string Params { get; set; }
public string PlaySessionId { get; set; } public string PlaySessionId { get; set; }
public string LiveStreamId { get; set; } public string LiveStreamId { get; set; }
public string Tag { get; set; }
} }
public class VideoStreamRequest : StreamRequest public class VideoStreamRequest : StreamRequest

View file

@ -5,9 +5,11 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Channels;
namespace MediaBrowser.Controller.Entities.Audio namespace MediaBrowser.Controller.Entities.Audio
@ -266,6 +268,11 @@ namespace MediaBrowser.Controller.Entities.Audio
Size = i.Size Size = 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.IsNullOrEmpty(info.Container))
{ {
if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual)

View file

@ -12,6 +12,7 @@ using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Channels;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
@ -611,6 +612,11 @@ namespace MediaBrowser.Controller.Entities
SupportsDirectStream = i.VideoType == VideoType.VideoFile SupportsDirectStream = i.VideoType == VideoType.VideoFile
}; };
if (info.Protocol == MediaProtocol.File)
{
info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");
}
if (i.IsShortcut) if (i.IsShortcut)
{ {
info.Path = i.ShortcutPath; info.Path = i.ShortcutPath;

View file

@ -252,6 +252,8 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? StringHelper.ToStringCultureInvariant(item.TranscodingMaxAudioChannels.Value) : string.Empty)); list.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("EnableSubtitlesInManifest", item.EnableSubtitlesInManifest.ToString().ToLower()));
list.Add(new NameValuePair("Tag", item.MediaSource.ETag ?? string.Empty));
return list; return list;
} }

View file

@ -20,6 +20,7 @@ namespace MediaBrowser.Model.Dto
public string Name { get; set; } public string Name { get; set; }
public string ETag { get; set; }
public long? RunTimeTicks { get; set; } public long? RunTimeTicks { get; set; }
public bool ReadAtNativeFramerate { get; set; } public bool ReadAtNativeFramerate { get; set; }
public bool SupportsTranscoding { get; set; } public bool SupportsTranscoding { get; set; }