mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-24 06:30:56 +02:00
Merge pull request #770 from 7illusions/master
Fixes DirectStreaming for Microsoft players
This commit is contained in:
commit
17a2beb7a2
|
@ -64,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("contentType");
|
throw new ArgumentNullException("contentType");
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeHeader = rangeHeader;
|
RangeHeader = rangeHeader;
|
||||||
SourceStream = source;
|
SourceStream = source;
|
||||||
IsHeadRequest = isHeadRequest;
|
IsHeadRequest = isHeadRequest;
|
||||||
|
@ -98,11 +98,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
RangeStart = requestedRange.Key;
|
RangeStart = requestedRange.Key;
|
||||||
RangeLength = 1 + RangeEnd - RangeStart;
|
RangeLength = 1 + RangeEnd - RangeStart;
|
||||||
|
|
||||||
// Content-Length is the length of what we're serving, not the original content
|
// Content-Length is the length of what we're serving, not the original content
|
||||||
Options["Content-Length"] = RangeLength.ToString(UsCulture);
|
Options["Content-Length"] = RangeLength.ToString(UsCulture);
|
||||||
Options["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);
|
Options["Content-Range"] = string.Format("bytes {0}-{1}/{2}", RangeStart, RangeEnd, TotalContentLength);
|
||||||
|
|
||||||
if (RangeStart > 0)
|
if (RangeStart > 0)
|
||||||
{
|
{
|
||||||
SourceStream.Position = RangeStart;
|
SourceStream.Position = RangeStart;
|
||||||
|
@ -178,19 +178,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
using (var source = SourceStream)
|
using (var source = SourceStream)
|
||||||
{
|
{
|
||||||
// If the requested range is "0-", we can optimize by just doing a stream copy
|
//Since we've already set the postion of the sourcestream, just copy the remains to the output
|
||||||
if (RangeEnd == TotalContentLength - 1)
|
await source.CopyToAsync(responseStream).ConfigureAwait(false);
|
||||||
{
|
|
||||||
await source.CopyToAsync(responseStream).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Read the bytes we need
|
|
||||||
var buffer = new byte[Convert.ToInt32(RangeLength)];
|
|
||||||
await source.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false);
|
|
||||||
|
|
||||||
await responseStream.WriteAsync(buffer, 0, Convert.ToInt32(RangeLength)).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue