StaticRemoteStreamWriter.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using MediaBrowser.Common.Net;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Model.Services;
  7. namespace MediaBrowser.Api.Playback
  8. {
  9. /// <summary>
  10. /// Class StaticRemoteStreamWriter
  11. /// </summary>
  12. public class StaticRemoteStreamWriter : IAsyncStreamWriter, IHasHeaders
  13. {
  14. /// <summary>
  15. /// The _input stream
  16. /// </summary>
  17. private readonly HttpResponseInfo _response;
  18. /// <summary>
  19. /// The _options
  20. /// </summary>
  21. private readonly IDictionary<string, string> _options = new Dictionary<string, string>();
  22. public StaticRemoteStreamWriter(HttpResponseInfo response)
  23. {
  24. _response = response;
  25. }
  26. /// <summary>
  27. /// Gets the options.
  28. /// </summary>
  29. /// <value>The options.</value>
  30. public IDictionary<string, string> Headers
  31. {
  32. get { return _options; }
  33. }
  34. public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
  35. {
  36. using (_response)
  37. {
  38. await _response.Content.CopyToAsync(responseStream, 81920, cancellationToken).ConfigureAwait(false);
  39. }
  40. }
  41. }
  42. }