add dlna service methods
This commit is contained in:
parent
80d84225b7
commit
6ac7675c15
68
MediaBrowser.Api/DlnaService.cs
Normal file
68
MediaBrowser.Api/DlnaService.cs
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,6 @@ using ServiceStack.Text.Controller;
|
||||||
using ServiceStack.Web;
|
using ServiceStack.Web;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -776,15 +775,6 @@ namespace MediaBrowser.Api.Images
|
||||||
|
|
||||||
var bytes = Convert.FromBase64String(text);
|
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)
|
var memoryStream = new MemoryStream(bytes)
|
||||||
{
|
{
|
||||||
Position = 0
|
Position = 0
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="ServiceStack.Interfaces">
|
<Reference Include="ServiceStack.Interfaces">
|
||||||
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath>
|
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath>
|
||||||
|
@ -67,6 +66,7 @@
|
||||||
<Link>Properties\SharedVersion.cs</Link>
|
<Link>Properties\SharedVersion.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ChannelService.cs" />
|
<Compile Include="ChannelService.cs" />
|
||||||
|
<Compile Include="DlnaService.cs" />
|
||||||
<Compile Include="Movies\CollectionService.cs" />
|
<Compile Include="Movies\CollectionService.cs" />
|
||||||
<Compile Include="Music\AlbumsService.cs" />
|
<Compile Include="Music\AlbumsService.cs" />
|
||||||
<Compile Include="AppThemeService.cs" />
|
<Compile Include="AppThemeService.cs" />
|
||||||
|
|
|
@ -24,6 +24,12 @@ namespace MediaBrowser.Controller.Dlna
|
||||||
/// <returns>DeviceProfile.</returns>
|
/// <returns>DeviceProfile.</returns>
|
||||||
DeviceProfile GetDefaultProfile();
|
DeviceProfile GetDefaultProfile();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the profile.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The identifier.</param>
|
||||||
|
void DeleteProfile(string id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the profile.
|
/// Gets the profile.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -154,7 +154,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
Codec = streamInfo.codec_name,
|
Codec = streamInfo.codec_name,
|
||||||
Profile = streamInfo.profile,
|
Profile = streamInfo.profile,
|
||||||
Level = streamInfo.level,
|
Level = streamInfo.level,
|
||||||
Index = streamInfo.index
|
Index = streamInfo.index,
|
||||||
|
PixelFormat = streamInfo.pix_fmt
|
||||||
};
|
};
|
||||||
|
|
||||||
if (streamInfo.tags != null)
|
if (streamInfo.tags != null)
|
||||||
|
@ -196,24 +197,21 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get stream bitrate
|
// Get stream bitrate
|
||||||
if (stream.Type != MediaStreamType.Subtitle)
|
var bitrate = 0;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(streamInfo.bit_rate))
|
||||||
{
|
{
|
||||||
var bitrate = 0;
|
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 (!string.IsNullOrEmpty(streamInfo.bit_rate))
|
if (bitrate > 0)
|
||||||
{
|
{
|
||||||
bitrate = int.Parse(streamInfo.bit_rate, UsCulture);
|
stream.BitRate = bitrate;
|
||||||
}
|
|
||||||
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 (bitrate > 0)
|
|
||||||
{
|
|
||||||
stream.BitRate = bitrate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamInfo.disposition != null)
|
if (streamInfo.disposition != null)
|
||||||
|
|
|
@ -350,6 +350,18 @@ namespace MediaBrowser.Dlna
|
||||||
Directory.CreateDirectory(UserProfilesPath);
|
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
|
class InternalProfileInfo
|
||||||
{
|
{
|
||||||
internal DeviceProfileInfo Info { get; set; }
|
internal DeviceProfileInfo Info { get; set; }
|
||||||
|
|
|
@ -123,6 +123,12 @@ namespace MediaBrowser.Model.Entities
|
||||||
/// <value>The filename.</value>
|
/// <value>The filename.</value>
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the pixel format.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The pixel format.</value>
|
||||||
|
public string PixelFormat { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the level.
|
/// Gets or sets the level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -422,6 +422,7 @@ namespace MediaBrowser.WebDashboard.Api
|
||||||
"dashboardinfo.js",
|
"dashboardinfo.js",
|
||||||
"dashboardpage.js",
|
"dashboardpage.js",
|
||||||
"directorybrowser.js",
|
"directorybrowser.js",
|
||||||
|
"dlnaprofile.js",
|
||||||
"dlnaprofiles.js",
|
"dlnaprofiles.js",
|
||||||
"dlnasettings.js",
|
"dlnasettings.js",
|
||||||
"editcollectionitems.js",
|
"editcollectionitems.js",
|
||||||
|
|
|
@ -224,6 +224,9 @@
|
||||||
<Content Include="dashboard-ui\dashboardinfopage.html">
|
<Content Include="dashboard-ui\dashboardinfopage.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\dlnaprofile.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\dlnaprofiles.html">
|
<Content Include="dashboard-ui\dlnaprofiles.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -515,6 +518,9 @@
|
||||||
<Content Include="dashboard-ui\scripts\dashboardinfo.js">
|
<Content Include="dashboard-ui\scripts\dashboardinfo.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\scripts\dlnaprofile.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\dlnaprofiles.js">
|
<Content Include="dashboard-ui\scripts\dlnaprofiles.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user