Skip to content

Commit

Permalink
Merge pull request #2641 from MediaBrowser/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
LukePulverenti authored May 16, 2017
2 parents 760e2e5 + 6dfaf14 commit d1abc98
Show file tree
Hide file tree
Showing 26 changed files with 263 additions and 994 deletions.
28 changes: 17 additions & 11 deletions Emby.Server.Implementations/Dto/DtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,24 +1582,30 @@ public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item)

ImageSize size;

if (supportedEnhancers.Count == 0)
{
var defaultAspectRatio = item.GetDefaultPrimaryImageAspectRatio();
var defaultAspectRatio = item.GetDefaultPrimaryImageAspectRatio();

if (defaultAspectRatio.HasValue)
if (defaultAspectRatio.HasValue)
{
if (supportedEnhancers.Count == 0)
{
return defaultAspectRatio.Value;
}
}

try
{
size = _imageProcessor.GetImageSize(imageInfo);
double dummyWidth = 200;
double dummyHeight = dummyWidth / defaultAspectRatio.Value;
size = new ImageSize(dummyWidth, dummyHeight);
}
catch
else
{
//_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
return null;
try
{
size = _imageProcessor.GetImageSize(imageInfo);
}
catch
{
//_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
return null;
}
}

foreach (var enhancer in supportedEnhancers)
Expand Down
31 changes: 30 additions & 1 deletion Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Logging;

Expand All @@ -29,7 +30,35 @@ public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile)
return targetFile;
}

public async Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
public Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
if (directStreamProvider != null)
{
return RecordFromDirectStreamProvider(directStreamProvider, targetFile, duration, onStarted, cancellationToken);
}

return RecordFromMediaSource(mediaSource, targetFile, duration, onStarted, cancellationToken);
}

private async Task RecordFromDirectStreamProvider(IDirectStreamProvider directStreamProvider, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
using (var output = _fileSystem.GetFileStream(targetFile, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
{
onStarted();

_logger.Info("Copying recording stream to file {0}", targetFile);

// The media source if infinite so we need to handle stopping ourselves
var durationToken = new CancellationTokenSource(duration);
cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;

await directStreamProvider.CopyToAsync(output, cancellationToken).ConfigureAwait(false);
}

_logger.Info("Recording completed to file {0}", targetFile);
}

private async Task RecordFromMediaSource(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
var httpRequestOptions = new HttpRequestOptions
{
Expand Down
22 changes: 16 additions & 6 deletions Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate,
EnforceKeepUpTo(timer, seriesPath);
};

await recorder.Record(mediaStreamInfo, recordPath, duration, onStarted, cancellationToken).ConfigureAwait(false);
await recorder.Record(liveStreamInfo.Item1 as IDirectStreamProvider, mediaStreamInfo, recordPath, duration, onStarted, cancellationToken).ConfigureAwait(false);

recordingStatus = RecordingStatus.Completed;
_logger.Info("Recording completed: {0}", recordPath);
Expand Down Expand Up @@ -1759,17 +1759,27 @@ private async Task<IRecorder> GetRecorder()
{
var config = GetConfiguration();

if (config.EnableRecordingEncoding)
{
var regInfo = await _liveTvManager.GetRegistrationInfo("embytvrecordingconversion").ConfigureAwait(false);
var regInfo = await _liveTvManager.GetRegistrationInfo("embytvrecordingconversion").ConfigureAwait(false);

if (regInfo.IsValid)
if (regInfo.IsValid)
{
if (config.EnableRecordingEncoding)
{
return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory, _config);
}

return new DirectRecorder(_logger, _httpClient, _fileSystem);

//var options = new LiveTvOptions
//{
// EnableOriginalAudioWithEncodedRecordings = true,
// RecordedVideoCodec = "copy",
// RecordingEncodingFormat = "ts"
//};
//return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, options, _httpClient, _processFactory, _config);
}

return new DirectRecorder(_logger, _httpClient, _fileSystem);
throw new InvalidOperationException("Emby DVR Requires an active Emby Premiere subscription.");
}

private async void OnSuccessfulRecording(TimerInfo timer, string path)
Expand Down
13 changes: 12 additions & 1 deletion Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Library;

namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
Expand Down Expand Up @@ -64,6 +65,10 @@ private string OutputFormat
{
return "mkv";
}
if (string.Equals(format, "ts", StringComparison.OrdinalIgnoreCase))
{
return "ts";
}

return "mp4";
}
Expand All @@ -90,7 +95,7 @@ public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile)
return Path.ChangeExtension(targetFile, "." + extension);
}

public async Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
public async Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
{
//var durationToken = new CancellationTokenSource(duration);
//cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
Expand Down Expand Up @@ -177,6 +182,8 @@ private string GetCommandLineArgs(MediaSourceInfo mediaSource, string inputTempF
videoArgs = "-codec:v:0 copy";
}

videoArgs += " -fflags +genpts";

var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);

var flags = new List<string>();
Expand All @@ -188,6 +195,10 @@ private string GetCommandLineArgs(MediaSourceInfo mediaSource, string inputTempF
{
flags.Add("+ignidx");
}
if (mediaSource.GenPtsInput)
{
flags.Add("+genpts");
}

var inputModifiers = "-async 1 -vsync -1";

Expand Down
9 changes: 2 additions & 7 deletions Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;

namespace Emby.Server.Implementations.LiveTv.EmbyTV
Expand All @@ -10,13 +11,7 @@ public interface IRecorder
/// <summary>
/// Records the specified media source.
/// </summary>
/// <param name="mediaSource">The media source.</param>
/// <param name="targetFile">The target file.</param>
/// <param name="duration">The duration.</param>
/// <param name="onStarted">The on started.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task Record(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken);
Task Record(IDirectStreamProvider directStreamProvider, MediaSourceInfo mediaSource, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken);

string GetOutputPath(MediaSourceInfo mediaSource, string targetFile);
}
Expand Down
8 changes: 0 additions & 8 deletions MediaBrowser.Api/MediaBrowser.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
Expand Down
8 changes: 0 additions & 8 deletions MediaBrowser.Common/MediaBrowser.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release Mono\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
Expand Down
8 changes: 0 additions & 8 deletions MediaBrowser.Controller/MediaBrowser.Controller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release Mono\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<None Include="project.json" />
<!-- A reference to the entire .NET Framework is automatically included -->
Expand Down
5 changes: 0 additions & 5 deletions MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' ">
<Optimize>false</Optimize>
<OutputPath>bin\Release Mono</OutputPath>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
Expand Down
18 changes: 0 additions & 18 deletions MediaBrowser.Mono.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Dlna", "Emby.Dlna\Emby
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing.ImageMagick", "Emby.Drawing.ImageMagick\Emby.Drawing.ImageMagick.csproj", "{6CFEE013-6E7C-432B-AC37-CABF0880C69A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing.Net", "Emby.Drawing.Net\Emby.Drawing.Net.csproj", "{C97A239E-A96C-4D64-A844-CCF8CC30AECB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocketHttpListener.Portable", "SocketHttpListener.Portable\SocketHttpListener.Portable.csproj", "{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}"
EndProject
Global
Expand Down Expand Up @@ -368,22 +366,6 @@ Global
{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|Any CPU.Build.0 = Release|Any CPU
{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|x86.ActiveCfg = Release|Any CPU
{6CFEE013-6E7C-432B-AC37-CABF0880C69A}.Signed|x86.Build.0 = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|x86.ActiveCfg = Debug|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Debug|x86.Build.0 = Debug|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|x86.ActiveCfg = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release Mono|x86.Build.0 = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|Any CPU.Build.0 = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|x86.ActiveCfg = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Release|x86.Build.0 = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|Any CPU.ActiveCfg = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|Any CPU.Build.0 = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|x86.ActiveCfg = Release|Any CPU
{C97A239E-A96C-4D64-A844-CCF8CC30AECB}.Signed|x86.Build.0 = Release|Any CPU
{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F26D5D8-A7B0-42B3-BA42-7CB7D245934E}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down
8 changes: 0 additions & 8 deletions MediaBrowser.Providers/MediaBrowser.Providers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release Mono\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release Mono|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release Mono\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
Expand Down
12 changes: 9 additions & 3 deletions MediaBrowser.Server.Mac/Emby.Server.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1030,12 +1030,12 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\itemidentifier\itemidentifier.template.html">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\itemidentifier\itemidentifier.template.html</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyloader-intersectionobserver.js">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyloader-intersectionobserver.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyedgehack.css">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyedgehack.css</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyloader-intersectionobserver.js">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyloader-intersectionobserver.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyloader-scroll.js">
<Link>Resources\dashboard-ui\bower_components\emby-webcomponents\lazyloader\lazyloader-scroll.js</Link>
</BundleResource>
Expand Down Expand Up @@ -1606,6 +1606,12 @@
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\requirejs\require.js">
<Link>Resources\dashboard-ui\bower_components\requirejs\require.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\resize-observer-polyfill\LICENSE">
<Link>Resources\dashboard-ui\bower_components\resize-observer-polyfill\LICENSE</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\resize-observer-polyfill\resizeobserver.js">
<Link>Resources\dashboard-ui\bower_components\resize-observer-polyfill\resizeobserver.js</Link>
</BundleResource>
<BundleResource Include="..\MediaBrowser.WebDashboard\dashboard-ui\bower_components\vibrant\gulpfile.coffee">
<Link>Resources\dashboard-ui\bower_components\vibrant\gulpfile.coffee</Link>
</BundleResource>
Expand Down
10 changes: 0 additions & 10 deletions MediaBrowser.Server.Mono/ImageEncoderHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Emby.Drawing;
using Emby.Drawing.Net;
using Emby.Drawing.ImageMagick;
using Emby.Server.Core;
using Emby.Server.Implementations;
Expand Down Expand Up @@ -33,15 +32,6 @@ public static IImageEncoder GetImageEncoder(ILogger logger,
}
}

try
{
return new GDIImageEncoder(fileSystem, logManager.GetLogger("GDI"));
}
catch
{
logger.Error("Error loading GDI. Will revert to NullImageEncoder.");
}

return new NullImageEncoder();
}
}
Expand Down
Loading

0 comments on commit d1abc98

Please sign in to comment.