update live stream buffers

This commit is contained in:
Luke Pulverenti
2017-06-01 01:05:36 -04:00
parent 804c98c864
commit 386ed8d34a
5 changed files with 27 additions and 24 deletions

View File

@@ -1,11 +1,17 @@
using System.IO;
using System.Threading;
using System;
namespace MediaBrowser.Controller.IO
{
public static class StreamHelper
{
public static void CopyTo(Stream source, Stream destination, int bufferSize, CancellationToken cancellationToken)
{
CopyTo(source, destination, bufferSize, null, cancellationToken);
}
public static void CopyTo(Stream source, Stream destination, int bufferSize, Action onStarted, CancellationToken cancellationToken)
{
byte[] buffer = new byte[bufferSize];
int read;
@@ -14,6 +20,12 @@ namespace MediaBrowser.Controller.IO
cancellationToken.ThrowIfCancellationRequested();
destination.Write(buffer, 0, read);
if (onStarted != null)
{
onStarted();
onStarted = null;
}
}
}
}