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> /// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
public bool IsFirstRun { get; private set; } 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> /// <summary>
/// Gets the kernel. /// Gets the kernel.
/// </summary> /// </summary>
@ -299,7 +268,6 @@ namespace MediaBrowser.Common.Implementations
RegisterSingleInstance(Logger); RegisterSingleInstance(Logger);
RegisterSingleInstance(TaskManager); RegisterSingleInstance(TaskManager);
RegisterSingleInstance(ProtobufSerializer);
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger); HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger);
@ -372,6 +340,8 @@ namespace MediaBrowser.Common.Implementations
protected void RegisterSingleInstance<T>(T obj, bool manageLifetime = true) protected void RegisterSingleInstance<T>(T obj, bool manageLifetime = true)
where T : class where T : class
{ {
Logger.Info("Registering " + obj.GetType().Name);
Container.RegisterSingle(obj); Container.RegisterSingle(obj);
if (manageLifetime) if (manageLifetime)
@ -380,8 +350,6 @@ namespace MediaBrowser.Common.Implementations
if (disposable != null) if (disposable != null)
{ {
Logger.Info("Registering " + disposable.GetType().Name);
DisposableParts.Add(disposable); DisposableParts.Add(disposable);
} }
} }

View File

@ -84,7 +84,6 @@
<Compile Include="ScheduledTasks\Tasks\SystemUpdateTask.cs" /> <Compile Include="ScheduledTasks\Tasks\SystemUpdateTask.cs" />
<Compile Include="Security\PluginSecurityManager.cs" /> <Compile Include="Security\PluginSecurityManager.cs" />
<Compile Include="Serialization\JsonSerializer.cs" /> <Compile Include="Serialization\JsonSerializer.cs" />
<Compile Include="Serialization\ProtobufSerializer.cs" />
<Compile Include="Serialization\XmlSerializer.cs" /> <Compile Include="Serialization\XmlSerializer.cs" />
<Compile Include="Updates\ApplicationUpdater.cs" /> <Compile Include="Updates\ApplicationUpdater.cs" />
<Compile Include="Updates\PackageManager.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> </ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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"> <Reference Include="ServiceStack.Common, Version=3.9.43.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ServiceStack.Common.3.9.43\lib\net35\ServiceStack.Common.dll</HintPath> <HintPath>..\packages\ServiceStack.Common.3.9.43\lib\net35\ServiceStack.Common.dll</HintPath>

View File

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

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <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.Common" version="3.9.43" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
</packages> </packages>

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions; using System.Globalization;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO; using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Entities.TV;
@ -58,11 +59,6 @@ namespace MediaBrowser.Controller.Drawing
/// </summary> /// </summary>
private readonly ILogger _logger; private readonly ILogger _logger;
/// <summary>
/// The _protobuf serializer
/// </summary>
private readonly IProtobufSerializer _protobufSerializer;
/// <summary> /// <summary>
/// The _kernel /// The _kernel
/// </summary> /// </summary>
@ -77,12 +73,10 @@ namespace MediaBrowser.Controller.Drawing
/// Initializes a new instance of the <see cref="ImageManager" /> class. /// Initializes a new instance of the <see cref="ImageManager" /> class.
/// </summary> /// </summary>
/// <param name="kernel">The kernel.</param> /// <param name="kernel">The kernel.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="appPaths">The app paths.</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; _logger = logger;
_kernel = kernel; _kernel = kernel;
@ -298,6 +292,8 @@ namespace MediaBrowser.Controller.Drawing
return _cachedImagedSizes.GetOrAdd(name, keyName => GetImageSize(keyName, imagePath)); return _cachedImagedSizes.GetOrAdd(name, keyName => GetImageSize(keyName, imagePath));
} }
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
/// <summary> /// <summary>
/// Gets the size of the image. /// Gets the size of the image.
/// </summary> /// </summary>
@ -307,11 +303,11 @@ namespace MediaBrowser.Controller.Drawing
private ImageSize GetImageSize(string keyName, string imagePath) private ImageSize GetImageSize(string keyName, string imagePath)
{ {
// Now check the file system cache // Now check the file system cache
var fullCachePath = ImageSizeCache.GetResourcePath(keyName, ".pb"); var fullCachePath = ImageSizeCache.GetResourcePath(keyName, ".txt");
try 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] }; return new ImageSize { Width = result[0], Height = result[1] };
} }
@ -325,7 +321,7 @@ namespace MediaBrowser.Controller.Drawing
var size = ImageHeader.GetDimensions(imagePath, _logger); var size = ImageHeader.GetDimensions(imagePath, _logger);
// Update the file system cache // 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 }; 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> public abstract class BaseFFProbeProvider<T> : BaseFFMpegProvider<T>
where T : BaseItem 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) : base(logManager, configurationManager, mediaEncoder)
{ {
ProtobufSerializer = protobufSerializer; JsonSerializer = jsonSerializer;
} }
protected readonly IProtobufSerializer ProtobufSerializer; protected readonly IJsonSerializer JsonSerializer;
/// <summary> /// <summary>
/// Gets or sets the FF probe cache. /// Gets or sets the FF probe cache.
@ -135,14 +135,14 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
var resourceName = item.Id + "_" + lastDateModified.Ticks + "_" + MediaEncoder.Version; var resourceName = item.Id + "_" + lastDateModified.Ticks + "_" + MediaEncoder.Version;
// Forumulate the cache file path // Forumulate the cache file path
var cacheFilePath = cache.GetResourcePath(resourceName, ".pb"); var cacheFilePath = cache.GetResourcePath(resourceName, ".js");
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
// Avoid File.Exists by just trying to deserialize // Avoid File.Exists by just trying to deserialize
try try
{ {
return ProtobufSerializer.DeserializeFromFile<MediaInfoResult>(cacheFilePath); return JsonSerializer.DeserializeFromFile<MediaInfoResult>(cacheFilePath);
} }
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
@ -161,7 +161,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
var info = await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false); var info = await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false);
ProtobufSerializer.SerializeToFile(info, cacheFilePath); JsonSerializer.SerializeToFile(info, cacheFilePath);
return info; return info;
} }

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
using MediaBrowser.Common; using MediaBrowser.Common;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Server.Implementations.HttpServer namespace MediaBrowser.Server.Implementations.HttpServer
{ {
@ -14,14 +13,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// Creates the server. /// Creates the server.
/// </summary> /// </summary>
/// <param name="applicationHost">The application host.</param> /// <param name="applicationHost">The application host.</param>
/// <param name="protobufSerializer">The protobuf serializer.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="serverName">Name of the server.</param> /// <param name="serverName">Name of the server.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param> /// <param name="defaultRedirectpath">The default redirectpath.</param>
/// <returns>IHttpServer.</returns> /// <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> /// <summary>
/// The _protobuf serializer /// The _protobuf serializer
/// </summary> /// </summary>
private readonly IProtobufSerializer _protobufSerializer; private readonly IJsonSerializer _jsonSerializer;
/// <summary> /// <summary>
/// The _app paths /// The _app paths
@ -59,22 +59,22 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class. /// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary> /// </summary>
/// <param name="appPaths">The app paths.</param> /// <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> /// <param name="logManager">The log manager.</param>
/// <exception cref="System.ArgumentNullException">protobufSerializer</exception> /// <exception cref="System.ArgumentNullException">protobufSerializer</exception>
public SQLiteDisplayPreferencesRepository(IApplicationPaths appPaths, IProtobufSerializer protobufSerializer, ILogManager logManager) public SQLiteDisplayPreferencesRepository(IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
: base(logManager) : base(logManager)
{ {
if (protobufSerializer == null) if (jsonSerializer == null)
{ {
throw new ArgumentNullException("protobufSerializer"); throw new ArgumentNullException("jsonSerializer");
} }
if (appPaths == null) if (appPaths == null)
{ {
throw new ArgumentNullException("appPaths"); throw new ArgumentNullException("appPaths");
} }
_protobufSerializer = protobufSerializer; _jsonSerializer = jsonSerializer;
_appPaths = appPaths; _appPaths = appPaths;
} }
@ -124,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var serialized = _protobufSerializer.SerializeToBytes(displayPreferences); var serialized = _jsonSerializer.SerializeToBytes(displayPreferences);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -180,7 +180,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
{ {
using (var stream = GetStream(reader, 0)) 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> /// <summary>
/// The _protobuf serializer /// The _protobuf serializer
/// </summary> /// </summary>
private readonly IProtobufSerializer _protobufSerializer; private readonly IJsonSerializer _jsonSerializer;
/// <summary> /// <summary>
/// The _app paths /// The _app paths
@ -60,22 +60,22 @@ namespace MediaBrowser.Server.Implementations.Sqlite
/// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class. /// Initializes a new instance of the <see cref="SQLiteUserDataRepository" /> class.
/// </summary> /// </summary>
/// <param name="appPaths">The app paths.</param> /// <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> /// <param name="logManager">The log manager.</param>
/// <exception cref="System.ArgumentNullException">protobufSerializer</exception> /// <exception cref="System.ArgumentNullException">protobufSerializer</exception>
public SQLiteUserDataRepository(IApplicationPaths appPaths, IProtobufSerializer protobufSerializer, ILogManager logManager) public SQLiteUserDataRepository(IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
: base(logManager) : base(logManager)
{ {
if (protobufSerializer == null) if (jsonSerializer == null)
{ {
throw new ArgumentNullException("protobufSerializer"); throw new ArgumentNullException("jsonSerializer");
} }
if (appPaths == null) if (appPaths == null)
{ {
throw new ArgumentNullException("appPaths"); throw new ArgumentNullException("appPaths");
} }
_protobufSerializer = protobufSerializer; _jsonSerializer = jsonSerializer;
_appPaths = appPaths; _appPaths = appPaths;
} }
@ -139,7 +139,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
var serialized = _protobufSerializer.SerializeToBytes(userData); var serialized = _jsonSerializer.SerializeToBytes(userData);
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -208,7 +208,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
{ {
using (var stream = GetStream(reader, 0)) 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(); ZipClient = new DotNetZipClient();
RegisterSingleInstance(ZipClient); RegisterSingleInstance(ZipClient);
HttpServer = ServerFactory.CreateServer(this, ProtobufSerializer, Logger, "Media Browser", "index.html"); HttpServer = ServerFactory.CreateServer(this, Logger, "Media Browser", "index.html");
RegisterSingleInstance(HttpServer, false); RegisterSingleInstance(HttpServer, false);
ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager, ServerKernel); ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager, ServerKernel);
@ -238,7 +238,7 @@ namespace MediaBrowser.ServerApplication
private void SetKernelProperties() private void SetKernelProperties()
{ {
ServerKernel.FFMpegManager = new FFMpegManager(ServerKernel, ApplicationPaths, MediaEncoder); 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( Parallel.Invoke(
() => ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>(), () => ServerKernel.UserDataRepositories = GetExports<IUserDataRepository>(),