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