mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
Convert TranscodeReason to Flags
This commit is contained in:
committed by
Cody Robibero
parent
a3057afde8
commit
d871dded9f
@@ -1,32 +1,51 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Session
|
||||
{
|
||||
[Flags]
|
||||
public enum TranscodeReason
|
||||
{
|
||||
ContainerNotSupported = 0,
|
||||
VideoCodecNotSupported = 1,
|
||||
AudioCodecNotSupported = 2,
|
||||
ContainerBitrateExceedsLimit = 3,
|
||||
AudioBitrateNotSupported = 4,
|
||||
AudioChannelsNotSupported = 5,
|
||||
VideoResolutionNotSupported = 6,
|
||||
UnknownVideoStreamInfo = 7,
|
||||
UnknownAudioStreamInfo = 8,
|
||||
AudioProfileNotSupported = 9,
|
||||
AudioSampleRateNotSupported = 10,
|
||||
AnamorphicVideoNotSupported = 11,
|
||||
InterlacedVideoNotSupported = 12,
|
||||
SecondaryAudioNotSupported = 13,
|
||||
RefFramesNotSupported = 14,
|
||||
VideoBitDepthNotSupported = 15,
|
||||
VideoBitrateNotSupported = 16,
|
||||
VideoFramerateNotSupported = 17,
|
||||
VideoLevelNotSupported = 18,
|
||||
VideoProfileNotSupported = 19,
|
||||
AudioBitDepthNotSupported = 20,
|
||||
SubtitleCodecNotSupported = 21,
|
||||
DirectPlayError = 22,
|
||||
AudioIsExternal = 23
|
||||
None = 0,
|
||||
|
||||
// Primary
|
||||
ContainerNotSupported = 1 << 0,
|
||||
VideoCodecNotSupported = 1 << 1,
|
||||
AudioCodecNotSupported = 1 << 2,
|
||||
SubtitleCodecNotSupported = 1 << 3,
|
||||
AudioIsExternal = 1 << 4,
|
||||
SecondaryAudioNotSupported = 1 << 5,
|
||||
|
||||
// Video Constraints
|
||||
VideoProfileNotSupported = 1 << 6,
|
||||
VideoLevelNotSupported = 1 << 7,
|
||||
VideoResolutionNotSupported = 1 << 8,
|
||||
VideoBitDepthNotSupported = 1 << 9,
|
||||
VideoFramerateNotSupported = 1 << 10,
|
||||
RefFramesNotSupported = 1 << 11,
|
||||
AnamorphicVideoNotSupported = 1 << 12,
|
||||
InterlacedVideoNotSupported = 1 << 13,
|
||||
|
||||
// Audio Constraints
|
||||
AudioChannelsNotSupported = 1 << 14,
|
||||
AudioProfileNotSupported = 1 << 15,
|
||||
AudioSampleRateNotSupported = 1 << 16,
|
||||
AudioBitDepthNotSupported = 1 << 20,
|
||||
|
||||
// Bitrate Constraints
|
||||
ContainerBitrateExceedsLimit = 1 << 17,
|
||||
VideoBitrateNotSupported = 1 << 18,
|
||||
AudioBitrateNotSupported = 1 << 19,
|
||||
|
||||
// Errors
|
||||
UnknownVideoStreamInfo = 1 << 20,
|
||||
UnknownAudioStreamInfo = 1 << 21,
|
||||
DirectPlayError = 1 << 22,
|
||||
|
||||
// Aliases
|
||||
ContainerReasons = ContainerNotSupported | ContainerBitrateExceedsLimit,
|
||||
AudioReasons = AudioCodecNotSupported | AudioBitrateNotSupported | AudioChannelsNotSupported | AudioProfileNotSupported | AudioSampleRateNotSupported | SecondaryAudioNotSupported | AudioBitDepthNotSupported | AudioIsExternal,
|
||||
VideoReasons = VideoCodecNotSupported | VideoResolutionNotSupported | AnamorphicVideoNotSupported | InterlacedVideoNotSupported | VideoBitDepthNotSupported | VideoBitrateNotSupported | VideoFramerateNotSupported | VideoLevelNotSupported | RefFramesNotSupported,
|
||||
}
|
||||
}
|
||||
|
||||
22
MediaBrowser.Model/Session/TranscodeReasonExtensions.cs
Normal file
22
MediaBrowser.Model/Session/TranscodeReasonExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Model.Session
|
||||
{
|
||||
public static class TranscodeReasonExtensions
|
||||
{
|
||||
private static TranscodeReason[] values = Enum.GetValues<TranscodeReason>();
|
||||
|
||||
public static string Serialize(this MediaBrowser.Model.Session.TranscodeReason reasons, string sep = ",")
|
||||
{
|
||||
return string.Join(sep, reasons.ToArray());
|
||||
}
|
||||
|
||||
public static TranscodeReason[] ToArray(this MediaBrowser.Model.Session.TranscodeReason reasons)
|
||||
{
|
||||
return values.Where(r => r != 0 && reasons.HasFlag(r)).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,12 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MediaBrowser.Model.Session
|
||||
{
|
||||
public class TranscodingInfo
|
||||
{
|
||||
public TranscodingInfo()
|
||||
{
|
||||
TranscodeReasons = Array.Empty<TranscodeReason>();
|
||||
}
|
||||
|
||||
public string AudioCodec { get; set; }
|
||||
|
||||
public string VideoCodec { get; set; }
|
||||
@@ -36,6 +31,9 @@ namespace MediaBrowser.Model.Session
|
||||
|
||||
public HardwareEncodingType? HardwareAccelerationType { get; set; }
|
||||
|
||||
public TranscodeReason[] TranscodeReasons { get; set; }
|
||||
public TranscodeReason[] TranscodeReasons { get => TranscodeReason.ToArray(); }
|
||||
|
||||
[JsonIgnore]
|
||||
public TranscodeReason TranscodeReason { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user