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);
|
ApiEntryPoint.Instance.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ProgressiveStreamWriter
|
return new ProgressiveStreamWriter(outputPath, state, Logger);
|
||||||
{
|
|
||||||
Path = outputPath,
|
|
||||||
State = state
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -9,9 +9,22 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
{
|
{
|
||||||
public class ProgressiveStreamWriter : IStreamWriter
|
public class ProgressiveStreamWriter : IStreamWriter
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
private string Path { get; set; }
|
||||||
public StreamState State { get; set; }
|
private StreamState State { get; set; }
|
||||||
public ILogger Logger { 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>
|
/// <summary>
|
||||||
/// Writes to.
|
/// Writes to.
|
||||||
|
@ -38,6 +51,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.ErrorException("Error streaming media", ex);
|
Logger.ErrorException("Error streaming media", ex);
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -267,7 +267,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
}
|
}
|
||||||
|
|
||||||
httpListenerResponse.ContentLength64 = stream.Length;
|
httpListenerResponse.ContentLength64 = stream.Length;
|
||||||
return new StreamWriter(stream);
|
return new StreamWriter(stream, Logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
string content;
|
string content;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using ServiceStack.Service;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using ServiceStack.Service;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -9,6 +11,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StreamWriter : IStreamWriter
|
public class StreamWriter : IStreamWriter
|
||||||
{
|
{
|
||||||
|
private ILogger Logger { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the source stream.
|
/// Gets or sets the source stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -19,9 +23,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
/// Initializes a new instance of the <see cref="StreamWriter" /> class.
|
/// Initializes a new instance of the <see cref="StreamWriter" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The source.</param>
|
/// <param name="source">The source.</param>
|
||||||
public StreamWriter(Stream source)
|
/// <param name="logger">The logger.</param>
|
||||||
|
public StreamWriter(Stream source, ILogger logger)
|
||||||
{
|
{
|
||||||
SourceStream = source;
|
SourceStream = source;
|
||||||
|
Logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -42,9 +48,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task WriteToAsync(Stream responseStream)
|
private async Task WriteToAsync(Stream responseStream)
|
||||||
{
|
{
|
||||||
using (var src = SourceStream)
|
try
|
||||||
{
|
{
|
||||||
await src.CopyToAsync(responseStream).ConfigureAwait(false);
|
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