diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-03-28 16:22:27 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-03-28 16:22:27 -0400 |
| commit | bd2ea703e31522d505407a33089b95f997f6b062 (patch) | |
| tree | ce9e3e4ea90c90fda7e287e841813b1aa0675294 /MediaBrowser.Model | |
| parent | 3add1872c860cae14f85b339fef843ff962574aa (diff) | |
implement modular media sources
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 24 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/SubtitleProfile.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/MediaSourceInfo.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/MediaSourceType.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/MediaStream.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs | 2 |
6 files changed, 59 insertions, 6 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 62ac321fe..6534eda10 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -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; diff --git a/MediaBrowser.Model/Dlna/SubtitleProfile.cs b/MediaBrowser.Model/Dlna/SubtitleProfile.cs index d3989829c..1795c374a 100644 --- a/MediaBrowser.Model/Dlna/SubtitleProfile.cs +++ b/MediaBrowser.Model/Dlna/SubtitleProfile.cs @@ -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); + } } }
\ No newline at end of file diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 31d310acd..92af8d671 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -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; } diff --git a/MediaBrowser.Model/Dto/MediaSourceType.cs b/MediaBrowser.Model/Dto/MediaSourceType.cs index a9cd71df5..e04978502 100644 --- a/MediaBrowser.Model/Dto/MediaSourceType.cs +++ b/MediaBrowser.Model/Dto/MediaSourceType.cs @@ -4,6 +4,6 @@ namespace MediaBrowser.Model.Dto { Default = 0, Grouping = 1, - Cache = 2 + Placeholder = 2 } }
\ No newline at end of file diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index 66fb48628..fa075490a 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -141,6 +141,11 @@ namespace MediaBrowser.Model.Entities { if (Type != MediaStreamType.Subtitle) return false; + if (string.IsNullOrEmpty(Codec) && !IsExternal) + { + return false; + } + return IsTextFormat(Codec); } } diff --git a/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs b/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs index 783fb4120..ffd4995ad 100644 --- a/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs +++ b/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs @@ -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; } } } |
