added SupportsExternalStream to MediaStream
This commit is contained in:
parent
49c0878a4b
commit
9110d23710
|
@ -239,7 +239,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
{
|
||||
Id = i.Id.ToString("N"),
|
||||
Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
|
||||
MediaStreams = ItemRepository.GetMediaStreams(new MediaStreamQuery { ItemId = i.Id }).ToList(),
|
||||
MediaStreams = MediaSourceManager.GetMediaStreams(new MediaStreamQuery { ItemId = i.Id }).ToList(),
|
||||
Name = i.Name,
|
||||
Path = enablePathSubstituion ? GetMappedPath(i.Path, locationType) : i.Path,
|
||||
RunTimeTicks = i.RunTimeTicks,
|
||||
|
|
|
@ -300,6 +300,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
public static IChannelManager ChannelManager { get; set; }
|
||||
public static ICollectionManager CollectionManager { get; set; }
|
||||
public static IImageProcessor ImageProcessor { get; set; }
|
||||
public static IMediaSourceManager MediaSourceManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="System.String" /> that represents this instance.
|
||||
|
|
|
@ -422,7 +422,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public virtual IEnumerable<MediaStream> GetMediaStreams()
|
||||
{
|
||||
return ItemRepository.GetMediaStreams(new MediaStreamQuery
|
||||
return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
|
||||
{
|
||||
ItemId = Id
|
||||
});
|
||||
|
@ -435,7 +435,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
return null;
|
||||
}
|
||||
|
||||
return ItemRepository.GetMediaStreams(new MediaStreamQuery
|
||||
return MediaSourceManager.GetMediaStreams(new MediaStreamQuery
|
||||
{
|
||||
ItemId = Id,
|
||||
Index = DefaultVideoStreamIndex.Value
|
||||
|
@ -474,7 +474,8 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type)
|
||||
{
|
||||
var mediaStreams = ItemRepository.GetMediaStreams(new MediaStreamQuery { ItemId = i.Id }).ToList();
|
||||
var mediaStreams = MediaSourceManager.GetMediaStreams(new MediaStreamQuery { ItemId = i.Id })
|
||||
.ToList();
|
||||
|
||||
var locationType = i.LocationType;
|
||||
|
||||
|
|
11
MediaBrowser.Controller/Library/IMediaSourceManager.cs
Normal file
11
MediaBrowser.Controller/Library/IMediaSourceManager.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
public interface IMediaSourceManager
|
||||
{
|
||||
IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query);
|
||||
}
|
||||
}
|
|
@ -170,6 +170,7 @@
|
|||
<Compile Include="FileOrganization\IFileOrganizationService.cs" />
|
||||
<Compile Include="Library\DeleteOptions.cs" />
|
||||
<Compile Include="Library\ILibraryPostScanTask.cs" />
|
||||
<Compile Include="Library\IMediaSourceManager.cs" />
|
||||
<Compile Include="Library\IMetadataFileSaver.cs" />
|
||||
<Compile Include="Library\IMetadataSaver.cs" />
|
||||
<Compile Include="Library\IMusicManager.cs" />
|
||||
|
|
|
@ -90,10 +90,16 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
|
||||
return index == -1 ? 100 : index;
|
||||
})
|
||||
.ThenBy(i => i.IsDefault)
|
||||
.ThenBy(i => i.IsTextSubtitleStream)
|
||||
.ThenBy(i => i.IsExternal)
|
||||
.ThenBy(i => GetBooleanOrderBy(i.IsDefault))
|
||||
.ThenBy(i => GetBooleanOrderBy(i.SupportsExternalStream))
|
||||
.ThenBy(i => GetBooleanOrderBy(i.IsTextSubtitleStream))
|
||||
.ThenBy(i => GetBooleanOrderBy(i.IsExternal))
|
||||
.ThenBy(i => i.Index);
|
||||
}
|
||||
|
||||
private static int GetBooleanOrderBy(bool value)
|
||||
{
|
||||
return value ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -543,9 +543,12 @@ namespace MediaBrowser.Model.Dlna
|
|||
// Look for an external profile that matches the stream type (text/graphical)
|
||||
foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles)
|
||||
{
|
||||
if (profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
|
||||
if (subtitleStream.SupportsExternalStream)
|
||||
{
|
||||
return profile;
|
||||
if (profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace MediaBrowser.Model.Entities
|
|||
/// </summary>
|
||||
/// <value>The reference frames.</value>
|
||||
public int? RefFrames { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the length of the packet.
|
||||
/// </summary>
|
||||
|
@ -156,6 +156,12 @@ namespace MediaBrowser.Model.Entities
|
|||
!StringHelper.EqualsIgnoreCase(codec, "sub");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [supports external stream].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [supports external stream]; otherwise, <c>false</c>.</value>
|
||||
public bool SupportsExternalStream { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the filename.
|
||||
/// </summary>
|
||||
|
|
|
@ -27,18 +27,18 @@ namespace MediaBrowser.Providers.Subtitles
|
|||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryMonitor _monitor;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
|
||||
public event EventHandler<SubtitleDownloadEventArgs> SubtitlesDownloaded;
|
||||
public event EventHandler<SubtitleDownloadFailureEventArgs> SubtitleDownloadFailure;
|
||||
|
||||
public SubtitleManager(ILogger logger, IFileSystem fileSystem, ILibraryMonitor monitor, ILibraryManager libraryManager, IItemRepository itemRepo)
|
||||
public SubtitleManager(ILogger logger, IFileSystem fileSystem, ILibraryMonitor monitor, ILibraryManager libraryManager, IMediaSourceManager mediaSourceManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
_monitor = monitor;
|
||||
_libraryManager = libraryManager;
|
||||
_itemRepo = itemRepo;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
}
|
||||
|
||||
public void AddParts(IEnumerable<ISubtitleProvider> subtitleProviders)
|
||||
|
@ -232,7 +232,7 @@ namespace MediaBrowser.Providers.Subtitles
|
|||
|
||||
public Task DeleteSubtitles(string itemId, int index)
|
||||
{
|
||||
var stream = _itemRepo.GetMediaStreams(new MediaStreamQuery
|
||||
var stream = _mediaSourceManager.GetMediaStreams(new MediaStreamQuery
|
||||
{
|
||||
Index = index,
|
||||
ItemId = new Guid(itemId),
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
public class MediaSourceManager : IMediaSourceManager
|
||||
{
|
||||
private readonly IItemRepository _itemRepo;
|
||||
|
||||
public MediaSourceManager(IItemRepository itemRepo)
|
||||
{
|
||||
_itemRepo = itemRepo;
|
||||
}
|
||||
|
||||
public IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query)
|
||||
{
|
||||
var list = _itemRepo.GetMediaStreams(query)
|
||||
.ToList();
|
||||
|
||||
foreach (var stream in list)
|
||||
{
|
||||
stream.SupportsExternalStream = StreamSupportsExternalStream(stream);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private bool StreamSupportsExternalStream(MediaStream stream)
|
||||
{
|
||||
if (stream.IsExternal)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (stream.IsTextSubtitleStream)
|
||||
{
|
||||
return InternalTextStreamSupportsExternalStream(stream);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool InternalTextStreamSupportsExternalStream(MediaStream stream)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -185,6 +185,7 @@
|
|||
<Compile Include="Library\CoreResolutionIgnoreRule.cs" />
|
||||
<Compile Include="Library\LibraryManager.cs" />
|
||||
<Compile Include="Library\LocalTrailerPostScanTask.cs" />
|
||||
<Compile Include="Library\MediaSourceManager.cs" />
|
||||
<Compile Include="Library\MusicManager.cs" />
|
||||
<Compile Include="Library\PathExtensions.cs" />
|
||||
<Compile Include="Library\Resolvers\SpecialFolderResolver.cs" />
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
private readonly IMusicManager _musicManager;
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly IImageProcessor _imageProcessor;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly IJsonSerializer _jsonSerializer;
|
||||
|
@ -97,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
|
||||
private readonly SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
|
||||
|
||||
public SessionManager(IUserDataManager userDataRepository, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IItemRepository itemRepo, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager)
|
||||
public SessionManager(IUserDataManager userDataRepository, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager)
|
||||
{
|
||||
_userDataRepository = userDataRepository;
|
||||
_logger = logger;
|
||||
|
@ -107,12 +107,12 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
_musicManager = musicManager;
|
||||
_dtoService = dtoService;
|
||||
_imageProcessor = imageProcessor;
|
||||
_itemRepo = itemRepo;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_appHost = appHost;
|
||||
_httpClient = httpClient;
|
||||
_authRepo = authRepo;
|
||||
_deviceManager = deviceManager;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
|
||||
_deviceManager.DeviceOptionsUpdated += _deviceManager_DeviceOptionsUpdated;
|
||||
}
|
||||
|
@ -1560,7 +1560,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(mediaSourceId))
|
||||
{
|
||||
info.MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery
|
||||
info.MediaStreams = _mediaSourceManager.GetMediaStreams(new MediaStreamQuery
|
||||
{
|
||||
ItemId = new Guid(mediaSourceId)
|
||||
|
||||
|
|
|
@ -616,7 +616,8 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
IsForced = subtitle.IsForced,
|
||||
IsExternal = true,
|
||||
Language = subtitle.Language,
|
||||
Path = fileInfo.Path
|
||||
Path = fileInfo.Path,
|
||||
SupportsExternalStream = true
|
||||
});
|
||||
|
||||
startingIndex++;
|
||||
|
|
|
@ -196,6 +196,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
private ISyncRepository SyncRepository { get; set; }
|
||||
private ITVSeriesManager TVSeriesManager { get; set; }
|
||||
private ICollectionManager CollectionManager { get; set; }
|
||||
private IMediaSourceManager MediaSourceManager { get; set; }
|
||||
|
||||
private readonly StartupOptions _startupOptions;
|
||||
private readonly string _remotePackageName;
|
||||
|
@ -459,7 +460,10 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger, FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));
|
||||
RegisterSingleInstance(DeviceManager);
|
||||
|
||||
SessionManager = new SessionManager(UserDataManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);
|
||||
MediaSourceManager = new MediaSourceManager(ItemRepository);
|
||||
RegisterSingleInstance(MediaSourceManager);
|
||||
|
||||
SessionManager = new SessionManager(UserDataManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
|
||||
RegisterSingleInstance(SessionManager);
|
||||
|
||||
var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
|
||||
|
@ -503,7 +507,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);
|
||||
RegisterSingleInstance(NotificationManager);
|
||||
|
||||
SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, ItemRepository);
|
||||
SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, MediaSourceManager);
|
||||
RegisterSingleInstance(SubtitleManager);
|
||||
|
||||
ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
|
||||
|
@ -696,6 +700,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
Folder.UserViewManager = UserViewManager;
|
||||
UserView.TVSeriesManager = TVSeriesManager;
|
||||
BaseItem.CollectionManager = CollectionManager;
|
||||
BaseItem.MediaSourceManager = MediaSourceManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user