Explorar el Código

display timestamp info

Luke Pulverenti hace 11 años
padre
commit
1544b7bf9c

+ 2 - 1
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -24,6 +24,7 @@ using System.Linq;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
+using MediaBrowser.Model.MediaInfo;
 
 namespace MediaBrowser.Api.Playback
 {
@@ -1437,7 +1438,7 @@ namespace MediaBrowser.Api.Playback
                         : video.PlayableStreamFileNames.ToList();
 
                     state.DeInterlace = string.Equals(video.Container, "wtv", StringComparison.OrdinalIgnoreCase);
-                    state.InputTimestamp = video.Timestamp;
+                    state.InputTimestamp = video.Timestamp ?? TransportStreamTimestamp.None;
                 }
 
                 state.RunTimeTicks = item.RunTimeTicks;

+ 2 - 2
MediaBrowser.Api/Playback/StreamState.cs

@@ -273,8 +273,8 @@ namespace MediaBrowser.Api.Playback
             get
             {
                 var defaultValue = string.Equals(OutputContainer, "m2ts", StringComparison.OrdinalIgnoreCase) ? 
-                    TransportStreamTimestamp.VALID : 
-                    TransportStreamTimestamp.NONE;
+                    TransportStreamTimestamp.Valid : 
+                    TransportStreamTimestamp.None;
 
                 return !Request.Static
                     ? defaultValue

+ 1 - 1
MediaBrowser.Controller/Entities/Video.cs

@@ -37,7 +37,7 @@ namespace MediaBrowser.Controller.Entities
         /// Gets or sets the timestamp.
         /// </summary>
         /// <value>The timestamp.</value>
-        public TransportStreamTimestamp Timestamp { get; set; }
+        public TransportStreamTimestamp? Timestamp { get; set; }
         
         public Video()
         {

+ 8 - 2
MediaBrowser.Model/Dlna/ConditionProcessor.cs

@@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Dlna
             double? videoLevel,
             double? videoFramerate,
             int? packetLength,
-            TransportStreamTimestamp timestamp)
+            TransportStreamTimestamp? timestamp)
         {
             switch (condition.Property)
             {
@@ -176,8 +176,14 @@ namespace MediaBrowser.Model.Dlna
             return false;
         }
         
-        private bool IsConditionSatisfied(ProfileCondition condition, TransportStreamTimestamp timestamp)
+        private bool IsConditionSatisfied(ProfileCondition condition, TransportStreamTimestamp? timestamp)
         {
+            if (!timestamp.HasValue)
+            {
+                // If the value is unknown, it satisfies if not marked as required
+                return !condition.IsRequired;
+            }
+            
             var expected = (TransportStreamTimestamp)Enum.Parse(typeof(TransportStreamTimestamp), condition.Value, true);
             
             switch (condition.Condition)

+ 5 - 5
MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs

@@ -67,10 +67,10 @@ namespace MediaBrowser.Model.Dlna
 
             switch (timestampType)
             {
-                case TransportStreamTimestamp.NONE:
+                case TransportStreamTimestamp.None:
                     suffix = "_ISO";
                     break;
-                case TransportStreamTimestamp.VALID:
+                case TransportStreamTimestamp.Valid:
                     suffix = "_T";
                     break;
             }
@@ -89,7 +89,7 @@ namespace MediaBrowser.Model.Dlna
                 list.Add(ValueOf("MPEG_TS_SD_EU" + suffix));
                 list.Add(ValueOf("MPEG_TS_SD_KO" + suffix));
 
-                if ((timestampType == TransportStreamTimestamp.VALID) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
+                if ((timestampType == TransportStreamTimestamp.Valid) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase))
                 {
                     list.Add(MediaFormatProfile.MPEG_TS_JP_T);
                 }
@@ -102,7 +102,7 @@ namespace MediaBrowser.Model.Dlna
 
                 if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase))
                 {
-                    if (timestampType == TransportStreamTimestamp.NONE)
+                    if (timestampType == TransportStreamTimestamp.None)
                     {
                         return new[] { MediaFormatProfile.AVC_TS_HD_DTS_ISO };
                     }
@@ -111,7 +111,7 @@ namespace MediaBrowser.Model.Dlna
 
                 if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
                 {
-                    if (timestampType == TransportStreamTimestamp.NONE)
+                    if (timestampType == TransportStreamTimestamp.None)
                     {
                         return new[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) };
                     }

+ 1 - 1
MediaBrowser.Model/Dlna/StreamBuilder.cs

@@ -286,7 +286,7 @@ namespace MediaBrowser.Model.Dlna
             var audioBitrate = audioStream == null ? null : audioStream.BitRate;
             var audioChannels = audioStream == null ? null : audioStream.Channels;
 
-            var timestamp = videoStream == null ? TransportStreamTimestamp.NONE : mediaSource.Timestamp;
+            var timestamp = videoStream == null ? TransportStreamTimestamp.None : mediaSource.Timestamp;
             var packetLength = videoStream == null ? null : videoStream.PacketLength;
 
             // Check container conditions

+ 3 - 3
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -341,12 +341,12 @@ namespace MediaBrowser.Model.Dlna
             get
             {
                 var defaultValue = string.Equals(Container, "m2ts", StringComparison.OrdinalIgnoreCase)
-                    ? TransportStreamTimestamp.VALID
-                    : TransportStreamTimestamp.NONE;
+                    ? TransportStreamTimestamp.Valid
+                    : TransportStreamTimestamp.None;
                 
                 return !IsDirectStream
                     ? defaultValue
-                    : MediaSource == null ? defaultValue : MediaSource.Timestamp;
+                    : MediaSource == null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None;
             }
         }
 

+ 1 - 1
MediaBrowser.Model/Dto/MediaVersionInfo.cs

@@ -31,7 +31,7 @@ namespace MediaBrowser.Model.Dto
         
         public int? Bitrate { get; set; }
 
-        public TransportStreamTimestamp Timestamp { get; set; }
+        public TransportStreamTimestamp? Timestamp { get; set; }
         
         public MediaSourceInfo()
         {

+ 3 - 3
MediaBrowser.Model/MediaInfo/BlurayDiscInfo.cs

@@ -37,8 +37,8 @@ namespace MediaBrowser.Model.MediaInfo
 
     public enum TransportStreamTimestamp
     {
-        NONE,
-        ZERO,
-        VALID
+        None,
+        Zero,
+        Valid
     }
 }

+ 6 - 3
MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs

@@ -1,4 +1,5 @@
 using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Movies;
@@ -43,6 +44,7 @@ namespace MediaBrowser.Providers.MediaInfo
         private readonly IApplicationPaths _appPaths;
         private readonly IJsonSerializer _json;
         private readonly IEncodingManager _encodingManager;
+        private readonly IFileSystem _fileSystem;
 
         public string Name
         {
@@ -94,7 +96,7 @@ namespace MediaBrowser.Providers.MediaInfo
             return FetchAudioInfo(item, cancellationToken);
         }
 
-        public FFProbeProvider(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager)
+        public FFProbeProvider(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager, IFileSystem fileSystem)
         {
             _logger = logger;
             _isoManager = isoManager;
@@ -105,6 +107,7 @@ namespace MediaBrowser.Providers.MediaInfo
             _appPaths = appPaths;
             _json = json;
             _encodingManager = encodingManager;
+            _fileSystem = fileSystem;
         }
 
         private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
@@ -131,7 +134,7 @@ namespace MediaBrowser.Providers.MediaInfo
                 return _cachedTask;
             }
 
-            var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager);
+            var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager, _fileSystem);
 
             return prober.ProbeVideo(item, directoryService, cancellationToken);
         }
@@ -162,7 +165,7 @@ namespace MediaBrowser.Providers.MediaInfo
 
                 if (video != null && !video.IsPlaceHolder)
                 {
-                    var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager);
+                    var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager, _fileSystem);
 
                     return !video.SubtitleFiles.SequenceEqual(prober.GetSubtitleFiles(video, directoryService).Select(i => i.FullName).OrderBy(i => i), StringComparer.OrdinalIgnoreCase);
                 }

+ 10 - 7
MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs

@@ -1,5 +1,6 @@
 using DvdLib.Ifo;
 using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Library;
@@ -7,7 +8,6 @@ using MediaBrowser.Controller.Localization;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Controller.Persistence;
 using MediaBrowser.Controller.Providers;
-using MediaBrowser.Model.Dlna;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
@@ -20,7 +20,6 @@ using System.IO;
 using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
-using MediaBrowser.Common.Extensions;
 
 namespace MediaBrowser.Providers.MediaInfo
 {
@@ -39,7 +38,7 @@ namespace MediaBrowser.Providers.MediaInfo
 
         private readonly CultureInfo _usCulture = new CultureInfo("en-US");
 
-        public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager)
+        public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager, IFileSystem fileSystem)
         {
             _logger = logger;
             _isoManager = isoManager;
@@ -50,6 +49,7 @@ namespace MediaBrowser.Providers.MediaInfo
             _appPaths = appPaths;
             _json = json;
             _encodingManager = encodingManager;
+            _fileSystem = fileSystem;
         }
 
         public async Task<ItemUpdateType> ProbeVideo<T>(T item, IDirectoryService directoryService, CancellationToken cancellationToken)
@@ -584,10 +584,13 @@ namespace MediaBrowser.Providers.MediaInfo
                     try
                     {
                         video.Timestamp = GetMpegTimestamp(video.Path);
+
+                        _logger.Debug("Video has {0} timestamp", video.Timestamp);
                     }
                     catch (Exception ex)
                     {
                         _logger.ErrorException("Error extracting timestamp info from {0}", ex, video.Path);
+                        video.Timestamp = null;
                     }
                 }
             }
@@ -604,20 +607,20 @@ namespace MediaBrowser.Providers.MediaInfo
 
             if (packetBuffer[0] == 71)
             {
-                return TransportStreamTimestamp.NONE;
+                return TransportStreamTimestamp.None;
             }
 
             if ((packetBuffer[4] == 71) && (packetBuffer['Ä'] == 71))
             {
                 if ((packetBuffer[0] == 0) && (packetBuffer[1] == 0) && (packetBuffer[2] == 0) && (packetBuffer[3] == 0))
                 {
-                    return TransportStreamTimestamp.ZERO;
+                    return TransportStreamTimestamp.Zero;
                 }
 
-                return TransportStreamTimestamp.VALID;
+                return TransportStreamTimestamp.Valid;
             }
 
-            return TransportStreamTimestamp.NONE;
+            return TransportStreamTimestamp.None;
         }
 
         private void FetchFromDvdLib(Video item, IIsoMount mount)