aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Dlna
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-03-25 01:25:03 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-03-25 01:25:03 -0400
commitf245fffad10bde5bf559e67ab5342df8dd2d0aa9 (patch)
treeea5e86df8e96db6b6a42c69dd240ea9b8c6a1638 /MediaBrowser.Controller/Dlna
parent1644d45dac4b465fa9615554f1ef02406e0d9d39 (diff)
implement dlna headers
Diffstat (limited to 'MediaBrowser.Controller/Dlna')
-rw-r--r--MediaBrowser.Controller/Dlna/DeviceIdentification.cs4
-rw-r--r--MediaBrowser.Controller/Dlna/DeviceProfile.cs147
-rw-r--r--MediaBrowser.Controller/Dlna/IDlnaManager.cs7
-rw-r--r--MediaBrowser.Controller/Dlna/MediaProfile.cs5
-rw-r--r--MediaBrowser.Controller/Dlna/TranscodingProfile.cs12
5 files changed, 162 insertions, 13 deletions
diff --git a/MediaBrowser.Controller/Dlna/DeviceIdentification.cs b/MediaBrowser.Controller/Dlna/DeviceIdentification.cs
index 461c77537..7b8e3a1e7 100644
--- a/MediaBrowser.Controller/Dlna/DeviceIdentification.cs
+++ b/MediaBrowser.Controller/Dlna/DeviceIdentification.cs
@@ -41,9 +41,7 @@ namespace MediaBrowser.Controller.Dlna
/// <summary>
/// Gets or sets the manufacturer.
/// </summary>
- /// <value>
- /// The manufacturer.
- /// </value>
+ /// <value>The manufacturer.</value>
public string Manufacturer { get; set; }
/// <summary>
/// Gets or sets the manufacturer URL.
diff --git a/MediaBrowser.Controller/Dlna/DeviceProfile.cs b/MediaBrowser.Controller/Dlna/DeviceProfile.cs
index f3de1bc34..f34c4bf64 100644
--- a/MediaBrowser.Controller/Dlna/DeviceProfile.cs
+++ b/MediaBrowser.Controller/Dlna/DeviceProfile.cs
@@ -1,4 +1,7 @@
-
+using MediaBrowser.Model.Entities;
+using System;
+using System.Linq;
+
namespace MediaBrowser.Controller.Dlna
{
public class DeviceProfile
@@ -10,12 +13,6 @@ namespace MediaBrowser.Controller.Dlna
public string Name { get; set; }
/// <summary>
- /// Gets or sets the type of the client.
- /// </summary>
- /// <value>The type of the client.</value>
- public string ClientType { get; set; }
-
- /// <summary>
/// Gets or sets the transcoding profiles.
/// </summary>
/// <value>The transcoding profiles.</value>
@@ -76,5 +73,141 @@ namespace MediaBrowser.Controller.Dlna
CodecProfiles = new CodecProfile[] { };
ContainerProfiles = new ContainerProfile[] { };
}
+
+ public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
+ {
+ container = (container ?? string.Empty).TrimStart('.');
+
+ return TranscodingProfiles.FirstOrDefault(i =>
+ {
+ if (i.Type != DlnaProfileType.Audio)
+ {
+ return false;
+ }
+
+ if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty))
+ {
+ return false;
+ }
+
+ return true;
+ });
+ }
+
+ public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
+ {
+ container = (container ?? string.Empty).TrimStart('.');
+
+ return TranscodingProfiles.FirstOrDefault(i =>
+ {
+ if (i.Type != DlnaProfileType.Video)
+ {
+ return false;
+ }
+
+ if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty))
+ {
+ return false;
+ }
+
+ if (!string.Equals(videoCodec, i.VideoCodec, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ return true;
+ });
+ }
+
+ public MediaProfile GetAudioMediaProfile(string container, string audioCodec, MediaStream audioStream)
+ {
+ container = (container ?? string.Empty).TrimStart('.');
+
+ return MediaProfiles.FirstOrDefault(i =>
+ {
+ if (i.Type != DlnaProfileType.Audio)
+ {
+ return false;
+ }
+
+ var containers = i.GetContainers().ToList();
+ if (containers.Count > 0 && !containers.Contains(container))
+ {
+ return false;
+ }
+
+ var audioCodecs = i.GetAudioCodecs().ToList();
+ if (audioCodecs.Count > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty))
+ {
+ return false;
+ }
+
+ return true;
+ });
+ }
+
+ public MediaProfile GetVideoMediaProfile(string container, string audioCodec, string videoCodec, MediaStream audioStream, MediaStream videoStream)
+ {
+ container = (container ?? string.Empty).TrimStart('.');
+
+ return MediaProfiles.FirstOrDefault(i =>
+ {
+ if (i.Type != DlnaProfileType.Video)
+ {
+ return false;
+ }
+
+ var containers = i.GetContainers().ToList();
+ if (containers.Count > 0 && !containers.Contains(container))
+ {
+ return false;
+ }
+
+ var audioCodecs = i.GetAudioCodecs().ToList();
+ if (audioCodecs.Count > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty))
+ {
+ return false;
+ }
+
+ var videoCodecs = i.GetVideoCodecs().ToList();
+ if (videoCodecs.Count > 0 && !videoCodecs.Contains(videoCodec ?? string.Empty))
+ {
+ return false;
+ }
+
+ return true;
+ });
+ }
+
+ public MediaProfile GetPhotoMediaProfile(string container)
+ {
+ container = (container ?? string.Empty).TrimStart('.');
+
+ return MediaProfiles.FirstOrDefault(i =>
+ {
+ if (i.Type != DlnaProfileType.Photo)
+ {
+ return false;
+ }
+
+ var containers = i.GetContainers().ToList();
+ if (containers.Count > 0 && !containers.Contains(container))
+ {
+ return false;
+ }
+
+ return true;
+ });
+ }
}
}
diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs
index 6de17e551..22d13fc3a 100644
--- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs
+++ b/MediaBrowser.Controller/Dlna/IDlnaManager.cs
@@ -19,6 +19,13 @@ namespace MediaBrowser.Controller.Dlna
/// <summary>
/// Gets the profile.
/// </summary>
+ /// <param name="headers">The headers.</param>
+ /// <returns>DeviceProfile.</returns>
+ DeviceProfile GetProfile(IDictionary<string,string> headers);
+
+ /// <summary>
+ /// Gets the profile.
+ /// </summary>
/// <param name="deviceInfo">The device information.</param>
/// <returns>DeviceProfile.</returns>
DeviceProfile GetProfile(DeviceIdentification deviceInfo);
diff --git a/MediaBrowser.Controller/Dlna/MediaProfile.cs b/MediaBrowser.Controller/Dlna/MediaProfile.cs
index 1d2613fac..9a9b56ddd 100644
--- a/MediaBrowser.Controller/Dlna/MediaProfile.cs
+++ b/MediaBrowser.Controller/Dlna/MediaProfile.cs
@@ -19,6 +19,11 @@ namespace MediaBrowser.Controller.Dlna
{
Conditions = new ProfileCondition[] {};
}
+
+ public List<string> GetContainers()
+ {
+ return (Container ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
+ }
public List<string> GetAudioCodecs()
{
diff --git a/MediaBrowser.Controller/Dlna/TranscodingProfile.cs b/MediaBrowser.Controller/Dlna/TranscodingProfile.cs
index 007cb632e..d4cfae989 100644
--- a/MediaBrowser.Controller/Dlna/TranscodingProfile.cs
+++ b/MediaBrowser.Controller/Dlna/TranscodingProfile.cs
@@ -1,4 +1,6 @@
-
+using System.Collections.Generic;
+using System.Linq;
+
namespace MediaBrowser.Controller.Dlna
{
public class TranscodingProfile
@@ -11,7 +13,7 @@ namespace MediaBrowser.Controller.Dlna
public string AudioCodec { get; set; }
public bool EstimateContentLength { get; set; }
-
+ public bool EnableMpegtsM2TsMode { get; set; }
public TranscodeSeekInfo TranscodeSeekInfo { get; set; }
public TranscodingSetting[] Settings { get; set; }
@@ -21,7 +23,11 @@ namespace MediaBrowser.Controller.Dlna
Settings = new TranscodingSetting[] { };
}
- public bool EnableMpegtsM2TsMode { get; set; }
+
+ public List<string> GetAudioCodecs()
+ {
+ return (AudioCodec ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
+ }
}
public class TranscodingSetting