DirectPlayProfile.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Xml.Serialization;
  2. using MediaBrowser.Model.Extensions;
  3. namespace MediaBrowser.Model.Dlna;
  4. /// <summary>
  5. /// Defines the <see cref="DirectPlayProfile"/>.
  6. /// </summary>
  7. public class DirectPlayProfile
  8. {
  9. /// <summary>
  10. /// Gets or sets the container.
  11. /// </summary>
  12. [XmlAttribute("container")]
  13. public string Container { get; set; } = string.Empty;
  14. /// <summary>
  15. /// Gets or sets the audio codec.
  16. /// </summary>
  17. [XmlAttribute("audioCodec")]
  18. public string? AudioCodec { get; set; }
  19. /// <summary>
  20. /// Gets or sets the video codec.
  21. /// </summary>
  22. [XmlAttribute("videoCodec")]
  23. public string? VideoCodec { get; set; }
  24. /// <summary>
  25. /// Gets or sets the Dlna profile type.
  26. /// </summary>
  27. [XmlAttribute("type")]
  28. public DlnaProfileType Type { get; set; }
  29. /// <summary>
  30. /// Returns whether the <see cref="Container"/> supports the <paramref name="container"/>.
  31. /// </summary>
  32. /// <param name="container">The container to match against.</param>
  33. /// <returns>True if supported.</returns>
  34. public bool SupportsContainer(string? container)
  35. {
  36. return ContainerHelper.ContainsContainer(Container, container);
  37. }
  38. /// <summary>
  39. /// Returns whether the <see cref="VideoCodec"/> supports the <paramref name="codec"/>.
  40. /// </summary>
  41. /// <param name="codec">The codec to match against.</param>
  42. /// <returns>True if supported.</returns>
  43. public bool SupportsVideoCodec(string? codec)
  44. {
  45. return Type == DlnaProfileType.Video && ContainerHelper.ContainsContainer(VideoCodec, codec);
  46. }
  47. /// <summary>
  48. /// Returns whether the <see cref="AudioCodec"/> supports the <paramref name="codec"/>.
  49. /// </summary>
  50. /// <param name="codec">The codec to match against.</param>
  51. /// <returns>True if supported.</returns>
  52. public bool SupportsAudioCodec(string? codec)
  53. {
  54. // Video profiles can have audio codec restrictions too, therefore include Video as valid type.
  55. return (Type == DlnaProfileType.Audio || Type == DlnaProfileType.Video) && ContainerHelper.ContainsContainer(AudioCodec, codec);
  56. }
  57. }