display timestamp info

This commit is contained in:
Luke Pulverenti 2014-04-24 22:45:06 -04:00
parent eca1ba0b12
commit 1544b7bf9c
11 changed files with 42 additions and 29 deletions

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Dlna
double? videoLevel, double? videoLevel,
double? videoFramerate, double? videoFramerate,
int? packetLength, int? packetLength,
TransportStreamTimestamp timestamp) TransportStreamTimestamp? timestamp)
{ {
switch (condition.Property) switch (condition.Property)
{ {
@ -176,8 +176,14 @@ namespace MediaBrowser.Model.Dlna
return false; 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); var expected = (TransportStreamTimestamp)Enum.Parse(typeof(TransportStreamTimestamp), condition.Value, true);
switch (condition.Condition) switch (condition.Condition)

View File

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

View File

@ -286,7 +286,7 @@ namespace MediaBrowser.Model.Dlna
var audioBitrate = audioStream == null ? null : audioStream.BitRate; var audioBitrate = audioStream == null ? null : audioStream.BitRate;
var audioChannels = audioStream == null ? null : audioStream.Channels; 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; var packetLength = videoStream == null ? null : videoStream.PacketLength;
// Check container conditions // Check container conditions

View File

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

View File

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

View File

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

View File

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

View File

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