Enable hardware acceleration for image extraction

This commit is contained in:
Luke Pulverenti 2017-08-02 03:30:17 -04:00
parent b89af7af43
commit 0ba267f8e2
10 changed files with 413 additions and 71 deletions

View File

@ -12,6 +12,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Xml;
@ -31,6 +32,7 @@ namespace Emby.Dlna.ContentDirectory
private readonly IUserViewManager _userViewManager;
private readonly Func<IMediaEncoder> _mediaEncoder;
protected readonly IXmlReaderSettingsFactory XmlReaderSettingsFactory;
private readonly ITVSeriesManager _tvSeriesManager;
public ContentDirectory(IDlnaManager dlna,
IUserDataManager userDataManager,
@ -39,7 +41,7 @@ namespace Emby.Dlna.ContentDirectory
IServerConfigurationManager config,
IUserManager userManager,
ILogger logger,
IHttpClient httpClient, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager, IUserViewManager userViewManager, Func<IMediaEncoder> mediaEncoder, IXmlReaderSettingsFactory xmlReaderSettingsFactory)
IHttpClient httpClient, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager, IUserViewManager userViewManager, Func<IMediaEncoder> mediaEncoder, IXmlReaderSettingsFactory xmlReaderSettingsFactory, ITVSeriesManager tvSeriesManager)
: base(logger, httpClient)
{
_dlna = dlna;
@ -54,6 +56,7 @@ namespace Emby.Dlna.ContentDirectory
_userViewManager = userViewManager;
_mediaEncoder = mediaEncoder;
XmlReaderSettingsFactory = xmlReaderSettingsFactory;
_tvSeriesManager = tvSeriesManager;
}
private int SystemUpdateId
@ -97,7 +100,8 @@ namespace Emby.Dlna.ContentDirectory
_mediaSourceManager,
_userViewManager,
_mediaEncoder(),
XmlReaderSettingsFactory)
XmlReaderSettingsFactory,
_tvSeriesManager)
.ProcessControlRequest(request);
}

View File

@ -27,6 +27,7 @@ using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Playlists;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Xml;
@ -40,6 +41,7 @@ namespace Emby.Dlna.ContentDirectory
private readonly IServerConfigurationManager _config;
private readonly User _user;
private readonly IUserViewManager _userViewManager;
private readonly ITVSeriesManager _tvSeriesManager;
private const string NS_DC = "http://purl.org/dc/elements/1.1/";
private const string NS_DIDL = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
@ -53,7 +55,7 @@ namespace Emby.Dlna.ContentDirectory
private readonly DeviceProfile _profile;
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, string accessToken, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager, IUserViewManager userViewManager, IMediaEncoder mediaEncoder, IXmlReaderSettingsFactory xmlReaderSettingsFactory)
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, string accessToken, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager, IUserViewManager userViewManager, IMediaEncoder mediaEncoder, IXmlReaderSettingsFactory xmlReaderSettingsFactory, ITVSeriesManager tvSeriesManager)
: base(config, logger, xmlReaderSettingsFactory)
{
_libraryManager = libraryManager;
@ -62,6 +64,7 @@ namespace Emby.Dlna.ContentDirectory
_systemUpdateId = systemUpdateId;
_channelManager = channelManager;
_userViewManager = userViewManager;
_tvSeriesManager = tvSeriesManager;
_profile = profile;
_config = config;
@ -488,6 +491,14 @@ namespace Emby.Dlna.ContentDirectory
{
return GetMusicFolders(item, user, stubType, sort, startIndex, limit);
}
if (collectionFolder != null && string.Equals(CollectionType.Movies, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase))
{
return GetMovieFolders(item, user, stubType, sort, startIndex, limit);
}
if (collectionFolder != null && string.Equals(CollectionType.TvShows, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase))
{
return GetTvFolders(item, user, stubType, sort, startIndex, limit);
}
if (stubType.HasValue)
{
@ -656,6 +667,231 @@ namespace Emby.Dlna.ContentDirectory
};
}
private QueryResult<ServerItem> GetMovieFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
{
var query = new InternalItemsQuery(user)
{
StartIndex = startIndex,
Limit = limit
};
SetSorting(query, sort, false);
if (stubType.HasValue && stubType.Value == StubType.ContinueWatching)
{
return GetMovieContinueWatching(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Latest)
{
return GetMovieLatest(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Movies)
{
return GetMovieMovies(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Collections)
{
return GetMovieCollections(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Favorites)
{
return GetMovieFavorites(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Genres)
{
return GetGenres(item, user, query);
}
var list = new List<ServerItem>();
list.Add(new ServerItem(item)
{
StubType = StubType.ContinueWatching
});
list.Add(new ServerItem(item)
{
StubType = StubType.Latest
});
list.Add(new ServerItem(item)
{
StubType = StubType.Movies
});
list.Add(new ServerItem(item)
{
StubType = StubType.Collections
});
list.Add(new ServerItem(item)
{
StubType = StubType.Favorites
});
list.Add(new ServerItem(item)
{
StubType = StubType.Genres
});
return new QueryResult<ServerItem>
{
Items = list.ToArray(),
TotalRecordCount = list.Count
};
}
private QueryResult<ServerItem> GetTvFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
{
var query = new InternalItemsQuery(user)
{
StartIndex = startIndex,
Limit = limit
};
SetSorting(query, sort, false);
if (stubType.HasValue && stubType.Value == StubType.ContinueWatching)
{
return GetMovieContinueWatching(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.NextUp)
{
return GetNextUp(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Latest)
{
return GetTvLatest(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Series)
{
return GetSeries(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.FavoriteSeries)
{
return GetFavoriteSeries(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.FavoriteEpisodes)
{
return GetFavoriteEpisodes(item, user, query);
}
if (stubType.HasValue && stubType.Value == StubType.Genres)
{
return GetGenres(item, user, query);
}
var list = new List<ServerItem>();
list.Add(new ServerItem(item)
{
StubType = StubType.ContinueWatching
});
list.Add(new ServerItem(item)
{
StubType = StubType.NextUp
});
list.Add(new ServerItem(item)
{
StubType = StubType.Latest
});
list.Add(new ServerItem(item)
{
StubType = StubType.Series
});
list.Add(new ServerItem(item)
{
StubType = StubType.FavoriteSeries
});
list.Add(new ServerItem(item)
{
StubType = StubType.FavoriteEpisodes
});
list.Add(new ServerItem(item)
{
StubType = StubType.Genres
});
return new QueryResult<ServerItem>
{
Items = list.ToArray(),
TotalRecordCount = list.Count
};
}
private QueryResult<ServerItem> GetMovieContinueWatching(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
query.Parent = parent;
query.SetUser(user);
query.OrderBy = new List<Tuple<string, SortOrder>>
{
new Tuple<string, SortOrder> (ItemSortBy.DatePlayed, SortOrder.Descending),
new Tuple<string, SortOrder> (ItemSortBy.SortName, SortOrder.Ascending)
};
query.IsResumable = true;
query.Limit = 10;
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetSeries(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
query.Parent = parent;
query.SetUser(user);
query.IncludeItemTypes = new[] { typeof(Series).Name };
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetMovieMovies(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
query.Parent = parent;
query.SetUser(user);
query.IncludeItemTypes = new[] { typeof(Movie).Name };
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetMovieCollections(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
//query.Parent = parent;
query.SetUser(user);
query.IncludeItemTypes = new[] { typeof(BoxSet).Name };
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetMusicAlbums(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
@ -695,6 +931,45 @@ namespace Emby.Dlna.ContentDirectory
return ToResult(result);
}
private QueryResult<ServerItem> GetFavoriteSeries(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
query.Parent = parent;
query.SetUser(user);
query.IsFavorite = true;
query.IncludeItemTypes = new[] { typeof(Series).Name };
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetFavoriteEpisodes(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
query.Parent = parent;
query.SetUser(user);
query.IsFavorite = true;
query.IncludeItemTypes = new[] { typeof(Episode).Name };
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetMovieFavorites(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
query.Parent = parent;
query.SetUser(user);
query.IsFavorite = true;
query.IncludeItemTypes = new[] { typeof(Movie).Name };
var result = _libraryManager.GetItemsResult(query);
return ToResult(result);
}
private QueryResult<ServerItem> GetFavoriteAlbums(BaseItem parent, User user, InternalItemsQuery query)
{
query.Recursive = true;
@ -708,6 +983,24 @@ namespace Emby.Dlna.ContentDirectory
return ToResult(result);
}
private QueryResult<ServerItem> GetGenres(BaseItem parent, User user, InternalItemsQuery query)
{
var genresResult = _libraryManager.GetGenres(new InternalItemsQuery(user)
{
AncestorIds = new[] { parent.Id.ToString("N") },
StartIndex = query.StartIndex,
Limit = query.Limit
});
var result = new QueryResult<BaseItem>
{
TotalRecordCount = genresResult.TotalRecordCount,
Items = genresResult.Items.Select(i => i.Item1).ToArray()
};
return ToResult(result);
}
private QueryResult<ServerItem> GetMusicGenres(BaseItem parent, User user, InternalItemsQuery query)
{
var genresResult = _libraryManager.GetMusicGenres(new InternalItemsQuery(user)
@ -810,6 +1103,55 @@ namespace Emby.Dlna.ContentDirectory
return ToResult(items);
}
private QueryResult<ServerItem> GetNextUp(BaseItem parent, User user, InternalItemsQuery query)
{
query.SortBy = new string[] { };
var result = _tvSeriesManager.GetNextUp(new NextUpQuery
{
Limit = query.Limit,
StartIndex = query.StartIndex,
UserId = query.User.Id.ToString("N")
}, new List<Folder> { (Folder)parent }, query.DtoOptions);
return ToResult(result);
}
private QueryResult<ServerItem> GetTvLatest(BaseItem parent, User user, InternalItemsQuery query)
{
query.SortBy = new string[] { };
var items = _userViewManager.GetLatestItems(new LatestItemsQuery
{
UserId = user.Id.ToString("N"),
Limit = 50,
IncludeItemTypes = new[] { typeof(Episode).Name },
ParentId = parent == null ? null : parent.Id.ToString("N"),
GroupItems = true
}, query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToList();
return ToResult(items);
}
private QueryResult<ServerItem> GetMovieLatest(BaseItem parent, User user, InternalItemsQuery query)
{
query.SortBy = new string[] { };
var items = _userViewManager.GetLatestItems(new LatestItemsQuery
{
UserId = user.Id.ToString("N"),
Limit = 50,
IncludeItemTypes = new[] { typeof(Movie).Name },
ParentId = parent == null ? null : parent.Id.ToString("N"),
GroupItems = true
}, query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToList();
return ToResult(items);
}
private QueryResult<ServerItem> GetMusicArtistItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit)
{
var query = new InternalItemsQuery(user)
@ -942,65 +1284,16 @@ namespace Emby.Dlna.ContentDirectory
id = parts[23];
}
if (id.StartsWith("folder_", StringComparison.OrdinalIgnoreCase))
var enumNames = Enum.GetNames(typeof(StubType));
foreach (var name in enumNames)
{
stubType = StubType.Folder;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("people_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.People;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("latest_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.Latest;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("playlists_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.Playlists;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("Albums_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.Albums;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("AlbumArtists_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.AlbumArtists;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("Artists_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.Artists;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("Genres_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.Genres;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("Songs_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.Songs;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("FavoriteAlbums_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.FavoriteAlbums;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("FavoriteArtists_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.FavoriteArtists;
id = id.Split(new[] { '_' }, 2)[1];
}
else if (id.StartsWith("FavoriteSongs_", StringComparison.OrdinalIgnoreCase))
{
stubType = StubType.FavoriteSongs;
id = id.Split(new[] { '_' }, 2)[1];
if (id.StartsWith(name + "_", StringComparison.OrdinalIgnoreCase))
{
stubType = (StubType)Enum.Parse(typeof(StubType), name, true);
id = id.Split(new[] { '_' }, 2)[1];
break;
}
}
if (Guid.TryParse(id, out itemId))
@ -1048,6 +1341,14 @@ namespace Emby.Dlna.ContentDirectory
Genres = 8,
FavoriteSongs = 9,
FavoriteArtists = 10,
FavoriteAlbums = 11
FavoriteAlbums = 11,
ContinueWatching = 12,
Movies = 13,
Collections = 14,
Favorites = 15,
NextUp = 16,
Series = 17,
FavoriteSeries = 18,
FavoriteEpisodes = 19
}
}

View File

@ -439,6 +439,38 @@ namespace Emby.Dlna.Didl
{
return _localization.GetLocalizedString("ViewTypeMusicFavoriteSongs");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.ContinueWatching)
{
return _localization.GetLocalizedString("ViewTypeMovieResume");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.Movies)
{
return _localization.GetLocalizedString("ViewTypeMovieMovies");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.Collections)
{
return _localization.GetLocalizedString("ViewTypeMovieCollections");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.Favorites)
{
return _localization.GetLocalizedString("ViewTypeMovieFavorites");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.NextUp)
{
return _localization.GetLocalizedString("ViewTypeTvNextUp");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.FavoriteSeries)
{
return _localization.GetLocalizedString("ViewTypeTvFavoriteSeries");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.FavoriteEpisodes)
{
return _localization.GetLocalizedString("ViewTypeTvFavoriteEpisodes");
}
if (itemStubType.HasValue && itemStubType.Value == StubType.Series)
{
return _localization.GetLocalizedString("ViewTypeTvShowSeries");
}
var episode = item as Episode;
var season = context as Season;

View File

@ -667,7 +667,7 @@ namespace Emby.Server.Core
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
RegisterSingleInstance(UserViewManager);
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager, UserViewManager, () => MediaEncoder, new XmlReaderSettingsFactory());
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager, UserViewManager, () => MediaEncoder, new XmlReaderSettingsFactory(), TVSeriesManager);
RegisterSingleInstance<IContentDirectory>(contentDirectory);
var mediaRegistrar = new MediaReceiverRegistrar(LogManager.GetLogger("MediaReceiverRegistrar"), HttpClient, ServerConfigurationManager, new XmlReaderSettingsFactory());

View File

@ -69,7 +69,7 @@
"ViewTypeTvResume": "Resume",
"ViewTypeTvNextUp": "Next Up",
"ViewTypeTvLatest": "Latest",
"ViewTypeTvShowSeries": "Series",
"ViewTypeTvShowSeries": "Shows",
"ViewTypeTvGenres": "Genres",
"ViewTypeTvFavoriteSeries": "Favorite Series",
"ViewTypeTvFavoriteEpisodes": "Favorite Episodes",

View File

@ -164,7 +164,7 @@ namespace MediaBrowser.Model.Dto
{
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Video && StringHelper.IndexOfIgnoreCase(i.Codec ?? string.Empty, "jpeg") == -1)
if (i.Type == MediaStreamType.Video)
{
return i;
}

View File

@ -60,10 +60,15 @@ namespace MediaBrowser.XbmcMetadata.Parsers
movie.SetProviderId(MetadataProviders.TmdbCollection, tmdbcolid);
}
var val = reader.ReadElementContentAsString();
var val = reader.ReadInnerXml();
if (!string.IsNullOrWhiteSpace(val) && movie != null)
{
movie.CollectionName = val;
// TODO Handle this better later
if (val.IndexOf('<') == -1)
{
movie.CollectionName = val;
}
}
break;

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.709</version>
<version>3.0.710</version>
<title>Emby.Common</title>
<authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.709</version>
<version>3.0.710</version>
<title>Emby.Server.Core</title>
<authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Emby Server.</description>
<copyright>Copyright © Emby 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.709" />
<dependency id="MediaBrowser.Common" version="3.0.710" />
</dependencies>
</metadata>
<files>

View File

@ -1,3 +1,3 @@
using System.Reflection;
[assembly: AssemblyVersion("3.2.26.11")]
[assembly: AssemblyVersion("3.2.26.12")]