mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
implement dlna headers
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Dlna
|
||||
{
|
||||
public class DeviceProfile
|
||||
@@ -9,12 +12,6 @@ namespace MediaBrowser.Controller.Dlna
|
||||
/// <value>The name.</value>
|
||||
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>
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,13 @@ namespace MediaBrowser.Controller.Dlna
|
||||
/// <returns>DlnaProfile.</returns>
|
||||
DeviceProfile GetDefaultProfile();
|
||||
|
||||
/// <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>
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -284,22 +283,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
break;
|
||||
}
|
||||
|
||||
case "TagLine":
|
||||
{
|
||||
var tagline = reader.ReadElementContentAsString();
|
||||
|
||||
var hasTaglines = item as IHasTaglines;
|
||||
if (hasTaglines != null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(tagline))
|
||||
{
|
||||
hasTaglines.AddTagline(tagline);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case "Language":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
@@ -380,9 +363,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
|
||||
case "ContentRating":
|
||||
case "certification":
|
||||
case "MPAARating":
|
||||
case "ESRBRating":
|
||||
{
|
||||
var rating = reader.ReadElementContentAsString();
|
||||
|
||||
@@ -415,7 +396,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
break;
|
||||
}
|
||||
|
||||
case "Runtime":
|
||||
case "RunningTime":
|
||||
{
|
||||
var text = reader.ReadElementContentAsString();
|
||||
@@ -431,19 +411,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
break;
|
||||
}
|
||||
|
||||
case "Genre":
|
||||
{
|
||||
foreach (var name in SplitNames(reader.ReadElementContentAsString()))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
item.AddGenre(name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "AspectRatio":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
@@ -587,7 +554,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
break;
|
||||
}
|
||||
|
||||
case "ReleaseYear":
|
||||
case "ProductionYear":
|
||||
{
|
||||
var val = reader.ReadElementContentAsString();
|
||||
@@ -606,7 +572,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
|
||||
case "Rating":
|
||||
case "IMDBrating":
|
||||
case "TGDBRating":
|
||||
{
|
||||
|
||||
var rating = reader.ReadElementContentAsString();
|
||||
@@ -683,22 +648,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "MusicbrainzId":
|
||||
{
|
||||
var mbz = reader.ReadElementContentAsString();
|
||||
if (!string.IsNullOrWhiteSpace(mbz))
|
||||
{
|
||||
if (item is MusicAlbum)
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.MusicBrainzAlbum, mbz);
|
||||
}
|
||||
else if (item is MusicArtist)
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.MusicBrainzArtist, mbz);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "MusicBrainzAlbumId":
|
||||
{
|
||||
var mbz = reader.ReadElementContentAsString();
|
||||
@@ -802,9 +751,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
break;
|
||||
|
||||
case "IMDB_ID":
|
||||
case "IMDB":
|
||||
case "IMDbId":
|
||||
var imDbId = reader.ReadElementContentAsString();
|
||||
if (!string.IsNullOrWhiteSpace(imDbId))
|
||||
{
|
||||
@@ -856,15 +803,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
break;
|
||||
}
|
||||
|
||||
case "ParentalRating":
|
||||
{
|
||||
using (var subtree = reader.ReadSubtree())
|
||||
{
|
||||
FetchFromParentalRatingNode(subtree, item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "Studios":
|
||||
{
|
||||
using (var subtree = reader.ReadSubtree())
|
||||
@@ -1227,32 +1165,6 @@ namespace MediaBrowser.Controller.Providers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches from parental rating node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
private void FetchFromParentalRatingNode(XmlReader reader, T item)
|
||||
{
|
||||
reader.MoveToContent();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
switch (reader.Name)
|
||||
{
|
||||
// Removed support for "Value" tag as it conflicted with MPAA rating but leaving this function for possible
|
||||
// future support of "Description" -ebr
|
||||
|
||||
default:
|
||||
reader.Skip();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the persons from XML node.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user