From 3cc608d781b72b9e9c2dd91f90d90a5cf6f0a57a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 24 Jan 2014 13:09:50 -0500 Subject: [PATCH] update next/previous buttons --- .../Playback/BaseStreamingService.cs | 34 +++++++++++++++---- .../Playback/Hls/DynamicHlsService.cs | 10 ++++-- .../Playback/Hls/VideoHlsService.cs | 10 ++++-- .../Playback/Progressive/VideoService.cs | 16 ++++++--- MediaBrowser.Api/Playback/StreamState.cs | 3 +- MediaBrowser.Controller/Entities/BaseItem.cs | 5 --- .../Providers/BaseItemXmlParser.cs | 6 +--- .../LiveTv/LiveTvServiceInfo.cs | 6 ++++ .../Movies/MovieDbProvider.cs | 3 -- .../Dto/DtoService.cs | 5 --- .../LiveTv/LiveTvDtoService.cs | 5 +-- .../LiveTv/LiveTvManager.cs | 15 +++++++- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 15 files changed, 83 insertions(+), 45 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 394ca69d5a..76cce0d66d 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -307,7 +307,7 @@ namespace MediaBrowser.Api.Playback if (videoCodec.Equals("libvpx", StringComparison.OrdinalIgnoreCase)) { // http://www.webmproject.org/docs/encoder-parameters/ - return "-speed 16 -quality good -profile:v 0 -slices 8"; + return "-speed 16 -quality good -profile:v 0 -slices 8 -crf 18"; } // asf/wmv @@ -321,11 +321,11 @@ namespace MediaBrowser.Api.Playback switch (GetQualitySetting()) { case EncodingQuality.HighSpeed: - return "-preset ultrafast"; + return "-preset ultrafast -crf 18"; case EncodingQuality.HighQuality: - return "-preset superfast"; + return "-preset superfast -crf 18"; case EncodingQuality.MaxQuality: - return "-preset superfast"; + return "-preset superfast -crf 18"; default: throw new Exception("Unrecognized MediaEncodingQuality value."); } @@ -381,7 +381,7 @@ namespace MediaBrowser.Api.Playback audioSampleRate, volParam, pts, - state.AudioSync.ToString(UsCulture)); + state.AudioSync); } /// @@ -994,6 +994,26 @@ namespace MediaBrowser.Api.Playback } } + protected double? GetFramerateParam(StreamState state) + { + if (state.VideoRequest != null && state.VideoRequest.Framerate.HasValue) + { + return state.VideoRequest.Framerate.Value; + } + + if (state.VideoStream != null) + { + var contentRate = state.VideoStream.AverageFrameRate ?? state.VideoStream.RealFrameRate; + + if (contentRate.HasValue && contentRate.Value > 23.976) + { + return 23.976; + } + } + + return null; + } + /// /// Gets the state. /// @@ -1068,7 +1088,7 @@ namespace MediaBrowser.Api.Playback //state.RunTimeTicks = recording.RunTimeTicks; state.ReadInputAtNativeFramerate = recording.RecordingInfo.Status == RecordingStatus.InProgress; state.SendInputOverStandardInput = recording.RecordingInfo.Status == RecordingStatus.InProgress; - state.AudioSync = 1000; + state.AudioSync = "1000"; state.DeInterlace = true; } else if (item is LiveTvChannel) @@ -1096,7 +1116,7 @@ namespace MediaBrowser.Api.Playback state.SendInputOverStandardInput = true; state.ReadInputAtNativeFramerate = true; - state.AudioSync = 1000; + state.AudioSync = "1000"; state.DeInterlace = true; } else diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index f064a13c6b..388339f171 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -317,12 +317,16 @@ namespace MediaBrowser.Api.Playback.Hls } } - if (state.VideoRequest.Framerate.HasValue) + var framerate = GetFramerateParam(state); + if (framerate.HasValue) { - args += string.Format(" -r {0}", state.VideoRequest.Framerate.Value); + args += string.Format(" -r {0}", framerate.Value.ToString(UsCulture)); } - args += " -vsync vfr"; + if (!string.IsNullOrEmpty(state.VideoSync)) + { + args += " -vsync " + state.VideoSync; + } if (!string.IsNullOrEmpty(state.VideoRequest.Profile)) { diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 7e7e8ba5bd..9d9c62a28e 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -194,12 +194,16 @@ namespace MediaBrowser.Api.Playback.Hls } } - if (state.VideoRequest.Framerate.HasValue) + var framerate = GetFramerateParam(state); + if (framerate.HasValue) { - args += string.Format(" -r {0}", state.VideoRequest.Framerate.Value); + args += string.Format(" -r {0}", framerate.Value.ToString(UsCulture)); } - args += " -vsync vfr"; + if (!string.IsNullOrEmpty(state.VideoSync)) + { + args += " -vsync " + state.VideoSync; + } if (!string.IsNullOrEmpty(state.VideoRequest.Profile)) { diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 826b034408..b16761595c 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -156,9 +156,10 @@ namespace MediaBrowser.Api.Playback.Progressive } } - if (request.Framerate.HasValue) + var framerate = GetFramerateParam(state); + if (framerate.HasValue) { - args += string.Format(" -r {0}", request.Framerate.Value); + args += string.Format(" -r {0}", framerate.Value.ToString(UsCulture)); } var qualityParam = GetVideoQualityParam(state, codec); @@ -169,11 +170,13 @@ namespace MediaBrowser.Api.Playback.Progressive { if (string.Equals(codec, "libvpx", StringComparison.OrdinalIgnoreCase)) { - qualityParam += string.Format(" -minrate:v ({0}*.90) -maxrate:v ({0}*1.10) -bufsize:v {0} -b:v {0}", bitrate.Value.ToString(UsCulture)); + qualityParam += string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); } else { - qualityParam += string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); + qualityParam += string.Format(" -maxrate {0} -bufsize {1}", + bitrate.Value.ToString(UsCulture), + (bitrate.Value * 2).ToString(UsCulture)); } } @@ -182,7 +185,10 @@ namespace MediaBrowser.Api.Playback.Progressive args += " " + qualityParam.Trim(); } - args += " -vsync vfr"; + if (!string.IsNullOrEmpty(state.VideoSync)) + { + args += " -vsync " + state.VideoSync; + } if (!string.IsNullOrEmpty(state.VideoRequest.Profile)) { diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 84cc8ecd36..55d7b22e2c 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -59,7 +59,8 @@ namespace MediaBrowser.Api.Playback public long? RunTimeTicks; - public int AudioSync = 1; + public string AudioSync = "1"; + public string VideoSync = "vfr"; public bool DeInterlace { get; set; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 58d5f1b942..7840fb3f07 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -541,11 +541,6 @@ namespace MediaBrowser.Controller.Entities /// The run time ticks. public long? RunTimeTicks { get; set; } - /// - /// Gets or sets the original run time ticks. - /// - /// The original run time ticks. - public long? OriginalRunTimeTicks { get; set; } /// /// Gets or sets the production year. /// diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 416437d35e..7bd6d824aa 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -423,11 +423,7 @@ namespace MediaBrowser.Controller.Providers if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out runtime)) { // For audio and video don't replace ffmpeg data - if (item is Video || item is Audio) - { - item.OriginalRunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks; - } - else + if (!(item is Video || item is Audio)) { item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks; } diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs index e764e679b9..85f58be3bc 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs @@ -144,6 +144,12 @@ namespace MediaBrowser.Model.LiveTv /// The channel identifier. public string ChannelId { get; set; } + /// + /// Gets or sets the name of the channel. + /// + /// The name of the channel. + public string ChannelName { get; set; } + /// /// Gets or sets the recording identifier. /// diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index d4367a5dbb..d6937293cc 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -796,9 +796,6 @@ namespace MediaBrowser.Providers.Movies boxset.OfficialRating = firstChild != null ? firstChild.OfficialRating : null; } - if (movieData.runtime > 0) - movie.OriginalRunTimeTicks = TimeSpan.FromMinutes(movieData.runtime).Ticks; - //studios if (movieData.production_companies != null && !movie.LockedFields.Contains(MetadataFields.Studios)) { diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 7fa2990506..7a9735e0e3 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -649,11 +649,6 @@ namespace MediaBrowser.Server.Implementations.Dto dto.DateCreated = item.DateCreated; } - if (fields.Contains(ItemFields.OriginalRunTimeTicks)) - { - dto.OriginalRunTimeTicks = item.OriginalRunTimeTicks; - } - dto.DisplayMediaType = item.DisplayMediaType; if (fields.Contains(ItemFields.Settings)) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index 5b25e259a6..4805adb1f0 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -271,7 +271,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return dto; } - public LiveTvTunerInfoDto GetTunerInfoDto(string serviceName, LiveTvTunerInfo info) + public LiveTvTunerInfoDto GetTunerInfoDto(string serviceName, LiveTvTunerInfo info, string channelName) { var dto = new LiveTvTunerInfoDto { @@ -280,7 +280,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv Clients = info.Clients, ProgramName = info.ProgramName, SourceType = info.SourceType, - Status = info.Status + Status = info.Status, + ChannelName = channelName }; if (!string.IsNullOrEmpty(info.ChannelId)) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 0d2f323b46..e256d7da58 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1435,7 +1435,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv info.HasUpdateAvailable = statusInfo.HasUpdateAvailable; info.HomePageUrl = service.HomePageUrl; - info.Tuners = statusInfo.Tuners.Select(i => _tvDtoService.GetTunerInfoDto(service.Name, i)).ToList(); + info.Tuners = statusInfo.Tuners.Select(i => + { + string channelName = null; + + if (!string.IsNullOrEmpty(i.ChannelId)) + { + var internalChannelId = _tvDtoService.GetInternalChannelId(service.Name, i.ChannelId); + var channel = GetInternalChannel(internalChannelId); + channelName = channel == null ? null : channel.Name; + } + + return _tvDtoService.GetTunerInfoDto(service.Name, i, channelName); + + }).ToList(); } catch (Exception ex) { diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 175ca99c4b..47e2e841ba 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.308 + 3.0.309 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index f4cafce406..376cc722d9 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.308 + 3.0.309 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index dea3753264..22dd1aa9a9 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.308 + 3.0.309 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +