diff options
Diffstat (limited to 'MediaBrowser.Model')
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 97 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamInfo.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/MediaVersionInfo.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/MediaStream.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/Session/GeneralCommand.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Model/Session/PlaybackReports.cs | 10 | ||||
| -rw-r--r-- | MediaBrowser.Model/Session/SessionInfoDto.cs | 30 |
7 files changed, 140 insertions, 37 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 576280599..3960b49ae 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Model.Dlna .ToList(); } - var streams = mediaSources.Select(i => BuildAudioItem(options.ItemId, i, options.Profile)).ToList(); + var streams = mediaSources.Select(i => BuildAudioItem(i, options)).ToList(); foreach (var stream in streams) { @@ -75,36 +75,40 @@ namespace MediaBrowser.Model.Dlna streams.FirstOrDefault(); } - private StreamInfo BuildAudioItem(string itemId, MediaSourceInfo item, DeviceProfile profile) + private StreamInfo BuildAudioItem(MediaSourceInfo item, AudioOptions options) { var playlistItem = new StreamInfo { - ItemId = itemId, + ItemId = options.ItemId, MediaType = DlnaProfileType.Audio, MediaSourceId = item.Id }; var audioStream = item.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); - var directPlay = profile.DirectPlayProfiles - .FirstOrDefault(i => i.Type == playlistItem.MediaType && IsAudioProfileSupported(i, item, audioStream)); - - if (directPlay != null) + // Honor the max bitrate setting + if (IsAudioEligibleForDirectPlay(item, options)) { - var audioCodec = audioStream == null ? null : audioStream.Codec; + var directPlay = options.Profile.DirectPlayProfiles + .FirstOrDefault(i => i.Type == playlistItem.MediaType && IsAudioDirectPlaySupported(i, item, audioStream)); - // Make sure audio codec profiles are satisfied - if (!string.IsNullOrEmpty(audioCodec) && profile.CodecProfiles.Where(i => i.Type == CodecType.Audio && i.ContainsCodec(audioCodec)) - .All(i => AreConditionsSatisfied(i.Conditions, item.Path, null, audioStream))) + if (directPlay != null) { - playlistItem.IsDirectStream = true; - playlistItem.Container = item.Container; + var audioCodec = audioStream == null ? null : audioStream.Codec; - return playlistItem; + // Make sure audio codec profiles are satisfied + if (!string.IsNullOrEmpty(audioCodec) && options.Profile.CodecProfiles.Where(i => i.Type == CodecType.Audio && i.ContainsCodec(audioCodec)) + .All(i => AreConditionsSatisfied(i.Conditions, item.Path, null, audioStream))) + { + playlistItem.IsDirectStream = true; + playlistItem.Container = item.Container; + + return playlistItem; + } } } - var transcodingProfile = profile.TranscodingProfiles + var transcodingProfile = options.Profile.TranscodingProfiles .FirstOrDefault(i => i.Type == playlistItem.MediaType); if (transcodingProfile != null) @@ -113,12 +117,28 @@ namespace MediaBrowser.Model.Dlna playlistItem.Container = transcodingProfile.Container; playlistItem.AudioCodec = transcodingProfile.AudioCodec; - var audioTranscodingConditions = profile.CodecProfiles + var audioTranscodingConditions = options.Profile.CodecProfiles .Where(i => i.Type == CodecType.Audio && i.ContainsCodec(transcodingProfile.AudioCodec)) .Take(1) .SelectMany(i => i.Conditions); ApplyTranscodingConditions(playlistItem, audioTranscodingConditions); + + // Honor requested max channels + if (options.MaxAudioChannels.HasValue) + { + var currentValue = playlistItem.MaxAudioChannels ?? options.MaxAudioChannels.Value; + + playlistItem.MaxAudioChannels = Math.Min(options.MaxAudioChannels.Value, currentValue); + } + + // Honor requested max bitrate + if (options.MaxBitrate.HasValue) + { + var currentValue = playlistItem.AudioBitrate ?? options.MaxBitrate.Value; + + playlistItem.AudioBitrate = Math.Min(options.MaxBitrate.Value, currentValue); + } } return playlistItem; @@ -140,7 +160,7 @@ namespace MediaBrowser.Model.Dlna { // See if it can be direct played var directPlay = options.Profile.DirectPlayProfiles - .FirstOrDefault(i => i.Type == playlistItem.MediaType && IsVideoProfileSupported(i, item, videoStream, audioStream)); + .FirstOrDefault(i => i.Type == playlistItem.MediaType && IsVideoDirectPlaySupported(i, item, videoStream, audioStream)); if (directPlay != null) { @@ -189,6 +209,37 @@ namespace MediaBrowser.Model.Dlna .SelectMany(i => i.Conditions); ApplyTranscodingConditions(playlistItem, audioTranscodingConditions); + + // Honor requested max channels + if (options.MaxAudioChannels.HasValue) + { + var currentValue = playlistItem.MaxAudioChannels ?? options.MaxAudioChannels.Value; + + playlistItem.MaxAudioChannels = Math.Min(options.MaxAudioChannels.Value, currentValue); + } + + // Honor requested max bitrate + if (options.MaxAudioTranscodingBitrate.HasValue) + { + var currentValue = playlistItem.AudioBitrate ?? options.MaxAudioTranscodingBitrate.Value; + + playlistItem.AudioBitrate = Math.Min(options.MaxAudioTranscodingBitrate.Value, currentValue); + } + + // Honor max rate + if (options.MaxBitrate.HasValue) + { + var videoBitrate = options.MaxBitrate.Value; + + if (playlistItem.AudioBitrate.HasValue) + { + videoBitrate -= playlistItem.AudioBitrate.Value; + } + + var currentValue = playlistItem.VideoBitrate ?? videoBitrate; + + playlistItem.VideoBitrate = Math.Min(videoBitrate, currentValue); + } } return playlistItem; @@ -207,7 +258,13 @@ namespace MediaBrowser.Model.Dlna return false; } - return true; + return IsAudioEligibleForDirectPlay(item, options); + } + + private bool IsAudioEligibleForDirectPlay(MediaSourceInfo item, AudioOptions options) + { + // Honor the max bitrate setting + return !options.MaxBitrate.HasValue || (item.Bitrate.HasValue && item.Bitrate.Value <= options.MaxBitrate.Value); } private void ValidateInput(VideoOptions options) @@ -331,7 +388,7 @@ namespace MediaBrowser.Model.Dlna } } - private bool IsAudioProfileSupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream audioStream) + private bool IsAudioDirectPlaySupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream audioStream) { if (profile.Container.Length > 0) { @@ -346,7 +403,7 @@ namespace MediaBrowser.Model.Dlna return true; } - private bool IsVideoProfileSupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream videoStream, MediaStream audioStream) + private bool IsVideoDirectPlaySupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream videoStream, MediaStream audioStream) { // Only plain video files can be direct played if (item.VideoType != VideoType.VideoFile) diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 21e4dae7b..209f33930 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -1,7 +1,7 @@ -using System; +using MediaBrowser.Model.Dto; +using System; using System.Collections.Generic; using System.Globalization; -using MediaBrowser.Model.Dto; namespace MediaBrowser.Model.Dlna { @@ -107,10 +107,25 @@ namespace MediaBrowser.Model.Dlna { public string ItemId { get; set; } public List<MediaSourceInfo> MediaSources { get; set; } - public int? MaxBitrateSetting { get; set; } public DeviceProfile Profile { get; set; } + + /// <summary> + /// Optional. Only needed if a specific AudioStreamIndex or SubtitleStreamIndex are requested. + /// </summary> public string MediaSourceId { get; set; } + public string DeviceId { get; set; } + + /// <summary> + /// Allows an override of supported number of audio channels + /// Example: DeviceProfile supports five channel, but user only has stereo speakers + /// </summary> + public int? MaxAudioChannels { get; set; } + + /// <summary> + /// The application's configured quality setting + /// </summary> + public int? MaxBitrate { get; set; } } /// <summary> @@ -120,5 +135,11 @@ namespace MediaBrowser.Model.Dlna { public int? AudioStreamIndex { get; set; } public int? SubtitleStreamIndex { get; set; } + public int? MaxAudioTranscodingBitrate { get; set; } + + public VideoOptions() + { + MaxAudioTranscodingBitrate = 128000; + } } } diff --git a/MediaBrowser.Model/Dto/MediaVersionInfo.cs b/MediaBrowser.Model/Dto/MediaVersionInfo.cs index 37aefae55..e174c5d55 100644 --- a/MediaBrowser.Model/Dto/MediaVersionInfo.cs +++ b/MediaBrowser.Model/Dto/MediaVersionInfo.cs @@ -24,5 +24,7 @@ namespace MediaBrowser.Model.Dto public Video3DFormat? Video3DFormat { get; set; } public List<MediaStream> MediaStreams { get; set; } + + public int? Bitrate { get; set; } } } diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index b644661f4..9719f4e7d 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -152,7 +152,11 @@ namespace MediaBrowser.Model.Entities /// <summary> /// The subtitle /// </summary> - Subtitle + Subtitle, + /// <summary> + /// The embedded image + /// </summary> + EmbeddedImage } public class MediaInfo diff --git a/MediaBrowser.Model/Session/GeneralCommand.cs b/MediaBrowser.Model/Session/GeneralCommand.cs index 0de7d6dd8..a50c3b5fe 100644 --- a/MediaBrowser.Model/Session/GeneralCommand.cs +++ b/MediaBrowser.Model/Session/GeneralCommand.cs @@ -43,6 +43,9 @@ namespace MediaBrowser.Model.Session VolumeDown = 18, Mute = 19, Unmute = 20, - ToggleMute = 21 + ToggleMute = 21, + SetVolume = 22, + SetAudioStreamIndex = 23, + SetSubtitleStreamIndex = 24 } } diff --git a/MediaBrowser.Model/Session/PlaybackReports.cs b/MediaBrowser.Model/Session/PlaybackReports.cs index 75dd3346c..b2361b876 100644 --- a/MediaBrowser.Model/Session/PlaybackReports.cs +++ b/MediaBrowser.Model/Session/PlaybackReports.cs @@ -16,6 +16,10 @@ namespace MediaBrowser.Model.Session public string[] QueueableMediaTypes { get; set; } + public int? AudioStreamIndex { get; set; } + + public int? SubtitleStreamIndex { get; set; } + public PlaybackStartInfo() { QueueableMediaTypes = new string[] { }; @@ -38,6 +42,12 @@ namespace MediaBrowser.Model.Session public bool IsPaused { get; set; } public bool IsMuted { get; set; } + + public int? AudioStreamIndex { get; set; } + + public int? SubtitleStreamIndex { get; set; } + + public int? VolumeLevel { get; set; } } /// <summary> diff --git a/MediaBrowser.Model/Session/SessionInfoDto.cs b/MediaBrowser.Model/Session/SessionInfoDto.cs index 5349a6360..4c51070ee 100644 --- a/MediaBrowser.Model/Session/SessionInfoDto.cs +++ b/MediaBrowser.Model/Session/SessionInfoDto.cs @@ -112,6 +112,24 @@ namespace MediaBrowser.Model.Session public string DeviceName { get; set; } /// <summary> + /// Gets or sets the volume level. + /// </summary> + /// <value>The volume level.</value> + public int? VolumeLevel { get; set; } + + /// <summary> + /// Gets or sets the index of the now playing audio stream. + /// </summary> + /// <value>The index of the now playing audio stream.</value> + public int? NowPlayingAudioStreamIndex { get; set; } + + /// <summary> + /// Gets or sets the index of the now playing subtitle stream. + /// </summary> + /// <value>The index of the now playing subtitle stream.</value> + public int? NowPlayingSubtitleStreamIndex { get; set; } + + /// <summary> /// Gets or sets a value indicating whether this instance is paused. /// </summary> /// <value><c>true</c> if this instance is paused; otherwise, <c>false</c>.</value> @@ -140,12 +158,6 @@ namespace MediaBrowser.Model.Session /// </summary> /// <value>The device id.</value> public string DeviceId { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether [supports fullscreen toggle]. - /// </summary> - /// <value><c>true</c> if [supports fullscreen toggle]; otherwise, <c>false</c>.</value> - public bool SupportsFullscreenToggle { get; set; } /// <summary> /// Gets or sets a value indicating whether [supports remote control]. @@ -154,12 +166,6 @@ namespace MediaBrowser.Model.Session public bool SupportsRemoteControl { get; set; } /// <summary> - /// Gets or sets a value indicating whether [supports osd toggle]. - /// </summary> - /// <value><c>true</c> if [supports osd toggle]; otherwise, <c>false</c>.</value> - public bool SupportsOsdToggle { get; set; } - - /// <summary> /// Gets or sets a value indicating whether [supports navigation commands]. /// </summary> /// <value><c>true</c> if [supports navigation commands]; otherwise, <c>false</c>.</value> |
