AudioOptions.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /// 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. /// Allows 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. /// The application's configured quality setting.
  37. /// </summary>
  38. public long? 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. /// <returns>System.Nullable&lt;System.Int32&gt;.</returns>
  53. public long? GetMaxBitrate(bool isAudio)
  54. {
  55. if (MaxBitrate.HasValue)
  56. {
  57. return MaxBitrate;
  58. }
  59. if (Profile == null)
  60. {
  61. return null;
  62. }
  63. if (Context == EncodingContext.Static)
  64. {
  65. if (isAudio && Profile.MaxStaticMusicBitrate.HasValue)
  66. {
  67. return Profile.MaxStaticMusicBitrate;
  68. }
  69. return Profile.MaxStaticBitrate;
  70. }
  71. return Profile.MaxStreamingBitrate;
  72. }
  73. }
  74. }