mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-28 11:44:48 +03:00
Port MediaEncoding and Api.Playback from 10e57ce8d21b4516733894075001819f3cd6db6b
This commit is contained in:
47
MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs
Normal file
47
MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Services;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
/// <summary>
|
||||
/// Class StaticRemoteStreamWriter
|
||||
/// </summary>
|
||||
public class StaticRemoteStreamWriter : IAsyncStreamWriter, IHasHeaders
|
||||
{
|
||||
/// <summary>
|
||||
/// The _input stream
|
||||
/// </summary>
|
||||
private readonly HttpResponseInfo _response;
|
||||
|
||||
/// <summary>
|
||||
/// The _options
|
||||
/// </summary>
|
||||
private readonly IDictionary<string, string> _options = new Dictionary<string, string>();
|
||||
|
||||
public StaticRemoteStreamWriter(HttpResponseInfo response)
|
||||
{
|
||||
_response = response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the options.
|
||||
/// </summary>
|
||||
/// <value>The options.</value>
|
||||
public IDictionary<string, string> Headers
|
||||
{
|
||||
get { return _options; }
|
||||
}
|
||||
|
||||
public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
|
||||
{
|
||||
using (_response)
|
||||
{
|
||||
await _response.Content.CopyToAsync(responseStream, 81920, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user