Video.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. using MediaBrowser.Controller.Library;
  2. using MediaBrowser.Controller.Persistence;
  3. using MediaBrowser.Controller.Providers;
  4. using MediaBrowser.Model.Dto;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.MediaInfo;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Globalization;
  10. using System.Linq;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using MediaBrowser.Common.Extensions;
  14. using MediaBrowser.Common.IO;
  15. using MediaBrowser.Controller.Channels;
  16. using MediaBrowser.Controller.IO;
  17. using MediaBrowser.Model.IO;
  18. using MediaBrowser.Model.Serialization;
  19. namespace MediaBrowser.Controller.Entities
  20. {
  21. /// <summary>
  22. /// Class Video
  23. /// </summary>
  24. public class Video : BaseItem,
  25. IHasAspectRatio,
  26. ISupportsPlaceHolders,
  27. IHasMediaSources
  28. {
  29. [IgnoreDataMember]
  30. public string PrimaryVersionId { get; set; }
  31. public List<string> AdditionalParts { get; set; }
  32. public List<string> LocalAlternateVersions { get; set; }
  33. public List<LinkedChild> LinkedAlternateVersions { get; set; }
  34. public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
  35. [IgnoreDataMember]
  36. public override bool SupportsPlayedStatus
  37. {
  38. get
  39. {
  40. return true;
  41. }
  42. }
  43. [IgnoreDataMember]
  44. public override bool SupportsPositionTicksResume
  45. {
  46. get
  47. {
  48. return true;
  49. }
  50. }
  51. [IgnoreDataMember]
  52. protected override bool SupportsIsInMixedFolderDetection
  53. {
  54. get
  55. {
  56. return true;
  57. }
  58. }
  59. public override string CreatePresentationUniqueKey()
  60. {
  61. if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
  62. {
  63. return PrimaryVersionId;
  64. }
  65. return base.CreatePresentationUniqueKey();
  66. }
  67. [IgnoreDataMember]
  68. public override bool EnableRefreshOnDateModifiedChange
  69. {
  70. get
  71. {
  72. return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso;
  73. }
  74. }
  75. [IgnoreDataMember]
  76. public override bool SupportsThemeMedia
  77. {
  78. get { return true; }
  79. }
  80. /// <summary>
  81. /// Gets or sets the timestamp.
  82. /// </summary>
  83. /// <value>The timestamp.</value>
  84. public TransportStreamTimestamp? Timestamp { get; set; }
  85. /// <summary>
  86. /// Gets or sets the subtitle paths.
  87. /// </summary>
  88. /// <value>The subtitle paths.</value>
  89. public List<string> SubtitleFiles { get; set; }
  90. /// <summary>
  91. /// Gets or sets a value indicating whether this instance has subtitles.
  92. /// </summary>
  93. /// <value><c>true</c> if this instance has subtitles; otherwise, <c>false</c>.</value>
  94. public bool HasSubtitles { get; set; }
  95. public bool IsPlaceHolder { get; set; }
  96. public bool IsShortcut { get; set; }
  97. public string ShortcutPath { get; set; }
  98. /// <summary>
  99. /// Gets or sets the default index of the video stream.
  100. /// </summary>
  101. /// <value>The default index of the video stream.</value>
  102. public int? DefaultVideoStreamIndex { get; set; }
  103. /// <summary>
  104. /// Gets or sets the type of the video.
  105. /// </summary>
  106. /// <value>The type of the video.</value>
  107. public VideoType VideoType { get; set; }
  108. /// <summary>
  109. /// Gets or sets the type of the iso.
  110. /// </summary>
  111. /// <value>The type of the iso.</value>
  112. public IsoType? IsoType { get; set; }
  113. /// <summary>
  114. /// Gets or sets the video3 D format.
  115. /// </summary>
  116. /// <value>The video3 D format.</value>
  117. public Video3DFormat? Video3DFormat { get; set; }
  118. /// <summary>
  119. /// If the video is a folder-rip, this will hold the file list for the largest playlist
  120. /// </summary>
  121. public List<string> PlayableStreamFileNames { get; set; }
  122. /// <summary>
  123. /// Gets the playable stream files.
  124. /// </summary>
  125. /// <returns>List{System.String}.</returns>
  126. public List<string> GetPlayableStreamFiles()
  127. {
  128. return GetPlayableStreamFiles(Path);
  129. }
  130. /// <summary>
  131. /// Gets or sets the aspect ratio.
  132. /// </summary>
  133. /// <value>The aspect ratio.</value>
  134. public string AspectRatio { get; set; }
  135. public Video()
  136. {
  137. PlayableStreamFileNames = new List<string>();
  138. AdditionalParts = new List<string>();
  139. LocalAlternateVersions = new List<string>();
  140. Tags = new List<string>();
  141. SubtitleFiles = new List<string>();
  142. LinkedAlternateVersions = new List<LinkedChild>();
  143. }
  144. public override bool CanDownload()
  145. {
  146. if (VideoType == VideoType.HdDvd || VideoType == VideoType.Dvd ||
  147. VideoType == VideoType.BluRay)
  148. {
  149. return false;
  150. }
  151. var locationType = LocationType;
  152. return locationType != LocationType.Remote &&
  153. locationType != LocationType.Virtual;
  154. }
  155. [IgnoreDataMember]
  156. public override bool SupportsAddingToPlaylist
  157. {
  158. get { return true; }
  159. }
  160. [IgnoreDataMember]
  161. public int MediaSourceCount
  162. {
  163. get
  164. {
  165. if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
  166. {
  167. var item = LibraryManager.GetItemById(PrimaryVersionId) as Video;
  168. if (item != null)
  169. {
  170. return item.MediaSourceCount;
  171. }
  172. }
  173. return LinkedAlternateVersions.Count + LocalAlternateVersions.Count + 1;
  174. }
  175. }
  176. [IgnoreDataMember]
  177. public bool IsStacked
  178. {
  179. get { return AdditionalParts.Count > 0; }
  180. }
  181. [IgnoreDataMember]
  182. public bool HasLocalAlternateVersions
  183. {
  184. get { return LocalAlternateVersions.Count > 0; }
  185. }
  186. public IEnumerable<Guid> GetAdditionalPartIds()
  187. {
  188. return AdditionalParts.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));
  189. }
  190. public IEnumerable<Guid> GetLocalAlternateVersionIds()
  191. {
  192. return LocalAlternateVersions.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));
  193. }
  194. [IgnoreDataMember]
  195. protected virtual bool EnableDefaultVideoUserDataKeys
  196. {
  197. get
  198. {
  199. return true;
  200. }
  201. }
  202. public override List<string> GetUserDataKeys()
  203. {
  204. var list = base.GetUserDataKeys();
  205. if (EnableDefaultVideoUserDataKeys)
  206. {
  207. if (ExtraType.HasValue)
  208. {
  209. var key = this.GetProviderId(MetadataProviders.Tmdb);
  210. if (!string.IsNullOrWhiteSpace(key))
  211. {
  212. list.Insert(0, GetUserDataKey(key));
  213. }
  214. key = this.GetProviderId(MetadataProviders.Imdb);
  215. if (!string.IsNullOrWhiteSpace(key))
  216. {
  217. list.Insert(0, GetUserDataKey(key));
  218. }
  219. }
  220. else
  221. {
  222. var key = this.GetProviderId(MetadataProviders.Imdb);
  223. if (!string.IsNullOrWhiteSpace(key))
  224. {
  225. list.Insert(0, key);
  226. }
  227. key = this.GetProviderId(MetadataProviders.Tmdb);
  228. if (!string.IsNullOrWhiteSpace(key))
  229. {
  230. list.Insert(0, key);
  231. }
  232. }
  233. }
  234. return list;
  235. }
  236. private string GetUserDataKey(string providerId)
  237. {
  238. var key = providerId + "-" + ExtraType.ToString().ToLower();
  239. // Make sure different trailers have their own data.
  240. if (RunTimeTicks.HasValue)
  241. {
  242. key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
  243. }
  244. return key;
  245. }
  246. public IEnumerable<Video> GetLinkedAlternateVersions()
  247. {
  248. var linkedVersions = LinkedAlternateVersions
  249. .Select(GetLinkedChild)
  250. .Where(i => i != null)
  251. .OfType<Video>();
  252. return linkedVersions
  253. .OrderBy(i => i.SortName);
  254. }
  255. /// <summary>
  256. /// Gets the additional parts.
  257. /// </summary>
  258. /// <returns>IEnumerable{Video}.</returns>
  259. public IEnumerable<Video> GetAdditionalParts()
  260. {
  261. return GetAdditionalPartIds()
  262. .Select(i => LibraryManager.GetItemById(i))
  263. .Where(i => i != null)
  264. .OfType<Video>()
  265. .OrderBy(i => i.SortName);
  266. }
  267. [IgnoreDataMember]
  268. public override string ContainingFolderPath
  269. {
  270. get
  271. {
  272. if (IsStacked)
  273. {
  274. return System.IO.Path.GetDirectoryName(Path);
  275. }
  276. if (!IsPlaceHolder)
  277. {
  278. if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd ||
  279. VideoType == VideoType.HdDvd)
  280. {
  281. return Path;
  282. }
  283. }
  284. return base.ContainingFolderPath;
  285. }
  286. }
  287. [IgnoreDataMember]
  288. public override string FileNameWithoutExtension
  289. {
  290. get
  291. {
  292. if (LocationType == LocationType.FileSystem)
  293. {
  294. if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd || VideoType == VideoType.HdDvd)
  295. {
  296. return System.IO.Path.GetFileName(Path);
  297. }
  298. return System.IO.Path.GetFileNameWithoutExtension(Path);
  299. }
  300. return null;
  301. }
  302. }
  303. internal override bool IsValidFromResolver(BaseItem newItem)
  304. {
  305. var current = this;
  306. var newAsVideo = newItem as Video;
  307. if (newAsVideo != null)
  308. {
  309. if (!current.AdditionalParts.SequenceEqual(newAsVideo.AdditionalParts, StringComparer.OrdinalIgnoreCase))
  310. {
  311. return false;
  312. }
  313. if (!current.LocalAlternateVersions.SequenceEqual(newAsVideo.LocalAlternateVersions, StringComparer.OrdinalIgnoreCase))
  314. {
  315. return false;
  316. }
  317. if (newAsVideo.VideoType != VideoType)
  318. {
  319. return false;
  320. }
  321. }
  322. return base.IsValidFromResolver(newItem);
  323. }
  324. /// <summary>
  325. /// Gets the playable stream files.
  326. /// </summary>
  327. /// <param name="rootPath">The root path.</param>
  328. /// <returns>List{System.String}.</returns>
  329. public List<string> GetPlayableStreamFiles(string rootPath)
  330. {
  331. var allFiles = FileSystem.GetFilePaths(rootPath, true).ToList();
  332. return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
  333. .Where(f => !string.IsNullOrEmpty(f))
  334. .ToList();
  335. }
  336. /// <summary>
  337. /// Gets a value indicating whether [is3 D].
  338. /// </summary>
  339. /// <value><c>true</c> if [is3 D]; otherwise, <c>false</c>.</value>
  340. [IgnoreDataMember]
  341. public bool Is3D
  342. {
  343. get { return Video3DFormat.HasValue; }
  344. }
  345. /// <summary>
  346. /// Gets the type of the media.
  347. /// </summary>
  348. /// <value>The type of the media.</value>
  349. [IgnoreDataMember]
  350. public override string MediaType
  351. {
  352. get
  353. {
  354. return Model.Entities.MediaType.Video;
  355. }
  356. }
  357. protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken)
  358. {
  359. var hasChanges = await base.RefreshedOwnedItems(options, fileSystemChildren, cancellationToken).ConfigureAwait(false);
  360. if (IsStacked)
  361. {
  362. var tasks = AdditionalParts
  363. .Select(i => RefreshMetadataForOwnedVideo(options, true, i, cancellationToken));
  364. await Task.WhenAll(tasks).ConfigureAwait(false);
  365. }
  366. // Must have a parent to have additional parts or alternate versions
  367. // In other words, it must be part of the Parent/Child tree
  368. // The additional parts won't have additional parts themselves
  369. if (LocationType == LocationType.FileSystem && GetParent() != null)
  370. {
  371. if (!IsStacked)
  372. {
  373. RefreshLinkedAlternateVersions();
  374. var tasks = LocalAlternateVersions
  375. .Select(i => RefreshMetadataForOwnedVideo(options, false, i, cancellationToken));
  376. await Task.WhenAll(tasks).ConfigureAwait(false);
  377. }
  378. }
  379. return hasChanges;
  380. }
  381. private void RefreshLinkedAlternateVersions()
  382. {
  383. foreach (var child in LinkedAlternateVersions)
  384. {
  385. // Reset the cached value
  386. if (child.ItemId.HasValue && child.ItemId.Value == Guid.Empty)
  387. {
  388. child.ItemId = null;
  389. }
  390. }
  391. }
  392. public override async Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
  393. {
  394. await base.UpdateToRepository(updateReason, cancellationToken).ConfigureAwait(false);
  395. var localAlternates = GetLocalAlternateVersionIds()
  396. .Select(i => LibraryManager.GetItemById(i))
  397. .Where(i => i != null);
  398. foreach (var item in localAlternates)
  399. {
  400. item.ImageInfos = ImageInfos;
  401. item.Overview = Overview;
  402. item.ProductionYear = ProductionYear;
  403. item.PremiereDate = PremiereDate;
  404. item.CommunityRating = CommunityRating;
  405. item.OfficialRating = OfficialRating;
  406. item.Genres = Genres;
  407. item.ProviderIds = ProviderIds;
  408. await item.UpdateToRepository(ItemUpdateType.MetadataDownload, cancellationToken).ConfigureAwait(false);
  409. }
  410. }
  411. public override IEnumerable<string> GetDeletePaths()
  412. {
  413. if (!DetectIsInMixedFolder())
  414. {
  415. return new[] { ContainingFolderPath };
  416. }
  417. return base.GetDeletePaths();
  418. }
  419. public IEnumerable<MediaStream> GetMediaStreams()
  420. {
  421. var mediaSource = GetMediaSources(false)
  422. .FirstOrDefault();
  423. if (mediaSource == null)
  424. {
  425. return new List<MediaStream>();
  426. }
  427. return mediaSource.MediaStreams;
  428. }
  429. public virtual MediaStream GetDefaultVideoStream()
  430. {
  431. if (!DefaultVideoStreamIndex.HasValue)
  432. {
  433. return null;
  434. }
  435. return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
  436. {
  437. ItemId = Id,
  438. Index = DefaultVideoStreamIndex.Value
  439. }).FirstOrDefault();
  440. }
  441. private List<Tuple<Video, MediaSourceType>> GetAllVideosForMediaSources()
  442. {
  443. var list = new List<Tuple<Video, MediaSourceType>>();
  444. list.Add(new Tuple<Video, MediaSourceType>(this, MediaSourceType.Default));
  445. list.AddRange(GetLinkedAlternateVersions().Select(i => new Tuple<Video, MediaSourceType>(i, MediaSourceType.Grouping)));
  446. if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
  447. {
  448. var primary = LibraryManager.GetItemById(PrimaryVersionId) as Video;
  449. if (primary != null)
  450. {
  451. var existingIds = list.Select(i => i.Item1.Id).ToList();
  452. list.Add(new Tuple<Video, MediaSourceType>(primary, MediaSourceType.Grouping));
  453. list.AddRange(primary.GetLinkedAlternateVersions().Where(i => !existingIds.Contains(i.Id)).Select(i => new Tuple<Video, MediaSourceType>(i, MediaSourceType.Grouping)));
  454. }
  455. }
  456. var localAlternates = list
  457. .SelectMany(i => i.Item1.GetLocalAlternateVersionIds())
  458. .Select(LibraryManager.GetItemById)
  459. .Where(i => i != null)
  460. .OfType<Video>()
  461. .ToList();
  462. list.AddRange(localAlternates.Select(i => new Tuple<Video, MediaSourceType>(i, MediaSourceType.Default)));
  463. return list;
  464. }
  465. public virtual IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution)
  466. {
  467. if (SourceType == SourceType.Channel)
  468. {
  469. var sources = ChannelManager.GetStaticMediaSources(this, CancellationToken.None)
  470. .Result.ToList();
  471. if (sources.Count > 0)
  472. {
  473. return sources;
  474. }
  475. return new List<MediaSourceInfo>
  476. {
  477. GetVersionInfo(enablePathSubstitution, this, MediaSourceType.Placeholder)
  478. };
  479. }
  480. var list = GetAllVideosForMediaSources();
  481. var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item1, i.Item2)).ToList();
  482. return result.OrderBy(i =>
  483. {
  484. if (i.VideoType == VideoType.VideoFile)
  485. {
  486. return 0;
  487. }
  488. return 1;
  489. }).ThenBy(i => i.Video3DFormat.HasValue ? 1 : 0)
  490. .ThenByDescending(i =>
  491. {
  492. var stream = i.VideoStream;
  493. return stream == null || stream.Width == null ? 0 : stream.Width.Value;
  494. })
  495. .ToList();
  496. }
  497. private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type)
  498. {
  499. var mediaStreams = MediaSourceManager.GetMediaStreams(i.Id)
  500. .ToList();
  501. var locationType = i.LocationType;
  502. var info = new MediaSourceInfo
  503. {
  504. Id = i.Id.ToString("N"),
  505. IsoType = i.IsoType,
  506. Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
  507. MediaStreams = mediaStreams,
  508. Name = GetMediaSourceName(i, mediaStreams),
  509. Path = enablePathSubstitution ? GetMappedPath(i, i.Path, locationType) : i.Path,
  510. RunTimeTicks = i.RunTimeTicks,
  511. Video3DFormat = i.Video3DFormat,
  512. VideoType = i.VideoType,
  513. Container = i.Container,
  514. Size = i.Size,
  515. Timestamp = i.Timestamp,
  516. Type = type,
  517. PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(),
  518. SupportsDirectStream = i.VideoType == VideoType.VideoFile
  519. };
  520. if (info.Protocol == MediaProtocol.File)
  521. {
  522. info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");
  523. }
  524. if (i.IsShortcut)
  525. {
  526. info.Path = i.ShortcutPath;
  527. if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase))
  528. {
  529. info.Protocol = MediaProtocol.Http;
  530. }
  531. else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase))
  532. {
  533. info.Protocol = MediaProtocol.Rtmp;
  534. }
  535. else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase))
  536. {
  537. info.Protocol = MediaProtocol.Rtsp;
  538. }
  539. else
  540. {
  541. info.Protocol = MediaProtocol.File;
  542. }
  543. }
  544. if (string.IsNullOrEmpty(info.Container))
  545. {
  546. if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso)
  547. {
  548. if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual)
  549. {
  550. info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.');
  551. }
  552. }
  553. }
  554. info.Bitrate = i.TotalBitrate;
  555. info.InferTotalBitrate();
  556. return info;
  557. }
  558. private static string GetMediaSourceName(Video video, List<MediaStream> mediaStreams)
  559. {
  560. var terms = new List<string>();
  561. var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
  562. var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
  563. if (video.Video3DFormat.HasValue)
  564. {
  565. terms.Add("3D");
  566. }
  567. if (video.VideoType == VideoType.BluRay)
  568. {
  569. terms.Add("Bluray");
  570. }
  571. else if (video.VideoType == VideoType.Dvd)
  572. {
  573. terms.Add("DVD");
  574. }
  575. else if (video.VideoType == VideoType.HdDvd)
  576. {
  577. terms.Add("HD-DVD");
  578. }
  579. else if (video.VideoType == VideoType.Iso)
  580. {
  581. if (video.IsoType.HasValue)
  582. {
  583. if (video.IsoType.Value == Model.Entities.IsoType.BluRay)
  584. {
  585. terms.Add("Bluray");
  586. }
  587. else if (video.IsoType.Value == Model.Entities.IsoType.Dvd)
  588. {
  589. terms.Add("DVD");
  590. }
  591. }
  592. else
  593. {
  594. terms.Add("ISO");
  595. }
  596. }
  597. if (videoStream != null)
  598. {
  599. if (videoStream.Width.HasValue)
  600. {
  601. if (videoStream.Width.Value >= 3800)
  602. {
  603. terms.Add("4K");
  604. }
  605. else if (videoStream.Width.Value >= 1900)
  606. {
  607. terms.Add("1080P");
  608. }
  609. else if (videoStream.Width.Value >= 1270)
  610. {
  611. terms.Add("720P");
  612. }
  613. else if (videoStream.Width.Value >= 700)
  614. {
  615. terms.Add("480P");
  616. }
  617. else
  618. {
  619. terms.Add("SD");
  620. }
  621. }
  622. }
  623. if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
  624. {
  625. terms.Add(videoStream.Codec.ToUpper());
  626. }
  627. if (audioStream != null)
  628. {
  629. var audioCodec = string.Equals(audioStream.Codec, "dca", StringComparison.OrdinalIgnoreCase)
  630. ? audioStream.Profile
  631. : audioStream.Codec;
  632. if (!string.IsNullOrEmpty(audioCodec))
  633. {
  634. terms.Add(audioCodec.ToUpper());
  635. }
  636. }
  637. return string.Join("/", terms.ToArray());
  638. }
  639. }
  640. }