From cb7f04e4d3ff0a14dabb89ff828dde5a4703dc6b Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Wed, 29 Aug 2012 08:21:56 -0400 Subject: [PATCH] Upgraded Protobuf, and added api support for it --- MediaBrowser.Api/ApiService.cs | 14 +++- MediaBrowser.Api/HttpHandlers/GenreHandler.cs | 2 +- .../HttpHandlers/GenresHandler.cs | 2 +- MediaBrowser.Api/HttpHandlers/ItemHandler.cs | 2 +- .../HttpHandlers/ItemListHandler.cs | 2 +- .../HttpHandlers/PersonHandler.cs | 2 +- .../PluginConfigurationHandler.cs | 2 +- .../HttpHandlers/PluginsHandler.cs | 2 +- .../HttpHandlers/StudioHandler.cs | 2 +- .../HttpHandlers/StudiosHandler.cs | 2 +- MediaBrowser.Api/HttpHandlers/UsersHandler.cs | 9 ++- MediaBrowser.Api/HttpHandlers/YearHandler.cs | 2 +- MediaBrowser.Api/HttpHandlers/YearsHandler.cs | 2 +- MediaBrowser.ApiInteraction/ApiClient.cs | 77 +++++++++++++----- .../IDataSerializer.cs | 7 +- .../MediaBrowser.Common.csproj | 5 +- .../Net/Handlers/BaseSerializationHandler.cs | 2 +- MediaBrowser.Common/packages.config | 2 +- MediaBrowser.Controller/Kernel.cs | 2 +- .../MediaBrowser.Controller.csproj | 4 +- MediaBrowser.Controller/packages.config | 2 +- MediaBrowser.Model/DTO/AudioInfo.cs | 12 ++- MediaBrowser.Model/DTO/DTOBaseItem.cs | 80 +++++++++++++++++-- MediaBrowser.Model/DTO/DTOUser.cs | 18 +++++ MediaBrowser.Model/DTO/IBNItem.cs | 21 ++++- MediaBrowser.Model/DTO/PluginInfo.cs | 13 +++ MediaBrowser.Model/DTO/VideoInfo.cs | 13 +++ .../Entities/ItemSpecialCounts.cs | 11 ++- MediaBrowser.Model/Entities/UserItemData.cs | 5 ++ MediaBrowser.Model/Entities/Video.cs | 19 +++++ MediaBrowser.Model/MediaBrowser.Model.csproj | 6 ++ 31 files changed, 286 insertions(+), 58 deletions(-) create mode 100644 MediaBrowser.Model/DTO/DTOUser.cs diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs index b8c4b96d9..e90755f5f 100644 --- a/MediaBrowser.Api/ApiService.cs +++ b/MediaBrowser.Api/ApiService.cs @@ -171,7 +171,7 @@ namespace MediaBrowser.Api } return baseItemStudio; - }); + }).ToArray(); } } @@ -218,7 +218,7 @@ namespace MediaBrowser.Api } return baseItemPerson; - }); + }).ToArray(); } } @@ -269,5 +269,15 @@ namespace MediaBrowser.Api Name = entity.Name }; } + + public static DTOUser GetDTOUser(User user) + { + return new DTOUser() + { + Id = user.Id, + Name = user.Name, + HasImage = !string.IsNullOrEmpty(user.PrimaryImagePath) + }; + } } } diff --git a/MediaBrowser.Api/HttpHandlers/GenreHandler.cs b/MediaBrowser.Api/HttpHandlers/GenreHandler.cs index eeadf1e45..c2b70e106 100644 --- a/MediaBrowser.Api/HttpHandlers/GenreHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/GenreHandler.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers /// /// Gets a single genre /// - public class GenreHandler : BaseSerializationHandler + public class GenreHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs index 8452bae3d..3280c3e32 100644 --- a/MediaBrowser.Api/HttpHandlers/GenresHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/GenresHandler.cs @@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Api.HttpHandlers { - public class GenresHandler : BaseSerializationHandler> + public class GenresHandler : BaseJsonHandler> { protected override Task> GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs index 35310f042..4f2a9c68e 100644 --- a/MediaBrowser.Api/HttpHandlers/ItemHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/ItemHandler.cs @@ -8,7 +8,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Api.HttpHandlers { - public class ItemHandler : BaseSerializationHandler + public class ItemHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs index 09814b191..9d5e3eb58 100644 --- a/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/ItemListHandler.cs @@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Api.HttpHandlers { - public class ItemListHandler : BaseSerializationHandler + public class ItemListHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/PersonHandler.cs b/MediaBrowser.Api/HttpHandlers/PersonHandler.cs index 0d496c240..3c34efae5 100644 --- a/MediaBrowser.Api/HttpHandlers/PersonHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/PersonHandler.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers /// /// Gets a single Person /// - public class PersonHandler : BaseSerializationHandler + public class PersonHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs index 6abfb9b2d..fbc16109d 100644 --- a/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/PluginConfigurationHandler.cs @@ -7,7 +7,7 @@ using MediaBrowser.Model.Plugins; namespace MediaBrowser.Api.HttpHandlers { - public class PluginConfigurationHandler : BaseSerializationHandler + public class PluginConfigurationHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs index 67246cbc6..1cb4e95f7 100644 --- a/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/PluginsHandler.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Api.HttpHandlers /// /// Provides information about installed plugins /// - public class PluginsHandler : BaseSerializationHandler> + public class PluginsHandler : BaseJsonHandler> { protected override Task> GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/StudioHandler.cs b/MediaBrowser.Api/HttpHandlers/StudioHandler.cs index 458dd9da1..af7e7fed0 100644 --- a/MediaBrowser.Api/HttpHandlers/StudioHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/StudioHandler.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers /// /// Gets a single studio /// - public class StudioHandler : BaseSerializationHandler + public class StudioHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs index 0f1e087fe..64348ac89 100644 --- a/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/StudiosHandler.cs @@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Api.HttpHandlers { - public class StudiosHandler : BaseSerializationHandler> + public class StudiosHandler : BaseJsonHandler> { protected override Task> GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs index 1c7ea6b27..44d23a208 100644 --- a/MediaBrowser.Api/HttpHandlers/UsersHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/UsersHandler.cs @@ -1,16 +1,17 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using MediaBrowser.Common.Net.Handlers; using MediaBrowser.Controller; -using MediaBrowser.Model.Entities; +using MediaBrowser.Model.DTO; namespace MediaBrowser.Api.HttpHandlers { - class UsersHandler : BaseSerializationHandler> + class UsersHandler : BaseJsonHandler> { - protected override Task> GetObjectToSerialize() + protected override Task> GetObjectToSerialize() { - return Task.FromResult>(Kernel.Instance.Users); + return Task.FromResult>(Kernel.Instance.Users.Select(u => ApiService.GetDTOUser(u))); } } } diff --git a/MediaBrowser.Api/HttpHandlers/YearHandler.cs b/MediaBrowser.Api/HttpHandlers/YearHandler.cs index 1b0c7f670..0eb674e27 100644 --- a/MediaBrowser.Api/HttpHandlers/YearHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/YearHandler.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers /// /// Gets a single year /// - public class YearHandler : BaseSerializationHandler + public class YearHandler : BaseJsonHandler { protected override Task GetObjectToSerialize() { diff --git a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs index 449be7c5e..ee07ac8b0 100644 --- a/MediaBrowser.Api/HttpHandlers/YearsHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/YearsHandler.cs @@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Api.HttpHandlers { - public class YearsHandler : BaseSerializationHandler> + public class YearsHandler : BaseJsonHandler> { protected override Task> GetObjectToSerialize() { diff --git a/MediaBrowser.ApiInteraction/ApiClient.cs b/MediaBrowser.ApiInteraction/ApiClient.cs index 1f7f653df..149529b80 100644 --- a/MediaBrowser.ApiInteraction/ApiClient.cs +++ b/MediaBrowser.ApiInteraction/ApiClient.cs @@ -40,10 +40,27 @@ namespace MediaBrowser.ApiInteraction } /// - /// Gets or sets the format to request from the server - /// The Data Serializer will have to be able to support it. + /// Gets the data format to request from the server /// - public SerializationFormat SerializationFormat { get; set; } + private SerializationFormat SerializationFormat + { + get + { + // First try Protobuf since it has the best performance + if (DataSerializer.CanDeserializeProtobuf) + { + return ApiInteraction.SerializationFormat.Protobuf; + } + + // Next best is jsv + if (DataSerializer.CanDeserializeJsv) + { + return ApiInteraction.SerializationFormat.Jsv; + } + + return ApiInteraction.SerializationFormat.Json; + } + } public HttpClient HttpClient { get; private set; } public IDataSerializer DataSerializer { get; set; } @@ -288,7 +305,7 @@ namespace MediaBrowser.ApiInteraction return url; } - + /// /// This is a helper to get a list of backdrop url's from a given ApiBaseItemWrapper. If the actual item does not have any backdrops it will return backdrops from the first parent that does. /// @@ -372,20 +389,20 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } /// /// Gets all Users /// - public async Task> GetAllUsersAsync() + public async Task> GetAllUsersAsync() { string url = ApiUrl + "/users"; using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -398,7 +415,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -411,7 +428,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -424,7 +441,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -437,7 +454,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -450,7 +467,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -465,7 +482,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -478,7 +495,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -491,7 +508,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream>(stream); + return DeserializeFromStream(stream); } } @@ -504,7 +521,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } @@ -517,7 +534,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } @@ -530,7 +547,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } @@ -543,7 +560,7 @@ namespace MediaBrowser.ApiInteraction using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) { - return DataSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } @@ -564,6 +581,25 @@ namespace MediaBrowser.ApiInteraction return GetStreamAsync(url); } + private T DeserializeFromStream(Stream stream) + { + return DeserializeFromStream(stream, SerializationFormat); + } + + private T DeserializeFromStream(Stream stream, SerializationFormat format) + { + if (format == ApiInteraction.SerializationFormat.Protobuf) + { + return DataSerializer.DeserializeProtobufFromStream(stream); + } + if (format == ApiInteraction.SerializationFormat.Jsv) + { + return DataSerializer.DeserializeJsvFromStream(stream); + } + + return DataSerializer.DeserializeJsonFromStream(stream); + } + /// /// This is just a helper around HttpClient /// @@ -581,6 +617,7 @@ namespace MediaBrowser.ApiInteraction public enum SerializationFormat { Json, - Jsv + Jsv, + Protobuf } } diff --git a/MediaBrowser.ApiInteraction/IDataSerializer.cs b/MediaBrowser.ApiInteraction/IDataSerializer.cs index 2eda7e486..04fe19af1 100644 --- a/MediaBrowser.ApiInteraction/IDataSerializer.cs +++ b/MediaBrowser.ApiInteraction/IDataSerializer.cs @@ -8,6 +8,11 @@ namespace MediaBrowser.ApiInteraction /// public interface IDataSerializer { - T DeserializeFromStream(Stream stream); + T DeserializeJsonFromStream(Stream stream); + T DeserializeJsvFromStream(Stream stream); + T DeserializeProtobufFromStream(Stream stream); + + bool CanDeserializeJsv { get; } + bool CanDeserializeProtobuf { get; } } } diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index 22a7b5920..d80303d1f 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -36,8 +36,9 @@ - - ..\packages\protobuf-net.2.0.0.480\lib\net40\protobuf-net.dll + + False + ..\packages\protobuf-net.2.0.0.580\lib\net40\protobuf-net.dll False diff --git a/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs b/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs index a0696d4a6..1a366c158 100644 --- a/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs +++ b/MediaBrowser.Common/Net/Handlers/BaseSerializationHandler.cs @@ -5,7 +5,7 @@ using MediaBrowser.Common.Serialization; namespace MediaBrowser.Common.Net.Handlers { - public abstract class BaseSerializationHandler : BaseHandler + public abstract class BaseJsonHandler : BaseHandler { public SerializationFormat SerializationFormat { diff --git a/MediaBrowser.Common/packages.config b/MediaBrowser.Common/packages.config index 3b8aa6748..60910df1c 100644 --- a/MediaBrowser.Common/packages.config +++ b/MediaBrowser.Common/packages.config @@ -1,7 +1,7 @@  - + diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index b80013206..8896ebc5a 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -228,7 +228,7 @@ namespace MediaBrowser.Controller user.Name = "Default User"; user.Id = Guid.Parse("5d1cf7fce25943b790d140095457a42b"); - user.PrimaryImagePath = "D:\\Video\\TV\\Archer (2009)\\folder.jpg"; + //user.PrimaryImagePath = "D:\\Video\\TV\\Archer (2009)\\folder.jpg"; list.Add(user); diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index d6f448ac6..ab141c79f 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -30,9 +30,9 @@ 4 - + False - ..\packages\protobuf-net.2.0.0.480\lib\net40\protobuf-net.dll + ..\packages\protobuf-net.2.0.0.580\lib\net40\protobuf-net.dll diff --git a/MediaBrowser.Controller/packages.config b/MediaBrowser.Controller/packages.config index d23d0cb13..bb0f05911 100644 --- a/MediaBrowser.Controller/packages.config +++ b/MediaBrowser.Controller/packages.config @@ -1,6 +1,6 @@  - + diff --git a/MediaBrowser.Model/DTO/AudioInfo.cs b/MediaBrowser.Model/DTO/AudioInfo.cs index b9a1c4db3..9f7675e17 100644 --- a/MediaBrowser.Model/DTO/AudioInfo.cs +++ b/MediaBrowser.Model/DTO/AudioInfo.cs @@ -1,13 +1,23 @@ - +using ProtoBuf; + namespace MediaBrowser.Model.DTO { + [ProtoContract] public class AudioInfo { + [ProtoMember(1)] public int BitRate { get; set; } + + [ProtoMember(2)] public int Channels { get; set; } + [ProtoMember(3)] public string Artist { get; set; } + + [ProtoMember(4)] public string Album { get; set; } + + [ProtoMember(5)] public string AlbumArtist { get; set; } } } diff --git a/MediaBrowser.Model/DTO/DTOBaseItem.cs b/MediaBrowser.Model/DTO/DTOBaseItem.cs index 53d921d45..7e85cc84e 100644 --- a/MediaBrowser.Model/DTO/DTOBaseItem.cs +++ b/MediaBrowser.Model/DTO/DTOBaseItem.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using MediaBrowser.Model.Entities; +using ProtoBuf; namespace MediaBrowser.Model.DTO { @@ -8,89 +9,151 @@ namespace MediaBrowser.Model.DTO /// This is strictly used as a data transfer object from the api layer. /// This holds information about a BaseItem in a format that is convenient for the client. /// + [ProtoContract] public class DTOBaseItem : IHasProviderIds { + [ProtoMember(1)] public string Name { get; set; } + + [ProtoMember(2)] public Guid Id { get; set; } + + [ProtoMember(3)] public DateTime DateCreated { get; set; } + [ProtoMember(4)] public string SortName { get; set; } + + [ProtoMember(5)] public DateTime? PremiereDate { get; set; } + + [ProtoMember(6)] public string Path { get; set; } + + [ProtoMember(7)] public string OfficialRating { get; set; } + + [ProtoMember(8)] public string Overview { get; set; } - public IEnumerable Taglines { get; set; } - public IEnumerable Genres { get; set; } + [ProtoMember(9)] + public IList Taglines { get; set; } + [ProtoMember(10)] + public IList Genres { get; set; } + + [ProtoMember(11)] public string DisplayMediaType { get; set; } + [ProtoMember(12)] public float? UserRating { get; set; } + + [ProtoMember(13)] public long? RunTimeTicks { get; set; } + [ProtoMember(14)] public string AspectRatio { get; set; } + + [ProtoMember(15)] public int? ProductionYear { get; set; } + [ProtoMember(16)] public int? IndexNumber { get; set; } + + [ProtoMember(17)] public int? ParentIndexNumber { get; set; } + [ProtoMember(18)] public string TrailerUrl { get; set; } + [ProtoMember(19)] public Dictionary ProviderIds { get; set; } + [ProtoMember(20)] public bool HasBanner { get; set; } + + [ProtoMember(21)] public bool HasArt { get; set; } + + [ProtoMember(22)] public bool HasLogo { get; set; } + + [ProtoMember(23)] public bool HasThumb { get; set; } + + [ProtoMember(24)] public bool HasPrimaryImage { get; set; } + [ProtoMember(25)] public string Language { get; set; } - + + [ProtoMember(26)] public int BackdropCount { get; set; } - public IEnumerable Children { get; set; } + [ProtoMember(27)] + public DTOBaseItem[] Children { get; set; } + [ProtoMember(28)] public bool IsFolder { get; set; } /// /// If the item is a Folder this will determine if it's the Root or not /// + [ProtoMember(29)] public bool? IsRoot { get; set; } /// /// If the item is a Folder this will determine if it's a VF or not /// + [ProtoMember(30)] public bool? IsVirtualFolder { get; set; } - + + [ProtoMember(31)] public Guid? ParentId { get; set; } + [ProtoMember(32)] public string Type { get; set; } - public IEnumerable People { get; set; } - public IEnumerable Studios { get; set; } + [ProtoMember(33)] + public BaseItemPerson[] People { get; set; } + + [ProtoMember(34)] + public BaseItemStudio[] Studios { get; set; } /// /// If the item does not have a logo, this will hold the Id of the Parent that has one. /// + [ProtoMember(35)] public Guid? ParentLogoItemId { get; set; } /// /// If the item does not have any backdrops, this will hold the Id of the Parent that has one. /// + [ProtoMember(36)] public Guid? ParentBackdropItemId { get; set; } + + [ProtoMember(37)] public int? ParentBackdropCount { get; set; } - public IEnumerable LocalTrailers { get; set; } + [ProtoMember(38)] + public DTOBaseItem[] LocalTrailers { get; set; } + + [ProtoMember(39)] public int LocalTrailerCount { get; set; } /// /// User data for this item based on the user it's being requested for /// + [ProtoMember(40)] public UserItemData UserData { get; set; } + [ProtoMember(41)] public ItemSpecialCounts SpecialCounts { get; set; } + [ProtoMember(42)] public AudioInfo AudioInfo { get; set; } + + [ProtoMember(43)] public VideoInfo VideoInfo { get; set; } public bool IsType(Type type) @@ -103,6 +166,7 @@ namespace MediaBrowser.Model.DTO return Type.Equals(type, StringComparison.OrdinalIgnoreCase); } + [ProtoMember(44)] public bool IsNew { get; set; } } } diff --git a/MediaBrowser.Model/DTO/DTOUser.cs b/MediaBrowser.Model/DTO/DTOUser.cs new file mode 100644 index 000000000..512985731 --- /dev/null +++ b/MediaBrowser.Model/DTO/DTOUser.cs @@ -0,0 +1,18 @@ +using System; +using ProtoBuf; + +namespace MediaBrowser.Model.DTO +{ + [ProtoContract] + public class DTOUser + { + [ProtoMember(1)] + public string Name { get; set; } + + [ProtoMember(2)] + public Guid Id { get; set; } + + [ProtoMember(3)] + public bool HasImage { get; set; } + } +} diff --git a/MediaBrowser.Model/DTO/IBNItem.cs b/MediaBrowser.Model/DTO/IBNItem.cs index fa5d72c85..588fe26d6 100644 --- a/MediaBrowser.Model/DTO/IBNItem.cs +++ b/MediaBrowser.Model/DTO/IBNItem.cs @@ -1,48 +1,65 @@ -using MediaBrowser.Model.Entities; -using System; +using System; +using ProtoBuf; namespace MediaBrowser.Model.DTO { /// /// This is a stub class used by the api to get IBN types along with their item counts /// + [ProtoContract] public class IBNItem { /// /// The name of the person, genre, etc /// + [ProtoMember(1)] public string Name { get; set; } /// /// The id of the person, genre, etc /// + [ProtoMember(2)] public Guid Id { get; set; } + [ProtoMember(3)] public bool HasImage { get; set; } /// /// The number of items that have the genre, year, studio, etc /// + [ProtoMember(4)] public int BaseItemCount { get; set; } } /// /// This is used by the api to get information about a Person within a BaseItem /// + [ProtoContract] public class BaseItemPerson { + [ProtoMember(1)] public string Name { get; set; } + + [ProtoMember(2)] public string Overview { get; set; } + + [ProtoMember(3)] public string Type { get; set; } + + [ProtoMember(4)] public bool HasImage { get; set; } } /// /// This is used by the api to get information about a studio within a BaseItem /// + [ProtoContract] public class BaseItemStudio { + [ProtoMember(1)] public string Name { get; set; } + + [ProtoMember(2)] public bool HasImage { get; set; } } } diff --git a/MediaBrowser.Model/DTO/PluginInfo.cs b/MediaBrowser.Model/DTO/PluginInfo.cs index 76e9026a6..9560b4d8b 100644 --- a/MediaBrowser.Model/DTO/PluginInfo.cs +++ b/MediaBrowser.Model/DTO/PluginInfo.cs @@ -1,17 +1,30 @@ using System; +using ProtoBuf; namespace MediaBrowser.Model.DTO { /// /// This is a serializable stub class that is used by the api to provide information about installed plugins. /// + [ProtoContract] public class PluginInfo { + [ProtoMember(1)] public string Name { get; set; } + + [ProtoMember(2)] public string Path { get; set; } + + [ProtoMember(3)] public bool Enabled { get; set; } + + [ProtoMember(4)] public bool DownloadToUI { get; set; } + + [ProtoMember(5)] public DateTime ConfigurationDateLastModified { get; set; } + + [ProtoMember(6)] public Version Version { get; set; } } } diff --git a/MediaBrowser.Model/DTO/VideoInfo.cs b/MediaBrowser.Model/DTO/VideoInfo.cs index 5cff413f2..d55d06626 100644 --- a/MediaBrowser.Model/DTO/VideoInfo.cs +++ b/MediaBrowser.Model/DTO/VideoInfo.cs @@ -1,18 +1,31 @@ using System.Collections.Generic; using MediaBrowser.Model.Entities; +using ProtoBuf; namespace MediaBrowser.Model.DTO { + [ProtoContract] public class VideoInfo { + [ProtoMember(1)] public string Codec { get; set; } + + [ProtoMember(2)] public int Height { get; set; } + + [ProtoMember(3)] public int Width { get; set; } + + [ProtoMember(4)] public string ScanType { get; set; } + [ProtoMember(5)] public VideoType VideoType { get; set; } + [ProtoMember(6)] public IEnumerable Subtitles { get; set; } + + [ProtoMember(7)] public IEnumerable AudioStreams { get; set; } } } diff --git a/MediaBrowser.Model/Entities/ItemSpecialCounts.cs b/MediaBrowser.Model/Entities/ItemSpecialCounts.cs index d5989ef1d..b57be6ca8 100644 --- a/MediaBrowser.Model/Entities/ItemSpecialCounts.cs +++ b/MediaBrowser.Model/Entities/ItemSpecialCounts.cs @@ -1,14 +1,23 @@ - +using ProtoBuf; + namespace MediaBrowser.Model.Entities { /// /// Since it can be slow to collect this data, this class helps provide a way to calculate them all at once. /// + [ProtoContract] public class ItemSpecialCounts { + [ProtoMember(1)] public int RecentlyAddedItemCount { get; set; } + + [ProtoMember(2)] public int RecentlyAddedUnPlayedItemCount { get; set; } + + [ProtoMember(3)] public int InProgressItemCount { get; set; } + + [ProtoMember(4)] public decimal PlayedPercentage { get; set; } } } diff --git a/MediaBrowser.Model/Entities/UserItemData.cs b/MediaBrowser.Model/Entities/UserItemData.cs index 817cf640e..d7b692014 100644 --- a/MediaBrowser.Model/Entities/UserItemData.cs +++ b/MediaBrowser.Model/Entities/UserItemData.cs @@ -1,13 +1,18 @@ using System; +using ProtoBuf; namespace MediaBrowser.Model.Entities { + [ProtoContract] public class UserItemData { + [ProtoMember(1)] public UserItemRating Rating { get; set; } + [ProtoMember(2)] public long PlaybackPositionTicks { get; set; } + [ProtoMember(3)] public int PlayCount { get; set; } } diff --git a/MediaBrowser.Model/Entities/Video.cs b/MediaBrowser.Model/Entities/Video.cs index 874b033ac..5d0e06202 100644 --- a/MediaBrowser.Model/Entities/Video.cs +++ b/MediaBrowser.Model/Entities/Video.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using ProtoBuf; namespace MediaBrowser.Model.Entities { @@ -17,20 +18,38 @@ namespace MediaBrowser.Model.Entities public string Codec { get; set; } } + [ProtoContract] public class AudioStream { + [ProtoMember(1)] public string Codec { get; set; } + + [ProtoMember(2)] public string Language { get; set; } + + [ProtoMember(3)] public int BitRate { get; set; } + + [ProtoMember(4)] public int Channels { get; set; } + + [ProtoMember(5)] public int SampleRate { get; set; } + + [ProtoMember(6)] public bool IsDefault { get; set; } } + [ProtoContract] public class SubtitleStream { + [ProtoMember(1)] public string Language { get; set; } + + [ProtoMember(2)] public bool IsDefault { get; set; } + + [ProtoMember(2)] public bool IsForced { get; set; } } diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 38acd3b03..9d9ae9f5f 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -34,6 +34,7 @@ + @@ -56,6 +57,11 @@ + + + ..\packages\protobuf-net.2.0.0.580\lib\sl4\protobuf-net.dll + +