AudioOptions.cs 2.5 KB

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