Merge pull request #2639 from MediaBrowser/beta

Beta
This commit is contained in:
Luke 2017-05-15 00:34:33 -04:00 committed by GitHub
commit a4efcf07f4
39 changed files with 300 additions and 360 deletions

View File

@ -488,7 +488,8 @@ namespace Emby.Dlna.Didl
var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container,
streamInfo.TargetAudioCodec,
targetChannels,
targetAudioBitrate);
targetAudioBitrate,
targetSampleRate);
var filename = url.Substring(0, url.IndexOf('?'));

View File

@ -130,7 +130,7 @@ namespace Emby.Drawing.ImageMagick
string.Equals(ext, ".webp", StringComparison.OrdinalIgnoreCase);
}
public void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
{
// Even if the caller specified 100, don't use it because it takes forever
quality = Math.Min(quality, 99);
@ -144,6 +144,16 @@ namespace Emby.Drawing.ImageMagick
originalImage.CurrentImage.TrimImage(10);
}
if (options.CropWhiteSpace || !originalImageSize.HasValue)
{
originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
}
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
var width = Convert.ToInt32(Math.Round(newImageSize.Width));
var height = Convert.ToInt32(Math.Round(newImageSize.Height));
ScaleImage(originalImage, width, height, options.Blur ?? 0);
if (autoOrient)
@ -162,9 +172,19 @@ namespace Emby.Drawing.ImageMagick
}
else
{
using (var wand = new MagickWand(width, height, options.BackgroundColor))
using (var originalImage = new MagickWand(inputPath))
{
using (var originalImage = new MagickWand(inputPath))
if (options.CropWhiteSpace || !originalImageSize.HasValue)
{
originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
}
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
var width = Convert.ToInt32(Math.Round(newImageSize.Width));
var height = Convert.ToInt32(Math.Round(newImageSize.Height));
using (var wand = new MagickWand(width, height, options.BackgroundColor))
{
ScaleImage(originalImage, width, height, options.Blur ?? 0);

View File

@ -11,6 +11,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using ImageFormat = MediaBrowser.Model.Drawing.ImageFormat;
using Emby.Drawing;
namespace Emby.Drawing.Net
{
@ -88,14 +89,19 @@ namespace Emby.Drawing.Net
return Image.FromFile(path);
}
public void EncodeImage(string inputPath, string cacheFilePath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
{
var hasPostProcessing = !string.IsNullOrEmpty(options.BackgroundColor) || options.UnplayedCount.HasValue || options.AddPlayedIndicator || options.PercentPlayed > 0;
using (var originalImage = GetImage(inputPath, options.CropWhiteSpace))
{
var newWidth = Convert.ToInt32(width);
var newHeight = Convert.ToInt32(height);
if (options.CropWhiteSpace || !originalImageSize.HasValue)
{
originalImageSize = new ImageSize(originalImage.Width, originalImage.Height);
}
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
var newWidth = Convert.ToInt32(Math.Round(newImageSize.Width));
var newHeight = Convert.ToInt32(Math.Round(newImageSize.Height));
// Graphics.FromImage will throw an exception if the PixelFormat is Indexed, so we need to handle that here
// Also, Webp only supports Format32bppArgb and Format32bppRgb
@ -132,10 +138,8 @@ namespace Emby.Drawing.Net
var outputFormat = GetOutputFormat(originalImage, selectedOutputFormat);
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath));
// Save to the cache location
using (var cacheFileStream = _fileSystem.GetFileStream(cacheFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, false))
using (var cacheFileStream = _fileSystem.GetFileStream(outputPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, false))
{
// Save to the memory stream
thumbnail.Save(outputFormat, cacheFileStream, quality);

View File

@ -226,7 +226,7 @@ namespace Emby.Drawing.Skia
return Decode(path);
}
public void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
{
if (string.IsNullOrWhiteSpace(inputPath))
{
@ -246,6 +246,16 @@ namespace Emby.Drawing.Skia
using (var bitmap = GetBitmap(inputPath, options.CropWhiteSpace))
{
if (options.CropWhiteSpace || !originalImageSize.HasValue)
{
originalImageSize = new ImageSize(bitmap.Width, bitmap.Height);
}
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
var width = Convert.ToInt32(Math.Round(newImageSize.Width));
var height = Convert.ToInt32(Math.Round(newImageSize.Height));
using (var resizedBitmap = new SKBitmap(width, height))//, bitmap.ColorType, bitmap.AlphaType))
{
// scale image

View File

@ -227,7 +227,7 @@ namespace Emby.Drawing
originalImageSize = null;
}
var newSize = GetNewImageSize(options, originalImageSize);
var newSize = ImageHelper.GetNewImageSize(options, originalImageSize);
var quality = options.Quality;
var outputFormat = GetOutputFormat(options.SupportedOutputFormats[0]);
@ -239,14 +239,11 @@ namespace Emby.Drawing
if (!_fileSystem.FileExists(cacheFilePath))
{
var newWidth = Convert.ToInt32(Math.Round(newSize.Width));
var newHeight = Convert.ToInt32(Math.Round(newSize.Height));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFilePath));
var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath));
_fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
_imageEncoder.EncodeImage(originalImagePath, tmpPath, AutoOrient(options.Item), newWidth, newHeight, quality, options, outputFormat);
_imageEncoder.EncodeImage(originalImagePath, originalImageSize, tmpPath, AutoOrient(options.Item), quality, options, outputFormat);
CopyFile(tmpPath, cacheFilePath);
return new Tuple<string, string, DateTime>(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath));
@ -328,66 +325,6 @@ namespace Emby.Drawing
return MimeTypes.GetMimeType(path);
}
private ImageSize GetNewImageSize(ImageProcessingOptions options, ImageSize? originalImageSize)
{
if (originalImageSize.HasValue)
{
// Determine the output size based on incoming parameters
var newSize = DrawingUtils.Resize(originalImageSize.Value, options.Width, options.Height, options.MaxWidth, options.MaxHeight);
return newSize;
}
return GetSizeEstimate(options);
}
private ImageSize GetSizeEstimate(ImageProcessingOptions options)
{
if (options.Width.HasValue && options.Height.HasValue)
{
return new ImageSize(options.Width.Value, options.Height.Value);
}
var aspect = GetEstimatedAspectRatio(options.Image.Type, options.Item);
var width = options.Width ?? options.MaxWidth;
if (width.HasValue)
{
var heightValue = width.Value / aspect;
return new ImageSize(width.Value, heightValue);
}
var height = options.Height ?? options.MaxHeight ?? 200;
var widthValue = aspect * height;
return new ImageSize(widthValue, height);
}
private double GetEstimatedAspectRatio(ImageType type, IHasImages item)
{
switch (type)
{
case ImageType.Art:
case ImageType.Backdrop:
case ImageType.Chapter:
case ImageType.Screenshot:
case ImageType.Thumb:
return 1.78;
case ImageType.Banner:
return 5.4;
case ImageType.Box:
case ImageType.BoxRear:
case ImageType.Disc:
case ImageType.Menu:
return 1;
case ImageType.Logo:
return 2.58;
case ImageType.Primary:
return item.GetDefaultPrimaryImageAspectRatio() ?? .667;
default:
return 1;
}
}
private ImageFormat GetOutputFormat(ImageFormat requestedFormat)
{
if (requestedFormat == ImageFormat.Webp && !_imageEncoder.SupportedOutputFormats.Contains(ImageFormat.Webp))
@ -513,20 +450,25 @@ namespace Emby.Drawing
/// <returns>ImageSize.</returns>
private ImageSize GetImageSizeInternal(string path, bool allowSlowMethod)
{
// Can't use taglib because it keeps a lock on the file
//try
//{
// using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), _fileSystem.OpenRead(path), null)))
// using (var fileStream = _fileSystem.OpenRead(path))
// {
// var image = file as TagLib.Image.File;
// var properties = image.Properties;
// return new ImageSize
// using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(path), fileStream, null)))
// {
// Height = properties.PhotoHeight,
// Width = properties.PhotoWidth
// };
// var image = file as TagLib.Image.File;
// if (image != null)
// {
// var properties = image.Properties;
// return new ImageSize
// {
// Height = properties.PhotoHeight,
// Width = properties.PhotoWidth
// };
// }
// }
// }
//}
//catch

View File

@ -32,7 +32,7 @@ namespace Emby.Drawing
throw new NotImplementedException();
}
public void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
{
throw new NotImplementedException();
}

View File

@ -35,110 +35,113 @@ namespace Emby.Photos
try
{
using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(item.Path), _fileSystem.OpenRead(item.Path), null)))
using (var fileStream = _fileSystem.OpenRead(item.Path))
{
var image = file as TagLib.Image.File;
var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;
if (tag != null)
using (var file = TagLib.File.Create(new StreamFileAbstraction(Path.GetFileName(item.Path), fileStream, null)))
{
var structure = tag.Structure;
var image = file as TagLib.Image.File;
if (structure != null)
var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;
if (tag != null)
{
var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry;
var structure = tag.Structure;
if (exif != null)
if (structure != null)
{
var exifStructure = exif.Structure;
var exif = structure.GetEntry(0, (ushort)IFDEntryTag.ExifIFD) as SubIFDEntry;
if (exifStructure != null)
if (exif != null)
{
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
var exifStructure = exif.Structure;
if (entry != null)
if (exifStructure != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.Aperture = val;
}
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
if (entry != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.Aperture = val;
}
if (entry != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.ShutterSpeed = val;
entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
if (entry != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.ShutterSpeed = val;
}
}
}
}
}
}
item.CameraMake = image.ImageTag.Make;
item.CameraModel = image.ImageTag.Model;
item.CameraMake = image.ImageTag.Make;
item.CameraModel = image.ImageTag.Model;
item.Width = image.Properties.PhotoWidth;
item.Height = image.Properties.PhotoHeight;
item.Width = image.Properties.PhotoWidth;
item.Height = image.Properties.PhotoHeight;
var rating = image.ImageTag.Rating;
if (rating.HasValue)
{
item.CommunityRating = rating;
}
else
{
item.CommunityRating = null;
}
item.Overview = image.ImageTag.Comment;
if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
{
item.Name = image.ImageTag.Title;
}
var dateTaken = image.ImageTag.DateTime;
if (dateTaken.HasValue)
{
item.DateCreated = dateTaken.Value;
item.PremiereDate = dateTaken.Value;
item.ProductionYear = dateTaken.Value.Year;
}
item.Genres = image.ImageTag.Genres.ToList();
item.Tags = image.ImageTag.Keywords.ToList();
item.Software = image.ImageTag.Software;
if (image.ImageTag.Orientation == TagLib.Image.ImageOrientation.None)
{
item.Orientation = null;
}
else
{
MediaBrowser.Model.Drawing.ImageOrientation orientation;
if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation))
var rating = image.ImageTag.Rating;
if (rating.HasValue)
{
item.Orientation = orientation;
item.CommunityRating = rating;
}
else
{
item.CommunityRating = null;
}
}
item.ExposureTime = image.ImageTag.ExposureTime;
item.FocalLength = image.ImageTag.FocalLength;
item.Overview = image.ImageTag.Comment;
item.Latitude = image.ImageTag.Latitude;
item.Longitude = image.ImageTag.Longitude;
item.Altitude = image.ImageTag.Altitude;
if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
{
item.Name = image.ImageTag.Title;
}
if (image.ImageTag.ISOSpeedRatings.HasValue)
{
item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value);
}
else
{
item.IsoSpeedRating = null;
var dateTaken = image.ImageTag.DateTime;
if (dateTaken.HasValue)
{
item.DateCreated = dateTaken.Value;
item.PremiereDate = dateTaken.Value;
item.ProductionYear = dateTaken.Value.Year;
}
item.Genres = image.ImageTag.Genres.ToList();
item.Tags = image.ImageTag.Keywords.ToList();
item.Software = image.ImageTag.Software;
if (image.ImageTag.Orientation == TagLib.Image.ImageOrientation.None)
{
item.Orientation = null;
}
else
{
MediaBrowser.Model.Drawing.ImageOrientation orientation;
if (Enum.TryParse(image.ImageTag.Orientation.ToString(), true, out orientation))
{
item.Orientation = orientation;
}
}
item.ExposureTime = image.ImageTag.ExposureTime;
item.FocalLength = image.ImageTag.FocalLength;
item.Latitude = image.ImageTag.Latitude;
item.Longitude = image.ImageTag.Longitude;
item.Altitude = image.ImageTag.Altitude;
if (image.ImageTag.ISOSpeedRatings.HasValue)
{
item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value);
}
else
{
item.IsoSpeedRating = null;
}
}
}
}

View File

@ -124,7 +124,7 @@ namespace Emby.Server.Implementations.Data
if (CacheSize.HasValue)
{
queries.Add("PRAGMA cache_size=-" + CacheSize.Value.ToString(CultureInfo.InvariantCulture));
queries.Add("PRAGMA cache_size=" + CacheSize.Value.ToString(CultureInfo.InvariantCulture));
}
if (EnableTempStoreMemory)
@ -132,12 +132,6 @@ namespace Emby.Server.Implementations.Data
queries.Add("PRAGMA temp_store = memory");
}
//var cacheSize = CacheSize;
//if (cacheSize.HasValue)
//{
//}
////foreach (var query in queries)
////{
//// db.Execute(query);

View File

@ -142,7 +142,7 @@ namespace Emby.Server.Implementations.Data
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
string[] queries = {
"PRAGMA locking_mode=NORMAL",
"PRAGMA locking_mode=EXCLUSIVE",
"create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)",
@ -1258,22 +1258,6 @@ namespace Emby.Server.Implementations.Data
{
if (_config.Configuration.SkipDeserializationForBasicTypes)
{
if (type == typeof(MusicGenre))
{
return false;
}
if (type == typeof(GameGenre))
{
return false;
}
if (type == typeof(Genre))
{
return false;
}
if (type == typeof(Studio))
{
return false;
}
if (type == typeof(Person))
{
return false;
@ -1282,26 +1266,10 @@ namespace Emby.Server.Implementations.Data
{
return false;
}
if (type == typeof(ManualCollectionsFolder))
{
return false;
}
if (type == typeof(CameraUploadsFolder))
{
return false;
}
if (type == typeof(PlaylistsFolder))
{
return false;
}
if (type == typeof(UserRootFolder))
{
return false;
}
if (type == typeof(PhotoAlbum))
{
return false;
}
if (type == typeof(Season))
{
return false;
@ -1312,6 +1280,41 @@ namespace Emby.Server.Implementations.Data
}
}
if (type == typeof(MusicGenre))
{
return false;
}
if (type == typeof(GameGenre))
{
return false;
}
if (type == typeof(Genre))
{
return false;
}
if (type == typeof(Studio))
{
return false;
}
if (type == typeof(ManualCollectionsFolder))
{
return false;
}
if (type == typeof(CameraUploadsFolder))
{
return false;
}
if (type == typeof(PlaylistsFolder))
{
return false;
}
if (type == typeof(PhotoAlbum))
{
return false;
}
if (type == typeof(Year))
{
return false;
@ -2851,7 +2854,7 @@ namespace Emby.Server.Implementations.Data
}
if (string.Equals(name, ItemSortBy.SeriesSortName, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("(Select SortName from TypedBaseItems where B.Guid=A.SeriesId)", false);
return new Tuple<string, bool>("SeriesName", false);
}
return new Tuple<string, bool>(name, false);

View File

@ -883,15 +883,6 @@ namespace Emby.Server.Implementations.Dto
dto.AspectRatio = hasAspectRatio.AspectRatio;
}
if (fields.Contains(ItemFields.AwardSummary))
{
var hasAwards = item as IHasAwards;
if (hasAwards != null)
{
dto.AwardSummary = hasAwards.AwardSummary;
}
}
var backdropLimit = options.GetImageLimit(ImageType.Backdrop);
if (backdropLimit > 0)
{

View File

@ -335,12 +335,6 @@ namespace MediaBrowser.Api
video.Video3DFormat = request.Video3DFormat;
}
var hasAwards = item as IHasAwards;
if (hasAwards != null)
{
hasAwards.AwardSummary = request.AwardSummary;
}
var game = item as Game;
if (game != null)

View File

@ -866,7 +866,7 @@ namespace MediaBrowser.Api.Playback
var videoCodec = state.ActualOutputVideoCodec;
var mediaProfile = state.VideoRequest == null ?
profile.GetAudioMediaProfile(state.OutputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate) :
profile.GetAudioMediaProfile(state.OutputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate, state.OutputAudioSampleRate) :
profile.GetVideoMediaProfile(state.OutputContainer,
audioCodec,
videoCodec,

View File

@ -234,11 +234,11 @@ namespace MediaBrowser.Api.Playback.Hls
try
{
return FileSystem.GetFileStream(tmpPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true);
return FileSystem.GetFileStream(tmpPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, FileOpenOptions.Asynchronous | FileOpenOptions.SequentialScan);
}
catch (IOException)
{
return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true);
return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, FileOpenOptions.Asynchronous | FileOpenOptions.SequentialScan);
}
}

View File

@ -15,18 +15,11 @@ namespace MediaBrowser.Controller.Drawing
/// </summary>
/// <value>The supported output formats.</value>
ImageFormat[] SupportedOutputFormats { get; }
/// <summary>
/// Encodes the image.
/// </summary>
/// <param name="inputPath">The input path.</param>
/// <param name="outputPath">The output path.</param>
/// <param name="autoOrient">if set to <c>true</c> [automatic orient].</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="quality">The quality.</param>
/// <param name="options">The options.</param>
/// <param name="outputFormat">The output format.</param>
void EncodeImage(string inputPath, string outputPath, bool autoOrient, int width, int height, int quality, ImageProcessingOptions options, ImageFormat outputFormat);
void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat outputFormat);
/// <summary>
/// Creates the image collage.

View File

@ -0,0 +1,69 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Drawing
{
public static class ImageHelper
{
public static ImageSize GetNewImageSize(ImageProcessingOptions options, ImageSize? originalImageSize)
{
if (originalImageSize.HasValue)
{
// Determine the output size based on incoming parameters
var newSize = DrawingUtils.Resize(originalImageSize.Value, options.Width, options.Height, options.MaxWidth, options.MaxHeight);
return newSize;
}
return GetSizeEstimate(options);
}
private static ImageSize GetSizeEstimate(ImageProcessingOptions options)
{
if (options.Width.HasValue && options.Height.HasValue)
{
return new ImageSize(options.Width.Value, options.Height.Value);
}
var aspect = GetEstimatedAspectRatio(options.Image.Type, options.Item);
var width = options.Width ?? options.MaxWidth;
if (width.HasValue)
{
var heightValue = width.Value / aspect;
return new ImageSize(width.Value, heightValue);
}
var height = options.Height ?? options.MaxHeight ?? 200;
var widthValue = aspect * height;
return new ImageSize(widthValue, height);
}
private static double GetEstimatedAspectRatio(ImageType type, IHasImages item)
{
switch (type)
{
case ImageType.Art:
case ImageType.Backdrop:
case ImageType.Chapter:
case ImageType.Screenshot:
case ImageType.Thumb:
return 1.78;
case ImageType.Banner:
return 5.4;
case ImageType.Box:
case ImageType.BoxRear:
case ImageType.Disc:
case ImageType.Menu:
return 1;
case ImageType.Logo:
return 2.58;
case ImageType.Primary:
return item.GetDefaultPrimaryImageAspectRatio() ?? .667;
default:
return 1;
}
}
}
}

View File

@ -1,15 +0,0 @@

namespace MediaBrowser.Controller.Entities
{
/// <summary>
/// Interface IHasAwards
/// </summary>
public interface IHasAwards
{
/// <summary>
/// Gets or sets the awards summary.
/// </summary>
/// <value>The awards summary.</value>
string AwardSummary { get; set; }
}
}

View File

@ -251,7 +251,7 @@ namespace MediaBrowser.Controller.Entities
if (policy.MaxParentalRating.HasValue)
{
BlockUnratedItems = policy.BlockUnratedItems;
BlockUnratedItems = policy.BlockUnratedItems.Where(i => i != UnratedItem.Other).ToArray();
}
ExcludeInheritedTags = policy.BlockedTags;

View File

@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <summary>
/// Class Movie
/// </summary>
public class Movie : Video, IHasSpecialFeatures, IHasTrailers, IHasAwards, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping
public class Movie : Video, IHasSpecialFeatures, IHasTrailers, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping
{
public List<Guid> SpecialFeatureIds { get; set; }
@ -29,8 +29,6 @@ namespace MediaBrowser.Controller.Entities.Movies
RemoteTrailerIds = new List<Guid>();
}
public string AwardSummary { get; set; }
public List<Guid> LocalTrailerIds { get; set; }
public List<Guid> RemoteTrailerIds { get; set; }

View File

@ -1,7 +1,4 @@
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Users;
using System.Linq;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Controller.Entities
{
@ -24,10 +21,5 @@ namespace MediaBrowser.Controller.Entities
return false;
}
}
protected override bool GetBlockUnratedValue(UserPolicy config)
{
return config.BlockUnratedItems.Contains(UnratedItem.Other);
}
}
}

View File

@ -91,6 +91,7 @@
<Compile Include="Drawing\IImageEncoder.cs" />
<Compile Include="Drawing\IImageProcessor.cs" />
<Compile Include="Drawing\ImageCollageOptions.cs" />
<Compile Include="Drawing\ImageHelper.cs" />
<Compile Include="Drawing\ImageProcessingOptions.cs" />
<Compile Include="Drawing\ImageProcessorExtensions.cs" />
<Compile Include="Drawing\ImageStream.cs" />
@ -131,7 +132,6 @@
<Compile Include="Entities\ItemImageInfo.cs" />
<Compile Include="Entities\LinkedChild.cs" />
<Compile Include="Entities\MusicVideo.cs" />
<Compile Include="Entities\IHasAwards.cs" />
<Compile Include="Entities\PeopleHelper.cs" />
<Compile Include="Entities\Photo.cs" />
<Compile Include="Entities\PhotoAlbum.cs" />

View File

@ -1749,7 +1749,8 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (!string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType))
{
return "-hwaccel auto";
// causing unpredictable results
//return "-hwaccel auto";
}
if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))

View File

@ -59,7 +59,7 @@ namespace MediaBrowser.Controller.MediaEncoding
{
get
{
return false;
return MediaSource.GenPtsInput;
}
}
@ -93,11 +93,13 @@ namespace MediaBrowser.Controller.MediaEncoding
{
get
{
// For live tv + recordings
if (string.Equals(InputContainer, "mpegts", StringComparison.OrdinalIgnoreCase) ||
string.Equals(InputContainer, "ts", StringComparison.OrdinalIgnoreCase))
// For live tv + in progress recordings
if (string.Equals(InputContainer, "mpegts", StringComparison.OrdinalIgnoreCase) || string.Equals(InputContainer, "ts", StringComparison.OrdinalIgnoreCase))
{
return "cfr";
if (!MediaSource.RunTimeTicks.HasValue)
{
return "cfr";
}
}
return "-1";

View File

@ -207,21 +207,6 @@ namespace MediaBrowser.LocalMetadata.Parsers
break;
}
case "AwardSummary":
{
var text = reader.ReadElementContentAsString();
var hasAwards = item as IHasAwards;
if (hasAwards != null)
{
if (!string.IsNullOrWhiteSpace(text))
{
hasAwards.AwardSummary = text;
}
}
break;
}
case "SortTitle":
{
var val = reader.ReadElementContentAsString();

View File

@ -35,7 +35,6 @@ namespace MediaBrowser.LocalMetadata.Savers
"AspectRatio",
"AudioDbAlbumId",
"AudioDbArtistId",
"AwardSummary",
"BirthDate",
// Deprecated. No longer saving in this field.
@ -403,12 +402,6 @@ namespace MediaBrowser.LocalMetadata.Savers
writer.WriteElementString("DisplayOrder", hasDisplayOrder.DisplayOrder);
}
var hasAwards = item as IHasAwards;
if (hasAwards != null && !string.IsNullOrEmpty(hasAwards.AwardSummary))
{
writer.WriteElementString("AwardSummary", hasAwards.AwardSummary);
}
if (item.CommunityRating.HasValue)
{
writer.WriteElementString("Rating", item.CommunityRating.Value.ToString(UsCulture));

View File

@ -263,7 +263,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
var outputContainer = state.Options.OutputContainer;
var mediaProfile = state.IsVideoRequest ?
profile.GetAudioMediaProfile(outputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate) :
profile.GetAudioMediaProfile(outputContainer, audioCodec, state.OutputAudioChannels, state.OutputAudioBitrate, state.OutputAudioSampleRate) :
profile.GetVideoMediaProfile(outputContainer,
audioCodec,
videoCodec,

View File

@ -76,7 +76,7 @@ namespace MediaBrowser.Model.Dlna
}
}
public bool IsAudioConditionSatisfied(ProfileCondition condition, int? audioChannels, int? audioBitrate)
public bool IsAudioConditionSatisfied(ProfileCondition condition, int? audioChannels, int? audioBitrate, int? audioSampleRate)
{
switch (condition.Property)
{
@ -84,6 +84,8 @@ namespace MediaBrowser.Model.Dlna
return IsConditionSatisfied(condition, audioBitrate);
case ProfileConditionValue.AudioChannels:
return IsConditionSatisfied(condition, audioChannels);
case ProfileConditionValue.AudioSampleRate:
return IsConditionSatisfied(condition, audioSampleRate);
default:
throw new ArgumentException("Unexpected condition on audio file: " + condition.Property);
}
@ -92,6 +94,7 @@ namespace MediaBrowser.Model.Dlna
public bool IsVideoAudioConditionSatisfied(ProfileCondition condition,
int? audioChannels,
int? audioBitrate,
int? audioSampleRate,
string audioProfile,
bool? isSecondaryTrack)
{
@ -105,6 +108,8 @@ namespace MediaBrowser.Model.Dlna
return IsConditionSatisfied(condition, audioChannels);
case ProfileConditionValue.IsSecondaryAudio:
return IsConditionSatisfied(condition, isSecondaryTrack);
case ProfileConditionValue.AudioSampleRate:
return IsConditionSatisfied(condition, audioSampleRate);
default:
throw new ArgumentException("Unexpected condition on audio file: " + condition.Property);
}

View File

@ -85,7 +85,8 @@ namespace MediaBrowser.Model.Dlna
ResponseProfile mediaProfile = _profile.GetAudioMediaProfile(container,
audioCodec,
audioChannels,
audioBitrate);
audioBitrate,
audioSampleRate);
string orgPn = mediaProfile == null ? null : mediaProfile.OrgPn;

View File

@ -185,7 +185,7 @@ namespace MediaBrowser.Model.Dlna
return null;
}
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate)
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate, int? audioSampleRate)
{
container = StringHelper.TrimStart(container ?? string.Empty, '.');
@ -213,7 +213,7 @@ namespace MediaBrowser.Model.Dlna
var anyOff = false;
foreach (ProfileCondition c in i.Conditions)
{
if (!conditionProcessor.IsAudioConditionSatisfied(GetModelProfileCondition(c), audioChannels, audioBitrate))
if (!conditionProcessor.IsAudioConditionSatisfied(GetModelProfileCondition(c), audioChannels, audioBitrate, audioSampleRate))
{
anyOff = true;
break;

View File

@ -22,6 +22,7 @@
IsSecondaryAudio = 18,
VideoCodecTag = 19,
IsAvc = 20,
IsInterlaced = 21
IsInterlaced = 21,
AudioSampleRate = 22
}
}

View File

@ -139,6 +139,7 @@ namespace MediaBrowser.Model.Dlna
int? inputAudioChannels = audioStream == null ? null : audioStream.Channels;
int? inputAudioBitrate = audioStream == null ? null : audioStream.BitDepth;
int? inputAudioSampleRate = audioStream == null ? null : audioStream.SampleRate;
if (directPlayMethods.Count > 0)
{
@ -155,7 +156,7 @@ namespace MediaBrowser.Model.Dlna
bool applyConditions = true;
foreach (ProfileCondition applyCondition in i.ApplyConditions)
{
if (!conditionProcessor.IsAudioConditionSatisfied(applyCondition, inputAudioChannels, inputAudioBitrate))
if (!conditionProcessor.IsAudioConditionSatisfied(applyCondition, inputAudioChannels, inputAudioBitrate, inputAudioSampleRate))
{
LogConditionFailure(options.Profile, "AudioCodecProfile", applyCondition, item);
applyConditions = false;
@ -176,7 +177,7 @@ namespace MediaBrowser.Model.Dlna
bool all = true;
foreach (ProfileCondition c in conditions)
{
if (!conditionProcessor.IsAudioConditionSatisfied(c, inputAudioChannels, inputAudioBitrate))
if (!conditionProcessor.IsAudioConditionSatisfied(c, inputAudioChannels, inputAudioBitrate, inputAudioSampleRate))
{
LogConditionFailure(options.Profile, "AudioCodecProfile", c, item);
all = false;
@ -251,7 +252,7 @@ namespace MediaBrowser.Model.Dlna
bool applyConditions = true;
foreach (ProfileCondition applyCondition in i.ApplyConditions)
{
if (!conditionProcessor.IsAudioConditionSatisfied(applyCondition, inputAudioChannels, inputAudioBitrate))
if (!conditionProcessor.IsAudioConditionSatisfied(applyCondition, inputAudioChannels, inputAudioBitrate, inputAudioSampleRate))
{
LogConditionFailure(options.Profile, "AudioCodecProfile", applyCondition, item);
applyConditions = false;
@ -519,8 +520,9 @@ namespace MediaBrowser.Model.Dlna
int? inputAudioBitrate = audioStream == null ? null : audioStream.BitRate;
int? audioChannels = audioStream == null ? null : audioStream.Channels;
string audioProfile = audioStream == null ? null : audioStream.Profile;
int? inputAudioSampleRate = audioStream == null ? null : audioStream.SampleRate;
if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, inputAudioBitrate, audioProfile, isSecondaryAudio))
if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, inputAudioBitrate, inputAudioSampleRate, audioProfile, isSecondaryAudio))
{
LogConditionFailure(options.Profile, "AudioCodecProfile", applyCondition, item);
applyConditions = false;
@ -752,6 +754,7 @@ namespace MediaBrowser.Model.Dlna
int? audioBitrate = audioStream == null ? null : audioStream.BitRate;
int? audioChannels = audioStream == null ? null : audioStream.Channels;
string audioProfile = audioStream == null ? null : audioStream.Profile;
int? audioSampleRate = audioStream == null ? null : audioStream.SampleRate;
TransportStreamTimestamp? timestamp = videoStream == null ? TransportStreamTimestamp.None : mediaSource.Timestamp;
int? packetLength = videoStream == null ? null : videoStream.PacketLength;
@ -841,7 +844,7 @@ namespace MediaBrowser.Model.Dlna
bool applyConditions = true;
foreach (ProfileCondition applyCondition in i.ApplyConditions)
{
if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, audioBitrate, audioProfile, isSecondaryAudio))
if (!conditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, audioBitrate, audioSampleRate, audioProfile, isSecondaryAudio))
{
LogConditionFailure(profile, "VideoAudioCodecProfile", applyCondition, mediaSource);
applyConditions = false;
@ -861,7 +864,7 @@ namespace MediaBrowser.Model.Dlna
foreach (ProfileCondition i in conditions)
{
if (!conditionProcessor.IsVideoAudioConditionSatisfied(i, audioChannels, audioBitrate, audioProfile, isSecondaryAudio))
if (!conditionProcessor.IsVideoAudioConditionSatisfied(i, audioChannels, audioBitrate, audioSampleRate, audioProfile, isSecondaryAudio))
{
LogConditionFailure(profile, "VideoAudioCodecProfile", i, mediaSource);

View File

@ -79,8 +79,6 @@ namespace MediaBrowser.Model.Dto
public string PreferredMetadataLanguage { get; set; }
public string PreferredMetadataCountryCode { get; set; }
public string AwardSummary { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [supports synchronize].
/// </summary>

View File

@ -31,6 +31,7 @@ namespace MediaBrowser.Model.Dto
public bool ReadAtNativeFramerate { get; set; }
public bool IgnoreDts { get; set; }
public bool IgnoreIndex { get; set; }
public bool GenPtsInput { get; set; }
public bool SupportsTranscoding { get; set; }
public bool SupportsDirectStream { get; set; }
public bool SupportsDirectPlay { get; set; }

View File

@ -15,11 +15,6 @@
/// </summary>
AlternateEpisodeNumbers,
/// <summary>
/// The awards summary
/// </summary>
AwardSummary,
/// <summary>
/// The can delete
/// </summary>

View File

@ -198,7 +198,6 @@ namespace MediaBrowser.Providers.Manager
MergeAlbumArtist(source, target, lockedFields, replaceData);
MergeCriticRating(source, target, lockedFields, replaceData);
MergeAwards(source, target, lockedFields, replaceData);
MergeTrailers(source, target, lockedFields, replaceData);
MergeVideoInfo(source, target, lockedFields, replaceData);
@ -273,20 +272,6 @@ namespace MediaBrowser.Providers.Manager
}
}
private static void MergeAwards(BaseItem source, BaseItem target, List<MetadataFields> lockedFields, bool replaceData)
{
var sourceCast = source as IHasAwards;
var targetCast = target as IHasAwards;
if (sourceCast != null && targetCast != null)
{
if (replaceData || string.IsNullOrEmpty(targetCast.AwardSummary))
{
targetCast.AwardSummary = sourceCast.AwardSummary;
}
}
}
private static void MergeCriticRating(BaseItem source, BaseItem target, List<MetadataFields> lockedFields, bool replaceData)
{
if (replaceData || !target.CriticRating.HasValue)

View File

@ -406,12 +406,6 @@ namespace MediaBrowser.Providers.Omdb
}
}
var hasAwards = item as IHasAwards;
if (hasAwards != null && !string.IsNullOrEmpty(result.Awards))
{
hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards);
}
if (isConfiguredForEnglish)
{
// Omdb is currently english only, so for other languages skip this and let secondary providers fill it in

View File

@ -2224,6 +2224,9 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\scripts\encodingsettings.js">
<Link>Resources\dashboard-ui\scripts\encodingsettings.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\scripts\episodes.js">
<Link>Resources\dashboard-ui\scripts\episodes.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\scripts\forgotpassword.js">
<Link>Resources\dashboard-ui\scripts\forgotpassword.js</Link>
</BundleResource>

View File

@ -775,8 +775,6 @@ namespace MediaBrowser.ServerApplication
return;
}
MessageBox.Show("The Visual C++ 2013 Runtime will now be installed.", "Install Visual C++ Runtime", MessageBoxButtons.OK, MessageBoxIcon.Information);
try
{
await InstallVcredist(GetVcredist2013Url()).ConfigureAwait(false);
@ -829,8 +827,6 @@ namespace MediaBrowser.ServerApplication
return;
}
MessageBox.Show("The Visual C++ 2015 Runtime will now be installed.", "Install Visual C++ Runtime", MessageBoxButtons.OK, MessageBoxIcon.Information);
try
{
await InstallVcredist(GetVcredist2015Url()).ConfigureAwait(false);

View File

@ -341,21 +341,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
case "awardsummary":
{
var text = reader.ReadElementContentAsString();
var hasAwards = item as IHasAwards;
if (hasAwards != null)
{
if (!string.IsNullOrWhiteSpace(text))
{
hasAwards.AwardSummary = text;
}
}
break;
}
case "sorttitle":
{
var val = reader.ReadElementContentAsString();

View File

@ -81,7 +81,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
"country",
"audiodbalbumid",
"audiodbartistid",
"awardsummary",
"enddate",
"lockedfields",
"zap2itid",
@ -711,12 +710,6 @@ namespace MediaBrowser.XbmcMetadata.Savers
writer.WriteElementString("plotkeyword", tag);
}
var hasAwards = item as IHasAwards;
if (hasAwards != null && !string.IsNullOrEmpty(hasAwards.AwardSummary))
{
writer.WriteElementString("awardsummary", hasAwards.AwardSummary);
}
var externalId = item.GetProviderId(MetadataProviders.AudioDbArtist);
if (!string.IsNullOrEmpty(externalId))