diff options
| -rw-r--r-- | MediaBrowser.Api/DlnaService.cs | 68 | ||||
| -rw-r--r-- | MediaBrowser.Api/Images/ImageService.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Api/MediaBrowser.Api.csproj | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Dlna/IDlnaManager.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs | 32 | ||||
| -rw-r--r-- | MediaBrowser.Dlna/DlnaManager.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/MediaStream.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/Api/DashboardService.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 6 |
9 files changed, 115 insertions, 28 deletions
diff --git a/MediaBrowser.Api/DlnaService.cs b/MediaBrowser.Api/DlnaService.cs new file mode 100644 index 000000000..d40492ee2 --- /dev/null +++ b/MediaBrowser.Api/DlnaService.cs @@ -0,0 +1,68 @@ +using MediaBrowser.Controller.Dlna; +using MediaBrowser.Model.Dlna; +using ServiceStack; +using System.Collections.Generic; +using System.Linq; + +namespace MediaBrowser.Api +{ + [Route("/Dlna/ProfileInfos", "GET", Summary = "Gets a list of profiles")] + public class GetProfileInfos : IReturn<List<DeviceProfileInfo>> + { + } + + [Route("/Dlna/Profiles/{Id}", "DELETE", Summary = "Deletes a profile")] + public class DeleteProfile : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] + public string Id { get; set; } + } + + [Route("/Dlna/Profiles/Default", "GET", Summary = "Gets the default profile")] + public class GetDefaultProfile : IReturn<DeviceProfile> + { + } + + [Route("/Dlna/Profiles/{Id}", "GET", Summary = "Gets a single profile")] + public class GetProfile : IReturn<DeviceProfile> + { + [ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + + public class DlnaService : BaseApiService + { + private readonly IDlnaManager _dlnaManager; + + public DlnaService(IDlnaManager dlnaManager) + { + _dlnaManager = dlnaManager; + } + + public object Get(GetProfileInfos request) + { + var result = _dlnaManager.GetProfileInfos().ToList(); + + return ToOptimizedResult(result); + } + + public object Get(GetProfile request) + { + var result = _dlnaManager.GetProfile(request.Id); + + return ToOptimizedResult(result); + } + + public object Get(GetDefaultProfile request) + { + var result = _dlnaManager.GetDefaultProfile(); + + return ToOptimizedResult(result); + } + + public void Delete(DeleteProfile request) + { + _dlnaManager.DeleteProfile(request.Id); + } + } +} diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 2cdaef1ed..562da40ee 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -15,7 +15,6 @@ using ServiceStack.Text.Controller; using ServiceStack.Web; using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Linq; using System.Threading; @@ -776,15 +775,6 @@ namespace MediaBrowser.Api.Images var bytes = Convert.FromBase64String(text); - // Validate first - using (var validationStream = new MemoryStream(bytes)) - { - // This will throw an exception if it's not a valid image - using (Image.FromStream(validationStream)) - { - } - } - var memoryStream = new MemoryStream(bytes) { Position = 0 diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 38cf39b54..18559a68d 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -53,7 +53,6 @@ <Reference Include="System.Core" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> - <Reference Include="System.Drawing" /> <Reference Include="System.Xml" /> <Reference Include="ServiceStack.Interfaces"> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath> @@ -67,6 +66,7 @@ <Link>Properties\SharedVersion.cs</Link> </Compile> <Compile Include="ChannelService.cs" /> + <Compile Include="DlnaService.cs" /> <Compile Include="Movies\CollectionService.cs" /> <Compile Include="Music\AlbumsService.cs" /> <Compile Include="AppThemeService.cs" /> diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs index dfed5e310..eb4b65e14 100644 --- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs +++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs @@ -23,6 +23,12 @@ namespace MediaBrowser.Controller.Dlna /// </summary> /// <returns>DeviceProfile.</returns> DeviceProfile GetDefaultProfile(); + + /// <summary> + /// Deletes the profile. + /// </summary> + /// <param name="id">The identifier.</param> + void DeleteProfile(string id); /// <summary> /// Gets the profile. diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs index 184033177..fd1f65101 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs @@ -154,7 +154,8 @@ namespace MediaBrowser.Controller.MediaEncoding Codec = streamInfo.codec_name, Profile = streamInfo.profile, Level = streamInfo.level, - Index = streamInfo.index + Index = streamInfo.index, + PixelFormat = streamInfo.pix_fmt }; if (streamInfo.tags != null) @@ -196,24 +197,21 @@ namespace MediaBrowser.Controller.MediaEncoding } // Get stream bitrate - if (stream.Type != MediaStreamType.Subtitle) - { - var bitrate = 0; + var bitrate = 0; - if (!string.IsNullOrEmpty(streamInfo.bit_rate)) - { - bitrate = int.Parse(streamInfo.bit_rate, UsCulture); - } - else if (formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate)) - { - // If the stream info doesn't have a bitrate get the value from the media format info - bitrate = int.Parse(formatInfo.bit_rate, UsCulture); - } + if (!string.IsNullOrEmpty(streamInfo.bit_rate)) + { + bitrate = int.Parse(streamInfo.bit_rate, UsCulture); + } + else if (formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video) + { + // If the stream info doesn't have a bitrate get the value from the media format info + bitrate = int.Parse(formatInfo.bit_rate, UsCulture); + } - if (bitrate > 0) - { - stream.BitRate = bitrate; - } + if (bitrate > 0) + { + stream.BitRate = bitrate; } if (streamInfo.disposition != null) diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 32d6c61ba..6582b4ee5 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -350,6 +350,18 @@ namespace MediaBrowser.Dlna Directory.CreateDirectory(UserProfilesPath); } + public void DeleteProfile(string id) + { + var info = GetProfileInfosInternal().First(i => string.Equals(id, i.Info.Id)); + + if (info.Info.Type == DeviceProfileType.System) + { + throw new ArgumentException("System profiles cannot be deleted."); + } + + File.Delete(info.Path); + } + class InternalProfileInfo { internal DeviceProfileInfo Info { get; set; } diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index a8f751c10..b644661f4 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -124,6 +124,12 @@ namespace MediaBrowser.Model.Entities public string Path { get; set; } /// <summary> + /// Gets or sets the pixel format. + /// </summary> + /// <value>The pixel format.</value> + public string PixelFormat { get; set; } + + /// <summary> /// Gets or sets the level. /// </summary> /// <value>The level.</value> diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index cb5915b70..99afbbdd7 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -422,6 +422,7 @@ namespace MediaBrowser.WebDashboard.Api "dashboardinfo.js", "dashboardpage.js", "directorybrowser.js", + "dlnaprofile.js", "dlnaprofiles.js", "dlnasettings.js", "editcollectionitems.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 97e8c9ba0..6a8cc49b1 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -224,6 +224,9 @@ <Content Include="dashboard-ui\dashboardinfopage.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\dlnaprofile.html">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\dlnaprofiles.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -515,6 +518,9 @@ <Content Include="dashboard-ui\scripts\dashboardinfo.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
+ <Content Include="dashboard-ui\scripts\dlnaprofile.js">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
<Content Include="dashboard-ui\scripts\dlnaprofiles.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
|
