made dlna logging optional
This commit is contained in:
parent
7683fe878f
commit
30496c1168
|
@ -259,7 +259,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
throw new HttpException(string.Format("Connection to {0} timed out", options.Url)) { IsTimedOut = true };
|
||||
}
|
||||
|
||||
_logger.Info("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url);
|
||||
if (options.LogRequest)
|
||||
{
|
||||
_logger.Info("HttpClientManager {0}: {1}", httpMethod.ToUpper(), options.Url);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -456,7 +459,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||
|
||||
options.Progress.Report(0);
|
||||
|
||||
_logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url);
|
||||
if (options.LogRequest)
|
||||
{
|
||||
_logger.Info("HttpClientManager.GetTempFileResponse url: {0}", options.Url);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -72,6 +72,8 @@ namespace MediaBrowser.Common.Net
|
|||
|
||||
public bool BufferContent { get; set; }
|
||||
|
||||
public bool LogRequest { get; set; }
|
||||
|
||||
public HttpRequestCachePolicy CachePolicy { get; set; }
|
||||
|
||||
private string GetHeaderValue(string name)
|
||||
|
@ -94,6 +96,8 @@ namespace MediaBrowser.Common.Net
|
|||
CachePolicy = HttpRequestCachePolicy.None;
|
||||
|
||||
RequestHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
LogRequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -9,7 +10,7 @@ using System.Xml.Linq;
|
|||
|
||||
namespace MediaBrowser.Dlna.PlayTo
|
||||
{
|
||||
public sealed class Device : IDisposable
|
||||
public class Device : IDisposable
|
||||
{
|
||||
const string ServiceAvtransportId = "urn:upnp-org:serviceId:AVTransport";
|
||||
const string ServiceRenderingId = "urn:upnp-org:serviceId:RenderingControl";
|
||||
|
@ -119,12 +120,14 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger)
|
||||
public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config)
|
||||
{
|
||||
Properties = deviceProperties;
|
||||
_httpClient = httpClient;
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
private int GetPlaybackTimerIntervalMs()
|
||||
|
@ -217,7 +220,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, value))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, value))
|
||||
.ConfigureAwait(false);
|
||||
Volume = value;
|
||||
return true;
|
||||
|
@ -236,7 +239,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType, String.Format("{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME"))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType, String.Format("{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME"))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return value;
|
||||
|
@ -266,7 +269,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType, url, dictionary), header)
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType, url, dictionary), header)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
|
||||
|
@ -311,7 +314,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType, value, dictionary), header)
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, AvCommands.BuildPost(command, service.ServiceType, value, dictionary), header)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
|
@ -332,7 +335,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, 1))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, 1))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
_lapsCount = GetLapsCount();
|
||||
|
@ -347,7 +350,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
|
||||
var service = Properties.Services.FirstOrDefault(s => s.ServiceId == ServiceAvtransportId);
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, 1))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, 1))
|
||||
.ConfigureAwait(false);
|
||||
await Task.Delay(50).ConfigureAwait(false);
|
||||
return true;
|
||||
|
@ -361,7 +364,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
|
||||
var service = Properties.Services.FirstOrDefault(s => s.ServiceId == ServiceAvtransportId);
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, 0))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType, 0))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
await Task.Delay(50).ConfigureAwait(false);
|
||||
|
@ -440,7 +443,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (result == null || result.Document == null)
|
||||
|
@ -471,7 +474,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
if (service == null)
|
||||
return;
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (result == null || result.Document == null)
|
||||
|
@ -501,7 +504,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (result == null || result.Document == null)
|
||||
|
@ -542,7 +545,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
throw new InvalidOperationException("Unable to find service");
|
||||
}
|
||||
|
||||
var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
var result = await new SsdpHttpClient(_httpClient, _config).SendCommandAsync(Properties.BaseUrl, service, command.Name, RendererCommands.BuildPost(command, service.ServiceType))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
if (result == null || result.Document == null)
|
||||
|
@ -603,7 +606,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
if (!url.StartsWith("/"))
|
||||
url = "/" + url;
|
||||
|
||||
var httpClient = new SsdpHttpClient(_httpClient);
|
||||
var httpClient = new SsdpHttpClient(_httpClient, _config);
|
||||
var document = await httpClient.GetDataAsync(new Uri(Properties.BaseUrl + url));
|
||||
|
||||
AvCommands = TransportCommands.Create(document);
|
||||
|
@ -621,7 +624,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
if (!url.StartsWith("/"))
|
||||
url = "/" + url;
|
||||
|
||||
var httpClient = new SsdpHttpClient(_httpClient);
|
||||
var httpClient = new SsdpHttpClient(_httpClient, _config);
|
||||
var document = await httpClient.GetDataAsync(new Uri(Properties.BaseUrl + url));
|
||||
|
||||
RendererCommands = TransportCommands.Create(document);
|
||||
|
@ -639,9 +642,9 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
set;
|
||||
}
|
||||
|
||||
public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, ILogger logger)
|
||||
public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger)
|
||||
{
|
||||
var ssdpHttpClient = new SsdpHttpClient(httpClient);
|
||||
var ssdpHttpClient = new SsdpHttpClient(httpClient, config);
|
||||
|
||||
var document = await ssdpHttpClient.GetDataAsync(url).ConfigureAwait(false);
|
||||
|
||||
|
@ -719,7 +722,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
if (isRenderer)
|
||||
{
|
||||
|
||||
var device = new Device(deviceProperties, httpClient, logger);
|
||||
var device = new Device(deviceProperties, httpClient, logger, config);
|
||||
|
||||
await device.GetRenderingProtocolAsync().ConfigureAwait(false);
|
||||
await device.GetAVProtocolAsync().ConfigureAwait(false);
|
||||
|
|
|
@ -31,8 +31,9 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
private readonly INetworkManager _networkManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDlnaManager _dlnaManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
public PlayToManager(ILogger logger,IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepository, ILibraryManager libraryManager, INetworkManager networkManager, IUserManager userManager, IDlnaManager dlnaManager)
|
||||
public PlayToManager(ILogger logger, IServerConfigurationManager config, ISessionManager sessionManager, IHttpClient httpClient, IItemRepository itemRepository, ILibraryManager libraryManager, INetworkManager networkManager, IUserManager userManager, IDlnaManager dlnaManager)
|
||||
{
|
||||
_locations = new ConcurrentDictionary<string, DateTime>();
|
||||
_tokenSource = new CancellationTokenSource();
|
||||
|
@ -45,6 +46,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
_networkManager = networkManager;
|
||||
_userManager = userManager;
|
||||
_dlnaManager = dlnaManager;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public async void Start()
|
||||
|
@ -212,7 +214,7 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
if (!IsUriValid(uri))
|
||||
return;
|
||||
|
||||
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _logger).ConfigureAwait(false);
|
||||
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger).ConfigureAwait(false);
|
||||
|
||||
if (device != null && device.RendererCommands != null && !_sessionManager.Sessions.Any(s => string.Equals(s.DeviceId, device.Properties.UUID) && s.IsActive))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
@ -16,10 +17,12 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
private static readonly CookieContainer Container = new CookieContainer();
|
||||
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
|
||||
public SsdpHttpClient(IHttpClient httpClient)
|
||||
public SsdpHttpClient(IHttpClient httpClient, IServerConfigurationManager config)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
public async Task<XDocument> SendCommandAsync(string baseUrl, DeviceService service, string command, string postData, string header = null)
|
||||
|
@ -45,7 +48,8 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
var options = new HttpRequestOptions
|
||||
{
|
||||
Url = url.ToString(),
|
||||
UserAgent = USERAGENT
|
||||
UserAgent = USERAGENT,
|
||||
LogRequest = _config.Configuration.DlnaOptions.EnablePlayToDebugLogging
|
||||
};
|
||||
|
||||
options.RequestHeaders["HOST"] = ip + ":" + port;
|
||||
|
@ -83,7 +87,8 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
var options = new HttpRequestOptions
|
||||
{
|
||||
Url = url.ToString(),
|
||||
UserAgent = USERAGENT
|
||||
UserAgent = USERAGENT,
|
||||
LogRequest = _config.Configuration.DlnaOptions.EnablePlayToDebugLogging
|
||||
};
|
||||
|
||||
options.RequestHeaders["FriendlyName.DLNA.ORG"] = FriendlyName;
|
||||
|
@ -106,7 +111,8 @@ namespace MediaBrowser.Dlna.PlayTo
|
|||
var options = new HttpRequestOptions
|
||||
{
|
||||
Url = url.ToString(),
|
||||
UserAgent = USERAGENT
|
||||
UserAgent = USERAGENT,
|
||||
LogRequest = _config.Configuration.DlnaOptions.EnablePlayToDebugLogging
|
||||
};
|
||||
|
||||
options.RequestHeaders["SOAPAction"] = soapAction;
|
||||
|
|
|
@ -4,5 +4,6 @@ namespace MediaBrowser.Model.Configuration
|
|||
public class DlnaOptions
|
||||
{
|
||||
public bool EnablePlayTo { get; set; }
|
||||
public bool EnablePlayToDebugLogging { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user