Skip to content

Commit

Permalink
Merge pull request #2636 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LukePulverenti authored May 14, 2017
2 parents 4fe6cb1 + bdafd2f commit 2a6b608
Show file tree
Hide file tree
Showing 27 changed files with 146 additions and 118 deletions.
25 changes: 15 additions & 10 deletions Emby.Drawing/ImageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,20 +513,25 @@ private ImageSize GetImageSize(string path, DateTime imageDateModified, bool all
/// <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
Expand Down
157 changes: 80 additions & 77 deletions Emby.Photos/PhotoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,110 +35,113 @@ public Task<ItemUpdateType> FetchAsync(Photo item, MetadataRefreshOptions option

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;

var tag = file.GetTag(TagTypes.TiffIFD) as IFDTag;

if (structure != null)
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;

if (entry != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.Aperture = val;
}

entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ShutterSpeedValue) as RationalIFDEntry;
var exifStructure = exif.Structure;

if (entry != null)
if (exifStructure != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.ShutterSpeed = val;
var entry = exifStructure.GetEntry(0, (ushort)ExifEntryTag.ApertureValue) as RationalIFDEntry;

if (entry != null)
{
double val = entry.Value.Numerator;
val /= entry.Value.Denominator;
item.Aperture = 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;
}
var rating = image.ImageTag.Rating;
if (rating.HasValue)
{
item.CommunityRating = rating;
}
else
{
item.CommunityRating = null;
}

item.Overview = image.ImageTag.Comment;
item.Overview = image.ImageTag.Comment;

if (!string.IsNullOrWhiteSpace(image.ImageTag.Title))
{
item.Name = image.ImageTag.Title;
}
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;
}
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;
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))
if (image.ImageTag.Orientation == TagLib.Image.ImageOrientation.None)
{
item.Orientation = orientation;
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.ExposureTime = image.ImageTag.ExposureTime;
item.FocalLength = image.ImageTag.FocalLength;

item.Latitude = image.ImageTag.Latitude;
item.Longitude = image.ImageTag.Longitude;
item.Altitude = image.ImageTag.Altitude;
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;
if (image.ImageTag.ISOSpeedRatings.HasValue)
{
item.IsoSpeedRating = Convert.ToInt32(image.ImageTag.ISOSpeedRatings.Value);
}
else
{
item.IsoSpeedRating = null;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Updates/InstallationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ public void UninstallPlugin(IPlugin plugin)
_logger.Info("Deleting plugin file {0}", path);

// Make this case-insensitive to account for possible incorrect assembly naming
var file = _fileSystem.GetFilePaths(path)
var file = _fileSystem.GetFilePaths(_fileSystem.GetDirectoryName(path))
.FirstOrDefault(i => string.Equals(i, path, StringComparison.OrdinalIgnoreCase));

if (!string.IsNullOrWhiteSpace(file))
Expand Down
4 changes: 2 additions & 2 deletions MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ protected Stream GetPlaylistFileStream(string path)

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);
}
}

Expand Down
12 changes: 7 additions & 5 deletions MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public bool GenPtsInput
{
get
{
return false;
return MediaSource.GenPtsInput;
}
}

Expand Down Expand Up @@ -93,11 +93,13 @@ public string OutputVideoSync
{
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";
Expand Down
1 change: 1 addition & 0 deletions MediaBrowser.Model/Dto/MediaSourceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class MediaSourceInfo
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; }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2a6b608

Please sign in to comment.