AudioOptions.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using MediaBrowser.Model.Dto;
  5. namespace MediaBrowser.Model.Dlna
  6. {
  7. /// <summary>
  8. /// Class AudioOptions.
  9. /// </summary>
  10. public class AudioOptions
  11. {
  12. public AudioOptions()
  13. {
  14. Context = EncodingContext.Streaming;
  15. EnableDirectPlay = true;
  16. EnableDirectStream = true;
  17. }
  18. public bool EnableDirectPlay { get; set; }
  19. public bool EnableDirectStream { get; set; }
  20. public bool ForceDirectPlay { get; set; }
  21. public bool ForceDirectStream { get; set; }
  22. public Guid ItemId { get; set; }
  23. public MediaSourceInfo[] MediaSources { get; set; }
  24. public DeviceProfile Profile { get; set; }
  25. /// <summary>
  26. /// Gets or sets a media source id. Optional. Only needed if a specific AudioStreamIndex or SubtitleStreamIndex are requested.
  27. /// </summary>
  28. public string MediaSourceId { get; set; }
  29. public string DeviceId { get; set; }
  30. /// <summary>
  31. /// Gets or sets an override of supported number of audio channels
  32. /// Example: DeviceProfile supports five channel, but user only has stereo speakers.
  33. /// </summary>
  34. public int? MaxAudioChannels { get; set; }
  35. /// <summary>
  36. /// Gets or sets the application's configured quality setting.
  37. /// </summary>
  38. public int? MaxBitrate { get; set; }
  39. /// <summary>
  40. /// Gets or sets the context.
  41. /// </summary>
  42. /// <value>The context.</value>
  43. public EncodingContext Context { get; set; }
  44. /// <summary>
  45. /// Gets or sets the audio transcoding bitrate.
  46. /// </summary>
  47. /// <value>The audio transcoding bitrate.</value>
  48. public int? AudioTranscodingBitrate { get; set; }
  49. /// <summary>
  50. /// Gets the maximum bitrate.
  51. /// </summary>
  52. /// <param name="isAudio">Whether or not this is audio.</param>
  53. /// <returns>System.Nullable&lt;System.Int32&gt;.</returns>
  54. public int? GetMaxBitrate(bool isAudio)
  55. {
  56. if (MaxBitrate.HasValue)
  57. {
  58. return MaxBitrate;
  59. }
  60. if (Profile == null)
  61. {
  62. return null;
  63. }
  64. if (Context == EncodingContext.Static)
  65. {
  66. if (isAudio && Profile.MaxStaticMusicBitrate.HasValue)
  67. {
  68. return Profile.MaxStaticMusicBitrate;
  69. }
  70. return Profile.MaxStaticBitrate;
  71. }
  72. return Profile.MaxStreamingBitrate;
  73. }
  74. }
  75. }