removed unneeded startup processes

This commit is contained in:
Luke Pulverenti 2013-04-07 18:09:48 -04:00
parent 8308528e6c
commit f5620c81be
15 changed files with 44 additions and 316 deletions

View File

@ -116,37 +116,6 @@ namespace MediaBrowser.Common.Implementations
/// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
public bool IsFirstRun { get; private set; }
/// <summary>
/// The _protobuf serializer initialized
/// </summary>
private bool _protobufSerializerInitialized;
/// <summary>
/// The _protobuf serializer sync lock
/// </summary>
private object _protobufSerializerSyncLock = new object();
/// <summary>
/// Gets a dynamically compiled generated serializer that can serialize protocontracts without reflection
/// </summary>
private IProtobufSerializer _protobufSerializer;
/// <summary>
/// Gets the protobuf serializer.
/// </summary>
/// <value>The protobuf serializer.</value>
protected IProtobufSerializer ProtobufSerializer
{
get
{
// Lazy load
LazyInitializer.EnsureInitialized(ref _protobufSerializer, ref _protobufSerializerInitialized, ref _protobufSerializerSyncLock, () => Serialization.ProtobufSerializer.Create(AllTypes));
return _protobufSerializer;
}
private set
{
_protobufSerializer = value;
_protobufSerializerInitialized = value != null;
}
}
/// <summary>
/// Gets the kernel.
/// </summary>
@ -299,7 +268,6 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance(Logger);
RegisterSingleInstance(TaskManager);
RegisterSingleInstance(ProtobufSerializer);
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger);
@ -372,6 +340,8 @@ namespace MediaBrowser.Common.Implementations
protected void RegisterSingleInstance<T>(T obj, bool manageLifetime = true)
where T : class
{
Logger.Info("Registering " + obj.GetType().Name);
Container.RegisterSingle(obj);
if (manageLifetime)
@ -380,8 +350,6 @@ namespace MediaBrowser.Common.Implementations
if (disposable != null)
{
Logger.Info("Registering " + disposable.GetType().Name);
DisposableParts.Add(disposable);
}
}

View File

@ -84,7 +84,6 @@
<Compile Include="ScheduledTasks\Tasks\SystemUpdateTask.cs" />
<Compile Include="Security\PluginSecurityManager.cs" />
<Compile Include="Serialization\JsonSerializer.cs" />
<Compile Include="Serialization\ProtobufSerializer.cs" />
<Compile Include="Serialization\XmlSerializer.cs" />
<Compile Include="Updates\ApplicationUpdater.cs" />
<Compile Include="Updates\PackageManager.cs" />

View File

@ -1,158 +0,0 @@
using MediaBrowser.Model.Serialization;
using ProtoBuf;
using ProtoBuf.Meta;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MediaBrowser.Common.Implementations.Serialization
{
/// <summary>
/// Creates a compiled protobuf serializer based on a set of assemblies
/// </summary>
public class ProtobufSerializer : IProtobufSerializer
{
/// <summary>
/// Gets or sets the type model.
/// </summary>
/// <value>The type model.</value>
private TypeModel TypeModel { get; set; }
/// <summary>
/// Serializes to stream.
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="stream">The stream.</param>
/// <exception cref="System.ArgumentNullException">obj</exception>
public void SerializeToStream(object obj, Stream stream)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
if (stream == null)
{
throw new ArgumentNullException("stream");
}
TypeModel.Serialize(stream, obj);
}
/// <summary>
/// Deserializes from stream.
/// </summary>
/// <param name="stream">The stream.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
/// <exception cref="System.ArgumentNullException">stream</exception>
public object DeserializeFromStream(Stream stream, Type type)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
return TypeModel.Deserialize(stream, null, type);
}
/// <summary>
/// Deserializes from stream.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="stream">The stream.</param>
/// <returns>``0.</returns>
public T DeserializeFromStream<T>(Stream stream)
where T : class
{
return DeserializeFromStream(stream, typeof(T)) as T;
}
/// <summary>
/// Serializes to file.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj">The obj.</param>
/// <param name="file">The file.</param>
/// <exception cref="System.ArgumentNullException">file</exception>
public void SerializeToFile<T>(T obj, string file)
{
if (string.IsNullOrEmpty(file))
{
throw new ArgumentNullException("file");
}
using (Stream stream = File.Open(file, FileMode.Create))
{
SerializeToStream(obj, stream);
}
}
/// <summary>
/// Deserializes from file.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="file">The file.</param>
/// <returns>``0.</returns>
/// <exception cref="System.ArgumentNullException">file</exception>
public T DeserializeFromFile<T>(string file)
where T : class
{
if (string.IsNullOrEmpty(file))
{
throw new ArgumentNullException("file");
}
using (Stream stream = File.OpenRead(file))
{
return DeserializeFromStream<T>(stream);
}
}
/// <summary>
/// Serializes to bytes.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj">The obj.</param>
/// <returns>System.Byte[][].</returns>
/// <exception cref="System.ArgumentNullException">obj</exception>
public byte[] SerializeToBytes<T>(T obj)
where T : class
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
using (var stream = new MemoryStream())
{
SerializeToStream(obj, stream);
return stream.ToArray();
}
}
/// <summary>
/// Creates the specified assemblies.
/// </summary>
/// <returns>DynamicProtobufSerializer.</returns>
/// <exception cref="System.ArgumentNullException">assemblies</exception>
public static ProtobufSerializer Create(IEnumerable<Type> types)
{
if (types == null)
{
throw new ArgumentNullException("types");
}
var model = TypeModel.Create();
var attributeType = typeof(ProtoContractAttribute);
// Find all ProtoContracts in the current assembly
foreach (var type in types.Where(t => Attribute.IsDefined(t, attributeType)))
{
model.Add(type, true);
}
return new ProtobufSerializer { TypeModel = model.Compile() };
}
}
}

View File

@ -38,10 +38,6 @@
</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="protobuf-net, Version=2.0.0.621, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Common, Version=3.9.43.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ServiceStack.Common.3.9.43\lib\net35\ServiceStack.Common.dll</HintPath>

View File

@ -1,5 +1,4 @@
using MediaBrowser.Model.Entities;
using ProtoBuf;
using System.Collections.Generic;
namespace MediaBrowser.Common.MediaInfo
@ -7,350 +6,300 @@ namespace MediaBrowser.Common.MediaInfo
/// <summary>
/// Class MediaInfoResult
/// </summary>
[ProtoContract]
public class MediaInfoResult
{
/// <summary>
/// Gets or sets the streams.
/// </summary>
/// <value>The streams.</value>
[ProtoMember(1)]
public MediaStreamInfo[] streams { get; set; }
/// <summary>
/// Gets or sets the format.
/// </summary>
/// <value>The format.</value>
[ProtoMember(2)]
public MediaFormatInfo format { get; set; }
/// <summary>
/// Gets or sets the chapters.
/// </summary>
/// <value>The chapters.</value>
[ProtoMember(3)]
public List<ChapterInfo> Chapters { get; set; }
}
/// <summary>
/// Represents a stream within the output
/// </summary>
[ProtoContract]
public class MediaStreamInfo
{
/// <summary>
/// Gets or sets the index.
/// </summary>
/// <value>The index.</value>
[ProtoMember(1)]
public int index { get; set; }
/// <summary>
/// Gets or sets the profile.
/// </summary>
/// <value>The profile.</value>
[ProtoMember(2)]
public string profile { get; set; }
/// <summary>
/// Gets or sets the codec_name.
/// </summary>
/// <value>The codec_name.</value>
[ProtoMember(3)]
public string codec_name { get; set; }
/// <summary>
/// Gets or sets the codec_long_name.
/// </summary>
/// <value>The codec_long_name.</value>
[ProtoMember(4)]
public string codec_long_name { get; set; }
/// <summary>
/// Gets or sets the codec_type.
/// </summary>
/// <value>The codec_type.</value>
[ProtoMember(5)]
public string codec_type { get; set; }
/// <summary>
/// Gets or sets the sample_rate.
/// </summary>
/// <value>The sample_rate.</value>
[ProtoMember(6)]
public string sample_rate { get; set; }
/// <summary>
/// Gets or sets the channels.
/// </summary>
/// <value>The channels.</value>
[ProtoMember(7)]
public int channels { get; set; }
/// <summary>
/// Gets or sets the avg_frame_rate.
/// </summary>
/// <value>The avg_frame_rate.</value>
[ProtoMember(8)]
public string avg_frame_rate { get; set; }
/// <summary>
/// Gets or sets the duration.
/// </summary>
/// <value>The duration.</value>
[ProtoMember(9)]
public string duration { get; set; }
/// <summary>
/// Gets or sets the bit_rate.
/// </summary>
/// <value>The bit_rate.</value>
[ProtoMember(10)]
public string bit_rate { get; set; }
/// <summary>
/// Gets or sets the width.
/// </summary>
/// <value>The width.</value>
[ProtoMember(11)]
public int width { get; set; }
/// <summary>
/// Gets or sets the height.
/// </summary>
/// <value>The height.</value>
[ProtoMember(12)]
public int height { get; set; }
/// <summary>
/// Gets or sets the display_aspect_ratio.
/// </summary>
/// <value>The display_aspect_ratio.</value>
[ProtoMember(13)]
public string display_aspect_ratio { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
[ProtoMember(14)]
public Dictionary<string, string> tags { get; set; }
/// <summary>
/// Gets or sets the bits_per_sample.
/// </summary>
/// <value>The bits_per_sample.</value>
[ProtoMember(17)]
public int bits_per_sample { get; set; }
/// <summary>
/// Gets or sets the r_frame_rate.
/// </summary>
/// <value>The r_frame_rate.</value>
[ProtoMember(18)]
public string r_frame_rate { get; set; }
/// <summary>
/// Gets or sets the has_b_frames.
/// </summary>
/// <value>The has_b_frames.</value>
[ProtoMember(19)]
public int has_b_frames { get; set; }
/// <summary>
/// Gets or sets the sample_aspect_ratio.
/// </summary>
/// <value>The sample_aspect_ratio.</value>
[ProtoMember(20)]
public string sample_aspect_ratio { get; set; }
/// <summary>
/// Gets or sets the pix_fmt.
/// </summary>
/// <value>The pix_fmt.</value>
[ProtoMember(21)]
public string pix_fmt { get; set; }
/// <summary>
/// Gets or sets the level.
/// </summary>
/// <value>The level.</value>
[ProtoMember(22)]
public int level { get; set; }
/// <summary>
/// Gets or sets the time_base.
/// </summary>
/// <value>The time_base.</value>
[ProtoMember(23)]
public string time_base { get; set; }
/// <summary>
/// Gets or sets the start_time.
/// </summary>
/// <value>The start_time.</value>
[ProtoMember(24)]
public string start_time { get; set; }
/// <summary>
/// Gets or sets the codec_time_base.
/// </summary>
/// <value>The codec_time_base.</value>
[ProtoMember(25)]
public string codec_time_base { get; set; }
/// <summary>
/// Gets or sets the codec_tag.
/// </summary>
/// <value>The codec_tag.</value>
[ProtoMember(26)]
public string codec_tag { get; set; }
/// <summary>
/// Gets or sets the codec_tag_string.
/// </summary>
/// <value>The codec_tag_string.</value>
[ProtoMember(27)]
public string codec_tag_string { get; set; }
/// <summary>
/// Gets or sets the sample_fmt.
/// </summary>
/// <value>The sample_fmt.</value>
[ProtoMember(28)]
public string sample_fmt { get; set; }
/// <summary>
/// Gets or sets the dmix_mode.
/// </summary>
/// <value>The dmix_mode.</value>
[ProtoMember(29)]
public string dmix_mode { get; set; }
/// <summary>
/// Gets or sets the start_pts.
/// </summary>
/// <value>The start_pts.</value>
[ProtoMember(30)]
public string start_pts { get; set; }
/// <summary>
/// Gets or sets the is_avc.
/// </summary>
/// <value>The is_avc.</value>
[ProtoMember(31)]
public string is_avc { get; set; }
/// <summary>
/// Gets or sets the nal_length_size.
/// </summary>
/// <value>The nal_length_size.</value>
[ProtoMember(32)]
public string nal_length_size { get; set; }
/// <summary>
/// Gets or sets the ltrt_cmixlev.
/// </summary>
/// <value>The ltrt_cmixlev.</value>
[ProtoMember(33)]
public string ltrt_cmixlev { get; set; }
/// <summary>
/// Gets or sets the ltrt_surmixlev.
/// </summary>
/// <value>The ltrt_surmixlev.</value>
[ProtoMember(34)]
public string ltrt_surmixlev { get; set; }
/// <summary>
/// Gets or sets the loro_cmixlev.
/// </summary>
/// <value>The loro_cmixlev.</value>
[ProtoMember(35)]
public string loro_cmixlev { get; set; }
/// <summary>
/// Gets or sets the loro_surmixlev.
/// </summary>
/// <value>The loro_surmixlev.</value>
[ProtoMember(36)]
public string loro_surmixlev { get; set; }
/// <summary>
/// Gets or sets the disposition.
/// </summary>
/// <value>The disposition.</value>
[ProtoMember(37)]
public Dictionary<string, string> disposition { get; set; }
}
/// <summary>
/// Class MediaFormat
/// </summary>
[ProtoContract]
public class MediaFormatInfo
{
/// <summary>
/// Gets or sets the filename.
/// </summary>
/// <value>The filename.</value>
[ProtoMember(1)]
public string filename { get; set; }
/// <summary>
/// Gets or sets the nb_streams.
/// </summary>
/// <value>The nb_streams.</value>
[ProtoMember(2)]
public int nb_streams { get; set; }
/// <summary>
/// Gets or sets the format_name.
/// </summary>
/// <value>The format_name.</value>
[ProtoMember(3)]
public string format_name { get; set; }
/// <summary>
/// Gets or sets the format_long_name.
/// </summary>
/// <value>The format_long_name.</value>
[ProtoMember(4)]
public string format_long_name { get; set; }
/// <summary>
/// Gets or sets the start_time.
/// </summary>
/// <value>The start_time.</value>
[ProtoMember(5)]
public string start_time { get; set; }
/// <summary>
/// Gets or sets the duration.
/// </summary>
/// <value>The duration.</value>
[ProtoMember(6)]
public string duration { get; set; }
/// <summary>
/// Gets or sets the size.
/// </summary>
/// <value>The size.</value>
[ProtoMember(7)]
public string size { get; set; }
/// <summary>
/// Gets or sets the bit_rate.
/// </summary>
/// <value>The bit_rate.</value>
[ProtoMember(8)]
public string bit_rate { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>The tags.</value>
[ProtoMember(9)]
public Dictionary<string, string> tags { get; set; }
}
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="protobuf-net" version="2.0.0.621" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
</packages>

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using System.Globalization;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
@ -58,11 +59,6 @@ namespace MediaBrowser.Controller.Drawing
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// The _protobuf serializer
/// </summary>
private readonly IProtobufSerializer _protobufSerializer;
/// <summary>
/// The _kernel
/// </summary>
@ -77,12 +73,10 @@ namespace MediaBrowser.Controller.Drawing
/// Initializes a new instance of the <see cref="ImageManager" /> class.
/// </summary>
/// <param name="kernel">The kernel.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="logger">The logger.</param>
/// <param name="appPaths">The app paths.</param>
public ImageManager(Kernel kernel, IProtobufSerializer protobufSerializer, ILogger logger, IServerApplicationPaths appPaths)
public ImageManager(Kernel kernel, ILogger logger, IServerApplicationPaths appPaths)
{
_protobufSerializer = protobufSerializer;
_logger = logger;
_kernel = kernel;
@ -298,6 +292,8 @@ namespace MediaBrowser.Controller.Drawing
return _cachedImagedSizes.GetOrAdd(name, keyName => GetImageSize(keyName, imagePath));
}
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary>
/// Gets the size of the image.
/// </summary>
@ -307,11 +303,11 @@ namespace MediaBrowser.Controller.Drawing
private ImageSize GetImageSize(string keyName, string imagePath)
{
// Now check the file system cache
var fullCachePath = ImageSizeCache.GetResourcePath(keyName, ".pb");
var fullCachePath = ImageSizeCache.GetResourcePath(keyName, ".txt");
try
{
var result = _protobufSerializer.DeserializeFromFile<int[]>(fullCachePath);
var result = File.ReadAllText(fullCachePath).Split('|').Select(i => double.Parse(i, UsCulture)).ToArray();
return new ImageSize { Width = result[0], Height = result[1] };
}
@ -325,7 +321,7 @@ namespace MediaBrowser.Controller.Drawing
var size = ImageHeader.GetDimensions(imagePath, _logger);
// Update the file system cache
Task.Run(() => _protobufSerializer.SerializeToFile(new[] { size.Width, size.Height }, fullCachePath));
Task.Run(() => File.WriteAllText(fullCachePath, size.Width.ToString(UsCulture) + @"|" + size.Height.ToString(UsCulture)));
return new ImageSize { Width = size.Width, Height = size.Height };
}

View File

@ -21,13 +21,13 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
public abstract class BaseFFProbeProvider<T> : BaseFFMpegProvider<T>
where T : BaseItem
{
protected BaseFFProbeProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder, IProtobufSerializer protobufSerializer)
protected BaseFFProbeProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder, IJsonSerializer jsonSerializer)
: base(logManager, configurationManager, mediaEncoder)
{
ProtobufSerializer = protobufSerializer;
JsonSerializer = jsonSerializer;
}
protected readonly IProtobufSerializer ProtobufSerializer;
protected readonly IJsonSerializer JsonSerializer;
/// <summary>
/// Gets or sets the FF probe cache.
@ -135,14 +135,14 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
var resourceName = item.Id + "_" + lastDateModified.Ticks + "_" + MediaEncoder.Version;
// Forumulate the cache file path
var cacheFilePath = cache.GetResourcePath(resourceName, ".pb");
var cacheFilePath = cache.GetResourcePath(resourceName, ".js");
cancellationToken.ThrowIfCancellationRequested();
// Avoid File.Exists by just trying to deserialize
try
{
return ProtobufSerializer.DeserializeFromFile<MediaInfoResult>(cacheFilePath);
return JsonSerializer.DeserializeFromFile<MediaInfoResult>(cacheFilePath);
}
catch (FileNotFoundException)
{
@ -161,7 +161,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
var info = await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false);
ProtobufSerializer.SerializeToFile(info, cacheFilePath);
JsonSerializer.SerializeToFile(info, cacheFilePath);
return info;
}

View File

@ -18,8 +18,8 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// </summary>
public class FFProbeAudioInfoProvider : BaseFFProbeProvider<Audio>
{
public FFProbeAudioInfoProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder, IProtobufSerializer protobufSerializer)
: base(logManager, configurationManager, mediaEncoder, protobufSerializer)
public FFProbeAudioInfoProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder, IJsonSerializer jsonSerializer)
: base(logManager, configurationManager, mediaEncoder, jsonSerializer)
{
}

View File

@ -21,8 +21,8 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// </summary>
public class FFProbeVideoInfoProvider : BaseFFProbeProvider<Video>
{
public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IProtobufSerializer protobufSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder)
: base(logManager, configurationManager, mediaEncoder, protobufSerializer)
public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IJsonSerializer jsonSerializer, ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder)
: base(logManager, configurationManager, mediaEncoder, jsonSerializer)
{
if (isoManager == null)
{
@ -32,10 +32,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
throw new ArgumentNullException("blurayExaminer");
}
if (protobufSerializer == null)
{
throw new ArgumentNullException("protobufSerializer");
}
_blurayExaminer = blurayExaminer;
_isoManager = isoManager;
@ -323,19 +319,19 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
// Get the path to the cache file
var cacheName = item.Id + "_" + item.DateModified.Ticks;
var cacheFile = bdInfoCache.GetResourcePath(cacheName, ".pb");
var cacheFile = bdInfoCache.GetResourcePath(cacheName, ".js");
BlurayDiscInfo result;
try
{
result = ProtobufSerializer.DeserializeFromFile<BlurayDiscInfo>(cacheFile);
result = JsonSerializer.DeserializeFromFile<BlurayDiscInfo>(cacheFile);
}
catch (FileNotFoundException)
{
result = GetBDInfo(inputPath);
ProtobufSerializer.SerializeToFile(result, cacheFile);
JsonSerializer.SerializeToFile(result, cacheFile);
}
cancellationToken.ThrowIfCancellationRequested();

View File

@ -61,12 +61,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <value>The HTTP listener.</value>
private IDisposable HttpListener { get; set; }
/// <summary>
/// Gets or sets the protobuf serializer.
/// </summary>
/// <value>The protobuf serializer.</value>
private IProtobufSerializer ProtobufSerializer { get; set; }
/// <summary>
/// Occurs when [web socket connected].
/// </summary>
@ -88,18 +82,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// Initializes a new instance of the <see cref="HttpServer" /> class.
/// </summary>
/// <param name="applicationHost">The application host.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="logger">The logger.</param>
/// <param name="serverName">Name of the server.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param>
/// <exception cref="System.ArgumentNullException">urlPrefix</exception>
public HttpServer(IApplicationHost applicationHost, IProtobufSerializer protobufSerializer, ILogger logger, string serverName, string defaultRedirectpath)
public HttpServer(IApplicationHost applicationHost, ILogger logger, string serverName, string defaultRedirectpath)
: base()
{
if (protobufSerializer == null)
{
throw new ArgumentNullException("protobufSerializer");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
@ -119,7 +108,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
ServerName = serverName;
DefaultRedirectPath = defaultRedirectpath;
ProtobufSerializer = protobufSerializer;
_logger = logger;
ApplicationHost = applicationHost;
@ -562,9 +550,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
_logger.Info("Calling EndpointHost.ConfigureHost");
EndpointHost.ConfigureHost(this, ServerName, CreateServiceManager());
_logger.Info("Registering protobuf as a content type filter");
ContentTypeFilters.Register(ContentType.ProtoBuf, (reqCtx, res, stream) => ProtobufSerializer.SerializeToStream(res, stream), (type, stream) => ProtobufSerializer.DeserializeFromStream(stream, type));
_logger.Info("Calling ServiceStack AppHost.Init");
Init();
}

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Server.Implementations.HttpServer
{
@ -14,14 +13,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// Creates the server.
/// </summary>
/// <param name="applicationHost">The application host.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="logger">The logger.</param>
/// <param name="serverName">Name of the server.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param>
/// <returns>IHttpServer.</returns>
public static IHttpServer CreateServer(IApplicationHost applicationHost, IProtobufSerializer protobufSerializer, ILogger logger, string serverName, string defaultRedirectpath)
public static IHttpServer CreateServer(IApplicationHost applicationHost, ILogger logger, string serverName, string defaultRedirectpath)
{
return new HttpServer(applicationHost, protobufSerializer, logger, serverName, defaultRedirectpath);
return new HttpServer(applicationHost, logger, serverName, defaultRedirectpath);
}
}
}

View File

@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// <summary>
/// The _protobuf serializer
/// </summary>
private readonly IProtobufSerializer _protobufSerializer;
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// The _app paths
@ -59,22 +59,22 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary>
/// <param name="appPaths">The app paths.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logManager">The log manager.</param>
/// <exception cref="System.ArgumentNullException">protobufSerializer</exception>
public SQLiteDisplayPreferencesRepository(IApplicationPaths appPaths, IProtobufSerializer protobufSerializer, ILogManager logManager)
public SQLiteDisplayPreferencesRepository(IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
: base(logManager)
{
if (protobufSerializer == null)
if (jsonSerializer == null)
{
throw new ArgumentNullException("protobufSerializer");
throw new ArgumentNullException("jsonSerializer");
}
if (appPaths == null)
{
throw new ArgumentNullException("appPaths");
}
_protobufSerializer = protobufSerializer;
_jsonSerializer = jsonSerializer;
_appPaths = appPaths;
}
@ -124,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
cancellationToken.ThrowIfCancellationRequested();
var serialized = _protobufSerializer.SerializeToBytes(displayPreferences);
var serialized = _jsonSerializer.SerializeToBytes(displayPreferences);
cancellationToken.ThrowIfCancellationRequested();
@ -180,7 +180,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
{
using (var stream = GetStream(reader, 0))
{
return _protobufSerializer.DeserializeFromStream<DisplayPreferences>(stream);
return _jsonSerializer.DeserializeFromStream<DisplayPreferences>(stream);
}
}
}

View File

@ -49,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// <summary>
/// The _protobuf serializer
/// </summary>
private readonly IProtobufSerializer _protobufSerializer;
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// The _app paths
@ -60,22 +60,22 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary>
/// <param name="appPaths">The app paths.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logManager">The log manager.</param>
/// <exception cref="System.ArgumentNullException">protobufSerializer</exception>
public SQLiteUserDataRepository(IApplicationPaths appPaths, IProtobufSerializer protobufSerializer, ILogManager logManager)
public SQLiteUserDataRepository(IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
: base(logManager)
{
if (protobufSerializer == null)
if (jsonSerializer == null)
{
throw new ArgumentNullException("protobufSerializer");
throw new ArgumentNullException("jsonSerializer");
}
if (appPaths == null)
{
throw new ArgumentNullException("appPaths");
}
_protobufSerializer = protobufSerializer;
_jsonSerializer = jsonSerializer;
_appPaths = appPaths;
}
@ -139,7 +139,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
cancellationToken.ThrowIfCancellationRequested();
var serialized = _protobufSerializer.SerializeToBytes(userData);
var serialized = _jsonSerializer.SerializeToBytes(userData);
cancellationToken.ThrowIfCancellationRequested();
@ -208,7 +208,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
{
using (var stream = GetStream(reader, 0))
{
return _protobufSerializer.DeserializeFromStream<UserItemData>(stream);
return _jsonSerializer.DeserializeFromStream<UserItemData>(stream);
}
}
}

View File

@ -198,7 +198,7 @@ namespace MediaBrowser.ServerApplication
ZipClient = new DotNetZipClient();
RegisterSingleInstance(ZipClient);
HttpServer = ServerFactory.CreateServer(this, ProtobufSerializer, Logger, "Media Browser", "index.html");
HttpServer = ServerFactory.CreateServer(this, Logger, "Media Browser", "index.html");
RegisterSingleInstance(HttpServer, false);
ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager, ServerKernel);
@ -238,7 +238,7 @@ namespace MediaBrowser.ServerApplication
private void SetKernelProperties()
{
ServerKernel.FFMpegManager = new FFMpegManager(ServerKernel, ApplicationPaths, MediaEncoder);
ServerKernel.ImageManager = new ImageManager(ServerKernel, ProtobufSerializer, LogManager.GetLogger("ImageManager"), ApplicationPaths);
ServerKernel.ImageManager = new ImageManager(ServerKernel, LogManager.GetLogger("ImageManager"), ApplicationPaths);
Parallel.Invoke(
() => ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>(),