diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 0c8646508f..017f69b626 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -116,37 +116,6 @@ namespace MediaBrowser.Common.Implementations
/// true if this instance is first run; otherwise, false.
public bool IsFirstRun { get; private set; }
- ///
- /// The _protobuf serializer initialized
- ///
- private bool _protobufSerializerInitialized;
- ///
- /// The _protobuf serializer sync lock
- ///
- private object _protobufSerializerSyncLock = new object();
- ///
- /// Gets a dynamically compiled generated serializer that can serialize protocontracts without reflection
- ///
- private IProtobufSerializer _protobufSerializer;
- ///
- /// Gets the protobuf serializer.
- ///
- /// The protobuf serializer.
- 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;
- }
- }
-
///
/// Gets the kernel.
///
@@ -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 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);
}
}
diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
index f5b6ab56c9..c1304f39c6 100644
--- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
+++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj
@@ -84,7 +84,6 @@
-
diff --git a/MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs
deleted file mode 100644
index 85325f3c19..0000000000
--- a/MediaBrowser.Common.Implementations/Serialization/ProtobufSerializer.cs
+++ /dev/null
@@ -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
-{
- ///
- /// Creates a compiled protobuf serializer based on a set of assemblies
- ///
- public class ProtobufSerializer : IProtobufSerializer
- {
- ///
- /// Gets or sets the type model.
- ///
- /// The type model.
- private TypeModel TypeModel { get; set; }
-
- ///
- /// Serializes to stream.
- ///
- /// The obj.
- /// The stream.
- /// obj
- 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);
- }
-
- ///
- /// Deserializes from stream.
- ///
- /// The stream.
- /// The type.
- /// System.Object.
- /// stream
- public object DeserializeFromStream(Stream stream, Type type)
- {
- if (stream == null)
- {
- throw new ArgumentNullException("stream");
- }
-
- return TypeModel.Deserialize(stream, null, type);
- }
-
- ///
- /// Deserializes from stream.
- ///
- ///
- /// The stream.
- /// ``0.
- public T DeserializeFromStream(Stream stream)
- where T : class
- {
- return DeserializeFromStream(stream, typeof(T)) as T;
- }
-
- ///
- /// Serializes to file.
- ///
- ///
- /// The obj.
- /// The file.
- /// file
- public void SerializeToFile(T obj, string file)
- {
- if (string.IsNullOrEmpty(file))
- {
- throw new ArgumentNullException("file");
- }
-
- using (Stream stream = File.Open(file, FileMode.Create))
- {
- SerializeToStream(obj, stream);
- }
- }
-
- ///
- /// Deserializes from file.
- ///
- ///
- /// The file.
- /// ``0.
- /// file
- public T DeserializeFromFile(string file)
- where T : class
- {
- if (string.IsNullOrEmpty(file))
- {
- throw new ArgumentNullException("file");
- }
-
- using (Stream stream = File.OpenRead(file))
- {
- return DeserializeFromStream(stream);
- }
- }
-
- ///
- /// Serializes to bytes.
- ///
- ///
- /// The obj.
- /// System.Byte[][].
- /// obj
- public byte[] SerializeToBytes(T obj)
- where T : class
- {
- if (obj == null)
- {
- throw new ArgumentNullException("obj");
- }
-
- using (var stream = new MemoryStream())
- {
- SerializeToStream(obj, stream);
- return stream.ToArray();
- }
- }
-
- ///
- /// Creates the specified assemblies.
- ///
- /// DynamicProtobufSerializer.
- /// assemblies
- public static ProtobufSerializer Create(IEnumerable 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() };
- }
- }
-}
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 511c26879a..f1e99f1e59 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -38,10 +38,6 @@
-
- False
- ..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll
-
False
..\packages\ServiceStack.Common.3.9.43\lib\net35\ServiceStack.Common.dll
diff --git a/MediaBrowser.Common/MediaInfo/MediaInfoResult.cs b/MediaBrowser.Common/MediaInfo/MediaInfoResult.cs
index 98dd36e57c..6fcb403002 100644
--- a/MediaBrowser.Common/MediaInfo/MediaInfoResult.cs
+++ b/MediaBrowser.Common/MediaInfo/MediaInfoResult.cs
@@ -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
///
/// Class MediaInfoResult
///
- [ProtoContract]
public class MediaInfoResult
{
///
/// Gets or sets the streams.
///
/// The streams.
- [ProtoMember(1)]
public MediaStreamInfo[] streams { get; set; }
///
/// Gets or sets the format.
///
/// The format.
- [ProtoMember(2)]
public MediaFormatInfo format { get; set; }
///
/// Gets or sets the chapters.
///
/// The chapters.
- [ProtoMember(3)]
public List Chapters { get; set; }
}
///
/// Represents a stream within the output
///
- [ProtoContract]
public class MediaStreamInfo
{
///
/// Gets or sets the index.
///
/// The index.
- [ProtoMember(1)]
public int index { get; set; }
///
/// Gets or sets the profile.
///
/// The profile.
- [ProtoMember(2)]
public string profile { get; set; }
///
/// Gets or sets the codec_name.
///
/// The codec_name.
- [ProtoMember(3)]
public string codec_name { get; set; }
///
/// Gets or sets the codec_long_name.
///
/// The codec_long_name.
- [ProtoMember(4)]
public string codec_long_name { get; set; }
///
/// Gets or sets the codec_type.
///
/// The codec_type.
- [ProtoMember(5)]
public string codec_type { get; set; }
///
/// Gets or sets the sample_rate.
///
/// The sample_rate.
- [ProtoMember(6)]
public string sample_rate { get; set; }
///
/// Gets or sets the channels.
///
/// The channels.
- [ProtoMember(7)]
public int channels { get; set; }
///
/// Gets or sets the avg_frame_rate.
///
/// The avg_frame_rate.
- [ProtoMember(8)]
public string avg_frame_rate { get; set; }
///
/// Gets or sets the duration.
///
/// The duration.
- [ProtoMember(9)]
public string duration { get; set; }
///
/// Gets or sets the bit_rate.
///
/// The bit_rate.
- [ProtoMember(10)]
public string bit_rate { get; set; }
///
/// Gets or sets the width.
///
/// The width.
- [ProtoMember(11)]
public int width { get; set; }
///
/// Gets or sets the height.
///
/// The height.
- [ProtoMember(12)]
public int height { get; set; }
///
/// Gets or sets the display_aspect_ratio.
///
/// The display_aspect_ratio.
- [ProtoMember(13)]
public string display_aspect_ratio { get; set; }
///
/// Gets or sets the tags.
///
/// The tags.
- [ProtoMember(14)]
public Dictionary tags { get; set; }
///
/// Gets or sets the bits_per_sample.
///
/// The bits_per_sample.
- [ProtoMember(17)]
public int bits_per_sample { get; set; }
///
/// Gets or sets the r_frame_rate.
///
/// The r_frame_rate.
- [ProtoMember(18)]
public string r_frame_rate { get; set; }
///
/// Gets or sets the has_b_frames.
///
/// The has_b_frames.
- [ProtoMember(19)]
public int has_b_frames { get; set; }
///
/// Gets or sets the sample_aspect_ratio.
///
/// The sample_aspect_ratio.
- [ProtoMember(20)]
public string sample_aspect_ratio { get; set; }
///
/// Gets or sets the pix_fmt.
///
/// The pix_fmt.
- [ProtoMember(21)]
public string pix_fmt { get; set; }
///
/// Gets or sets the level.
///
/// The level.
- [ProtoMember(22)]
public int level { get; set; }
///
/// Gets or sets the time_base.
///
/// The time_base.
- [ProtoMember(23)]
public string time_base { get; set; }
///
/// Gets or sets the start_time.
///
/// The start_time.
- [ProtoMember(24)]
public string start_time { get; set; }
///
/// Gets or sets the codec_time_base.
///
/// The codec_time_base.
- [ProtoMember(25)]
public string codec_time_base { get; set; }
///
/// Gets or sets the codec_tag.
///
/// The codec_tag.
- [ProtoMember(26)]
public string codec_tag { get; set; }
///
/// Gets or sets the codec_tag_string.
///
/// The codec_tag_string.
- [ProtoMember(27)]
public string codec_tag_string { get; set; }
///
/// Gets or sets the sample_fmt.
///
/// The sample_fmt.
- [ProtoMember(28)]
public string sample_fmt { get; set; }
///
/// Gets or sets the dmix_mode.
///
/// The dmix_mode.
- [ProtoMember(29)]
public string dmix_mode { get; set; }
///
/// Gets or sets the start_pts.
///
/// The start_pts.
- [ProtoMember(30)]
public string start_pts { get; set; }
///
/// Gets or sets the is_avc.
///
/// The is_avc.
- [ProtoMember(31)]
public string is_avc { get; set; }
///
/// Gets or sets the nal_length_size.
///
/// The nal_length_size.
- [ProtoMember(32)]
public string nal_length_size { get; set; }
///
/// Gets or sets the ltrt_cmixlev.
///
/// The ltrt_cmixlev.
- [ProtoMember(33)]
public string ltrt_cmixlev { get; set; }
///
/// Gets or sets the ltrt_surmixlev.
///
/// The ltrt_surmixlev.
- [ProtoMember(34)]
public string ltrt_surmixlev { get; set; }
///
/// Gets or sets the loro_cmixlev.
///
/// The loro_cmixlev.
- [ProtoMember(35)]
public string loro_cmixlev { get; set; }
///
/// Gets or sets the loro_surmixlev.
///
/// The loro_surmixlev.
- [ProtoMember(36)]
public string loro_surmixlev { get; set; }
///
/// Gets or sets the disposition.
///
/// The disposition.
- [ProtoMember(37)]
public Dictionary disposition { get; set; }
}
///
/// Class MediaFormat
///
- [ProtoContract]
public class MediaFormatInfo
{
///
/// Gets or sets the filename.
///
/// The filename.
- [ProtoMember(1)]
public string filename { get; set; }
///
/// Gets or sets the nb_streams.
///
/// The nb_streams.
- [ProtoMember(2)]
public int nb_streams { get; set; }
///
/// Gets or sets the format_name.
///
/// The format_name.
- [ProtoMember(3)]
public string format_name { get; set; }
///
/// Gets or sets the format_long_name.
///
/// The format_long_name.
- [ProtoMember(4)]
public string format_long_name { get; set; }
///
/// Gets or sets the start_time.
///
/// The start_time.
- [ProtoMember(5)]
public string start_time { get; set; }
///
/// Gets or sets the duration.
///
/// The duration.
- [ProtoMember(6)]
public string duration { get; set; }
///
/// Gets or sets the size.
///
/// The size.
- [ProtoMember(7)]
public string size { get; set; }
///
/// Gets or sets the bit_rate.
///
/// The bit_rate.
- [ProtoMember(8)]
public string bit_rate { get; set; }
///
/// Gets or sets the tags.
///
/// The tags.
- [ProtoMember(9)]
public Dictionary tags { get; set; }
}
}
diff --git a/MediaBrowser.Common/packages.config b/MediaBrowser.Common/packages.config
index 95e6873229..b5e4f03216 100644
--- a/MediaBrowser.Common/packages.config
+++ b/MediaBrowser.Common/packages.config
@@ -1,6 +1,5 @@
-
\ No newline at end of file
diff --git a/MediaBrowser.Controller/Drawing/ImageManager.cs b/MediaBrowser.Controller/Drawing/ImageManager.cs
index b47ae164aa..7e6b65b48f 100644
--- a/MediaBrowser.Controller/Drawing/ImageManager.cs
+++ b/MediaBrowser.Controller/Drawing/ImageManager.cs
@@ -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
///
private readonly ILogger _logger;
- ///
- /// The _protobuf serializer
- ///
- private readonly IProtobufSerializer _protobufSerializer;
-
///
/// The _kernel
///
@@ -77,12 +73,10 @@ namespace MediaBrowser.Controller.Drawing
/// Initializes a new instance of the class.
///
/// The kernel.
- /// The protobuf serializer.
/// The logger.
/// The app paths.
- 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");
+
///
/// Gets the size of the image.
///
@@ -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(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 };
}
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs
index eac10d5221..2c1019288b 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs
@@ -21,13 +21,13 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
public abstract class BaseFFProbeProvider : BaseFFMpegProvider
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;
///
/// 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(cacheFilePath);
+ return JsonSerializer.DeserializeFromFile(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;
}
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs
index e767d51965..479a2b1afb 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs
@@ -18,8 +18,8 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
///
public class FFProbeAudioInfoProvider : BaseFFProbeProvider