using System;
using MediaBrowser.Model.Dto;
namespace MediaBrowser.Model.Dlna
{
///
/// Class MediaOptions.
///
public class MediaOptions
{
///
/// Initializes a new instance of the class.
///
public MediaOptions()
{
Context = EncodingContext.Streaming;
EnableDirectPlay = true;
EnableDirectStream = true;
}
///
/// Gets or sets a value indicating whether direct playback is allowed.
///
public bool EnableDirectPlay { get; set; }
///
/// Gets or sets a value indicating whether direct streaming is allowed.
///
public bool EnableDirectStream { get; set; }
///
/// Gets or sets a value indicating whether direct playback is forced.
///
public bool ForceDirectPlay { get; set; }
///
/// Gets or sets a value indicating whether direct streaming is forced.
///
public bool ForceDirectStream { get; set; }
///
/// Gets or sets a value indicating whether audio stream copy is allowed.
///
public bool AllowAudioStreamCopy { get; set; }
///
/// Gets or sets a value indicating whether video stream copy is allowed.
///
public bool AllowVideoStreamCopy { get; set; }
///
/// Gets or sets the item id.
///
public Guid ItemId { get; set; }
///
/// Gets or sets the media sources.
///
public MediaSourceInfo[] MediaSources { get; set; } = Array.Empty();
///
/// Gets or sets the device profile.
///
required 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; }
///
/// Gets or sets the device id.
///
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 maximum bitrate.
///
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;
}
}
}