From 5f0d8000a5ec26fd66c5f188f3bb517bb139b74b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 5 Dec 2013 22:39:44 -0500 Subject: moved media streams to the database --- MediaBrowser.Controller/Entities/Audio/Audio.cs | 14 ++++---- MediaBrowser.Controller/Entities/Book.cs | 15 +++++++-- .../Entities/IHasMediaStreams.cs | 10 ++++++ .../Entities/IHasScreenshots.cs | 5 +++ MediaBrowser.Controller/Entities/Video.cs | 37 +++++++++++----------- .../MediaBrowser.Controller.csproj | 2 ++ MediaBrowser.Controller/MediaInfo/FFMpegManager.cs | 18 ++++++++--- .../Persistence/IItemRepository.cs | 16 ++++++++++ .../Persistence/MediaStreamQuery.cs | 26 +++++++++++++++ .../Resolvers/EntityResolutionHelper.cs | 2 +- 10 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/IHasMediaStreams.cs create mode 100644 MediaBrowser.Controller/Persistence/MediaStreamQuery.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 2a7aa4fea9..63c907c1f2 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Model.Entities; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; @@ -13,7 +12,6 @@ namespace MediaBrowser.Controller.Entities.Audio { public Audio() { - MediaStreams = new List(); Artists = new List(); } @@ -22,13 +20,13 @@ namespace MediaBrowser.Controller.Entities.Audio /// /// The language. public string Language { get; set; } - + /// - /// Gets or sets the media streams. + /// Gets or sets a value indicating whether this instance has embedded image. /// - /// The media streams. - public List MediaStreams { get; set; } - + /// true if this instance has embedded image; otherwise, false. + public bool HasEmbeddedImage { get; set; } + /// /// Override this to true if class should be grouped under a container in indicies /// The container class should be defined via IndexContainer diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index 20df731a78..87b90b824f 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -1,7 +1,8 @@ - +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { - public class Book : BaseItem + public class Book : BaseItem, IHasTags { public override string MediaType { @@ -10,6 +11,11 @@ namespace MediaBrowser.Controller.Entities return Model.Entities.MediaType.Book; } } + /// + /// Gets or sets the tags. + /// + /// The tags. + public List Tags { get; set; } public string SeriesName { get; set; } @@ -31,5 +37,10 @@ namespace MediaBrowser.Controller.Entities return !IsInMixedFolder; } } + + public Book() + { + Tags = new List(); + } } } diff --git a/MediaBrowser.Controller/Entities/IHasMediaStreams.cs b/MediaBrowser.Controller/Entities/IHasMediaStreams.cs new file mode 100644 index 0000000000..b700ef628a --- /dev/null +++ b/MediaBrowser.Controller/Entities/IHasMediaStreams.cs @@ -0,0 +1,10 @@ + +namespace MediaBrowser.Controller.Entities +{ + /// + /// This is essentially a marker interface + /// + public interface IHasMediaStreams + { + } +} diff --git a/MediaBrowser.Controller/Entities/IHasScreenshots.cs b/MediaBrowser.Controller/Entities/IHasScreenshots.cs index 341d6403f2..2276c707a7 100644 --- a/MediaBrowser.Controller/Entities/IHasScreenshots.cs +++ b/MediaBrowser.Controller/Entities/IHasScreenshots.cs @@ -12,5 +12,10 @@ namespace MediaBrowser.Controller.Entities /// /// The screenshot image paths. List ScreenshotImagePaths { get; set; } + + /// + /// Validates the screenshots. + /// + void ValidateScreenshots(); } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 9b02571b00..425e418ed6 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -22,11 +22,28 @@ namespace MediaBrowser.Controller.Entities public Video() { - MediaStreams = new List(); PlayableStreamFileNames = new List(); AdditionalPartIds = new List(); } + /// + /// Gets or sets a value indicating whether this instance has subtitles. + /// + /// true if this instance has subtitles; otherwise, false. + public bool HasSubtitles { get; set; } + + /// + /// Gets or sets the video bit rate. + /// + /// The video bit rate. + public int? VideoBitRate { get; set; } + + /// + /// Gets or sets the default index of the video stream. + /// + /// The default index of the video stream. + public int? DefaultVideoStreamIndex { get; set; } + /// /// Gets or sets the type of the video. /// @@ -45,12 +62,6 @@ namespace MediaBrowser.Controller.Entities /// The video3 D format. public Video3DFormat? Video3DFormat { get; set; } - /// - /// Gets or sets the media streams. - /// - /// The media streams. - public List MediaStreams { get; set; } - /// /// If the video is a folder-rip, this will hold the file list for the largest playlist /// @@ -70,7 +81,7 @@ namespace MediaBrowser.Controller.Entities /// /// The aspect ratio. public string AspectRatio { get; set; } - + /// /// Should be overridden to return the proper folder where metadata lives /// @@ -122,16 +133,6 @@ namespace MediaBrowser.Controller.Entities .ToList(); } - /// - /// The default video stream for this video. Use this to determine media info for this item. - /// - /// The default video stream. - [IgnoreDataMember] - public MediaStream DefaultVideoStream - { - get { return MediaStreams != null ? MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video) : null; } - } - /// /// Gets a value indicating whether [is3 D]. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 03aa1413b1..21c9e39f19 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -93,6 +93,7 @@ + @@ -124,6 +125,7 @@ + diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs index fd1b12c2f2..e53acfc023 100644 --- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs +++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.MediaInfo return Path.Combine(_appPaths.CachePath, "subtitles"); } } - + /// /// The first chapter ticks /// @@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.MediaInfo public async Task PopulateChapterImages(Video video, List chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken) { // Can't extract images if there are no video streams - if (video.MediaStreams == null || video.MediaStreams.All(m => m.Type != MediaStreamType.Video)) + if (!video.DefaultVideoStreamIndex.HasValue) { return true; } @@ -164,7 +164,7 @@ namespace MediaBrowser.Controller.MediaInfo var parentPath = Path.GetDirectoryName(path); Directory.CreateDirectory(parentPath); - + await _encoder.ExtractImage(inputPath, type, video.Video3DFormat, time, path, cancellationToken).ConfigureAwait(false); chapter.ImagePath = path; changesMade = true; @@ -203,7 +203,17 @@ namespace MediaBrowser.Controller.MediaInfo { var ticksParam = offset.HasValue ? "_" + offset.Value.Ticks : ""; - var stream = input.MediaStreams[subtitleStreamIndex]; + var stream = _itemRepo.GetMediaStreams(new MediaStreamQuery + { + ItemId = input.Id, + Index = subtitleStreamIndex + + }).FirstOrDefault(); + + if (stream == null) + { + return null; + } if (stream.IsExternal) { diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index e04f256053..3a5cb4e870 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -95,6 +95,22 @@ namespace MediaBrowser.Controller.Persistence /// The cancellation token. /// Task. Task SaveChildren(Guid parentId, IEnumerable children, CancellationToken cancellationToken); + + /// + /// Gets the media streams. + /// + /// The query. + /// IEnumerable{MediaStream}. + IEnumerable GetMediaStreams(MediaStreamQuery query); + + /// + /// Saves the media streams. + /// + /// The identifier. + /// The streams. + /// The cancellation token. + /// Task. + Task SaveMediaStreams(Guid id, IEnumerable streams, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Persistence/MediaStreamQuery.cs b/MediaBrowser.Controller/Persistence/MediaStreamQuery.cs new file mode 100644 index 0000000000..10985f57db --- /dev/null +++ b/MediaBrowser.Controller/Persistence/MediaStreamQuery.cs @@ -0,0 +1,26 @@ +using MediaBrowser.Model.Entities; +using System; + +namespace MediaBrowser.Controller.Persistence +{ + public class MediaStreamQuery + { + /// + /// Gets or sets the type. + /// + /// The type. + public MediaStreamType? Type { get; set; } + + /// + /// Gets or sets the index. + /// + /// The index. + public int? Index { get; set; } + + /// + /// Gets or sets the item identifier. + /// + /// The item identifier. + public Guid ItemId { get; set; } + } +} diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs index b39205b5dc..7d9739448a 100644 --- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using System; using System.Collections.Generic; @@ -46,6 +45,7 @@ namespace MediaBrowser.Controller.Resolvers ".3gp", ".webm", ".mts", + ".m2v", ".rec" }; -- cgit v1.2.3