better streaming logging
This commit is contained in:
parent
de755c4b93
commit
7c677e0ee6
|
@ -135,11 +135,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||
ApiEntryPoint.Instance.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
|
||||
}
|
||||
|
||||
return new ProgressiveStreamWriter
|
||||
{
|
||||
Path = outputPath,
|
||||
State = state
|
||||
};
|
||||
return new ProgressiveStreamWriter(outputPath, state, Logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -9,9 +9,22 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||
{
|
||||
public class ProgressiveStreamWriter : IStreamWriter
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public StreamState State { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
private string Path { get; set; }
|
||||
private StreamState State { get; set; }
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ProgressiveStreamWriter" /> class.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <param name="state">The state.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public ProgressiveStreamWriter(string path, StreamState state, ILogger logger)
|
||||
{
|
||||
Path = path;
|
||||
State = state;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes to.
|
||||
|
@ -38,6 +51,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error streaming media", ex);
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -267,7 +267,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||
}
|
||||
|
||||
httpListenerResponse.ContentLength64 = stream.Length;
|
||||
return new StreamWriter(stream);
|
||||
return new StreamWriter(stream, Logger);
|
||||
}
|
||||
|
||||
string content;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using ServiceStack.Service;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using ServiceStack.Service;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -9,6 +11,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||
/// </summary>
|
||||
public class StreamWriter : IStreamWriter
|
||||
{
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the source stream.
|
||||
/// </summary>
|
||||
|
@ -19,9 +23,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||
/// Initializes a new instance of the <see cref="StreamWriter" /> class.
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
public StreamWriter(Stream source)
|
||||
/// <param name="logger">The logger.</param>
|
||||
public StreamWriter(Stream source, ILogger logger)
|
||||
{
|
||||
SourceStream = source;
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -41,11 +47,20 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||
/// <param name="responseStream">The response stream.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task WriteToAsync(Stream responseStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var src = SourceStream)
|
||||
{
|
||||
await src.CopyToAsync(responseStream).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error streaming media", ex);
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user