MediaOptions.cs 4.2 KB

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