| | | 1 | | using System; |
| | | 2 | | using MediaBrowser.Model.Dto; |
| | | 3 | | |
| | | 4 | | namespace MediaBrowser.Model.Dlna |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Class MediaOptions. |
| | | 8 | | /// </summary> |
| | | 9 | | public class MediaOptions |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Initializes a new instance of the <see cref="MediaOptions"/> class. |
| | | 13 | | /// </summary> |
| | | 14 | | public MediaOptions() |
| | | 15 | | { |
| | | 16 | | Context = EncodingContext.Streaming; |
| | | 17 | | |
| | | 18 | | EnableDirectPlay = true; |
| | | 19 | | EnableDirectStream = true; |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets or sets a value indicating whether direct playback is allowed. |
| | | 24 | | /// </summary> |
| | | 25 | | public bool EnableDirectPlay { get; set; } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets or sets a value indicating whether direct streaming is allowed. |
| | | 29 | | /// </summary> |
| | | 30 | | public bool EnableDirectStream { get; set; } |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Gets or sets a value indicating whether direct playback is forced. |
| | | 34 | | /// </summary> |
| | | 35 | | public bool ForceDirectPlay { get; set; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Gets or sets a value indicating whether direct streaming is forced. |
| | | 39 | | /// </summary> |
| | | 40 | | public bool ForceDirectStream { get; set; } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Gets or sets a value indicating whether audio stream copy is allowed. |
| | | 44 | | /// </summary> |
| | | 45 | | public bool AllowAudioStreamCopy { get; set; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets or sets a value indicating whether video stream copy is allowed. |
| | | 49 | | /// </summary> |
| | | 50 | | public bool AllowVideoStreamCopy { get; set; } |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Gets or sets a value indicating whether always burn in subtitles when transcoding. |
| | | 54 | | /// </summary> |
| | | 55 | | public bool AlwaysBurnInSubtitleWhenTranscoding { get; set; } |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Gets or sets the item id. |
| | | 59 | | /// </summary> |
| | | 60 | | public Guid ItemId { get; set; } |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Gets or sets the media sources. |
| | | 64 | | /// </summary> |
| | | 65 | | public MediaSourceInfo[] MediaSources { get; set; } = Array.Empty<MediaSourceInfo>(); |
| | | 66 | | |
| | | 67 | | /// <summary> |
| | | 68 | | /// Gets or sets the device profile. |
| | | 69 | | /// </summary> |
| | | 70 | | public required DeviceProfile Profile { get; set; } |
| | | 71 | | |
| | | 72 | | /// <summary> |
| | | 73 | | /// Gets or sets a media source id. Optional. Only needed if a specific AudioStreamIndex or SubtitleStreamIndex |
| | | 74 | | /// </summary> |
| | | 75 | | public string? MediaSourceId { get; set; } |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Gets or sets the device id. |
| | | 79 | | /// </summary> |
| | | 80 | | public string? DeviceId { get; set; } |
| | | 81 | | |
| | | 82 | | /// <summary> |
| | | 83 | | /// Gets or sets an override of supported number of audio channels |
| | | 84 | | /// Example: DeviceProfile supports five channel, but user only has stereo speakers. |
| | | 85 | | /// </summary> |
| | | 86 | | public int? MaxAudioChannels { get; set; } |
| | | 87 | | |
| | | 88 | | /// <summary> |
| | | 89 | | /// Gets or sets the application's configured maximum bitrate. |
| | | 90 | | /// </summary> |
| | | 91 | | public int? MaxBitrate { get; set; } |
| | | 92 | | |
| | | 93 | | /// <summary> |
| | | 94 | | /// Gets or sets the context. |
| | | 95 | | /// </summary> |
| | | 96 | | /// <value>The context.</value> |
| | | 97 | | public EncodingContext Context { get; set; } |
| | | 98 | | |
| | | 99 | | /// <summary> |
| | | 100 | | /// Gets or sets the audio transcoding bitrate. |
| | | 101 | | /// </summary> |
| | | 102 | | /// <value>The audio transcoding bitrate.</value> |
| | | 103 | | public int? AudioTranscodingBitrate { get; set; } |
| | | 104 | | |
| | | 105 | | /// <summary> |
| | | 106 | | /// Gets or sets an override for the audio stream index. |
| | | 107 | | /// </summary> |
| | | 108 | | public int? AudioStreamIndex { get; set; } |
| | | 109 | | |
| | | 110 | | /// <summary> |
| | | 111 | | /// Gets or sets an override for the subtitle stream index. |
| | | 112 | | /// </summary> |
| | | 113 | | public int? SubtitleStreamIndex { get; set; } |
| | | 114 | | |
| | | 115 | | /// <summary> |
| | | 116 | | /// Gets the maximum bitrate. |
| | | 117 | | /// </summary> |
| | | 118 | | /// <param name="isAudio">Whether or not this is audio.</param> |
| | | 119 | | /// <returns>System.Nullable<System.Int32>.</returns> |
| | | 120 | | public int? GetMaxBitrate(bool isAudio) |
| | | 121 | | { |
| | 848 | 122 | | if (MaxBitrate.HasValue) |
| | | 123 | | { |
| | 0 | 124 | | return MaxBitrate; |
| | | 125 | | } |
| | | 126 | | |
| | 848 | 127 | | if (Profile is null) |
| | | 128 | | { |
| | 0 | 129 | | return null; |
| | | 130 | | } |
| | | 131 | | |
| | 848 | 132 | | if (Context == EncodingContext.Static) |
| | | 133 | | { |
| | 0 | 134 | | if (isAudio && Profile.MaxStaticMusicBitrate.HasValue) |
| | | 135 | | { |
| | 0 | 136 | | return Profile.MaxStaticMusicBitrate; |
| | | 137 | | } |
| | | 138 | | |
| | 0 | 139 | | return Profile.MaxStaticBitrate; |
| | | 140 | | } |
| | | 141 | | |
| | 848 | 142 | | return Profile.MaxStreamingBitrate; |
| | | 143 | | } |
| | | 144 | | } |
| | | 145 | | } |