aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-05 22:39:44 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-05 22:39:44 -0500
commit5f0d8000a5ec26fd66c5f188f3bb517bb139b74b (patch)
tree769514a446fc33ba812d1a9a05a66f0845c9e590 /MediaBrowser.Controller
parentebe483db9a5d31528a644200a71f2b36ac2864bd (diff)
moved media streams to the database
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/Audio/Audio.cs14
-rw-r--r--MediaBrowser.Controller/Entities/Book.cs15
-rw-r--r--MediaBrowser.Controller/Entities/IHasMediaStreams.cs10
-rw-r--r--MediaBrowser.Controller/Entities/IHasScreenshots.cs5
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs37
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj2
-rw-r--r--MediaBrowser.Controller/MediaInfo/FFMpegManager.cs18
-rw-r--r--MediaBrowser.Controller/Persistence/IItemRepository.cs16
-rw-r--r--MediaBrowser.Controller/Persistence/MediaStreamQuery.cs26
-rw-r--r--MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs2
10 files changed, 112 insertions, 33 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs
index 2a7aa4fea..63c907c1f 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<MediaStream>();
Artists = new List<string>();
}
@@ -22,13 +20,13 @@ namespace MediaBrowser.Controller.Entities.Audio
/// </summary>
/// <value>The language.</value>
public string Language { get; set; }
-
+
/// <summary>
- /// Gets or sets the media streams.
+ /// Gets or sets a value indicating whether this instance has embedded image.
/// </summary>
- /// <value>The media streams.</value>
- public List<MediaStream> MediaStreams { get; set; }
-
+ /// <value><c>true</c> if this instance has embedded image; otherwise, <c>false</c>.</value>
+ public bool HasEmbeddedImage { get; set; }
+
/// <summary>
/// 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 20df731a7..87b90b824 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;
}
}
+ /// <summary>
+ /// Gets or sets the tags.
+ /// </summary>
+ /// <value>The tags.</value>
+ public List<string> Tags { get; set; }
public string SeriesName { get; set; }
@@ -31,5 +37,10 @@ namespace MediaBrowser.Controller.Entities
return !IsInMixedFolder;
}
}
+
+ public Book()
+ {
+ Tags = new List<string>();
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/IHasMediaStreams.cs b/MediaBrowser.Controller/Entities/IHasMediaStreams.cs
new file mode 100644
index 000000000..b700ef628
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/IHasMediaStreams.cs
@@ -0,0 +1,10 @@
+
+namespace MediaBrowser.Controller.Entities
+{
+ /// <summary>
+ /// This is essentially a marker interface
+ /// </summary>
+ public interface IHasMediaStreams
+ {
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/IHasScreenshots.cs b/MediaBrowser.Controller/Entities/IHasScreenshots.cs
index 341d6403f..2276c707a 100644
--- a/MediaBrowser.Controller/Entities/IHasScreenshots.cs
+++ b/MediaBrowser.Controller/Entities/IHasScreenshots.cs
@@ -12,5 +12,10 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The screenshot image paths.</value>
List<string> ScreenshotImagePaths { get; set; }
+
+ /// <summary>
+ /// Validates the screenshots.
+ /// </summary>
+ void ValidateScreenshots();
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 9b02571b0..425e418ed 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -22,12 +22,29 @@ namespace MediaBrowser.Controller.Entities
public Video()
{
- MediaStreams = new List<MediaStream>();
PlayableStreamFileNames = new List<string>();
AdditionalPartIds = new List<Guid>();
}
/// <summary>
+ /// Gets or sets a value indicating whether this instance has subtitles.
+ /// </summary>
+ /// <value><c>true</c> if this instance has subtitles; otherwise, <c>false</c>.</value>
+ public bool HasSubtitles { get; set; }
+
+ /// <summary>
+ /// Gets or sets the video bit rate.
+ /// </summary>
+ /// <value>The video bit rate.</value>
+ public int? VideoBitRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the default index of the video stream.
+ /// </summary>
+ /// <value>The default index of the video stream.</value>
+ public int? DefaultVideoStreamIndex { get; set; }
+
+ /// <summary>
/// Gets or sets the type of the video.
/// </summary>
/// <value>The type of the video.</value>
@@ -46,12 +63,6 @@ namespace MediaBrowser.Controller.Entities
public Video3DFormat? Video3DFormat { get; set; }
/// <summary>
- /// Gets or sets the media streams.
- /// </summary>
- /// <value>The media streams.</value>
- public List<MediaStream> MediaStreams { get; set; }
-
- /// <summary>
/// If the video is a folder-rip, this will hold the file list for the largest playlist
/// </summary>
public List<string> PlayableStreamFileNames { get; set; }
@@ -70,7 +81,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The aspect ratio.</value>
public string AspectRatio { get; set; }
-
+
/// <summary>
/// Should be overridden to return the proper folder where metadata lives
/// </summary>
@@ -123,16 +134,6 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
- /// The default video stream for this video. Use this to determine media info for this item.
- /// </summary>
- /// <value>The default video stream.</value>
- [IgnoreDataMember]
- public MediaStream DefaultVideoStream
- {
- get { return MediaStreams != null ? MediaStreams.FirstOrDefault(s => s.Type == MediaStreamType.Video) : null; }
- }
-
- /// <summary>
/// Gets a value indicating whether [is3 D].
/// </summary>
/// <value><c>true</c> if [is3 D]; otherwise, <c>false</c>.</value>
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 03aa1413b..21c9e39f1 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -93,6 +93,7 @@
<Compile Include="Entities\IHasBudget.cs" />
<Compile Include="Entities\IHasCriticRating.cs" />
<Compile Include="Entities\IHasLanguage.cs" />
+ <Compile Include="Entities\IHasMediaStreams.cs" />
<Compile Include="Entities\IHasProductionLocations.cs" />
<Compile Include="Entities\IHasScreenshots.cs" />
<Compile Include="Entities\IHasSoundtracks.cs" />
@@ -124,6 +125,7 @@
<Compile Include="Localization\ILocalizationManager.cs" />
<Compile Include="Notifications\INotificationsRepository.cs" />
<Compile Include="Notifications\NotificationUpdateEventArgs.cs" />
+ <Compile Include="Persistence\MediaStreamQuery.cs" />
<Compile Include="Providers\IDynamicInfoProvider.cs" />
<Compile Include="Providers\IImageProvider.cs" />
<Compile Include="Providers\NameParser.cs" />
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
index fd1b12c2f..e53acfc02 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");
}
}
-
+
/// <summary>
/// The first chapter ticks
/// </summary>
@@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.MediaInfo
public async Task<bool> PopulateChapterImages(Video video, List<ChapterInfo> 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 e04f25605..3a5cb4e87 100644
--- a/MediaBrowser.Controller/Persistence/IItemRepository.cs
+++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs
@@ -95,6 +95,22 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
Task SaveChildren(Guid parentId, IEnumerable<Guid> children, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Gets the media streams.
+ /// </summary>
+ /// <param name="query">The query.</param>
+ /// <returns>IEnumerable{MediaStream}.</returns>
+ IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query);
+
+ /// <summary>
+ /// Saves the media streams.
+ /// </summary>
+ /// <param name="id">The identifier.</param>
+ /// <param name="streams">The streams.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task.</returns>
+ Task SaveMediaStreams(Guid id, IEnumerable<MediaStream> streams, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/Persistence/MediaStreamQuery.cs b/MediaBrowser.Controller/Persistence/MediaStreamQuery.cs
new file mode 100644
index 000000000..10985f57d
--- /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
+ {
+ /// <summary>
+ /// Gets or sets the type.
+ /// </summary>
+ /// <value>The type.</value>
+ public MediaStreamType? Type { get; set; }
+
+ /// <summary>
+ /// Gets or sets the index.
+ /// </summary>
+ /// <value>The index.</value>
+ public int? Index { get; set; }
+
+ /// <summary>
+ /// Gets or sets the item identifier.
+ /// </summary>
+ /// <value>The item identifier.</value>
+ public Guid ItemId { get; set; }
+ }
+}
diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
index b39205b5d..7d9739448 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"
};