2014-02-13 16:38:43 +00:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2013-05-17 18:05:49 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2016-11-12 06:58:50 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2016-10-25 19:02:04 +00:00
|
|
|
|
using MediaBrowser.Model.Services;
|
2013-05-17 18:05:49 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.Playback
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class StaticRemoteStreamWriter
|
|
|
|
|
/// </summary>
|
2016-11-12 06:58:50 +00:00
|
|
|
|
public class StaticRemoteStreamWriter : IAsyncStreamWriter, IHasHeaders
|
2013-05-17 18:05:49 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _input stream
|
|
|
|
|
/// </summary>
|
2014-02-13 16:38:43 +00:00
|
|
|
|
private readonly HttpResponseInfo _response;
|
2013-05-17 18:05:49 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The _options
|
|
|
|
|
/// </summary>
|
|
|
|
|
private readonly IDictionary<string, string> _options = new Dictionary<string, string>();
|
|
|
|
|
|
2014-02-13 16:38:43 +00:00
|
|
|
|
public StaticRemoteStreamWriter(HttpResponseInfo response)
|
2013-05-17 18:05:49 +00:00
|
|
|
|
{
|
2014-02-13 16:38:43 +00:00
|
|
|
|
_response = response;
|
2013-05-17 18:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the options.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The options.</value>
|
2016-10-25 19:02:04 +00:00
|
|
|
|
public IDictionary<string, string> Headers
|
2013-05-17 18:05:49 +00:00
|
|
|
|
{
|
|
|
|
|
get { return _options; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 06:58:50 +00:00
|
|
|
|
public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
|
2013-05-17 18:05:49 +00:00
|
|
|
|
{
|
2015-01-30 05:18:46 +00:00
|
|
|
|
using (_response)
|
|
|
|
|
{
|
2016-11-12 06:58:50 +00:00
|
|
|
|
await _response.Content.CopyToAsync(responseStream, 81920, cancellationToken).ConfigureAwait(false);
|
2015-01-30 05:18:46 +00:00
|
|
|
|
}
|
2013-05-17 18:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|