mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-27 20:41:54 +00:00
implement modular media sources
This commit is contained in:
@@ -239,6 +239,16 @@ namespace MediaBrowser.Model.Dlna
|
||||
return playlistItem;
|
||||
}
|
||||
|
||||
private int? GetBitrateForDirectPlayCheck(MediaSourceInfo item, AudioOptions options)
|
||||
{
|
||||
if (item.Protocol == MediaProtocol.File)
|
||||
{
|
||||
return options.Profile.MaxStaticBitrate;
|
||||
}
|
||||
|
||||
return options.GetMaxBitrate();
|
||||
}
|
||||
|
||||
private List<PlayMethod> GetAudioDirectPlayMethods(MediaSourceInfo item, MediaStream audioStream, AudioOptions options)
|
||||
{
|
||||
DirectPlayProfile directPlayProfile = null;
|
||||
@@ -263,7 +273,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
// The profile describes what the device supports
|
||||
// If device requirements are satisfied then allow both direct stream and direct play
|
||||
if (IsAudioEligibleForDirectPlay(item, options.Profile.MaxStaticBitrate))
|
||||
if (IsAudioEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options)))
|
||||
{
|
||||
playMethods.Add(PlayMethod.DirectPlay);
|
||||
}
|
||||
@@ -293,7 +303,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
MediaStream videoStream = item.VideoStream;
|
||||
|
||||
// TODO: This doesn't accout for situation of device being able to handle media bitrate, but wifi connection not fast enough
|
||||
bool isEligibleForDirectPlay = IsEligibleForDirectPlay(item, options.Profile.MaxStaticBitrate, subtitleStream, options);
|
||||
bool isEligibleForDirectPlay = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options), subtitleStream, options);
|
||||
bool isEligibleForDirectStream = IsEligibleForDirectPlay(item, options.GetMaxBitrate(), subtitleStream, options);
|
||||
|
||||
if (isEligibleForDirectPlay || isEligibleForDirectStream)
|
||||
@@ -604,6 +614,11 @@ namespace MediaBrowser.Model.Dlna
|
||||
// Look for an external profile that matches the stream type (text/graphical)
|
||||
foreach (SubtitleProfile profile in subtitleProfiles)
|
||||
{
|
||||
if (!profile.SupportsLanguage(subtitleStream.Language))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
|
||||
{
|
||||
if (subtitleStream.SupportsExternalStream)
|
||||
@@ -621,6 +636,11 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
foreach (SubtitleProfile profile in subtitleProfiles)
|
||||
{
|
||||
if (!profile.SupportsLanguage(subtitleStream.Language))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (profile.Method == SubtitleDeliveryMethod.Embed && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
|
||||
{
|
||||
return profile;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Xml.Serialization;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
@@ -13,5 +15,28 @@ namespace MediaBrowser.Model.Dlna
|
||||
[XmlAttribute("didlMode")]
|
||||
public string DidlMode { get; set; }
|
||||
|
||||
[XmlAttribute("language")]
|
||||
public string Language { get; set; }
|
||||
|
||||
public List<string> GetLanguages()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
foreach (string i in (Language ?? string.Empty).Split(','))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool SupportsLanguage(string language)
|
||||
{
|
||||
if (string.IsNullOrEmpty(language))
|
||||
{
|
||||
language = "und";
|
||||
}
|
||||
|
||||
List<string> languages = GetLanguages();
|
||||
return languages.Count == 0 || ListHelper.ContainsIgnoreCase(languages, language);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,11 @@ namespace MediaBrowser.Model.Dto
|
||||
public bool SupportsDirectStream { get; set; }
|
||||
public bool SupportsDirectPlay { get; set; }
|
||||
|
||||
public bool RequiresOpening { get; set; }
|
||||
public string OpenKey { get; set; }
|
||||
public bool RequiresClosing { get; set; }
|
||||
public string CloseKey { get; set; }
|
||||
|
||||
public VideoType? VideoType { get; set; }
|
||||
|
||||
public IsoType? IsoType { get; set; }
|
||||
|
||||
@@ -4,6 +4,6 @@ namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
Default = 0,
|
||||
Grouping = 1,
|
||||
Cache = 2
|
||||
Placeholder = 2
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,11 @@ namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
if (Type != MediaStreamType.Subtitle) return false;
|
||||
|
||||
if (string.IsNullOrEmpty(Codec) && !IsExternal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsTextFormat(Codec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Dto;
|
||||
|
||||
namespace MediaBrowser.Model.MediaInfo
|
||||
{
|
||||
public class PlaybackInfoRequest
|
||||
{
|
||||
public DeviceProfile DeviceProfile { get; set; }
|
||||
public MediaSourceInfo MediaSource { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user