aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Playback
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/Playback')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs6
-rw-r--r--MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs78
-rw-r--r--MediaBrowser.Api/Playback/Progressive/VideoService.cs1
3 files changed, 21 insertions, 64 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index a6be071b8..ae259a4f5 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -609,12 +609,12 @@ namespace MediaBrowser.Api.Playback
{
foreach (var param in Request.QueryString)
{
- if (char.IsLower(param.Name[0]))
+ if (char.IsLower(param.Key[0]))
{
// This was probably not parsed initially and should be a StreamOptions
// TODO: This should be incorporated either in the lower framework for parsing requests
// or the generated URL should correctly serialize it
- request.StreamOptions[param.Name] = param.Value;
+ request.StreamOptions[param.Key] = param.Value;
}
}
}
@@ -867,7 +867,7 @@ namespace MediaBrowser.Api.Playback
private void ApplyDeviceProfileSettings(StreamState state)
{
- var headers = Request.Headers.ToDictionary();
+ var headers = Request.Headers;
if (!string.IsNullOrWhiteSpace(state.Request.DeviceProfileId))
{
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index 6a98c5e8a..f43f26b2f 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -17,6 +17,7 @@ using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
+using Microsoft.Net.Http.Headers;
namespace MediaBrowser.Api.Playback.Progressive
{
@@ -154,7 +155,7 @@ namespace MediaBrowser.Api.Playback.Progressive
var outputHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
// TODO: Don't hardcode this
- outputHeaders["Content-Type"] = MediaBrowser.Model.Net.MimeTypes.GetMimeType("file.ts");
+ outputHeaders[HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType("file.ts");
return new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, EnvironmentInfo, CancellationToken.None)
{
@@ -196,9 +197,11 @@ namespace MediaBrowser.Api.Playback.Progressive
{
if (state.MediaSource.IsInfiniteStream)
{
- var outputHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ var outputHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
+ {
+ [HeaderNames.ContentType] = contentType
+ };
- outputHeaders["Content-Type"] = contentType;
return new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, EnvironmentInfo, CancellationToken.None)
{
@@ -298,16 +301,16 @@ namespace MediaBrowser.Api.Playback.Progressive
if (trySupportSeek)
{
- if (!string.IsNullOrWhiteSpace(Request.QueryString["Range"]))
+ if (!string.IsNullOrWhiteSpace(Request.QueryString[HeaderNames.Range]))
{
- options.RequestHeaders["Range"] = Request.QueryString["Range"];
+ options.RequestHeaders[HeaderNames.Range] = Request.QueryString[HeaderNames.Range];
}
}
var response = await HttpClient.GetResponse(options).ConfigureAwait(false);
if (trySupportSeek)
{
- foreach (var name in new[] { "Content-Range", "Accept-Ranges" })
+ foreach (var name in new[] { HeaderNames.ContentRange, HeaderNames.AcceptRanges })
{
var val = response.Headers[name];
if (!string.IsNullOrWhiteSpace(val))
@@ -318,13 +321,7 @@ namespace MediaBrowser.Api.Playback.Progressive
}
else
{
- responseHeaders["Accept-Ranges"] = "none";
- }
-
- // Seeing cases of -1 here
- if (response.ContentLength.HasValue && response.ContentLength.Value >= 0)
- {
- responseHeaders["Content-Length"] = response.ContentLength.Value.ToString(UsCulture);
+ responseHeaders[HeaderNames.AcceptRanges] = "none";
}
if (isHeadRequest)
@@ -337,7 +334,7 @@ namespace MediaBrowser.Api.Playback.Progressive
var result = new StaticRemoteStreamWriter(response);
- result.Headers["Content-Type"] = response.ContentType;
+ result.Headers[HeaderNames.ContentType] = response.ContentType;
// Add the response headers to the result object
foreach (var header in responseHeaders)
@@ -361,41 +358,15 @@ namespace MediaBrowser.Api.Playback.Progressive
// Use the command line args with a dummy playlist path
var outputPath = state.OutputFilePath;
- responseHeaders["Accept-Ranges"] = "none";
+ responseHeaders[HeaderNames.AcceptRanges] = "none";
var contentType = state.GetMimeType(outputPath);
// TODO: The isHeadRequest is only here because ServiceStack will add Content-Length=0 to the response
- // What we really want to do is hunt that down and remove that
- var contentLength = state.EstimateContentLength || isHeadRequest ? GetEstimatedContentLength(state) : null;
-
- if (contentLength.HasValue)
- {
- responseHeaders["Content-Length"] = contentLength.Value.ToString(UsCulture);
- }
-
// Headers only
if (isHeadRequest)
{
- var streamResult = ResultFactory.GetResult(null, new byte[] { }, contentType, responseHeaders);
-
- var hasHeaders = streamResult as IHasHeaders;
- if (hasHeaders != null)
- {
- if (contentLength.HasValue)
- {
- hasHeaders.Headers["Content-Length"] = contentLength.Value.ToString(CultureInfo.InvariantCulture);
- }
- else
- {
- if (hasHeaders.Headers.ContainsKey("Content-Length"))
- {
- hasHeaders.Headers.Remove("Content-Length");
- }
- }
- }
-
- return streamResult;
+ return ResultFactory.GetResult(null, Array.Empty<byte>(), contentType, responseHeaders);
}
var transcodingLock = ApiEntryPoint.Instance.GetTranscodingLock(outputPath);
@@ -414,9 +385,11 @@ namespace MediaBrowser.Api.Playback.Progressive
state.Dispose();
}
- var outputHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ var outputHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
+ {
+ [HeaderNames.ContentType] = contentType
+ };
- outputHeaders["Content-Type"] = contentType;
// Add the response headers to the result object
foreach (var item in responseHeaders)
@@ -431,22 +404,5 @@ namespace MediaBrowser.Api.Playback.Progressive
transcodingLock.Release();
}
}
-
- /// <summary>
- /// Gets the length of the estimated content.
- /// </summary>
- /// <param name="state">The state.</param>
- /// <returns>System.Nullable{System.Int64}.</returns>
- private long? GetEstimatedContentLength(StreamState state)
- {
- var totalBitrate = state.TotalOutputBitrate ?? 0;
-
- if (totalBitrate > 0 && state.RunTimeTicks.HasValue)
- {
- return Convert.ToInt64(totalBitrate * TimeSpan.FromTicks(state.RunTimeTicks.Value).TotalSeconds / 8);
- }
-
- return null;
- }
}
}
diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
index 7aeb0e9e8..bf15cc756 100644
--- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
@@ -37,6 +37,7 @@ namespace MediaBrowser.Api.Playback.Progressive
[Route("/Videos/{Id}/stream.mov", "GET")]
[Route("/Videos/{Id}/stream.iso", "GET")]
[Route("/Videos/{Id}/stream.flv", "GET")]
+ [Route("/Videos/{Id}/stream.rm", "GET")]
[Route("/Videos/{Id}/stream", "GET")]
[Route("/Videos/{Id}/stream.ts", "HEAD")]
[Route("/Videos/{Id}/stream.webm", "HEAD")]