aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-11-03 16:38:47 -0700
committercrobibero <cody@robibe.ro>2020-11-03 16:38:47 -0700
commitb4d52d8009d8e4a6836dc431ac5f336910a07d6c (patch)
tree3a050bf5a54e69dc1fb4515f79394b17c95a3483
parent5d88e610768c8b680096938a372585638ef18fe3 (diff)
Apply patch
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs5
-rw-r--r--Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs5
-rw-r--r--Jellyfin.Api/Controllers/LiveTvController.cs7
-rw-r--r--Jellyfin.Api/Helpers/ProgressiveFileStream.cs12
-rw-r--r--MediaBrowser.Controller/Library/IMediaSourceManager.cs2
5 files changed, 22 insertions, 9 deletions
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
index 6730751d5..858c10030 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs
@@ -131,6 +131,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
await taskCompletionSource.Task.ConfigureAwait(false);
}
+ public string GetFilePath()
+ {
+ return TempFilePath;
+ }
+
private Task StartStreaming(UdpClient udpClient, HdHomerunManager hdHomerunManager, IPAddress remoteAddress, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
{
return Task.Run(async () =>
diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
index 10e5eab73..2e1b89509 100644
--- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs
@@ -122,6 +122,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
}
}
+ public string GetFilePath()
+ {
+ return TempFilePath;
+ }
+
private Task StartStreaming(HttpResponseMessage response, TaskCompletionSource<bool> openTaskCompletionSource, CancellationToken cancellationToken)
{
return Task.Run(async () =>
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs
index 58c7473c2..88a7542ce 100644
--- a/Jellyfin.Api/Controllers/LiveTvController.cs
+++ b/Jellyfin.Api/Controllers/LiveTvController.cs
@@ -1220,11 +1220,8 @@ namespace Jellyfin.Api.Controllers
return NotFound();
}
- await new ProgressiveFileCopier(liveStreamInfo, null, _transcodingJobHelper, CancellationToken.None)
- .WriteToAsync(Response.Body, CancellationToken.None)
- .ConfigureAwait(false);
- Response.ContentType = MimeTypes.GetMimeType("file." + container);
- return Ok();
+ var liveStream = new ProgressiveFileStream(liveStreamInfo.GetFilePath(), null, _transcodingJobHelper);
+ return new FileStreamResult(liveStream, MimeTypes.GetMimeType("file." + container));
}
private void AssertUserCanManageLiveTv()
diff --git a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
index b3566b6f8..824870c7e 100644
--- a/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
+++ b/Jellyfin.Api/Helpers/ProgressiveFileStream.cs
@@ -82,20 +82,23 @@ namespace Jellyfin.Api.Helpers
int totalBytesRead = 0;
int remainingBytesToRead = count;
+ int newOffset = offset;
while (remainingBytesToRead > 0)
{
cancellationToken.ThrowIfCancellationRequested();
int bytesRead;
if (_allowAsyncFileRead)
{
- bytesRead = await _fileStream.ReadAsync(buffer, offset, remainingBytesToRead, cancellationToken).ConfigureAwait(false);
+ bytesRead = await _fileStream.ReadAsync(buffer, newOffset, remainingBytesToRead, cancellationToken).ConfigureAwait(false);
}
else
{
- bytesRead = _fileStream.Read(buffer, offset, remainingBytesToRead);
+ bytesRead = _fileStream.Read(buffer, newOffset, remainingBytesToRead);
}
remainingBytesToRead -= bytesRead;
+ newOffset += bytesRead;
+
if (bytesRead > 0)
{
_bytesWritten += bytesRead;
@@ -108,12 +111,13 @@ namespace Jellyfin.Api.Helpers
}
else
{
- if (_job == null || _job.HasExited)
+ // If the job is null it's a live stream and will require user action to close
+ if (_job?.HasExited ?? false)
{
break;
}
- await Task.Delay(100, cancellationToken).ConfigureAwait(false);
+ await Task.Delay(50, cancellationToken).ConfigureAwait(false);
}
}
diff --git a/MediaBrowser.Controller/Library/IMediaSourceManager.cs b/MediaBrowser.Controller/Library/IMediaSourceManager.cs
index 22bf9488f..21c6ef2af 100644
--- a/MediaBrowser.Controller/Library/IMediaSourceManager.cs
+++ b/MediaBrowser.Controller/Library/IMediaSourceManager.cs
@@ -115,5 +115,7 @@ namespace MediaBrowser.Controller.Library
public interface IDirectStreamProvider
{
Task CopyToAsync(Stream stream, CancellationToken cancellationToken);
+
+ string GetFilePath();
}
}