AudioOptions.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 bool AllowAudioStreamCopy { get; set; }
  23. public Guid ItemId { get; set; }
  24. public MediaSourceInfo[] MediaSources { get; set; }
  25. public DeviceProfile Profile { get; set; }
  26. /// <summary>
  27. /// Gets or sets a media source id. Optional. Only needed if a specific AudioStreamIndex or SubtitleStreamIndex are requested.
  28. /// </summary>
  29. public string MediaSourceId { get; set; }
  30. public string DeviceId { get; set; }
  31. /// <summary>
  32. /// Gets or sets an override of supported number of audio channels
  33. /// Example: DeviceProfile supports five channel, but user only has stereo speakers.
  34. /// </summary>
  35. public int? MaxAudioChannels { get; set; }
  36. /// <summary>
  37. /// Gets or sets the application's configured quality setting.
  38. /// </summary>
  39. public int? MaxBitrate { get; set; }
  40. /// <summary>
  41. /// Gets or sets the context.
  42. /// </summary>
  43. /// <value>The context.</value>
  44. public EncodingContext Context { get; set; }
  45. /// <summary>
  46. /// Gets or sets the audio transcoding bitrate.
  47. /// </summary>
  48. /// <value>The audio transcoding bitrate.</value>
  49. public int? AudioTranscodingBitrate { get; set; }
  50. /// <summary>
  51. /// Gets the maximum bitrate.
  52. /// </summary>
  53. /// <param name="isAudio">Whether or not this is audio.</param>
  54. /// <returns>System.Nullable&lt;System.Int32&gt;.</returns>
  55. public int? GetMaxBitrate(bool isAudio)
  56. {
  57. if (MaxBitrate.HasValue)
  58. {
  59. return MaxBitrate;
  60. }
  61. if (Profile == null)
  62. {
  63. return null;
  64. }
  65. if (Context == EncodingContext.Static)
  66. {
  67. if (isAudio && Profile.MaxStaticMusicBitrate.HasValue)
  68. {
  69. return Profile.MaxStaticMusicBitrate;
  70. }
  71. return Profile.MaxStaticBitrate;
  72. }
  73. return Profile.MaxStreamingBitrate;
  74. }
  75. }
  76. }