aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-05-16 01:48:25 -0400
committerGitHub <noreply@github.com>2017-05-16 01:48:25 -0400
commit12a7e360272a9a4dde862b43af2a1f886e79032a (patch)
treeec02a264f7b552a0401b26017b2646a79be9d83c /Emby.Server.Implementations
parentd5989b5a882c085494225e13f06d6e96d95ab952 (diff)
parent0375bbd3ed9d80e5eb96690589f2bd414d17940e (diff)
Merge pull request #2641 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs28
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs31
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs22
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs13
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs9
5 files changed, 77 insertions, 26 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index d784bcb09..0b66a8e1f 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -1582,24 +1582,30 @@ namespace Emby.Server.Implementations.Dto
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)
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
index ef440899c..e43e05839 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs
@@ -6,6 +6,7 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.IO;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Logging;
@@ -29,7 +30,35 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
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
{
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index f1b3f41b4..7f1a9ba6d 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -1517,7 +1517,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
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);
@@ -1759,17 +1759,27 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
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)
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 790e6c27d..2f449bee2 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
@@ -21,6 +21,7 @@ using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.Library;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
@@ -64,6 +65,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
return "mkv";
}
+ if (string.Equals(format, "ts", StringComparison.OrdinalIgnoreCase))
+ {
+ return "ts";
+ }
return "mp4";
}
@@ -90,7 +95,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
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;
@@ -177,6 +182,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
videoArgs = "-codec:v:0 copy";
}
+ videoArgs += " -fflags +genpts";
+
var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);
var flags = new List<string>();
@@ -188,6 +195,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
flags.Add("+ignidx");
}
+ if (mediaSource.GenPtsInput)
+ {
+ flags.Add("+genpts");
+ }
var inputModifiers = "-async 1 -vsync -1";
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
index 3b5e60c4a..e639a312c 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/IRecorder.cs
@@ -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
@@ -10,13 +11,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
/// <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);
}