PlaylistItem.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using MediaBrowser.Controller.Entities;
  2. using MediaBrowser.Dlna.PlayTo.Configuration;
  3. using System;
  4. namespace MediaBrowser.Dlna.PlayTo
  5. {
  6. public class PlaylistItem
  7. {
  8. public string ItemId { get; set; }
  9. public bool Transcode { get; set; }
  10. public bool IsVideo { get; set; }
  11. public bool IsAudio { get; set; }
  12. public string FileFormat { get; set; }
  13. public string MimeType { get; set; }
  14. public int PlayState { get; set; }
  15. public string StreamUrl { get; set; }
  16. public string DlnaHeaders { get; set; }
  17. public string Didl { get; set; }
  18. public long StartPositionTicks { get; set; }
  19. public static PlaylistItem GetBasicConfig(BaseItem item, TranscodeSettings[] profileTranscodings)
  20. {
  21. var playlistItem = new PlaylistItem();
  22. playlistItem.ItemId = item.Id.ToString();
  23. if (string.Equals(item.MediaType, Model.Entities.MediaType.Video, StringComparison.OrdinalIgnoreCase))
  24. {
  25. playlistItem.IsVideo = true;
  26. }
  27. else
  28. {
  29. playlistItem.IsAudio = true;
  30. }
  31. var path = item.Path.ToLower();
  32. //Check the DlnaProfile associated with the renderer
  33. if (profileTranscodings != null)
  34. {
  35. foreach (TranscodeSettings transcodeSetting in profileTranscodings)
  36. {
  37. if (string.IsNullOrWhiteSpace(transcodeSetting.Container))
  38. continue;
  39. if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.TargetContainer))
  40. {
  41. playlistItem.Transcode = true;
  42. playlistItem.FileFormat = transcodeSetting.TargetContainer;
  43. if (string.IsNullOrWhiteSpace(transcodeSetting.MimeType))
  44. playlistItem.MimeType = transcodeSetting.MimeType;
  45. return playlistItem;
  46. }
  47. if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.MimeType))
  48. {
  49. playlistItem.Transcode = false;
  50. playlistItem.FileFormat = transcodeSetting.Container;
  51. playlistItem.MimeType = transcodeSetting.MimeType;
  52. return playlistItem;
  53. }
  54. }
  55. }
  56. if (playlistItem.IsVideo)
  57. {
  58. //Check to see if we support serving the format statically
  59. foreach (string supported in PlayToConfiguration.SupportedStaticFormats)
  60. {
  61. if (path.EndsWith(supported))
  62. {
  63. playlistItem.Transcode = false;
  64. playlistItem.FileFormat = supported;
  65. return playlistItem;
  66. }
  67. }
  68. playlistItem.Transcode = true;
  69. playlistItem.FileFormat = "ts";
  70. }
  71. else
  72. {
  73. foreach (string supported in PlayToConfiguration.SupportedStaticFormats)
  74. {
  75. if (path.EndsWith(supported))
  76. {
  77. playlistItem.Transcode = false;
  78. playlistItem.FileFormat = supported;
  79. return playlistItem;
  80. }
  81. }
  82. playlistItem.Transcode = true;
  83. playlistItem.FileFormat = "mp3";
  84. }
  85. return playlistItem;
  86. }
  87. }
  88. }