2014-02-13 16:38:43 +00:00
|
|
|
|
using MediaBrowser.Common.Net;
|
|
|
|
|
using ServiceStack.Web;
|
2013-05-17 18:05:49 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.Playback
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class StaticRemoteStreamWriter
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class StaticRemoteStreamWriter : IStreamWriter, IHasOptions
|
|
|
|
|
{
|
|
|
|
|
/// <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>
|
|
|
|
|
public IDictionary<string, string> Options
|
|
|
|
|
{
|
|
|
|
|
get { return _options; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes to.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="responseStream">The response stream.</param>
|
|
|
|
|
public void WriteTo(Stream responseStream)
|
|
|
|
|
{
|
|
|
|
|
var task = WriteToAsync(responseStream);
|
|
|
|
|
|
|
|
|
|
Task.WaitAll(task);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes to async.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="responseStream">The response stream.</param>
|
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
|
public async Task WriteToAsync(Stream responseStream)
|
|
|
|
|
{
|
2014-10-12 01:46:02 +00:00
|
|
|
|
using (_response)
|
2013-05-17 18:05:49 +00:00
|
|
|
|
{
|
2014-10-12 01:46:02 +00:00
|
|
|
|
await _response.Content.CopyToAsync(responseStream, 819200).ConfigureAwait(false);
|
2013-05-17 18:05:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|