From 697efec86ecdca90d879ca65a18f4319f604990e Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Sat, 26 Mar 2022 12:11:00 +0100 Subject: Cleanup and refactor streambuilder --- MediaBrowser.Model/Dlna/MediaOptions.cs | 116 ++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 MediaBrowser.Model/Dlna/MediaOptions.cs (limited to 'MediaBrowser.Model/Dlna/MediaOptions.cs') diff --git a/MediaBrowser.Model/Dlna/MediaOptions.cs b/MediaBrowser.Model/Dlna/MediaOptions.cs new file mode 100644 index 0000000000..939caf813e --- /dev/null +++ b/MediaBrowser.Model/Dlna/MediaOptions.cs @@ -0,0 +1,116 @@ +#nullable disable +#pragma warning disable CS1591 + +using System; +using MediaBrowser.Model.Dto; + +namespace MediaBrowser.Model.Dlna +{ + /// + /// Class MediaOptions. + /// + public class MediaOptions + { + public MediaOptions() + { + Context = EncodingContext.Streaming; + + EnableDirectPlay = true; + EnableDirectStream = true; + } + + public bool EnableDirectPlay { get; set; } + + public bool EnableDirectStream { get; set; } + + public bool ForceDirectPlay { get; set; } + + public bool ForceDirectStream { get; set; } + + /// + /// Gets or sets an override for allowing stream copy. + /// + public bool AllowAudioStreamCopy { get; set; } + + /// + /// Gets or sets an override for allowing stream copy. + /// + public bool AllowVideoStreamCopy { get; set; } + + public Guid ItemId { get; set; } + + public MediaSourceInfo[] MediaSources { get; set; } + + public DeviceProfile Profile { get; set; } + + /// + /// Gets or sets a media source id. Optional. Only needed if a specific AudioStreamIndex or SubtitleStreamIndex are requested. + /// + public string MediaSourceId { get; set; } + + public string DeviceId { get; set; } + + /// + /// Gets or sets an override of supported number of audio channels + /// Example: DeviceProfile supports five channel, but user only has stereo speakers. + /// + public int? MaxAudioChannels { get; set; } + + /// + /// Gets or sets the application's configured quality setting. + /// + public int? MaxBitrate { get; set; } + + /// + /// Gets or sets the context. + /// + /// The context. + public EncodingContext Context { get; set; } + + /// + /// Gets or sets the audio transcoding bitrate. + /// + /// The audio transcoding bitrate. + public int? AudioTranscodingBitrate { get; set; } + + /// + /// Gets or sets an override for the audio stream index. + /// + public int? AudioStreamIndex { get; set; } + + /// + /// Gets or sets an override for the subtitle stream index. + /// + public int? SubtitleStreamIndex { get; set; } + + /// + /// Gets the maximum bitrate. + /// + /// Whether or not this is audio. + /// System.Nullable<System.Int32>. + public int? GetMaxBitrate(bool isAudio) + { + if (MaxBitrate.HasValue) + { + return MaxBitrate; + } + + if (Profile is null) + { + return null; + } + + if (Context == EncodingContext.Static) + { + if (isAudio && Profile.MaxStaticMusicBitrate.HasValue) + { + return Profile.MaxStaticMusicBitrate; + } + + return Profile.MaxStaticBitrate; + } + + return Profile.MaxStreamingBitrate; + } + } +} -- cgit v1.2.3