mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 10:04:44 +01:00
Merge branch 'master' into externalid-type
This commit is contained in:
@@ -7,23 +7,29 @@ namespace MediaBrowser.Controller.Authentication
|
||||
/// </summary>
|
||||
public class AuthenticationException : Exception
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthenticationException"/> class.
|
||||
/// </summary>
|
||||
public AuthenticationException() : base()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthenticationException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public AuthenticationException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AuthenticationException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
|
||||
public AuthenticationException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Chapters
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IChapterManager
|
||||
/// Interface IChapterManager.
|
||||
/// </summary>
|
||||
public interface IChapterManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Saves the chapters.
|
||||
/// </summary>
|
||||
void SaveChapters(string itemId, List<ChapterInfo> chapters);
|
||||
void SaveChapters(Guid itemId, IReadOnlyList<ChapterInfo> chapters);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Devices;
|
||||
using MediaBrowser.Model.Events;
|
||||
@@ -11,11 +9,6 @@ namespace MediaBrowser.Controller.Devices
|
||||
{
|
||||
public interface IDeviceManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [camera image uploaded].
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<CameraImageUploadInfo>> CameraImageUploaded;
|
||||
|
||||
/// <summary>
|
||||
/// Saves the capabilities.
|
||||
/// </summary>
|
||||
@@ -45,22 +38,6 @@ namespace MediaBrowser.Controller.Devices
|
||||
/// <returns>IEnumerable<DeviceInfo>.</returns>
|
||||
QueryResult<DeviceInfo> GetDevices(DeviceQuery query);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the upload history.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device identifier.</param>
|
||||
/// <returns>ContentUploadHistory.</returns>
|
||||
ContentUploadHistory GetCameraUploadHistory(string deviceId);
|
||||
|
||||
/// <summary>
|
||||
/// Accepts the upload.
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device identifier.</param>
|
||||
/// <param name="stream">The stream.</param>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance [can access device] the specified user identifier.
|
||||
/// </summary>
|
||||
|
||||
@@ -40,15 +40,6 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// <returns>ImageDimensions</returns>
|
||||
ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dimensions of the image.
|
||||
/// </summary>
|
||||
/// <param name="item">The base item.</param>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <param name="updateItem">Whether or not the item info should be updated.</param>
|
||||
/// <returns>ImageDimensions</returns>
|
||||
ImageDimensions GetImageDimensions(BaseItem item, ItemImageInfo info, bool updateItem);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image cache tag.
|
||||
/// </summary>
|
||||
|
||||
@@ -15,7 +15,6 @@ using MediaBrowser.Controller.Extensions;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
@@ -550,7 +549,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
[JsonIgnore]
|
||||
public DateTime DateModified { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime DateLastSaved { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
@@ -1327,8 +1325,9 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
|
||||
// Use some hackery to get the extra type based on foldername
|
||||
Enum.TryParse(extraFolderName.Replace(" ", ""), true, out ExtraType extraType);
|
||||
item.ExtraType = extraType;
|
||||
item.ExtraType = Enum.TryParse(extraFolderName.Replace(" ", string.Empty), true, out ExtraType extraType)
|
||||
? extraType
|
||||
: Model.Entities.ExtraType.Unknown;
|
||||
|
||||
return item;
|
||||
|
||||
@@ -2741,7 +2740,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
var list = GetEtagValues(user);
|
||||
|
||||
return string.Join("|", list.ToArray()).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
return string.Join("|", list).GetMD5().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
protected virtual List<string> GetEtagValues(User user)
|
||||
@@ -2784,8 +2783,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
var view = this as IHasCollectionType;
|
||||
if (view != null)
|
||||
if (this is IHasCollectionType view)
|
||||
{
|
||||
if (string.Equals(view.CollectionType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -2878,14 +2876,29 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <value>The remote trailers.</value>
|
||||
public IReadOnlyList<MediaUrl> RemoteTrailers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get all extras associated with this item, sorted by <see cref="SortName"/>.
|
||||
/// </summary>
|
||||
/// <returns>An enumerable containing the items.</returns>
|
||||
public IEnumerable<BaseItem> GetExtras()
|
||||
{
|
||||
return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i != null).OrderBy(i => i.SortName);
|
||||
return ExtraIds
|
||||
.Select(LibraryManager.GetItemById)
|
||||
.Where(i => i != null)
|
||||
.OrderBy(i => i.SortName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all extras with specific types that are associated with this item.
|
||||
/// </summary>
|
||||
/// <param name="extraTypes">The types of extras to retrieve.</param>
|
||||
/// <returns>An enumerable containing the extras.</returns>
|
||||
public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
|
||||
{
|
||||
return ExtraIds.Select(LibraryManager.GetItemById).Where(i => i?.ExtraType != null && extraTypes.Contains(i.ExtraType.Value));
|
||||
return ExtraIds
|
||||
.Select(LibraryManager.GetItemById)
|
||||
.Where(i => i != null)
|
||||
.Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value));
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTrailers()
|
||||
@@ -2896,11 +2909,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return Array.Empty<BaseItem>();
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetDisplayExtras()
|
||||
{
|
||||
return GetExtras(DisplayExtraTypes);
|
||||
}
|
||||
|
||||
public virtual bool IsHD => Height >= 720;
|
||||
|
||||
public bool IsShortcut { get; set; }
|
||||
@@ -2918,8 +2926,19 @@ namespace MediaBrowser.Controller.Entities
|
||||
return RunTimeTicks ?? 0;
|
||||
}
|
||||
|
||||
// Possible types of extra videos
|
||||
public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new[] { Model.Entities.ExtraType.BehindTheScenes, Model.Entities.ExtraType.Clip, Model.Entities.ExtraType.DeletedScene, Model.Entities.ExtraType.Interview, Model.Entities.ExtraType.Sample, Model.Entities.ExtraType.Scene };
|
||||
/// <summary>
|
||||
/// Extra types that should be counted and displayed as "Special Features" in the UI.
|
||||
/// </summary>
|
||||
public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new HashSet<ExtraType>
|
||||
{
|
||||
Model.Entities.ExtraType.Unknown,
|
||||
Model.Entities.ExtraType.BehindTheScenes,
|
||||
Model.Entities.ExtraType.Clip,
|
||||
Model.Entities.ExtraType.DeletedScene,
|
||||
Model.Entities.ExtraType.Interview,
|
||||
Model.Entities.ExtraType.Sample,
|
||||
Model.Entities.ExtraType.Scene
|
||||
};
|
||||
|
||||
public virtual bool SupportsExternalTransfer => false;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -28,7 +30,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public class Folder : BaseItem
|
||||
{
|
||||
public static IUserManager UserManager { get; set; }
|
||||
public static IUserViewManager UserViewManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -620,7 +621,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
EnableImages = false
|
||||
}
|
||||
|
||||
}).TotalRecordCount;
|
||||
}
|
||||
|
||||
@@ -864,7 +864,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return SortItemsByRequest(query, result);
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
return result;
|
||||
}
|
||||
|
||||
return GetItemsInternal(query).Items;
|
||||
@@ -1713,7 +1713,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
EnableImages = false
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
double unplayedCount = unplayedQueryResult.TotalRecordCount;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker interface
|
||||
/// Marker interface.
|
||||
/// </summary>
|
||||
public interface IItemByName
|
||||
{
|
||||
|
||||
@@ -4,11 +4,21 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public class InternalPeopleQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of items the query should return.
|
||||
/// </summary>
|
||||
public int Limit { get; set; }
|
||||
|
||||
public Guid ItemId { get; set; }
|
||||
|
||||
public string[] PersonTypes { get; set; }
|
||||
|
||||
public string[] ExcludePersonTypes { get; set; }
|
||||
|
||||
public int? MaxListOrder { get; set; }
|
||||
|
||||
public Guid AppearsInItemId { get; set; }
|
||||
|
||||
public string NameContains { get; set; }
|
||||
|
||||
public InternalPeopleQuery()
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using MediaBrowser.Controller.Extensions;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace MediaBrowser.Controller.Extensions
|
||||
@@ -7,6 +8,11 @@ namespace MediaBrowser.Controller.Extensions
|
||||
/// </summary>
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The key for a setting that indicates whether the application should host web client content.
|
||||
/// </summary>
|
||||
public const string HostWebClientKey = "hostwebclient";
|
||||
|
||||
/// <summary>
|
||||
/// The key for the FFmpeg probe size option.
|
||||
/// </summary>
|
||||
@@ -22,6 +28,15 @@ namespace MediaBrowser.Controller.Extensions
|
||||
/// </summary>
|
||||
public const string PlaylistsAllowDuplicatesKey = "playlists:allowDuplicates";
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>.
|
||||
/// </summary>
|
||||
/// <param name="configuration">The configuration to retrieve the value from.</param>
|
||||
/// <returns>The parsed config value.</returns>
|
||||
/// <exception cref="FormatException">The config value is not a valid bool string. See <see cref="bool.Parse(string)"/>.</exception>
|
||||
public static bool HostWebClient(this IConfiguration configuration)
|
||||
=> configuration.GetValue<bool>(HostWebClientKey);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the FFmpeg probe size from the <see cref="IConfiguration" />.
|
||||
/// </summary>
|
||||
|
||||
@@ -39,10 +39,9 @@ namespace MediaBrowser.Controller
|
||||
int HttpsPort { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [supports HTTPS].
|
||||
/// Gets a value indicating whether the server should listen on an HTTPS port.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [supports HTTPS]; otherwise, <c>false</c>.</value>
|
||||
bool EnableHttps { get; }
|
||||
bool ListenWithHttps { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance has update available.
|
||||
@@ -57,31 +56,56 @@ namespace MediaBrowser.Controller
|
||||
string FriendlyName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local ip address.
|
||||
/// Gets all the local IP addresses of this API instance. Each address is validated by sending a 'ping' request
|
||||
/// to the API that should exist at the address.
|
||||
/// </summary>
|
||||
/// <value>The local ip address.</value>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
|
||||
/// <returns>A list containing all the local IP addresses of the server.</returns>
|
||||
Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local API URL.
|
||||
/// Gets a local (LAN) URL that can be used to access the API. The hostname used is the first valid configured
|
||||
/// IP address that can be found via <see cref="GetLocalIpAddresses"/>. HTTPS will be preferred when available.
|
||||
/// </summary>
|
||||
/// <value>The local API URL.</value>
|
||||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
|
||||
/// <returns>The server URL.</returns>
|
||||
Task<string> GetLocalApiUrl(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local API URL.
|
||||
/// Gets a localhost URL that can be used to access the API using the loop-back IP address (127.0.0.1)
|
||||
/// over HTTP (not HTTPS).
|
||||
/// </summary>
|
||||
/// <param name="hostname">The hostname.</param>
|
||||
/// <returns>The local API URL.</returns>
|
||||
string GetLocalApiUrl(ReadOnlySpan<char> hostname);
|
||||
/// <returns>The API URL.</returns>
|
||||
string GetLoopbackHttpApiUrl();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local API URL.
|
||||
/// Gets a local (LAN) URL that can be used to access the API. HTTPS will be preferred when available.
|
||||
/// </summary>
|
||||
/// <param name="address">The IP address.</param>
|
||||
/// <returns>The local API URL.</returns>
|
||||
/// <param name="address">The IP address to use as the hostname in the URL.</param>
|
||||
/// <returns>The API URL.</returns>
|
||||
string GetLocalApiUrl(IPAddress address);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a local (LAN) URL that can be used to access the API.
|
||||
/// Note: if passing non-null scheme or port it is up to the caller to ensure they form the correct pair.
|
||||
/// </summary>
|
||||
/// <param name="hostname">The hostname to use in the URL.</param>
|
||||
/// <param name="scheme">
|
||||
/// The scheme to use for the URL. If null, the scheme will be selected automatically,
|
||||
/// preferring HTTPS, if available.
|
||||
/// </param>
|
||||
/// <param name="port">
|
||||
/// The port to use for the URL. If null, the port will be selected automatically,
|
||||
/// preferring the HTTPS port, if available.
|
||||
/// </param>
|
||||
/// <returns>The API URL.</returns>
|
||||
string GetLocalApiUrl(ReadOnlySpan<char> hostname, string scheme = null, int? port = null);
|
||||
|
||||
/// <summary>
|
||||
/// Open a URL in an external browser window.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL to open.</param>
|
||||
/// <exception cref="NotSupportedException"><see cref="CanLaunchWebBrowser"/> is false.</exception>
|
||||
void LaunchUrl(string url);
|
||||
|
||||
void EnableLoopback(string appName);
|
||||
@@ -92,7 +116,5 @@ namespace MediaBrowser.Controller
|
||||
string ReverseVirtualPath(string path);
|
||||
|
||||
Task ExecuteHttpHandlerAsync(HttpContext context, Func<Task> next);
|
||||
|
||||
Task ExecuteWebsocketHandlerAsync(HttpContext context, Func<Task> next);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,12 @@ namespace MediaBrowser.Controller
|
||||
string UserConfigurationDirectoryPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the internal metadata path.
|
||||
/// Gets the default internal metadata path.
|
||||
/// </summary>
|
||||
string DefaultInternalMetadataPath { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the internal metadata path, either a custom path or the default.
|
||||
/// </summary>
|
||||
/// <value>The internal metadata path.</value>
|
||||
string InternalMetadataPath { get; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#pragma warning disable CS1591
|
||||
#pragma warning disable SA1600
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
@@ -143,6 +143,14 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <returns>UserDto.</returns>
|
||||
UserDto GetUserDto(User user, string remoteEndPoint = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user public dto.
|
||||
/// </summary>
|
||||
/// <param name="user">Ther user.</param>\
|
||||
/// <param name="remoteEndPoint">The remote end point.</param>
|
||||
/// <returns>A public UserDto, aka a UserDto stripped of personal data.</returns>
|
||||
PublicUserDto GetPublicUserDto(User user, string remoteEndPoint = null);
|
||||
|
||||
/// <summary>
|
||||
/// Authenticates the user.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Extensions;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- ProjectGuid is only included as a requirement for SonarQube analysis -->
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Jellyfin Contributors</Authors>
|
||||
<PackageId>Jellyfin.Controller</PackageId>
|
||||
@@ -8,8 +13,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -78,8 +78,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
|
||||
if (!string.IsNullOrEmpty(hwType)
|
||||
&& encodingOptions.EnableHardwareEncoding
|
||||
&& codecMap.ContainsKey(hwType)
|
||||
&& CheckVaapi(state, hwType, encodingOptions))
|
||||
&& codecMap.ContainsKey(hwType))
|
||||
{
|
||||
var preferredEncoder = codecMap[hwType];
|
||||
|
||||
@@ -93,23 +92,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
return defaultEncoder;
|
||||
}
|
||||
|
||||
private bool CheckVaapi(EncodingJobInfo state, string hwType, EncodingOptions encodingOptions)
|
||||
{
|
||||
if (!string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// No vaapi requested, return OK.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(encodingOptions.VaapiDevice))
|
||||
{
|
||||
// No device specified, return OK.
|
||||
return true;
|
||||
}
|
||||
|
||||
return IsVaapiSupported(state);
|
||||
}
|
||||
|
||||
private bool IsVaapiSupported(EncodingJobInfo state)
|
||||
{
|
||||
var videoStream = state.VideoStream;
|
||||
@@ -424,7 +406,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
|
||||
if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "aac -strict experimental";
|
||||
// Use libfdk_aac for better audio quality if using custom build of FFmpeg which has fdk_aac support
|
||||
if (_mediaEncoder.SupportsEncoder("libfdk_aac"))
|
||||
{
|
||||
return "libfdk_aac";
|
||||
}
|
||||
|
||||
return "aac";
|
||||
}
|
||||
|
||||
if (string.Equals(codec, "mp3", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -460,16 +448,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
if (state.IsVideoRequest
|
||||
&& string.Equals(encodingOptions.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
var hwOutputFormat = "vaapi";
|
||||
|
||||
if (hasGraphicalSubs)
|
||||
{
|
||||
hwOutputFormat = "yuv420p";
|
||||
}
|
||||
|
||||
arg.Append("-hwaccel vaapi -hwaccel_output_format ")
|
||||
.Append(hwOutputFormat)
|
||||
arg.Append("-hwaccel vaapi -hwaccel_output_format vaapi")
|
||||
.Append(" -vaapi_device ")
|
||||
.Append(encodingOptions.VaapiDevice)
|
||||
.Append(' ');
|
||||
@@ -481,19 +460,25 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions);
|
||||
var outputVideoCodec = GetVideoEncoder(state, encodingOptions);
|
||||
|
||||
if (encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv", StringComparison.OrdinalIgnoreCase))
|
||||
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
if (!hasTextSubs)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase))
|
||||
// While using QSV encoder
|
||||
if ((outputVideoCodec ?? string.Empty).IndexOf("qsv", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
arg.Append("-hwaccel qsv ");
|
||||
}
|
||||
else
|
||||
{
|
||||
arg.Append("-init_hw_device qsv=hw -filter_hw_device hw ");
|
||||
// While using QSV decoder
|
||||
if ((videoDecoder ?? string.Empty).IndexOf("qsv", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
arg.Append("-hwaccel qsv ");
|
||||
}
|
||||
// While using SW decoder
|
||||
else
|
||||
{
|
||||
arg.Append("-init_hw_device qsv=hw -filter_hw_device hw ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arg.Append(videoDecoder + " ");
|
||||
}
|
||||
|
||||
arg.Append("-i ")
|
||||
@@ -503,17 +488,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
|
||||
&& state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
|
||||
{
|
||||
if (state.VideoStream != null && state.VideoStream.Width.HasValue)
|
||||
{
|
||||
// This is hacky but not sure how to get the exact subtitle resolution
|
||||
int height = Convert.ToInt32(state.VideoStream.Width.Value / 16.0 * 9.0);
|
||||
|
||||
arg.Append(" -canvas_size ")
|
||||
.Append(state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture))
|
||||
.Append(':')
|
||||
.Append(height.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var subtitlePath = state.SubtitleStream.Path;
|
||||
|
||||
if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -1546,9 +1520,12 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the internal graphical subtitle param.
|
||||
/// Gets the graphical subtitle param.
|
||||
/// </summary>
|
||||
public string GetGraphicalSubtitleParam(EncodingJobInfo state, EncodingOptions options, string outputVideoCodec)
|
||||
public string GetGraphicalSubtitleParam(
|
||||
EncodingJobInfo state,
|
||||
EncodingOptions options,
|
||||
string outputVideoCodec)
|
||||
{
|
||||
var outputSizeParam = string.Empty;
|
||||
|
||||
@@ -1562,53 +1539,77 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
outputSizeParam = GetOutputSizeParam(state, options, outputVideoCodec).TrimEnd('"');
|
||||
|
||||
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
var index = outputSizeParam.IndexOf("hwdownload", StringComparison.OrdinalIgnoreCase);
|
||||
if (index != -1)
|
||||
{
|
||||
var index = outputSizeParam.IndexOf("format", StringComparison.OrdinalIgnoreCase);
|
||||
if (index != -1)
|
||||
{
|
||||
outputSizeParam = "," + outputSizeParam.Substring(index);
|
||||
}
|
||||
outputSizeParam = "," + outputSizeParam.Substring(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
var index = outputSizeParam.IndexOf("scale", StringComparison.OrdinalIgnoreCase);
|
||||
index = outputSizeParam.IndexOf("format", StringComparison.OrdinalIgnoreCase);
|
||||
if (index != -1)
|
||||
{
|
||||
outputSizeParam = "," + outputSizeParam.Substring(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
|
||||
&& outputSizeParam.Length == 0)
|
||||
{
|
||||
outputSizeParam = ",format=nv12|vaapi,hwupload";
|
||||
|
||||
// Add parameters to use VAAPI with burn-in subttiles (GH issue #642)
|
||||
if (state.SubtitleStream != null
|
||||
&& state.SubtitleStream.IsTextSubtitleStream
|
||||
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode) {
|
||||
outputSizeParam += ",hwmap=mode=read+write+direct";
|
||||
else
|
||||
{
|
||||
index = outputSizeParam.IndexOf("yadif", StringComparison.OrdinalIgnoreCase);
|
||||
if (index != -1)
|
||||
{
|
||||
outputSizeParam = "," + outputSizeParam.Substring(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
index = outputSizeParam.IndexOf("scale", StringComparison.OrdinalIgnoreCase);
|
||||
if (index != -1)
|
||||
{
|
||||
outputSizeParam = "," + outputSizeParam.Substring(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var videoSizeParam = string.Empty;
|
||||
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
|
||||
|
||||
// Setup subtitle scaling
|
||||
if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue)
|
||||
{
|
||||
// force_original_aspect_ratio=decrease
|
||||
// Enable decreasing output video width or height if necessary to keep the original aspect ratio
|
||||
videoSizeParam = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"scale={0}:{1}",
|
||||
"scale={0}:{1}:force_original_aspect_ratio=decrease",
|
||||
state.VideoStream.Width.Value,
|
||||
state.VideoStream.Height.Value);
|
||||
|
||||
//For QSV, feed it into hardware encoder now
|
||||
// For QSV, feed it into hardware encoder now
|
||||
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
videoSizeParam += ",hwupload=extra_hw_frames=64";
|
||||
}
|
||||
|
||||
// For VAAPI and CUVID decoder
|
||||
// these encoders cannot automatically adjust the size of graphical subtitles to fit the output video,
|
||||
// thus needs to be manually adjusted.
|
||||
if ((IsVaapiSupported(state) && string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
|| (videoDecoder ?? string.Empty).IndexOf("cuvid", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
var videoStream = state.VideoStream;
|
||||
var inputWidth = videoStream?.Width;
|
||||
var inputHeight = videoStream?.Height;
|
||||
var (width, height) = GetFixedOutputSize(inputWidth, inputHeight, request.Width, request.Height, request.MaxWidth, request.MaxHeight);
|
||||
|
||||
if (width.HasValue && height.HasValue)
|
||||
{
|
||||
videoSizeParam = string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"scale={0}:{1}:force_original_aspect_ratio=decrease",
|
||||
width.Value,
|
||||
height.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var mapPrefix = state.SubtitleStream.IsExternal ?
|
||||
@@ -1619,12 +1620,35 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
? 0
|
||||
: state.SubtitleStream.Index;
|
||||
|
||||
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
|
||||
|
||||
// Setup default filtergraph utilizing FFMpeg overlay() and FFMpeg scale() (see the return of this function for index reference)
|
||||
var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"";
|
||||
|
||||
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
// When the input may or may not be hardware VAAPI decodable
|
||||
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
/*
|
||||
[base]: HW scaling video to OutputSize
|
||||
[sub]: SW scaling subtitle to FixedOutputSize
|
||||
[base][sub]: SW overlay
|
||||
*/
|
||||
outputSizeParam = outputSizeParam.TrimStart(',');
|
||||
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]{3},hwdownload[base];[base][sub]overlay,format=nv12,hwupload\"";
|
||||
}
|
||||
|
||||
// If we're hardware VAAPI decoding and software encoding, download frames from the decoder first
|
||||
else if (IsVaapiSupported(state) && string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(outputVideoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
/*
|
||||
[base]: SW scaling video to OutputSize
|
||||
[sub]: SW scaling subtitle to FixedOutputSize
|
||||
[base][sub]: SW overlay
|
||||
*/
|
||||
outputSizeParam = outputSizeParam.TrimStart(',');
|
||||
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]{3}[base];[base][sub]overlay\"";
|
||||
}
|
||||
|
||||
else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
/*
|
||||
QSV in FFMpeg can now setup hardware overlay for transcodes.
|
||||
@@ -1688,7 +1712,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
return (Convert.ToInt32(outputWidth), Convert.ToInt32(outputHeight));
|
||||
}
|
||||
|
||||
public List<string> GetScalingFilters(int? videoWidth,
|
||||
public List<string> GetScalingFilters(EncodingJobInfo state,
|
||||
int? videoWidth,
|
||||
int? videoHeight,
|
||||
Video3DFormat? threedFormat,
|
||||
string videoDecoder,
|
||||
@@ -1707,7 +1732,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
requestedMaxWidth,
|
||||
requestedMaxHeight);
|
||||
|
||||
if ((string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) || string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
if (string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) || (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) && !hasTextSubs)
|
||||
&& width.HasValue
|
||||
&& height.HasValue)
|
||||
{
|
||||
@@ -1737,7 +1764,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv));
|
||||
}
|
||||
}
|
||||
else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1
|
||||
else if ((videoDecoder ?? string.Empty).IndexOf("cuvid", StringComparison.OrdinalIgnoreCase) != -1
|
||||
&& width.HasValue
|
||||
&& height.HasValue)
|
||||
{
|
||||
@@ -1941,8 +1968,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
public string GetOutputSizeParam(
|
||||
EncodingJobInfo state,
|
||||
EncodingOptions options,
|
||||
string outputVideoCodec,
|
||||
bool allowTimeStampCopy = true)
|
||||
string outputVideoCodec)
|
||||
{
|
||||
// http://sonnati.wordpress.com/2012/10/19/ffmpeg-the-swiss-army-knife-of-internet-streaming-part-vi/
|
||||
|
||||
@@ -1951,42 +1977,61 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
var videoStream = state.VideoStream;
|
||||
var filters = new List<string>();
|
||||
|
||||
// If we're hardware VAAPI decoding and software encoding, download frames from the decoder first
|
||||
var hwType = options.HardwareAccelerationType ?? string.Empty;
|
||||
if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !options.EnableHardwareEncoding )
|
||||
{
|
||||
filters.Add("hwdownload");
|
||||
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
|
||||
var inputWidth = videoStream?.Width;
|
||||
var inputHeight = videoStream?.Height;
|
||||
var threeDFormat = state.MediaSource.Video3DFormat;
|
||||
|
||||
// If transcoding from 10 bit, transform colour spaces too
|
||||
if (!string.IsNullOrEmpty(videoStream.PixelFormat)
|
||||
&& videoStream.PixelFormat.IndexOf("p10", StringComparison.OrdinalIgnoreCase) != -1
|
||||
&& string.Equals(outputVideoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
filters.Add("format=p010le");
|
||||
filters.Add("format=nv12");
|
||||
}
|
||||
else
|
||||
{
|
||||
filters.Add("format=nv12");
|
||||
}
|
||||
}
|
||||
var hasTextSubs = state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
// When the input may or may not be hardware VAAPI decodable
|
||||
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
filters.Add("format=nv12|vaapi");
|
||||
filters.Add("hwupload");
|
||||
}
|
||||
|
||||
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
|
||||
|
||||
// If we are software decoding, and hardware encoding
|
||||
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv", StringComparison.OrdinalIgnoreCase)))
|
||||
// When the input may or may not be hardware QSV decodable
|
||||
else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
filters.Add("format=nv12|qsv");
|
||||
filters.Add("hwupload=extra_hw_frames=64");
|
||||
if (!hasTextSubs)
|
||||
{
|
||||
filters.Add("format=nv12|qsv");
|
||||
filters.Add("hwupload=extra_hw_frames=64");
|
||||
}
|
||||
}
|
||||
|
||||
// If we're hardware VAAPI decoding and software encoding, download frames from the decoder first
|
||||
else if (IsVaapiSupported(state) && string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
|
||||
&& string.Equals(outputVideoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var codec = videoStream.Codec.ToLowerInvariant();
|
||||
var isColorDepth10 = !string.IsNullOrEmpty(videoStream.Profile) && (videoStream.Profile.Contains("Main 10", StringComparison.OrdinalIgnoreCase)
|
||||
|| videoStream.Profile.Contains("High 10", StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
// Assert 10-bit hardware VAAPI decodable
|
||||
if (isColorDepth10 && (string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
/*
|
||||
Download data from GPU to CPU as p010le format.
|
||||
Colorspace conversion is unnecessary here as libx264 will handle it.
|
||||
If this step is missing, it will fail on AMD but not on intel.
|
||||
*/
|
||||
filters.Add("hwdownload");
|
||||
filters.Add("format=p010le");
|
||||
}
|
||||
|
||||
// Assert 8-bit hardware VAAPI decodable
|
||||
else if (!isColorDepth10)
|
||||
{
|
||||
filters.Add("hwdownload");
|
||||
filters.Add("format=nv12");
|
||||
}
|
||||
}
|
||||
|
||||
// Add hardware deinterlace filter before scaling filter
|
||||
if (state.DeInterlace("h264", true))
|
||||
{
|
||||
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -1995,17 +2040,23 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
}
|
||||
else if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_qsv"));
|
||||
if (!hasTextSubs)
|
||||
{
|
||||
filters.Add(string.Format(CultureInfo.InvariantCulture, "deinterlace_qsv"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true))
|
||||
&& !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
// Add software deinterlace filter before scaling filter
|
||||
if (((state.DeInterlace("h264", true) || state.DeInterlace("h265", true) || state.DeInterlace("hevc", true))
|
||||
&& !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
|
||||
&& !string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
|| (hasTextSubs && state.DeInterlace("h264", true) && string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var inputFramerate = videoStream?.RealFrameRate;
|
||||
|
||||
// If it is already 60fps then it will create an output framerate that is much too high for roku and others to handle
|
||||
if (string.Equals(options.DeinterlaceMethod, "bobandweave", StringComparison.OrdinalIgnoreCase) && (inputFramerate ?? 60) <= 30)
|
||||
if (string.Equals(options.DeinterlaceMethod, "yadif_bob", StringComparison.OrdinalIgnoreCase) && (inputFramerate ?? 60) <= 30)
|
||||
{
|
||||
filters.Add("yadif=1:-1:0");
|
||||
}
|
||||
@@ -2015,11 +2066,21 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
}
|
||||
}
|
||||
|
||||
var inputWidth = videoStream?.Width;
|
||||
var inputHeight = videoStream?.Height;
|
||||
var threeDFormat = state.MediaSource.Video3DFormat;
|
||||
// Add scaling filter: scale_*=format=nv12 or scale_*=w=*:h=*:format=nv12 or scale=expr
|
||||
filters.AddRange(GetScalingFilters(state, inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight));
|
||||
|
||||
filters.AddRange(GetScalingFilters(inputWidth, inputHeight, threeDFormat, videoDecoder, outputVideoCodec, request.Width, request.Height, request.MaxWidth, request.MaxHeight));
|
||||
// Add parameters to use VAAPI with burn-in text subttiles (GH issue #642)
|
||||
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (state.SubtitleStream != null
|
||||
&& state.SubtitleStream.IsTextSubtitleStream
|
||||
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
|
||||
{
|
||||
// Test passed on Intel and AMD gfx
|
||||
filters.Add("hwmap=mode=read+write");
|
||||
filters.Add("format=nv12");
|
||||
}
|
||||
}
|
||||
|
||||
var output = string.Empty;
|
||||
|
||||
@@ -2037,11 +2098,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
filters.Add("hwmap");
|
||||
}
|
||||
|
||||
if (allowTimeStampCopy)
|
||||
{
|
||||
output += " -copyts";
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.Count > 0)
|
||||
@@ -2218,7 +2274,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
inputModifier += " " + videoDecoder;
|
||||
|
||||
if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
if ((videoDecoder ?? string.Empty).IndexOf("cuvid", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
var videoStream = state.VideoStream;
|
||||
var inputWidth = videoStream?.Width;
|
||||
@@ -2227,7 +2283,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
|
||||
var (width, height) = GetFixedOutputSize(inputWidth, inputHeight, request.Width, request.Height, request.MaxWidth, request.MaxHeight);
|
||||
|
||||
if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1
|
||||
if ((videoDecoder ?? string.Empty).IndexOf("cuvid", StringComparison.OrdinalIgnoreCase) != -1
|
||||
&& width.HasValue
|
||||
&& height.HasValue)
|
||||
{
|
||||
@@ -2491,7 +2547,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
encodingOptions.HardwareDecodingCodecs = Array.Empty<string>();
|
||||
return null;
|
||||
}
|
||||
return "-c:v h264_qsv ";
|
||||
return "-c:v h264_qsv";
|
||||
}
|
||||
break;
|
||||
case "hevc":
|
||||
@@ -2499,19 +2555,19 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
if (_mediaEncoder.SupportsDecoder("hevc_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
//return "-c:v hevc_qsv -load_plugin hevc_hw ";
|
||||
return "-c:v hevc_qsv ";
|
||||
return "-c:v hevc_qsv";
|
||||
}
|
||||
break;
|
||||
case "mpeg2video":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg2_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg2_qsv ";
|
||||
return "-c:v mpeg2_qsv";
|
||||
}
|
||||
break;
|
||||
case "vc1":
|
||||
if (_mediaEncoder.SupportsDecoder("vc1_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v vc1_qsv ";
|
||||
return "-c:v vc1_qsv";
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2525,32 +2581,38 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
case "h264":
|
||||
if (_mediaEncoder.SupportsDecoder("h264_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v h264_cuvid ";
|
||||
// cuvid decoder does not support 10-bit input
|
||||
if ((videoStream.BitDepth ?? 8) > 8)
|
||||
{
|
||||
encodingOptions.HardwareDecodingCodecs = Array.Empty<string>();
|
||||
return null;
|
||||
}
|
||||
return "-c:v h264_cuvid";
|
||||
}
|
||||
break;
|
||||
case "hevc":
|
||||
case "h265":
|
||||
if (_mediaEncoder.SupportsDecoder("hevc_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v hevc_cuvid ";
|
||||
return "-c:v hevc_cuvid";
|
||||
}
|
||||
break;
|
||||
case "mpeg2video":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg2_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg2_cuvid ";
|
||||
return "-c:v mpeg2_cuvid";
|
||||
}
|
||||
break;
|
||||
case "vc1":
|
||||
if (_mediaEncoder.SupportsDecoder("vc1_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v vc1_cuvid ";
|
||||
return "-c:v vc1_cuvid";
|
||||
}
|
||||
break;
|
||||
case "mpeg4":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg4_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg4_cuvid ";
|
||||
return "-c:v mpeg4_cuvid";
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2564,38 +2626,38 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
case "h264":
|
||||
if (_mediaEncoder.SupportsDecoder("h264_mediacodec") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v h264_mediacodec ";
|
||||
return "-c:v h264_mediacodec";
|
||||
}
|
||||
break;
|
||||
case "hevc":
|
||||
case "h265":
|
||||
if (_mediaEncoder.SupportsDecoder("hevc_mediacodec") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v hevc_mediacodec ";
|
||||
return "-c:v hevc_mediacodec";
|
||||
}
|
||||
break;
|
||||
case "mpeg2video":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg2_mediacodec") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg2_mediacodec ";
|
||||
return "-c:v mpeg2_mediacodec";
|
||||
}
|
||||
break;
|
||||
case "mpeg4":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg4_mediacodec") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg4_mediacodec ";
|
||||
return "-c:v mpeg4_mediacodec";
|
||||
}
|
||||
break;
|
||||
case "vp8":
|
||||
if (_mediaEncoder.SupportsDecoder("vp8_mediacodec") && encodingOptions.HardwareDecodingCodecs.Contains("vp8", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v vp8_mediacodec ";
|
||||
return "-c:v vp8_mediacodec";
|
||||
}
|
||||
break;
|
||||
case "vp9":
|
||||
if (_mediaEncoder.SupportsDecoder("vp9_mediacodec") && encodingOptions.HardwareDecodingCodecs.Contains("vp9", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v vp9_mediacodec ";
|
||||
return "-c:v vp9_mediacodec";
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2609,25 +2671,25 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
case "h264":
|
||||
if (_mediaEncoder.SupportsDecoder("h264_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v h264_mmal ";
|
||||
return "-c:v h264_mmal";
|
||||
}
|
||||
break;
|
||||
case "mpeg2video":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg2_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg2_mmal ";
|
||||
return "-c:v mpeg2_mmal";
|
||||
}
|
||||
break;
|
||||
case "mpeg4":
|
||||
if (_mediaEncoder.SupportsDecoder("mpeg4_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v mpeg4_mmal ";
|
||||
return "-c:v mpeg4_mmal";
|
||||
}
|
||||
break;
|
||||
case "vc1":
|
||||
if (_mediaEncoder.SupportsDecoder("vc1_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-c:v vc1_mmal ";
|
||||
return "-c:v vc1_mmal";
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2637,7 +2699,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
{
|
||||
if(Environment.OSVersion.Version.Major > 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor > 1))
|
||||
if (Environment.OSVersion.Version.Major > 6 || (Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor > 1))
|
||||
return "-hwaccel d3d11va";
|
||||
else
|
||||
return "-hwaccel dxva2";
|
||||
@@ -2772,14 +2834,27 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
var hasCopyTs = false;
|
||||
|
||||
// Add resolution params, if specified
|
||||
if (!hasGraphicalSubs)
|
||||
{
|
||||
var outputSizeParam = GetOutputSizeParam(state, encodingOptions, videoCodec);
|
||||
|
||||
args += outputSizeParam;
|
||||
|
||||
hasCopyTs = outputSizeParam.IndexOf("copyts", StringComparison.OrdinalIgnoreCase) != -1;
|
||||
}
|
||||
|
||||
// This is for graphical subs
|
||||
if (hasGraphicalSubs)
|
||||
{
|
||||
var graphicalSubtitleParam = GetGraphicalSubtitleParam(state, encodingOptions, videoCodec);
|
||||
|
||||
args += graphicalSubtitleParam;
|
||||
|
||||
hasCopyTs = graphicalSubtitleParam.IndexOf("copyts", StringComparison.OrdinalIgnoreCase) != -1;
|
||||
}
|
||||
|
||||
if (state.RunTimeTicks.HasValue && state.BaseRequest.CopyTimestamps)
|
||||
{
|
||||
if (!hasCopyTs)
|
||||
@@ -2787,13 +2862,12 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
args += " -copyts";
|
||||
}
|
||||
|
||||
args += " -avoid_negative_ts disabled -start_at_zero";
|
||||
}
|
||||
args += " -avoid_negative_ts disabled";
|
||||
|
||||
// This is for internal graphical subs
|
||||
if (hasGraphicalSubs)
|
||||
{
|
||||
args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec);
|
||||
if (!(state.SubtitleStream != null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream))
|
||||
{
|
||||
args += " -start_at_zero";
|
||||
}
|
||||
}
|
||||
|
||||
var qualityParam = GetVideoQualityParam(state, videoCodec, encodingOptions, defaultPreset);
|
||||
@@ -2899,6 +2973,5 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
string.Empty,
|
||||
string.Empty).Trim();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Session;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Session;
|
||||
|
||||
namespace MediaBrowser.Controller.MediaEncoding
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -12,6 +14,6 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
/// <summary>
|
||||
/// Refreshes the chapter images.
|
||||
/// </summary>
|
||||
Task<bool> RefreshChapterImages(Video video, IDirectoryService directoryService, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
|
||||
Task<bool> RefreshChapterImages(Video video, IDirectoryService directoryService, IReadOnlyList<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,6 @@ namespace MediaBrowser.Controller.Net
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
/// <summary>
|
||||
/// Starts sending messages over a web socket
|
||||
/// </summary>
|
||||
@@ -87,12 +85,12 @@ namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
var vals = message.Data.Split(',');
|
||||
|
||||
var dueTimeMs = long.Parse(vals[0], UsCulture);
|
||||
var periodMs = long.Parse(vals[1], UsCulture);
|
||||
var dueTimeMs = long.Parse(vals[0], CultureInfo.InvariantCulture);
|
||||
var periodMs = long.Parse(vals[1], CultureInfo.InvariantCulture);
|
||||
|
||||
var cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
Logger.LogDebug("{1} Begin transmitting over websocket to {0}", message.Connection.RemoteEndPoint, GetType().Name);
|
||||
Logger.LogDebug("WS {1} begin transmitting to {0}", message.Connection.RemoteEndPoint, GetType().Name);
|
||||
|
||||
var state = new TStateType
|
||||
{
|
||||
@@ -154,7 +152,6 @@ namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
MessageType = Name,
|
||||
Data = data
|
||||
|
||||
}, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
state.DateLastSendUtc = DateTime.UtcNow;
|
||||
@@ -197,7 +194,7 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <param name="connection">The connection.</param>
|
||||
private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, TStateType> connection)
|
||||
{
|
||||
Logger.LogDebug("{1} stop transmitting over websocket to {0}", connection.Item1.RemoteEndPoint, GetType().Name);
|
||||
Logger.LogDebug("WS {1} stop transmitting to {0}", connection.Item1.RemoteEndPoint, GetType().Name);
|
||||
|
||||
// TODO disposing the connection seems to break websockets in subtle ways, so what is the purpose of this function really...
|
||||
// connection.Item1.Dispose();
|
||||
@@ -242,6 +239,7 @@ namespace MediaBrowser.Controller.Net
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Services;
|
||||
@@ -9,9 +8,9 @@ using Microsoft.AspNetCore.Http;
|
||||
namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IHttpServer
|
||||
/// Interface IHttpServer.
|
||||
/// </summary>
|
||||
public interface IHttpServer : IDisposable
|
||||
public interface IHttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the URL prefix.
|
||||
@@ -19,11 +18,6 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <value>The URL prefix.</value>
|
||||
string[] UrlPrefixes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Stops this instance.
|
||||
/// </summary>
|
||||
void Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [web socket connected].
|
||||
/// </summary>
|
||||
@@ -32,30 +26,25 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <summary>
|
||||
/// Inits this instance.
|
||||
/// </summary>
|
||||
void Init(IEnumerable<IService> services, IEnumerable<IWebSocketListener> listener, IEnumerable<string> urlPrefixes);
|
||||
void Init(IEnumerable<Type> serviceTypes, IEnumerable<IWebSocketListener> listener, IEnumerable<string> urlPrefixes);
|
||||
|
||||
/// <summary>
|
||||
/// If set, all requests will respond with this message
|
||||
/// </summary>
|
||||
string GlobalResponse { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sends the http context to the socket listener
|
||||
/// </summary>
|
||||
/// <param name="ctx"></param>
|
||||
/// <returns></returns>
|
||||
Task ProcessWebSocketRequest(HttpContext ctx);
|
||||
|
||||
/// <summary>
|
||||
/// The HTTP request handler
|
||||
/// </summary>
|
||||
/// <param name="httpReq"></param>
|
||||
/// <param name="urlString"></param>
|
||||
/// <param name="host"></param>
|
||||
/// <param name="localPath"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
Task RequestHandler(IHttpRequest httpReq, string urlString, string host, string localPath,
|
||||
CancellationToken cancellationToken);
|
||||
Task RequestHandler(HttpContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Get the default CORS headers
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
IDictionary<string, string> GetDefaultCorsHeaders(IRequest req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.WebSockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -7,18 +10,12 @@ using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
public interface IWebSocketConnection : IDisposable
|
||||
public interface IWebSocketConnection
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [closed].
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Closed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the id.
|
||||
/// </summary>
|
||||
/// <value>The id.</value>
|
||||
Guid Id { get; }
|
||||
event EventHandler<EventArgs>? Closed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last activity date.
|
||||
@@ -26,22 +23,17 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <value>The last activity date.</value>
|
||||
DateTime LastActivityDate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URL.
|
||||
/// </summary>
|
||||
/// <value>The URL.</value>
|
||||
string Url { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the query string.
|
||||
/// </summary>
|
||||
/// <value>The query string.</value>
|
||||
IQueryCollection QueryString { get; set; }
|
||||
IQueryCollection QueryString { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the receive action.
|
||||
/// </summary>
|
||||
/// <value>The receive action.</value>
|
||||
Func<WebSocketMessageInfo, Task> OnReceive { get; set; }
|
||||
Func<WebSocketMessageInfo, Task>? OnReceive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state.
|
||||
@@ -53,7 +45,7 @@ namespace MediaBrowser.Controller.Net
|
||||
/// Gets the remote end point.
|
||||
/// </summary>
|
||||
/// <value>The remote end point.</value>
|
||||
string RemoteEndPoint { get; }
|
||||
IPAddress? RemoteEndPoint { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message asynchronously.
|
||||
@@ -65,21 +57,6 @@ namespace MediaBrowser.Controller.Net
|
||||
/// <exception cref="ArgumentNullException">message</exception>
|
||||
Task SendAsync<T>(WebSocketMessage<T> message, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The buffer.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SendAsync(byte[] buffer, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="text">The text.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <exception cref="ArgumentNullException">buffer</exception>
|
||||
Task SendAsync(string text, CancellationToken cancellationToken);
|
||||
Task ProcessAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,36 @@ using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// The exception that is thrown when a user is authenticated, but not authorized to access a requested resource.
|
||||
/// </summary>
|
||||
public class SecurityException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SecurityException"/> class.
|
||||
/// </summary>
|
||||
public SecurityException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SecurityException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public SecurityException(string message)
|
||||
: base(message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SecurityExceptionType SecurityExceptionType { get; set; }
|
||||
}
|
||||
|
||||
public enum SecurityExceptionType
|
||||
{
|
||||
Unauthenticated = 0,
|
||||
ParentalControl = 1
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SecurityException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
|
||||
public SecurityException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,30 +6,34 @@ using MediaBrowser.Model.Entities;
|
||||
namespace MediaBrowser.Controller.Persistence
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IDisplayPreferencesRepository
|
||||
/// Interface IDisplayPreferencesRepository.
|
||||
/// </summary>
|
||||
public interface IDisplayPreferencesRepository : IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Saves display preferences for an item
|
||||
/// Saves display preferences for an item.
|
||||
/// </summary>
|
||||
/// <param name="displayPreferences">The display preferences.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="client">The client.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client,
|
||||
CancellationToken cancellationToken);
|
||||
void SaveDisplayPreferences(
|
||||
DisplayPreferences displayPreferences,
|
||||
string userId,
|
||||
string client,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Saves all display preferences for a user
|
||||
/// Saves all display preferences for a user.
|
||||
/// </summary>
|
||||
/// <param name="displayPreferences">The display preferences.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
void SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId,
|
||||
CancellationToken cancellationToken);
|
||||
void SaveAllDisplayPreferences(
|
||||
IEnumerable<DisplayPreferences> displayPreferences,
|
||||
Guid userId,
|
||||
CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display preferences.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// Deletes the item.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
void DeleteItem(Guid id, CancellationToken cancellationToken);
|
||||
void DeleteItem(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the items.
|
||||
@@ -61,7 +60,7 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// <summary>
|
||||
/// Saves the chapters.
|
||||
/// </summary>
|
||||
void SaveChapters(Guid id, List<ChapterInfo> chapters);
|
||||
void SaveChapters(Guid id, IReadOnlyList<ChapterInfo> chapters);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the media streams.
|
||||
@@ -169,4 +168,3 @@ namespace MediaBrowser.Controller.Persistence
|
||||
List<string> GetAllArtistNames();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,10 @@ namespace MediaBrowser.Controller.Providers
|
||||
return file;
|
||||
}
|
||||
|
||||
public List<string> GetFilePaths(string path)
|
||||
{
|
||||
return GetFilePaths(path, false);
|
||||
}
|
||||
public IReadOnlyList<string> GetFilePaths(string path)
|
||||
=> GetFilePaths(path, false);
|
||||
|
||||
public List<string> GetFilePaths(string path, bool clearCache)
|
||||
public IReadOnlyList<string> GetFilePaths(string path, bool clearCache)
|
||||
{
|
||||
if (clearCache || !_filePathCache.TryGetValue(path, out List<string> result))
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace MediaBrowser.Controller.Providers
|
||||
|
||||
FileSystemMetadata GetFile(string path);
|
||||
|
||||
List<string> GetFilePaths(string path);
|
||||
IReadOnlyList<string> GetFilePaths(string path);
|
||||
|
||||
List<string> GetFilePaths(string path, bool clearCache);
|
||||
IReadOnlyList<string> GetFilePaths(string path, bool clearCache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -20,6 +21,6 @@ namespace MediaBrowser.Controller.Session
|
||||
/// <summary>
|
||||
/// Sends the message.
|
||||
/// </summary>
|
||||
Task SendMessage<T>(string name, string messageId, T data, ISessionController[] allControllers, CancellationToken cancellationToken);
|
||||
Task SendMessage<T>(string name, Guid messageId, T data, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,23 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Controller.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SessionInfo
|
||||
/// Class SessionInfo.
|
||||
/// </summary>
|
||||
public class SessionInfo : IDisposable
|
||||
public sealed class SessionInfo : IDisposable
|
||||
{
|
||||
private ISessionManager _sessionManager;
|
||||
// 1 second
|
||||
private const long ProgressIncrement = 10000000;
|
||||
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
|
||||
private readonly object _progressLock = new object();
|
||||
private Timer _progressTimer;
|
||||
private PlaybackProgressInfo _lastProgressInfo;
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
public SessionInfo(ISessionManager sessionManager, ILogger logger)
|
||||
{
|
||||
_sessionManager = sessionManager;
|
||||
@@ -97,8 +107,6 @@ namespace MediaBrowser.Controller.Session
|
||||
/// <value>The name of the device.</value>
|
||||
public string DeviceName { get; set; }
|
||||
|
||||
public string DeviceType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the now playing item.
|
||||
/// </summary>
|
||||
@@ -128,22 +136,6 @@ namespace MediaBrowser.Controller.Session
|
||||
[JsonIgnore]
|
||||
public ISessionController[] SessionControllers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the supported commands.
|
||||
/// </summary>
|
||||
/// <value>The supported commands.</value>
|
||||
public string[] SupportedCommands
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Capabilities == null)
|
||||
{
|
||||
return new string[] { };
|
||||
}
|
||||
return Capabilities.SupportedCommands;
|
||||
}
|
||||
}
|
||||
|
||||
public TranscodingInfo TranscodingInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -215,6 +207,14 @@ namespace MediaBrowser.Controller.Session
|
||||
}
|
||||
}
|
||||
|
||||
public QueueItem[] NowPlayingQueue { get; set; }
|
||||
|
||||
public bool HasCustomDeviceName { get; set; }
|
||||
|
||||
public string PlaylistItemId { get; set; }
|
||||
|
||||
public string UserPrimaryImageTag { get; set; }
|
||||
|
||||
public Tuple<ISessionController, bool> EnsureController<T>(Func<SessionInfo, ISessionController> factory)
|
||||
{
|
||||
var controllers = SessionControllers.ToList();
|
||||
@@ -258,10 +258,6 @@ namespace MediaBrowser.Controller.Session
|
||||
return false;
|
||||
}
|
||||
|
||||
private readonly object _progressLock = new object();
|
||||
private Timer _progressTimer;
|
||||
private PlaybackProgressInfo _lastProgressInfo;
|
||||
|
||||
public void StartAutomaticProgress(PlaybackProgressInfo progressInfo)
|
||||
{
|
||||
if (_disposed)
|
||||
@@ -284,9 +280,6 @@ namespace MediaBrowser.Controller.Session
|
||||
}
|
||||
}
|
||||
|
||||
// 1 second
|
||||
private const long ProgressIncrement = 10000000;
|
||||
|
||||
private async void OnProgressTimerCallback(object state)
|
||||
{
|
||||
if (_disposed)
|
||||
@@ -345,8 +338,7 @@ namespace MediaBrowser.Controller.Session
|
||||
}
|
||||
}
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_disposed = true;
|
||||
@@ -358,30 +350,12 @@ namespace MediaBrowser.Controller.Session
|
||||
|
||||
foreach (var controller in controllers)
|
||||
{
|
||||
var disposable = controller as IDisposable;
|
||||
|
||||
if (disposable != null)
|
||||
if (controller is IDisposable disposable)
|
||||
{
|
||||
_logger.LogDebug("Disposing session controller {0}", disposable.GetType().Name);
|
||||
|
||||
try
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error disposing session controller");
|
||||
}
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
_sessionManager = null;
|
||||
}
|
||||
|
||||
public QueueItem[] NowPlayingQueue { get; set; }
|
||||
public bool HasCustomDeviceName { get; set; }
|
||||
public string PlaylistItemId { get; set; }
|
||||
public string ServerId { get; set; }
|
||||
public string UserPrimaryImageTag { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Controller.Sorting
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user