aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Playback
diff options
context:
space:
mode:
authorTthecreator <epostvanthomas@kpnmail.nl>2019-01-22 15:22:42 +0000
committerGitHub <noreply@github.com>2019-01-22 15:22:42 +0000
commit189b99df16bd4c93cc96422d7282d01d9ff5b82f (patch)
tree26d7da95fe3e3b2772b8b39a2463a6c0ac7652fc /MediaBrowser.Api/Playback
parenta00c0defa8cb22774f5dc8a7d566eb36ac7307e8 (diff)
parentedcfd8b565f632088c8b1f826db8e2fbecf9790d (diff)
Merge pull request #1 from jellyfin/dev
Update from jellyfin repo
Diffstat (limited to 'MediaBrowser.Api/Playback')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs41
-rw-r--r--MediaBrowser.Api/Playback/Hls/BaseHlsService.cs25
-rw-r--r--MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs28
-rw-r--r--MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs7
-rw-r--r--MediaBrowser.Api/Playback/Hls/VideoHlsService.cs6
-rw-r--r--MediaBrowser.Api/Playback/MediaInfoService.cs18
-rw-r--r--MediaBrowser.Api/Playback/Progressive/AudioService.cs7
-rw-r--r--MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs20
-rw-r--r--MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs16
-rw-r--r--MediaBrowser.Api/Playback/Progressive/VideoService.cs8
-rw-r--r--MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs7
-rw-r--r--MediaBrowser.Api/Playback/StreamRequest.cs34
-rw-r--r--MediaBrowser.Api/Playback/StreamState.cs125
-rw-r--r--MediaBrowser.Api/Playback/TranscodingThrottler.cs4
-rw-r--r--MediaBrowser.Api/Playback/UniversalAudioService.cs4
15 files changed, 103 insertions, 247 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index ba7f7070b6..bb525adc73 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1,16 +1,3 @@
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Devices;
-using MediaBrowser.Controller.Dlna;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Extensions;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -19,11 +6,23 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Devices;
+using MediaBrowser.Controller.Dlna;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Diagnostics;
+using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.MediaInfo;
+using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Playback
@@ -142,10 +141,7 @@ namespace MediaBrowser.Api.Playback
return Path.Combine(folder, dataHash + (outputFileExtension ?? string.Empty).ToLower());
}
- protected virtual bool EnableOutputInSubFolder
- {
- get { return false; }
- }
+ protected virtual bool EnableOutputInSubFolder => false;
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
@@ -535,8 +531,7 @@ namespace MediaBrowser.Api.Playback
{
if (!string.IsNullOrWhiteSpace(val) && videoRequest != null)
{
- SubtitleDeliveryMethod method;
- if (Enum.TryParse(val, out method))
+ if (Enum.TryParse(val, out SubtitleDeliveryMethod method))
{
videoRequest.SubtitleMethod = method;
}
@@ -640,8 +635,7 @@ namespace MediaBrowser.Api.Playback
if (value.IndexOf(':') == -1)
{
// Parses npt times in the format of '417.33'
- double seconds;
- if (double.TryParse(value, NumberStyles.Any, UsCulture, out seconds))
+ if (double.TryParse(value, NumberStyles.Any, UsCulture, out var seconds))
{
return TimeSpan.FromSeconds(seconds).Ticks;
}
@@ -656,8 +650,7 @@ namespace MediaBrowser.Api.Playback
foreach (var time in tokens)
{
- double digit;
- if (double.TryParse(time, NumberStyles.Any, UsCulture, out digit))
+ if (double.TryParse(time, NumberStyles.Any, UsCulture, out var digit))
{
secondsSum += digit * timeFactor;
}
@@ -755,7 +748,7 @@ namespace MediaBrowser.Api.Playback
MediaSourceInfo mediaSource = null;
if (string.IsNullOrWhiteSpace(request.LiveStreamId))
{
- TranscodingJob currentJob = !string.IsNullOrWhiteSpace(request.PlaySessionId) ?
+ var currentJob = !string.IsNullOrWhiteSpace(request.PlaySessionId) ?
ApiEntryPoint.Instance.GetTranscodingJob(request.PlaySessionId)
: null;
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 3e17d0b748..1e90d03b0a 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -1,20 +1,20 @@
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Devices;
-using MediaBrowser.Controller.Dlna;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.Extensions;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Net;
-using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Devices;
+using MediaBrowser.Controller.Dlna;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Net;
+using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Playback.Hls
@@ -52,10 +52,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// Gets the type of the transcoding job.
/// </summary>
/// <value>The type of the transcoding job.</value>
- protected override TranscodingJobType TranscodingJobType
- {
- get { return TranscodingJobType.Hls; }
- }
+ protected override TranscodingJobType TranscodingJobType => TranscodingJobType.Hls;
/// <summary>
/// Processes the request.
@@ -201,7 +198,7 @@ namespace MediaBrowser.Api.Playback.Hls
while (!reader.EndOfStream)
{
- var line = reader.ReadLine();
+ var line = reader.ReadLine();
if (line.IndexOf("#EXTINF:", StringComparison.OrdinalIgnoreCase) != -1)
{
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index ff3712f8af..a488576da5 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -1,27 +1,27 @@
-using MediaBrowser.Common.Net;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net;
+using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Services;
-using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
using Microsoft.Extensions.Logging;
+using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Api.Playback.Hls
{
@@ -936,10 +936,10 @@ namespace MediaBrowser.Api.Playback.Hls
var timeDeltaParam = string.Empty;
- if (isEncoding && startNumber > 0)
+ if (isEncoding && state.TargetFramerate > 0)
{
- var startTime = state.SegmentLength * startNumber;
- timeDeltaParam = string.Format("-segment_time_delta -{0}", startTime);
+ float startTime = 1 / (state.TargetFramerate.Value * 2);
+ timeDeltaParam = string.Format("-segment_time_delta {0}", Math.Round(startTime, 3));
}
var segmentFormat = GetSegmentFileExtension(state.Request).TrimStart('.');
diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
index 52cc025283..02b8379123 100644
--- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
+++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
@@ -1,12 +1,11 @@
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Net;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Services;
diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
index 1ae7ea3a84..142dc2dfd4 100644
--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
@@ -1,14 +1,14 @@
+using System;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Serialization;
-using System;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Playback.Hls
diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs
index b0154cc7e7..1c7be52f3e 100644
--- a/MediaBrowser.Api/Playback/MediaInfoService.cs
+++ b/MediaBrowser.Api/Playback/MediaInfoService.cs
@@ -1,23 +1,23 @@
-using MediaBrowser.Common.Net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.Session;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
+using MediaBrowser.Model.Session;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Playback
diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs
index 44e096dd7f..150571ce9a 100644
--- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs
@@ -1,17 +1,14 @@
-using MediaBrowser.Common.Net;
+using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Serialization;
-using System.Collections.Generic;
-using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index cc59b1049f..bb21fe5ae1 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -1,4 +1,9 @@
-using MediaBrowser.Common.Net;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
@@ -9,16 +14,8 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
-using Microsoft.Extensions.Logging;
-using MediaBrowser.Api.LiveTv;
namespace MediaBrowser.Api.Playback.Progressive
{
@@ -105,10 +102,7 @@ namespace MediaBrowser.Api.Playback.Progressive
/// Gets the type of the transcoding job.
/// </summary>
/// <value>The type of the transcoding job.</value>
- protected override TranscodingJobType TranscodingJobType
- {
- get { return TranscodingJobType.Progressive; }
- }
+ protected override TranscodingJobType TranscodingJobType => TranscodingJobType.Progressive;
/// <summary>
/// Processes the request.
diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
index ed2930b4d4..3dd9de2a1b 100644
--- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
+++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
@@ -1,12 +1,10 @@
-using System;
+using System;
+using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Controller.Net;
-using System.Collections.Generic;
-using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging;
@@ -52,13 +50,7 @@ namespace MediaBrowser.Api.Playback.Progressive
_environment = environment;
}
- public IDictionary<string, string> Headers
- {
- get
- {
- return _outputHeaders;
- }
- }
+ public IDictionary<string, string> Headers => _outputHeaders;
private Stream GetInputStream(bool allowAsyncFileRead)
{
diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
index a41b4cbf54..00b79ccdd2 100644
--- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
@@ -1,14 +1,14 @@
+using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Serialization;
-using System.Threading.Tasks;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
@@ -97,4 +97,4 @@ namespace MediaBrowser.Api.Playback.Progressive
return EncodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, outputPath, GetDefaultH264Preset());
}
}
-} \ No newline at end of file
+}
diff --git a/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs b/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs
index 6bb3b6b804..3b8b299957 100644
--- a/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs
+++ b/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs
@@ -1,8 +1,8 @@
-using MediaBrowser.Common.Net;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Net;
using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Playback
@@ -31,10 +31,7 @@ namespace MediaBrowser.Api.Playback
/// Gets the options.
/// </summary>
/// <value>The options.</value>
- public IDictionary<string, string> Headers
- {
- get { return _options; }
- }
+ public IDictionary<string, string> Headers => _options;
public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
{
diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs
index 6b0725f317..7626cc3785 100644
--- a/MediaBrowser.Api/Playback/StreamRequest.cs
+++ b/MediaBrowser.Api/Playback/StreamRequest.cs
@@ -1,6 +1,5 @@
-using System;
+using System;
using MediaBrowser.Controller.MediaEncoding;
-using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Playback
@@ -10,29 +9,6 @@ namespace MediaBrowser.Api.Playback
/// </summary>
public class StreamRequest : BaseEncodingJobOptions
{
- /// <summary>
- /// Gets or sets the id.
- /// </summary>
- /// <value>The id.</value>
- [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public Guid Id { get; set; }
-
- [ApiMember(Name = "MediaSourceId", Description = "The media version id, if playing an alternate version", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string MediaSourceId { get; set; }
-
- [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
- public string DeviceId { get; set; }
-
- [ApiMember(Name = "Container", Description = "Container", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
- public string Container { get; set; }
-
- /// <summary>
- /// Gets or sets the audio codec.
- /// </summary>
- /// <value>The audio codec.</value>
- [ApiMember(Name = "AudioCodec", Description = "Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
- public string AudioCodec { get; set; }
-
[ApiMember(Name = "DeviceProfileId", Description = "Optional. The dlna device profile id to utilize.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string DeviceProfileId { get; set; }
@@ -51,13 +27,7 @@ namespace MediaBrowser.Api.Playback
/// Gets a value indicating whether this instance has fixed resolution.
/// </summary>
/// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value>
- public bool HasFixedResolution
- {
- get
- {
- return Width.HasValue || Height.HasValue;
- }
- }
+ public bool HasFixedResolution => Width.HasValue || Height.HasValue;
public bool EnableSubtitlesInManifest { get; set; }
}
diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs
index 73741d527b..96dc4ab4c7 100644
--- a/MediaBrowser.Api/Playback/StreamState.cs
+++ b/MediaBrowser.Api/Playback/StreamState.cs
@@ -1,18 +1,9 @@
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.Drawing;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.Net;
using System;
-using System.Collections.Generic;
-using System.Globalization;
using System.IO;
-using System.Linq;
-using System.Threading;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Dlna;
+using MediaBrowser.Model.Net;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Playback
@@ -26,7 +17,7 @@ namespace MediaBrowser.Api.Playback
public StreamRequest Request
{
- get { return (StreamRequest)BaseRequest; }
+ get => (StreamRequest)BaseRequest;
set
{
BaseRequest = value;
@@ -37,10 +28,7 @@ namespace MediaBrowser.Api.Playback
public TranscodingThrottler TranscodingThrottler { get; set; }
- public VideoStreamRequest VideoRequest
- {
- get { return Request as VideoStreamRequest; }
- }
+ public VideoStreamRequest VideoRequest => Request as VideoStreamRequest;
/// <summary>
/// Gets or sets the log file stream.
@@ -51,10 +39,7 @@ namespace MediaBrowser.Api.Playback
public string WaitForPath { get; set; }
- public bool IsOutputVideo
- {
- get { return Request is VideoStreamRequest; }
- }
+ public bool IsOutputVideo => Request is VideoStreamRequest;
public int SegmentLength
{
@@ -107,82 +92,60 @@ namespace MediaBrowser.Api.Playback
}
}
- public int HlsListSize
- {
- get
- {
- return 0;
- }
- }
-
public string UserAgent { get; set; }
public StreamState(IMediaSourceManager mediaSourceManager, ILogger logger, TranscodingJobType transcodingType)
- : base(logger, mediaSourceManager, transcodingType)
+ : base(transcodingType)
{
_mediaSourceManager = mediaSourceManager;
_logger = logger;
}
- public string MimeType { get; set; }
-
public bool EstimateContentLength { get; set; }
public TranscodeSeekInfo TranscodeSeekInfo { get; set; }
- public long? EncodingDurationTicks { get; set; }
-
- public string GetMimeType(string outputPath, bool enableStreamDefault = true)
- {
- if (!string.IsNullOrEmpty(MimeType))
- {
- return MimeType;
- }
-
- return MimeTypes.GetMimeType(outputPath, enableStreamDefault);
- }
-
public bool EnableDlnaHeaders { get; set; }
- public void Dispose()
+ public override void Dispose()
{
DisposeTranscodingThrottler();
- DisposeLiveStream();
DisposeLogStream();
+ DisposeLiveStream();
TranscodingJob = null;
}
- private void DisposeLogStream()
+ private void DisposeTranscodingThrottler()
{
- if (LogFileStream != null)
+ if (TranscodingThrottler != null)
{
try
{
- LogFileStream.Dispose();
+ TranscodingThrottler.Dispose();
}
catch (Exception ex)
{
- _logger.LogError(ex, "Error disposing log stream");
+ _logger.LogError(ex, "Error disposing TranscodingThrottler");
}
- LogFileStream = null;
+ TranscodingThrottler = null;
}
}
- private void DisposeTranscodingThrottler()
+ private void DisposeLogStream()
{
- if (TranscodingThrottler != null)
+ if (LogFileStream != null)
{
try
{
- TranscodingThrottler.Dispose();
+ LogFileStream.Dispose();
}
catch (Exception ex)
{
- _logger.LogError(ex, "Error disposing TranscodingThrottler");
+ _logger.LogError(ex, "Error disposing log stream");
}
- TranscodingThrottler = null;
+ LogFileStream = null;
}
}
@@ -201,58 +164,12 @@ namespace MediaBrowser.Api.Playback
}
}
- public string OutputFilePath { get; set; }
-
- public string ActualOutputVideoCodec
- {
- get
- {
- var codec = OutputVideoCodec;
-
- if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
- {
- var stream = VideoStream;
-
- if (stream != null)
- {
- return stream.Codec;
- }
-
- return null;
- }
-
- return codec;
- }
- }
-
- public string ActualOutputAudioCodec
- {
- get
- {
- var codec = OutputAudioCodec;
-
- if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
- {
- var stream = AudioStream;
-
- if (stream != null)
- {
- return stream.Codec;
- }
-
- return null;
- }
-
- return codec;
- }
- }
-
public DeviceProfile DeviceProfile { get; set; }
public TranscodingJob TranscodingJob;
- public override void ReportTranscodingProgress(TimeSpan? transcodingPosition, float framerate, double? percentComplete, long bytesTranscoded, int? bitRate)
+ public void ReportTranscodingProgress(TimeSpan? transcodingPosition, float? framerate, double? percentComplete, long? bytesTranscoded, int? bitRate)
{
- ApiEntryPoint.Instance.ReportTranscodingProgress(TranscodingJob, this, transcodingPosition, 0, percentComplete, 0, bitRate);
+ ApiEntryPoint.Instance.ReportTranscodingProgress(TranscodingJob, this, transcodingPosition, framerate, percentComplete, bytesTranscoded, bitRate);
}
}
}
diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs
index 5852852f69..97f21c8f30 100644
--- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs
+++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs
@@ -1,6 +1,6 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Model.Configuration;
using System;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Threading;
using Microsoft.Extensions.Logging;
diff --git a/MediaBrowser.Api/Playback/UniversalAudioService.cs b/MediaBrowser.Api/Playback/UniversalAudioService.cs
index 6f928000a6..1faa32ba94 100644
--- a/MediaBrowser.Api/Playback/UniversalAudioService.cs
+++ b/MediaBrowser.Api/Playback/UniversalAudioService.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -128,7 +128,7 @@ namespace MediaBrowser.Api.Playback
var directPlayProfiles = new List<DirectPlayProfile>();
- var containers = (request.Container ?? string.Empty).Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+ var containers = (request.Container ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var container in containers)
{