AudioOptions.cs 2.5 KB

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