Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions FlyleafLib/Controls/WPF/FlyleafHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using Brushes = System.Windows.Media.Brushes;

using static FlyleafLib.Utils;
using static FlyleafLib.Utils.NativeMethods;

using FlyleafLib.MediaPlayer;
Expand Down Expand Up @@ -1104,7 +1103,7 @@ private void Host_LayoutUpdated(object sender, EventArgs e)
catch (Exception ex)
{
// It has been noticed with NavigationService (The visual tree changes, visual root IsVisible is false but FlyleafHost is still visible)
if (Logger.CanDebug) Log.Debug($"Host_LayoutUpdated: {ex.Message}");
if (CanDebug) Log.Debug($"Host_LayoutUpdated: {ex.Message}");

// TBR: (Currently handle on each time Visible=true) It's possible that the owner/parent has been changed (for some reason Host_Loaded will not be called) *probably when the Owner stays the same but the actual Handle changes
//if (ex.Message == "The specified Visual is not an ancestor of this Visual.")
Expand Down Expand Up @@ -1769,16 +1768,16 @@ public FlyleafHost()
return;

MarginTarget= this;
Log = new LogHandler(("[#" + UniqueId + "]").PadRight(8, ' ') + $" [FlyleafHost NP] ");
Log = new(("[#" + UniqueId + "]").PadRight(8, ' ') + $" [FlyleafHost NP] ");
Loaded += Host_Loaded;
}
public FlyleafHost(Window standAloneOverlay)
{
UniqueId = idGenerator++;
Log = new LogHandler(("[#" + UniqueId + "]").PadRight(8, ' ') + $" [FlyleafHost NP] ");
UniqueId = idGenerator++;
Log = new(("[#" + UniqueId + "]").PadRight(8, ' ') + $" [FlyleafHost NP] ");

IsStandAlone = true;
IsAttached = false;
IsStandAlone= true;
IsAttached = false;

this.standAloneOverlay = standAloneOverlay;
standAloneOverlay.Loaded += OverlayStandAlone_Loaded;
Expand Down
16 changes: 6 additions & 10 deletions FlyleafLib/Controls/WPF/PlayerDebug.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
</UserControl.Resources>
<StackPanel>
<TextBlock HorizontalAlignment="Left" Background="{Binding BoxColor, ElementName=DebugControl}" Style="{StaticResource TextValue}" Padding="10" Width="690" TextWrapping="Wrap" Text="{Binding Player.Playlist.Url}"/>
<TextBlock HorizontalAlignment="Left" Background="{Binding BoxColor, ElementName=DebugControl}" Style="{StaticResource TextValue}" Padding="10" Width="690" TextWrapping="Wrap" Text="{Binding Player.Playlist.Selected.Title}"/>
<Grid x:Name="rootGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
Expand All @@ -62,14 +63,9 @@

<StackPanel>
<!-- Player -->
<StackPanel Style="{StaticResource FlowTable}">
<StackPanel Style="{StaticResource FlowTable}" Height="320">
<TextBlock Style="{StaticResource TextHeader}" Text="Player"/>

<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextInfo}" Text="Title"/>
<TextBlock Style="{StaticResource TextValue}" Text="{Binding Player.Playlist.Selected.Title}" Margin="-100 0 0 0" Width="235"/>
</StackPanel>

<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextInfo}" Text="CurTime"/>
<TextBlock Style="{StaticResource TextValue}" Text="{Binding Player.CurTime, Converter={StaticResource TicksToTimeSpan}, StringFormat={}{0:hh\\:mm\\:ss\\.fff}}"/>
Expand Down Expand Up @@ -143,8 +139,8 @@

</StackPanel>

<!-- Audio -->
<StackPanel Style="{StaticResource FlowTable}">
<!-- Audio (Manual Height-->
<StackPanel Style="{StaticResource FlowTable}" Height="320">
<TextBlock Style="{StaticResource TextHeader}" Text="Audio"/>

<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -211,7 +207,7 @@

<StackPanel Grid.Column="1">
<!-- Video -->
<StackPanel Style="{StaticResource FlowTable}">
<StackPanel Style="{StaticResource FlowTable}" Height="320">
<TextBlock Style="{StaticResource TextHeader}" Text="Video"/>

<StackPanel Orientation="Horizontal">
Expand Down Expand Up @@ -315,7 +311,7 @@
</StackPanel>

<!-- Stats -->
<StackPanel Style="{StaticResource FlowTable}">
<StackPanel Style="{StaticResource FlowTable}" Height="172">
<TextBlock Style="{StaticResource TextHeader}" Text="Stats"/>

<StackPanel Orientation="Horizontal">
Expand Down
3 changes: 1 addition & 2 deletions FlyleafLib/Controls/WPF/RelayCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Windows.Input;
using System.Windows.Input;

namespace FlyleafLib.Controls.WPF;

Expand Down
3 changes: 1 addition & 2 deletions FlyleafLib/Controls/WPF/RelayCommandSimple.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Windows.Input;
using System.Windows.Input;

namespace FlyleafLib.Controls.WPF;

Expand Down
17 changes: 6 additions & 11 deletions FlyleafLib/Engine/Config.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;

using FlyleafLib.Controls.WPF;
Expand All @@ -15,7 +11,6 @@
using FlyleafLib.MediaPlayer.Translation;
using FlyleafLib.MediaPlayer.Translation.Services;
using FlyleafLib.Plugins;
using static FlyleafLib.Utils;

namespace FlyleafLib;

Expand Down Expand Up @@ -776,7 +771,7 @@ public System.Windows.Media.Color
/// * D3D11 possible performs better with color conversion and filters, FLVP supports only brightness/contrast filters<br/>
/// * D3D11 supports deinterlace (bob)
/// </summary>
public VideoProcessors VideoProcessor { get => _VideoProcessor; set { if (Set(ref _VideoProcessor, value)) player?.renderer?.UpdateVideoProcessor(); } }
public VideoProcessors VideoProcessor { get => _VideoProcessor; set { if (Set(ref _VideoProcessor, value)) player?.renderer?.UpdateVideoProcessor(); } }
VideoProcessors _VideoProcessor = VideoProcessors.Auto;

/// <summary>
Expand All @@ -791,20 +786,20 @@ public System.Windows.Media.Color
public Vortice.DXGI.PresentFlags
PresentFlags { get; set; } = Vortice.DXGI.PresentFlags.DoNotWait;

public DeInterlace DeInterlace { get => _DeInterlace; set { if (Set(ref _DeInterlace, value)) player?.renderer?.UpdateDeinterlace(); } }
public DeInterlace DeInterlace { get => _DeInterlace; set { if (Set(ref _DeInterlace, value)) player?.renderer?.UpdateDeinterlace(); } }
DeInterlace _DeInterlace = DeInterlace.Auto;

/// <summary>
/// The HDR to SDR method that will be used by the pixel shader
/// </summary>
public unsafe HDRtoSDRMethod
HDRtoSDRMethod { get => _HDRtoSDRMethod; set { if (Set(ref _HDRtoSDRMethod, value) && player != null && player.VideoDecoder.VideoStream != null && player.VideoDecoder.VideoStream.ColorSpace == ColorSpace.BT2020) player.renderer.UpdateHDRtoSDR(); }}
HDRtoSDRMethod { get => _HDRtoSDRMethod; set { if (Set(ref _HDRtoSDRMethod, value)) player?.renderer?.UpdateHDRtoSDR(); }}
HDRtoSDRMethod _HDRtoSDRMethod = HDRtoSDRMethod.Hable;

/// <summary>
/// SDR Display Peak Luminance (will be used for HDR to SDR conversion)
/// </summary>
public unsafe float SDRDisplayNits { get => _SDRDisplayNits; set { if (Set(ref _SDRDisplayNits, value) && player != null && player.VideoDecoder.VideoStream != null && player.VideoDecoder.VideoStream.ColorSpace == ColorSpace.BT2020) player.renderer.UpdateHDRtoSDR(); } }
public unsafe float SDRDisplayNits { get => _SDRDisplayNits; set { if (Set(ref _SDRDisplayNits, value)) player?.renderer?.UpdateHDRtoSDR(); } }
float _SDRDisplayNits = Engine.Video != null ? Engine.Video.RecommendedLuminance : 200;

/// <summary>
Expand Down Expand Up @@ -1378,7 +1373,7 @@ public Flyleaf.FFmpeg.LogLevel
/// <para>:console -> System.Console</para>
/// <para>&lt;path&gt; -> Absolute or relative file path</para>
/// </summary>
public string LogOutput { get => _LogOutput; set { _LogOutput = value; if (Engine.IsLoaded) Logger.SetOutput(); } }
public string LogOutput { get => _LogOutput; set { _LogOutput = value; if (Engine.IsLoaded) SetOutput(); } }
string _LogOutput = "";

/// <summary>
Expand Down
9 changes: 3 additions & 6 deletions FlyleafLib/Engine/Engine.Audio.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Data;

using SharpGen.Runtime;
Expand Down Expand Up @@ -96,7 +93,7 @@ private void EnumerateDevices()
CurrentDevice.Id = defaultDevice.Id;
CurrentDevice.Name = defaultDevice.FriendlyName;

if (Logger.CanInfo)
if (CanInfo)
{
string dump = "";
foreach (var device in deviceEnum.EnumAudioEndpoints(DataFlow.Render, DeviceStates.Active))
Expand All @@ -117,7 +114,7 @@ private void EnumerateDevices()
}
private void RefreshDevices()
{
Utils.UIInvokeIfRequired(() => // UI Required?
UIInvokeIfRequired(() => // UI Required?
{
lock (locker)
{
Expand Down
8 changes: 4 additions & 4 deletions FlyleafLib/Engine/Engine.FFmpeg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal FFmpegEngine()
try
{
Engine.Log.Info($"Loading FFmpeg libraries from '{Engine.Config.FFmpegPath}'");
Folder = Utils.GetFolderPath(Engine.Config.FFmpegPath);
Folder = GetFolderPath(Engine.Config.FFmpegPath);
LoadLibraries(Folder, Engine.Config.FFmpegLoadProfile);

uint ver = avformat_version();
Expand Down Expand Up @@ -51,15 +51,15 @@ internal static void SetLogLevel()
byte* buffer = stackalloc byte[AV_LOG_BUFFER_SIZE];
int printPrefix = 1;
av_log_format_line2(p0, level, format, vl, buffer, AV_LOG_BUFFER_SIZE, &printPrefix);
string line = Utils.BytePtrToStringUTF8(buffer);
string line = BytePtrToStringUTF8(buffer);

Logger.Output($"FFmpeg|{level,-7}|{line.Trim()}");
Output($"FFmpeg|{level,-7}|{line.Trim()}");
};

internal unsafe static string ErrorCodeToMsg(int error)
{
byte* buffer = stackalloc byte[AV_LOG_BUFFER_SIZE];
av_strerror(error, buffer, AV_LOG_BUFFER_SIZE);
return Utils.BytePtrToStringUTF8(buffer);
return BytePtrToStringUTF8(buffer);
}
}
8 changes: 3 additions & 5 deletions FlyleafLib/Engine/Engine.Plugins.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Reflection;

using FlyleafLib.Plugins;

Expand All @@ -17,7 +15,7 @@ public Dictionary<string, PluginType>

internal PluginsEngine()
{
Folder = string.IsNullOrEmpty(Engine.Config.PluginsPath) ? null : Utils.GetFolderPath(Engine.Config.PluginsPath);
Folder = string.IsNullOrEmpty(Engine.Config.PluginsPath) ? null : GetFolderPath(Engine.Config.PluginsPath);

LoadAssemblies();
}
Expand Down Expand Up @@ -69,6 +67,6 @@ public void LoadPlugin(Assembly assembly)
}
}
}
catch (Exception e) { Engine.Log.Error($"[PluginHandler] [Error] Failed to load assembly ({e.Message} {Utils.GetRecInnerException(e)})"); }
catch (Exception e) { Engine.Log.Error($"[PluginHandler] [Error] Failed to load assembly ({e.Message} {GetRecInnerException(e)})"); }
}
}
4 changes: 1 addition & 3 deletions FlyleafLib/Engine/Engine.Video.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Windows.Data;

using Vortice.DXGI;
using Vortice.MediaFoundation;
Expand Down
25 changes: 11 additions & 14 deletions FlyleafLib/Engine/Engine.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
using System.Windows;
using System.Windows;

using FlyleafLib.MediaPlayer;

Expand Down Expand Up @@ -82,7 +79,7 @@ public static void TimeBeginPeriod1()
if (timePeriod == 1)
{
Log.Trace("timeBeginPeriod(1)");
Utils.NativeMethods.TimeBeginPeriod(1);
NativeMethods.TimeBeginPeriod(1);
}
}
}
Expand All @@ -99,7 +96,7 @@ public static void TimeEndPeriod1()
if (timePeriod == 0)
{
Log.Trace("timeEndPeriod(1)");
Utils.NativeMethods.TimeEndPeriod(1);
NativeMethods.TimeEndPeriod(1);
}
}
}
Expand All @@ -116,7 +113,7 @@ private static void StartInternal(EngineConfig config = null, bool async = false
Config = config ?? new EngineConfig();

if (Application.Current == null)
new Application();
_ = new Application();

StartInternalUI();

Expand All @@ -138,19 +135,19 @@ private static void StartInternalUI()
Players[0].Dispose();
};

Logger.SetOutput();
Log = new LogHandler("[FlyleafEngine] ");
Audio = new AudioEngine();
SetOutput();
Log = new("[FlyleafEngine] ");
Audio = new();
}

private static void StartInternalNonUI()
{
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Log.Info($"FlyleafLib {version.Major }.{version.Minor}.{version.Build}");

FFmpeg = new FFmpegEngine();
Video = new VideoEngine();
Plugins = new PluginsEngine();
FFmpeg = new();
Video = new();
Plugins = new();
Players = [];

IsLoaded= true;
Expand Down Expand Up @@ -325,7 +322,7 @@ void UIAction()
catch { }
}

Utils.UI(UIAction);
UI(UIAction);
Thread.Sleep(Config.UIRefreshInterval);

} catch { curLoop = 0; }
Expand Down
Loading