Upgraded Protobuf, and added api support for it

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-29 08:21:56 -04:00
parent de74609784
commit cb7f04e4d3
31 changed files with 286 additions and 58 deletions

View File

@ -171,7 +171,7 @@ namespace MediaBrowser.Api
} }
return baseItemStudio; return baseItemStudio;
}); }).ToArray();
} }
} }
@ -218,7 +218,7 @@ namespace MediaBrowser.Api
} }
return baseItemPerson; return baseItemPerson;
}); }).ToArray();
} }
} }
@ -269,5 +269,15 @@ namespace MediaBrowser.Api
Name = entity.Name Name = entity.Name
}; };
} }
public static DTOUser GetDTOUser(User user)
{
return new DTOUser()
{
Id = user.Id,
Name = user.Name,
HasImage = !string.IsNullOrEmpty(user.PrimaryImagePath)
};
}
} }
} }

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary> /// <summary>
/// Gets a single genre /// Gets a single genre
/// </summary> /// </summary>
public class GenreHandler : BaseSerializationHandler<IBNItem> public class GenreHandler : BaseJsonHandler<IBNItem>
{ {
protected override Task<IBNItem> GetObjectToSerialize() protected override Task<IBNItem> GetObjectToSerialize()
{ {

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
public class GenresHandler : BaseSerializationHandler<IEnumerable<IBNItem>> public class GenresHandler : BaseJsonHandler<IEnumerable<IBNItem>>
{ {
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize() protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
{ {

View File

@ -8,7 +8,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
public class ItemHandler : BaseSerializationHandler<DTOBaseItem> public class ItemHandler : BaseJsonHandler<DTOBaseItem>
{ {
protected override Task<DTOBaseItem> GetObjectToSerialize() protected override Task<DTOBaseItem> GetObjectToSerialize()
{ {

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
public class ItemListHandler : BaseSerializationHandler<DTOBaseItem[]> public class ItemListHandler : BaseJsonHandler<DTOBaseItem[]>
{ {
protected override Task<DTOBaseItem[]> GetObjectToSerialize() protected override Task<DTOBaseItem[]> GetObjectToSerialize()
{ {

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary> /// <summary>
/// Gets a single Person /// Gets a single Person
/// </summary> /// </summary>
public class PersonHandler : BaseSerializationHandler<IBNItem> public class PersonHandler : BaseJsonHandler<IBNItem>
{ {
protected override Task<IBNItem> GetObjectToSerialize() protected override Task<IBNItem> GetObjectToSerialize()
{ {

View File

@ -7,7 +7,7 @@ using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration> public class PluginConfigurationHandler : BaseJsonHandler<BasePluginConfiguration>
{ {
protected override Task<BasePluginConfiguration> GetObjectToSerialize() protected override Task<BasePluginConfiguration> GetObjectToSerialize()
{ {

View File

@ -10,7 +10,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary> /// <summary>
/// Provides information about installed plugins /// Provides information about installed plugins
/// </summary> /// </summary>
public class PluginsHandler : BaseSerializationHandler<IEnumerable<PluginInfo>> public class PluginsHandler : BaseJsonHandler<IEnumerable<PluginInfo>>
{ {
protected override Task<IEnumerable<PluginInfo>> GetObjectToSerialize() protected override Task<IEnumerable<PluginInfo>> GetObjectToSerialize()
{ {

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary> /// <summary>
/// Gets a single studio /// Gets a single studio
/// </summary> /// </summary>
public class StudioHandler : BaseSerializationHandler<IBNItem> public class StudioHandler : BaseJsonHandler<IBNItem>
{ {
protected override Task<IBNItem> GetObjectToSerialize() protected override Task<IBNItem> GetObjectToSerialize()
{ {

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
public class StudiosHandler : BaseSerializationHandler<IEnumerable<IBNItem>> public class StudiosHandler : BaseJsonHandler<IEnumerable<IBNItem>>
{ {
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize() protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
{ {

View File

@ -1,16 +1,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common.Net.Handlers; using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.DTO;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
class UsersHandler : BaseSerializationHandler<IEnumerable<User>> class UsersHandler : BaseJsonHandler<IEnumerable<DTOUser>>
{ {
protected override Task<IEnumerable<User>> GetObjectToSerialize() protected override Task<IEnumerable<DTOUser>> GetObjectToSerialize()
{ {
return Task.FromResult<IEnumerable<User>>(Kernel.Instance.Users); return Task.FromResult<IEnumerable<DTOUser>>(Kernel.Instance.Users.Select(u => ApiService.GetDTOUser(u)));
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary> /// <summary>
/// Gets a single year /// Gets a single year
/// </summary> /// </summary>
public class YearHandler : BaseSerializationHandler<IBNItem> public class YearHandler : BaseJsonHandler<IBNItem>
{ {
protected override Task<IBNItem> GetObjectToSerialize() protected override Task<IBNItem> GetObjectToSerialize()
{ {

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers namespace MediaBrowser.Api.HttpHandlers
{ {
public class YearsHandler : BaseSerializationHandler<IEnumerable<IBNItem>> public class YearsHandler : BaseJsonHandler<IEnumerable<IBNItem>>
{ {
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize() protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
{ {

View File

@ -40,10 +40,27 @@ namespace MediaBrowser.ApiInteraction
} }
/// <summary> /// <summary>
/// Gets or sets the format to request from the server /// Gets the data format to request from the server
/// The Data Serializer will have to be able to support it.
/// </summary> /// </summary>
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 HttpClient HttpClient { get; private set; }
public IDataSerializer DataSerializer { get; set; } public IDataSerializer DataSerializer { get; set; }
@ -372,20 +389,20 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<DTOBaseItem>(stream); return DeserializeFromStream<DTOBaseItem>(stream);
} }
} }
/// <summary> /// <summary>
/// Gets all Users /// Gets all Users
/// </summary> /// </summary>
public async Task<IEnumerable<User>> GetAllUsersAsync() public async Task<IEnumerable<DTOUser>> GetAllUsersAsync()
{ {
string url = ApiUrl + "/users"; string url = ApiUrl + "/users";
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<User>>(stream); return DeserializeFromStream<DTOUser[]>(stream);
} }
} }
@ -398,7 +415,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem>>(stream); return DeserializeFromStream<IBNItem[]>(stream);
} }
} }
@ -411,7 +428,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem>>(stream); return DeserializeFromStream<IBNItem[]>(stream);
} }
} }
@ -424,7 +441,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<DTOBaseItem>>(stream); return DeserializeFromStream<DTOBaseItem[]>(stream);
} }
} }
@ -437,7 +454,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<DTOBaseItem>>(stream); return DeserializeFromStream<DTOBaseItem[]>(stream);
} }
} }
@ -450,7 +467,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<DTOBaseItem>>(stream); return DeserializeFromStream<DTOBaseItem[]>(stream);
} }
} }
@ -465,7 +482,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<DTOBaseItem>>(stream); return DeserializeFromStream<DTOBaseItem[]>(stream);
} }
} }
@ -478,7 +495,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<IBNItem>>(stream); return DeserializeFromStream<IBNItem[]>(stream);
} }
} }
@ -491,7 +508,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IEnumerable<DTOBaseItem>>(stream); return DeserializeFromStream<DTOBaseItem[]>(stream);
} }
} }
@ -504,7 +521,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IBNItem>(stream); return DeserializeFromStream<IBNItem>(stream);
} }
} }
@ -517,7 +534,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IBNItem>(stream); return DeserializeFromStream<IBNItem>(stream);
} }
} }
@ -530,7 +547,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IBNItem>(stream); return DeserializeFromStream<IBNItem>(stream);
} }
} }
@ -543,7 +560,7 @@ namespace MediaBrowser.ApiInteraction
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false)) using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{ {
return DataSerializer.DeserializeFromStream<IBNItem>(stream); return DeserializeFromStream<IBNItem>(stream);
} }
} }
@ -564,6 +581,25 @@ namespace MediaBrowser.ApiInteraction
return GetStreamAsync(url); return GetStreamAsync(url);
} }
private T DeserializeFromStream<T>(Stream stream)
{
return DeserializeFromStream<T>(stream, SerializationFormat);
}
private T DeserializeFromStream<T>(Stream stream, SerializationFormat format)
{
if (format == ApiInteraction.SerializationFormat.Protobuf)
{
return DataSerializer.DeserializeProtobufFromStream<T>(stream);
}
if (format == ApiInteraction.SerializationFormat.Jsv)
{
return DataSerializer.DeserializeJsvFromStream<T>(stream);
}
return DataSerializer.DeserializeJsonFromStream<T>(stream);
}
/// <summary> /// <summary>
/// This is just a helper around HttpClient /// This is just a helper around HttpClient
/// </summary> /// </summary>
@ -581,6 +617,7 @@ namespace MediaBrowser.ApiInteraction
public enum SerializationFormat public enum SerializationFormat
{ {
Json, Json,
Jsv Jsv,
Protobuf
} }
} }

View File

@ -8,6 +8,11 @@ namespace MediaBrowser.ApiInteraction
/// </summary> /// </summary>
public interface IDataSerializer public interface IDataSerializer
{ {
T DeserializeFromStream<T>(Stream stream); T DeserializeJsonFromStream<T>(Stream stream);
T DeserializeJsvFromStream<T>(Stream stream);
T DeserializeProtobufFromStream<T>(Stream stream);
bool CanDeserializeJsv { get; }
bool CanDeserializeProtobuf { get; }
} }
} }

View File

@ -36,8 +36,9 @@
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="protobuf-net"> <Reference Include="protobuf-net, Version=2.0.0.580, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net.2.0.0.480\lib\net40\protobuf-net.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\protobuf-net.2.0.0.580\lib\net40\protobuf-net.dll</HintPath>
</Reference> </Reference>
<Reference Include="ServiceStack.Text, Version=3.9.5.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="ServiceStack.Text, Version=3.9.5.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>

View File

@ -5,7 +5,7 @@ using MediaBrowser.Common.Serialization;
namespace MediaBrowser.Common.Net.Handlers namespace MediaBrowser.Common.Net.Handlers
{ {
public abstract class BaseSerializationHandler<T> : BaseHandler public abstract class BaseJsonHandler<T> : BaseHandler
{ {
public SerializationFormat SerializationFormat public SerializationFormat SerializationFormat
{ {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MahApps.Metro" version="0.9.0.0" targetFramework="net45" /> <package id="MahApps.Metro" version="0.9.0.0" targetFramework="net45" />
<package id="protobuf-net" version="2.0.0.480" targetFramework="net45" /> <package id="protobuf-net" version="2.0.0.580" targetFramework="net45" />
<package id="Rx-Core" version="2.0.20823" targetFramework="net45" /> <package id="Rx-Core" version="2.0.20823" targetFramework="net45" />
<package id="Rx-Interfaces" version="2.0.20823" targetFramework="net45" /> <package id="Rx-Interfaces" version="2.0.20823" targetFramework="net45" />
<package id="Rx-Linq" version="2.0.20823" targetFramework="net45" /> <package id="Rx-Linq" version="2.0.20823" targetFramework="net45" />

View File

@ -228,7 +228,7 @@ namespace MediaBrowser.Controller
user.Name = "Default User"; user.Name = "Default User";
user.Id = Guid.Parse("5d1cf7fce25943b790d140095457a42b"); 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); list.Add(user);

View File

@ -30,9 +30,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="protobuf-net, Version=2.0.0.480, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL"> <Reference Include="protobuf-net, Version=2.0.0.580, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\protobuf-net.2.0.0.480\lib\net40\protobuf-net.dll</HintPath> <HintPath>..\packages\protobuf-net.2.0.0.580\lib\net40\protobuf-net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" /> <Reference Include="System.ComponentModel.Composition" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="protobuf-net" version="2.0.0.480" targetFramework="net45" /> <package id="protobuf-net" version="2.0.0.580" targetFramework="net45" />
<package id="Rx-Core" version="2.0.20823" targetFramework="net45" /> <package id="Rx-Core" version="2.0.20823" targetFramework="net45" />
<package id="Rx-Interfaces" version="2.0.20823" targetFramework="net45" /> <package id="Rx-Interfaces" version="2.0.20823" targetFramework="net45" />
<package id="Rx-Linq" version="2.0.20823" targetFramework="net45" /> <package id="Rx-Linq" version="2.0.20823" targetFramework="net45" />

View File

@ -1,13 +1,23 @@
 using ProtoBuf;
namespace MediaBrowser.Model.DTO namespace MediaBrowser.Model.DTO
{ {
[ProtoContract]
public class AudioInfo public class AudioInfo
{ {
[ProtoMember(1)]
public int BitRate { get; set; } public int BitRate { get; set; }
[ProtoMember(2)]
public int Channels { get; set; } public int Channels { get; set; }
[ProtoMember(3)]
public string Artist { get; set; } public string Artist { get; set; }
[ProtoMember(4)]
public string Album { get; set; } public string Album { get; set; }
[ProtoMember(5)]
public string AlbumArtist { get; set; } public string AlbumArtist { get; set; }
} }
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using ProtoBuf;
namespace MediaBrowser.Model.DTO 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 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. /// This holds information about a BaseItem in a format that is convenient for the client.
/// </summary> /// </summary>
[ProtoContract]
public class DTOBaseItem : IHasProviderIds public class DTOBaseItem : IHasProviderIds
{ {
[ProtoMember(1)]
public string Name { get; set; } public string Name { get; set; }
[ProtoMember(2)]
public Guid Id { get; set; } public Guid Id { get; set; }
[ProtoMember(3)]
public DateTime DateCreated { get; set; } public DateTime DateCreated { get; set; }
[ProtoMember(4)]
public string SortName { get; set; } public string SortName { get; set; }
[ProtoMember(5)]
public DateTime? PremiereDate { get; set; } public DateTime? PremiereDate { get; set; }
[ProtoMember(6)]
public string Path { get; set; } public string Path { get; set; }
[ProtoMember(7)]
public string OfficialRating { get; set; } public string OfficialRating { get; set; }
[ProtoMember(8)]
public string Overview { get; set; } public string Overview { get; set; }
public IEnumerable<string> Taglines { get; set; }
public IEnumerable<string> Genres { get; set; } [ProtoMember(9)]
public IList<string> Taglines { get; set; }
[ProtoMember(10)]
public IList<string> Genres { get; set; }
[ProtoMember(11)]
public string DisplayMediaType { get; set; } public string DisplayMediaType { get; set; }
[ProtoMember(12)]
public float? UserRating { get; set; } public float? UserRating { get; set; }
[ProtoMember(13)]
public long? RunTimeTicks { get; set; } public long? RunTimeTicks { get; set; }
[ProtoMember(14)]
public string AspectRatio { get; set; } public string AspectRatio { get; set; }
[ProtoMember(15)]
public int? ProductionYear { get; set; } public int? ProductionYear { get; set; }
[ProtoMember(16)]
public int? IndexNumber { get; set; } public int? IndexNumber { get; set; }
[ProtoMember(17)]
public int? ParentIndexNumber { get; set; } public int? ParentIndexNumber { get; set; }
[ProtoMember(18)]
public string TrailerUrl { get; set; } public string TrailerUrl { get; set; }
[ProtoMember(19)]
public Dictionary<string, string> ProviderIds { get; set; } public Dictionary<string, string> ProviderIds { get; set; }
[ProtoMember(20)]
public bool HasBanner { get; set; } public bool HasBanner { get; set; }
[ProtoMember(21)]
public bool HasArt { get; set; } public bool HasArt { get; set; }
[ProtoMember(22)]
public bool HasLogo { get; set; } public bool HasLogo { get; set; }
[ProtoMember(23)]
public bool HasThumb { get; set; } public bool HasThumb { get; set; }
[ProtoMember(24)]
public bool HasPrimaryImage { get; set; } public bool HasPrimaryImage { get; set; }
[ProtoMember(25)]
public string Language { get; set; } public string Language { get; set; }
[ProtoMember(26)]
public int BackdropCount { get; set; } public int BackdropCount { get; set; }
public IEnumerable<DTOBaseItem> Children { get; set; } [ProtoMember(27)]
public DTOBaseItem[] Children { get; set; }
[ProtoMember(28)]
public bool IsFolder { get; set; } public bool IsFolder { get; set; }
/// <summary> /// <summary>
/// If the item is a Folder this will determine if it's the Root or not /// If the item is a Folder this will determine if it's the Root or not
/// </summary> /// </summary>
[ProtoMember(29)]
public bool? IsRoot { get; set; } public bool? IsRoot { get; set; }
/// <summary> /// <summary>
/// If the item is a Folder this will determine if it's a VF or not /// If the item is a Folder this will determine if it's a VF or not
/// </summary> /// </summary>
[ProtoMember(30)]
public bool? IsVirtualFolder { get; set; } public bool? IsVirtualFolder { get; set; }
[ProtoMember(31)]
public Guid? ParentId { get; set; } public Guid? ParentId { get; set; }
[ProtoMember(32)]
public string Type { get; set; } public string Type { get; set; }
public IEnumerable<BaseItemPerson> People { get; set; } [ProtoMember(33)]
public IEnumerable<BaseItemStudio> Studios { get; set; } public BaseItemPerson[] People { get; set; }
[ProtoMember(34)]
public BaseItemStudio[] Studios { get; set; }
/// <summary> /// <summary>
/// If the item does not have a logo, this will hold the Id of the Parent that has one. /// If the item does not have a logo, this will hold the Id of the Parent that has one.
/// </summary> /// </summary>
[ProtoMember(35)]
public Guid? ParentLogoItemId { get; set; } public Guid? ParentLogoItemId { get; set; }
/// <summary> /// <summary>
/// If the item does not have any backdrops, this will hold the Id of the Parent that has one. /// If the item does not have any backdrops, this will hold the Id of the Parent that has one.
/// </summary> /// </summary>
[ProtoMember(36)]
public Guid? ParentBackdropItemId { get; set; } public Guid? ParentBackdropItemId { get; set; }
[ProtoMember(37)]
public int? ParentBackdropCount { get; set; } public int? ParentBackdropCount { get; set; }
public IEnumerable<DTOBaseItem> LocalTrailers { get; set; } [ProtoMember(38)]
public DTOBaseItem[] LocalTrailers { get; set; }
[ProtoMember(39)]
public int LocalTrailerCount { get; set; } public int LocalTrailerCount { get; set; }
/// <summary> /// <summary>
/// User data for this item based on the user it's being requested for /// User data for this item based on the user it's being requested for
/// </summary> /// </summary>
[ProtoMember(40)]
public UserItemData UserData { get; set; } public UserItemData UserData { get; set; }
[ProtoMember(41)]
public ItemSpecialCounts SpecialCounts { get; set; } public ItemSpecialCounts SpecialCounts { get; set; }
[ProtoMember(42)]
public AudioInfo AudioInfo { get; set; } public AudioInfo AudioInfo { get; set; }
[ProtoMember(43)]
public VideoInfo VideoInfo { get; set; } public VideoInfo VideoInfo { get; set; }
public bool IsType(Type type) public bool IsType(Type type)
@ -103,6 +166,7 @@ namespace MediaBrowser.Model.DTO
return Type.Equals(type, StringComparison.OrdinalIgnoreCase); return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
} }
[ProtoMember(44)]
public bool IsNew { get; set; } public bool IsNew { get; set; }
} }
} }

View File

@ -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; }
}
}

View File

@ -1,48 +1,65 @@
using MediaBrowser.Model.Entities; using System;
using System; using ProtoBuf;
namespace MediaBrowser.Model.DTO namespace MediaBrowser.Model.DTO
{ {
/// <summary> /// <summary>
/// This is a stub class used by the api to get IBN types along with their item counts /// This is a stub class used by the api to get IBN types along with their item counts
/// </summary> /// </summary>
[ProtoContract]
public class IBNItem public class IBNItem
{ {
/// <summary> /// <summary>
/// The name of the person, genre, etc /// The name of the person, genre, etc
/// </summary> /// </summary>
[ProtoMember(1)]
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// The id of the person, genre, etc /// The id of the person, genre, etc
/// </summary> /// </summary>
[ProtoMember(2)]
public Guid Id { get; set; } public Guid Id { get; set; }
[ProtoMember(3)]
public bool HasImage { get; set; } public bool HasImage { get; set; }
/// <summary> /// <summary>
/// The number of items that have the genre, year, studio, etc /// The number of items that have the genre, year, studio, etc
/// </summary> /// </summary>
[ProtoMember(4)]
public int BaseItemCount { get; set; } public int BaseItemCount { get; set; }
} }
/// <summary> /// <summary>
/// This is used by the api to get information about a Person within a BaseItem /// This is used by the api to get information about a Person within a BaseItem
/// </summary> /// </summary>
[ProtoContract]
public class BaseItemPerson public class BaseItemPerson
{ {
[ProtoMember(1)]
public string Name { get; set; } public string Name { get; set; }
[ProtoMember(2)]
public string Overview { get; set; } public string Overview { get; set; }
[ProtoMember(3)]
public string Type { get; set; } public string Type { get; set; }
[ProtoMember(4)]
public bool HasImage { get; set; } public bool HasImage { get; set; }
} }
/// <summary> /// <summary>
/// This is used by the api to get information about a studio within a BaseItem /// This is used by the api to get information about a studio within a BaseItem
/// </summary> /// </summary>
[ProtoContract]
public class BaseItemStudio public class BaseItemStudio
{ {
[ProtoMember(1)]
public string Name { get; set; } public string Name { get; set; }
[ProtoMember(2)]
public bool HasImage { get; set; } public bool HasImage { get; set; }
} }
} }

View File

@ -1,17 +1,30 @@
using System; using System;
using ProtoBuf;
namespace MediaBrowser.Model.DTO namespace MediaBrowser.Model.DTO
{ {
/// <summary> /// <summary>
/// This is a serializable stub class that is used by the api to provide information about installed plugins. /// This is a serializable stub class that is used by the api to provide information about installed plugins.
/// </summary> /// </summary>
[ProtoContract]
public class PluginInfo public class PluginInfo
{ {
[ProtoMember(1)]
public string Name { get; set; } public string Name { get; set; }
[ProtoMember(2)]
public string Path { get; set; } public string Path { get; set; }
[ProtoMember(3)]
public bool Enabled { get; set; } public bool Enabled { get; set; }
[ProtoMember(4)]
public bool DownloadToUI { get; set; } public bool DownloadToUI { get; set; }
[ProtoMember(5)]
public DateTime ConfigurationDateLastModified { get; set; } public DateTime ConfigurationDateLastModified { get; set; }
[ProtoMember(6)]
public Version Version { get; set; } public Version Version { get; set; }
} }
} }

View File

@ -1,18 +1,31 @@
using System.Collections.Generic; using System.Collections.Generic;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using ProtoBuf;
namespace MediaBrowser.Model.DTO namespace MediaBrowser.Model.DTO
{ {
[ProtoContract]
public class VideoInfo public class VideoInfo
{ {
[ProtoMember(1)]
public string Codec { get; set; } public string Codec { get; set; }
[ProtoMember(2)]
public int Height { get; set; } public int Height { get; set; }
[ProtoMember(3)]
public int Width { get; set; } public int Width { get; set; }
[ProtoMember(4)]
public string ScanType { get; set; } public string ScanType { get; set; }
[ProtoMember(5)]
public VideoType VideoType { get; set; } public VideoType VideoType { get; set; }
[ProtoMember(6)]
public IEnumerable<SubtitleStream> Subtitles { get; set; } public IEnumerable<SubtitleStream> Subtitles { get; set; }
[ProtoMember(7)]
public IEnumerable<AudioStream> AudioStreams { get; set; } public IEnumerable<AudioStream> AudioStreams { get; set; }
} }
} }

View File

@ -1,14 +1,23 @@
 using ProtoBuf;
namespace MediaBrowser.Model.Entities namespace MediaBrowser.Model.Entities
{ {
/// <summary> /// <summary>
/// Since it can be slow to collect this data, this class helps provide a way to calculate them all at once. /// Since it can be slow to collect this data, this class helps provide a way to calculate them all at once.
/// </summary> /// </summary>
[ProtoContract]
public class ItemSpecialCounts public class ItemSpecialCounts
{ {
[ProtoMember(1)]
public int RecentlyAddedItemCount { get; set; } public int RecentlyAddedItemCount { get; set; }
[ProtoMember(2)]
public int RecentlyAddedUnPlayedItemCount { get; set; } public int RecentlyAddedUnPlayedItemCount { get; set; }
[ProtoMember(3)]
public int InProgressItemCount { get; set; } public int InProgressItemCount { get; set; }
[ProtoMember(4)]
public decimal PlayedPercentage { get; set; } public decimal PlayedPercentage { get; set; }
} }
} }

View File

@ -1,13 +1,18 @@
using System; using System;
using ProtoBuf;
namespace MediaBrowser.Model.Entities namespace MediaBrowser.Model.Entities
{ {
[ProtoContract]
public class UserItemData public class UserItemData
{ {
[ProtoMember(1)]
public UserItemRating Rating { get; set; } public UserItemRating Rating { get; set; }
[ProtoMember(2)]
public long PlaybackPositionTicks { get; set; } public long PlaybackPositionTicks { get; set; }
[ProtoMember(3)]
public int PlayCount { get; set; } public int PlayCount { get; set; }
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using ProtoBuf;
namespace MediaBrowser.Model.Entities namespace MediaBrowser.Model.Entities
{ {
@ -17,20 +18,38 @@ namespace MediaBrowser.Model.Entities
public string Codec { get; set; } public string Codec { get; set; }
} }
[ProtoContract]
public class AudioStream public class AudioStream
{ {
[ProtoMember(1)]
public string Codec { get; set; } public string Codec { get; set; }
[ProtoMember(2)]
public string Language { get; set; } public string Language { get; set; }
[ProtoMember(3)]
public int BitRate { get; set; } public int BitRate { get; set; }
[ProtoMember(4)]
public int Channels { get; set; } public int Channels { get; set; }
[ProtoMember(5)]
public int SampleRate { get; set; } public int SampleRate { get; set; }
[ProtoMember(6)]
public bool IsDefault { get; set; } public bool IsDefault { get; set; }
} }
[ProtoContract]
public class SubtitleStream public class SubtitleStream
{ {
[ProtoMember(1)]
public string Language { get; set; } public string Language { get; set; }
[ProtoMember(2)]
public bool IsDefault { get; set; } public bool IsDefault { get; set; }
[ProtoMember(2)]
public bool IsForced { get; set; } public bool IsForced { get; set; }
} }

View File

@ -34,6 +34,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="DTO\AudioInfo.cs" /> <Compile Include="DTO\AudioInfo.cs" />
<Compile Include="DTO\DTOBaseItem.cs" /> <Compile Include="DTO\DTOBaseItem.cs" />
<Compile Include="DTO\DTOUser.cs" />
<Compile Include="DTO\VideoInfo.cs" /> <Compile Include="DTO\VideoInfo.cs" />
<Compile Include="Entities\Audio.cs" /> <Compile Include="Entities\Audio.cs" />
<Compile Include="Entities\BaseEntity.cs" /> <Compile Include="Entities\BaseEntity.cs" />
@ -56,6 +57,11 @@
<Compile Include="Entities\User.cs" /> <Compile Include="Entities\User.cs" />
<Compile Include="Entities\UserItemData.cs" /> <Compile Include="Entities\UserItemData.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Reference Include="protobuf-net">
<HintPath>..\packages\protobuf-net.2.0.0.580\lib\sl4\protobuf-net.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.