Luke Pulverenti 10 éve
szülő
commit
07de09f350

+ 1 - 1
MediaBrowser.Api/ApiEntryPoint.cs

@@ -296,7 +296,7 @@ namespace MediaBrowser.Api
                 // TODO: Lower this hls timeout
                 // TODO: Lower this hls timeout
                 var timerDuration = job.Type == TranscodingJobType.Progressive ?
                 var timerDuration = job.Type == TranscodingJobType.Progressive ?
                     1000 :
                     1000 :
-                    14400000;
+                    7200000;
 
 
                 if (job.KillTimer == null)
                 if (job.KillTimer == null)
                 {
                 {

+ 37 - 1
MediaBrowser.Api/Playback/MediaInfoService.cs

@@ -272,6 +272,11 @@ namespace MediaBrowser.Api.Playback
 
 
                 // Set this back to what it was
                 // Set this back to what it was
                 mediaSource.SupportsDirectStream = supportsDirectStream;
                 mediaSource.SupportsDirectStream = supportsDirectStream;
+
+                if (streamInfo != null)
+                {
+                    SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
+                }
             }
             }
 
 
             if (mediaSource.SupportsDirectStream)
             if (mediaSource.SupportsDirectStream)
@@ -285,6 +290,11 @@ namespace MediaBrowser.Api.Playback
                 {
                 {
                     mediaSource.SupportsDirectStream = false;
                     mediaSource.SupportsDirectStream = false;
                 }
                 }
+
+                if (streamInfo != null)
+                {
+                    SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
+                }
             }
             }
 
 
             if (mediaSource.SupportsTranscoding)
             if (mediaSource.SupportsTranscoding)
@@ -297,10 +307,36 @@ namespace MediaBrowser.Api.Playback
                 if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode)
                 if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode)
                 {
                 {
                     streamInfo.StartPositionTicks = startTimeTicks;
                     streamInfo.StartPositionTicks = startTimeTicks;
-                    mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).Substring(1);
+                    mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');
                     mediaSource.TranscodingContainer = streamInfo.Container;
                     mediaSource.TranscodingContainer = streamInfo.Container;
                     mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
                     mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
                 }
                 }
+
+                if (streamInfo != null)
+                {
+                    SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
+                }
+            }
+        }
+
+        private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string accessToken)
+        {
+            var profiles = info.GetSubtitleProfiles(false, "-", accessToken);
+
+            foreach (var profile in profiles)
+            {
+                foreach (var stream in mediaSource.MediaStreams)
+                {
+                    if (stream.Type == MediaStreamType.Subtitle && stream.Index == profile.Index)
+                    {
+                        stream.DeliveryMethod = profile.DeliveryMethod;
+
+                        if (profile.DeliveryMethod == SubtitleDeliveryMethod.External)
+                        {
+                            stream.DeliveryUrl = profile.Url.TrimStart('-');
+                        }
+                    }
+                }
             }
             }
         }
         }
 
 

+ 5 - 2
MediaBrowser.Dlna/Didl/DidlBuilder.cs

@@ -167,9 +167,12 @@ namespace MediaBrowser.Dlna.Didl
                 AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
                 AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
             }
             }
 
 
-            foreach (var subtitle in streamInfo.GetExternalSubtitles(_serverAddress, _accessToken, false))
+            foreach (var subtitle in streamInfo.GetSubtitleProfiles(false, _serverAddress, _accessToken))
             {
             {
-                AddSubtitleElement(container, subtitle);
+                if (subtitle.DeliveryMethod == SubtitleDeliveryMethod.External)
+                {
+                    AddSubtitleElement(container, subtitle);
+                }
             }
             }
         }
         }
 
 

+ 33 - 63
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -51,7 +51,7 @@ namespace MediaBrowser.Model.Dlna
 
 
         public int? MaxVideoBitDepth { get; set; }
         public int? MaxVideoBitDepth { get; set; }
         public int? MaxRefFrames { get; set; }
         public int? MaxRefFrames { get; set; }
-        
+
         public float? MaxFramerate { get; set; }
         public float? MaxFramerate { get; set; }
 
 
         public DeviceProfile DeviceProfile { get; set; }
         public DeviceProfile DeviceProfile { get; set; }
@@ -81,7 +81,8 @@ namespace MediaBrowser.Model.Dlna
 
 
         public bool IsDirectStream
         public bool IsDirectStream
         {
         {
-            get { 
+            get
+            {
                 return PlayMethod == PlayMethod.DirectStream ||
                 return PlayMethod == PlayMethod.DirectStream ||
                     PlayMethod == PlayMethod.DirectPlay;
                     PlayMethod == PlayMethod.DirectPlay;
             }
             }
@@ -175,7 +176,7 @@ namespace MediaBrowser.Model.Dlna
             {
             {
                 list.Add(pair.Value);
                 list.Add(pair.Value);
             }
             }
-            
+
             return string.Format("Params={0}", string.Join(";", list.ToArray()));
             return string.Format("Params={0}", string.Join(";", list.ToArray()));
         }
         }
 
 
@@ -199,7 +200,7 @@ namespace MediaBrowser.Model.Dlna
             list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxHeight.Value) : string.Empty));
             list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxHeight.Value) : string.Empty));
             list.Add(new NameValuePair("StartTimeTicks", StringHelper.ToStringCultureInvariant(item.StartPositionTicks)));
             list.Add(new NameValuePair("StartTimeTicks", StringHelper.ToStringCultureInvariant(item.StartPositionTicks)));
             list.Add(new NameValuePair("Level", item.VideoLevel.HasValue ? StringHelper.ToStringCultureInvariant(item.VideoLevel.Value) : string.Empty));
             list.Add(new NameValuePair("Level", item.VideoLevel.HasValue ? StringHelper.ToStringCultureInvariant(item.VideoLevel.Value) : string.Empty));
-            
+
             list.Add(new NameValuePair("ClientTime", item.IsDirectStream ? string.Empty : DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture)));
             list.Add(new NameValuePair("ClientTime", item.IsDirectStream ? string.Empty : DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture)));
             list.Add(new NameValuePair("MaxRefFrames", item.MaxRefFrames.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxRefFrames.Value) : string.Empty));
             list.Add(new NameValuePair("MaxRefFrames", item.MaxRefFrames.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxRefFrames.Value) : string.Empty));
             list.Add(new NameValuePair("MaxVideoBitDepth", item.MaxVideoBitDepth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxVideoBitDepth.Value) : string.Empty));
             list.Add(new NameValuePair("MaxVideoBitDepth", item.MaxVideoBitDepth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxVideoBitDepth.Value) : string.Empty));
@@ -216,53 +217,25 @@ namespace MediaBrowser.Model.Dlna
             return list;
             return list;
         }
         }
 
 
-        public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly)
+        public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly, string baseUrl, string accessToken)
         {
         {
-            List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
+            List<SubtitleStreamInfo> list = GetSubtitleProfiles(includeSelectedTrackOnly, baseUrl, accessToken);
+            List<SubtitleStreamInfo> newList = new List<SubtitleStreamInfo>();
 
 
             // First add the selected track
             // First add the selected track
-            if (SubtitleStreamIndex.HasValue)
+            foreach (SubtitleStreamInfo stream in list)
             {
             {
-                foreach (MediaStream stream in MediaSource.MediaStreams)
-                {
-                    if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
-                    {
-                        SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
-
-                        if (info != null)
-                        {
-                            list.Add(info);
-                        }
-                    }
-                }
-            }
-
-            if (!includeSelectedTrackOnly)
-            {
-                foreach (MediaStream stream in MediaSource.MediaStreams)
+                if (stream.DeliveryMethod == SubtitleDeliveryMethod.External)
                 {
                 {
-                    if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
-                    {
-                        SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
-
-                        if (info != null)
-                        {
-                            list.Add(info);
-                        }
-                    }
+                    newList.Add(stream);
                 }
                 }
             }
             }
 
 
-            return list;
+            return newList;
         }
         }
 
 
-        public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl, string accessToken, bool includeSelectedTrackOnly)
+        public List<SubtitleStreamInfo> GetSubtitleProfiles(bool includeSelectedTrackOnly, string baseUrl, string accessToken)
         {
         {
-            if (string.IsNullOrEmpty(baseUrl))
-            {
-                throw new ArgumentNullException(baseUrl);
-            }
-
             List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
             List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
 
 
             // HLS will preserve timestamps so we can just grab the full subtitle stream
             // HLS will preserve timestamps so we can just grab the full subtitle stream
@@ -279,10 +252,7 @@ namespace MediaBrowser.Model.Dlna
                     {
                     {
                         SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
                         SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
 
 
-                        if (info != null)
-                        {
-                            list.Add(info);
-                        }
+                        list.Add(info);
                     }
                     }
                 }
                 }
             }
             }
@@ -295,14 +265,11 @@ namespace MediaBrowser.Model.Dlna
                     {
                     {
                         SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
                         SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
 
 
-                        if (info != null)
-                        {
-                            list.Add(info);
-                        }
+                        list.Add(info);
                     }
                     }
                 }
                 }
             }
             }
-            
+
             return list;
             return list;
         }
         }
 
 
@@ -310,15 +277,22 @@ namespace MediaBrowser.Model.Dlna
         {
         {
             SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
             SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
 
 
-            if (info != null)
+            if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
             {
             {
-                info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
-                    baseUrl,
-                    ItemId,
-                    MediaSourceId,
-                    StringHelper.ToStringCultureInvariant(stream.Index),
-                    StringHelper.ToStringCultureInvariant(startPositionTicks),
-                    SubtitleFormat);
+                if (MediaSource.Protocol == MediaProtocol.Http)
+                {
+                    info.Url = stream.Path;
+                }
+                else if (!string.IsNullOrEmpty(baseUrl))
+                {
+                    info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
+                        baseUrl,
+                        ItemId,
+                        MediaSourceId,
+                        StringHelper.ToStringCultureInvariant(stream.Index),
+                        StringHelper.ToStringCultureInvariant(startPositionTicks),
+                        SubtitleFormat);
+                }
             }
             }
 
 
             return info;
             return info;
@@ -328,18 +302,14 @@ namespace MediaBrowser.Model.Dlna
         {
         {
             SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile.SubtitleProfiles, Context);
             SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile.SubtitleProfiles, Context);
 
 
-            if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
-            {
-                return null;
-            }
-
             return new SubtitleStreamInfo
             return new SubtitleStreamInfo
             {
             {
                 IsForced = stream.IsForced,
                 IsForced = stream.IsForced,
                 Language = stream.Language,
                 Language = stream.Language,
                 Name = stream.Language ?? "Unknown",
                 Name = stream.Language ?? "Unknown",
                 Format = SubtitleFormat,
                 Format = SubtitleFormat,
-                Index = stream.Index
+                Index = stream.Index,
+                DeliveryMethod = subtitleProfile.Method
             };
             };
         }
         }
 
 

+ 1 - 0
MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs

@@ -8,5 +8,6 @@ namespace MediaBrowser.Model.Dlna
         public bool IsForced { get; set; }
         public bool IsForced { get; set; }
         public string Format { get; set; }
         public string Format { get; set; }
         public int Index { get; set; }
         public int Index { get; set; }
+        public SubtitleDeliveryMethod DeliveryMethod { get; set; }
     }
     }
 }
 }

+ 13 - 1
MediaBrowser.Model/Entities/MediaStream.cs

@@ -1,4 +1,5 @@
-using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.Extensions;
 using System.Diagnostics;
 using System.Diagnostics;
 
 
 namespace MediaBrowser.Model.Entities
 namespace MediaBrowser.Model.Entities
@@ -135,6 +136,17 @@ namespace MediaBrowser.Model.Entities
         /// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
         /// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
         public bool IsExternal { get; set; }
         public bool IsExternal { get; set; }
 
 
+        /// <summary>
+        /// Gets or sets the method.
+        /// </summary>
+        /// <value>The method.</value>
+        public SubtitleDeliveryMethod? DeliveryMethod { get; set; }
+        /// <summary>
+        /// Gets or sets the delivery URL.
+        /// </summary>
+        /// <value>The delivery URL.</value>
+        public string DeliveryUrl { get; set; }
+
         public bool IsTextSubtitleStream
         public bool IsTextSubtitleStream
         {
         {
             get
             get

+ 5 - 0
MediaBrowser.Server.Implementations/Sync/CloudSyncProfile.cs

@@ -227,6 +227,11 @@ namespace MediaBrowser.Server.Implementations.Sync
                 {
                 {
                     Format = "srt",
                     Format = "srt",
                     Method = SubtitleDeliveryMethod.External
                     Method = SubtitleDeliveryMethod.External
+                },
+                new SubtitleProfile
+                {
+                    Format = "vtt",
+                    Method = SubtitleDeliveryMethod.External
                 }
                 }
             };
             };
 
 

+ 1 - 1
MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs

@@ -495,7 +495,7 @@ namespace MediaBrowser.Server.Implementations.Sync
             // No sense creating external subs if we're already burning one into the video
             // No sense creating external subs if we're already burning one into the video
             var externalSubs = streamInfo.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode ?
             var externalSubs = streamInfo.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode ?
                 new List<SubtitleStreamInfo>() :
                 new List<SubtitleStreamInfo>() :
-                streamInfo.GetExternalSubtitles(false);
+                streamInfo.GetExternalSubtitles(false, null, null);
 
 
             // Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
             // Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
             var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && jobOptions.IsConverting;
             var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && jobOptions.IsConverting;

+ 1 - 1
MediaBrowser.Server.Implementations/Sync/SyncManager.cs

@@ -677,7 +677,6 @@ namespace MediaBrowser.Server.Implementations.Sync
             syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
             syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
 
 
             syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
             syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
-
             if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
             if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
             {
             {
                 syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
                 syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
@@ -686,6 +685,7 @@ namespace MediaBrowser.Server.Implementations.Sync
             // This will be null for items that are not audio/video
             // This will be null for items that are not audio/video
             if (mediaSource != null)
             if (mediaSource != null)
             {
             {
+                syncedItem.OriginalFileName = Path.ChangeExtension(syncedItem.OriginalFileName, Path.GetExtension(mediaSource.Path));
                 syncedItem.Item.MediaSources.Add(mediaSource);
                 syncedItem.Item.MediaSources.Add(mediaSource);
             }
             }