using MediaBrowser.Common.Net;
using ServiceStack.Web;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Api.Playback
{
///
/// Class StaticRemoteStreamWriter
///
public class StaticRemoteStreamWriter : IStreamWriter, IHasOptions
{
///
/// The _input stream
///
private readonly HttpResponseInfo _response;
///
/// The _options
///
private readonly IDictionary _options = new Dictionary();
public StaticRemoteStreamWriter(HttpResponseInfo response)
{
_response = response;
}
///
/// Gets the options.
///
/// The options.
public IDictionary Options
{
get { return _options; }
}
///
/// Writes to.
///
/// The response stream.
public void WriteTo(Stream responseStream)
{
var task = WriteToAsync(responseStream);
Task.WaitAll(task);
}
///
/// Writes to async.
///
/// The response stream.
/// Task.
public async Task WriteToAsync(Stream responseStream)
{
using (_response)
{
await _response.Content.CopyToAsync(responseStream, 819200).ConfigureAwait(false);
}
}
}
}